:root {
  --navy: #1d3557; --navy-2: #24436b; --navy-3: #2f5485; --edge: #7fa3d1; --edge-dark: #10203a;
  --text: #e8f0fa; --dim: #a9bdd8; --green: #35d357; --gold: #f2c14e; --red: #e0453a;
  --panel: linear-gradient(180deg, #2b4d7c 0%, #1f3a5f 60%, #182f4f 100%);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #223d25; font-family: "Trebuchet MS", "Lucida Grande", "Segoe UI", system-ui, sans-serif; color: var(--text); }
#game { position: fixed; inset: 0; display: block; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 11px; }
.panel { background: var(--panel); border: 2px solid var(--edge); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--edge-dark), 0 6px 18px rgba(0,0,0,.4); }
.panelTitle { font-weight: 800; font-size: 12px; letter-spacing: .4px; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.btn, .tiny, .toolBtn { font: inherit; font-weight: 800; color: var(--text); background: linear-gradient(180deg, #3f6ea8, #2c4f7d); border: 1px solid var(--edge); border-radius: 7px; padding: 5px 10px; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 2px rgba(0,0,0,.4); font-size: 12px; }
.btn:hover, .tiny:hover, .toolBtn:hover { filter: brightness(1.12); }
.btn.primary { background: linear-gradient(180deg, #4fd36a, #2fa94a); border-color: #9ff0b0; color: #0b2a12; font-size: 18px; padding: 10px 20px; }
.tiny { padding: 1px 6px; font-size: 11px; border-radius: 5px; }
.toolBtn.active, .btn.active { background: linear-gradient(180deg, #f6cf5e, #d9a63a); color: #2a1d06; }

/* ---- bottom control panel ---- */
#bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 158px; background: var(--panel); border-top: 3px solid var(--edge); box-shadow: 0 -6px 20px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,255,255,.15); display: grid; grid-template-columns: 76px 180px 1fr 1fr 190px; gap: 10px; padding: 10px 12px; }
#bottom > div { min-width: 0; }
.modes { display: flex; flex-direction: column; gap: 6px; }
.modeBtn { flex: 1; font: inherit; font-weight: 900; font-size: 11px; letter-spacing: .3px; color: var(--text); background: linear-gradient(180deg, #355d92, #223f66); border: 1px solid var(--edge); border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.modeBtn span { font-size: 16px; }
.modeBtn.active { background: linear-gradient(180deg, #5fe27a, #2fa94a); color: #0b2a12; border-color: #c4f5cf; }
.info { display: flex; flex-direction: column; justify-content: center; gap: 3px; border-right: 1px solid rgba(127,163,209,.35); padding-right: 10px; }
.hh { font-weight: 900; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clockRow { display: flex; gap: 8px; align-items: baseline; font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.clockRow .dim { font-size: 12px; }
.money { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 20px; color: var(--gold); background: rgba(0,0,0,.25); border-radius: 6px; padding: 2px 8px; border: 1px solid rgba(0,0,0,.35); }
.money .sym { font-size: 16px; }
.bondRow { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bondBar { flex: 1; height: 9px; background: rgba(0,0,0,.35); border-radius: 5px; overflow: hidden; border: 1px solid rgba(0,0,0,.4); }
#bondFill { height: 100%; width: 0; background: linear-gradient(90deg, #f28ab2, #e04f8a); transition: width .4s; }
#bondLabel { font-size: 11px; font-weight: 800; }
.sq { display: flex; gap: 10px; align-items: stretch; background: rgba(0,0,0,.18); border: 1px solid rgba(127,163,209,.35); border-radius: 10px; padding: 8px 10px; }
.portraitWrap { position: relative; flex: none; align-self: center; }
.portrait { border-radius: 8px; background: linear-gradient(180deg, #7fb3e6, #3f7fbf); border: 2px solid var(--edge); display: block; }
.plumbob { position: absolute; top: -8px; right: -8px; width: 14px; height: 14px; background: var(--green); transform: rotate(45deg); border: 1px solid rgba(0,0,0,.4); box-shadow: 0 0 8px rgba(53,211,87,.8); }
.sqMain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sqHead { display: flex; align-items: baseline; gap: 8px; }
.name { font-weight: 900; font-size: 15px; }
.mood { font-weight: 800; font-size: 12px; }
.doing { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.needs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; margin-top: 2px; }
.need { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 800; color: var(--dim); text-transform: uppercase; letter-spacing: .3px; }
.need .bar { height: 9px; background: rgba(0,0,0,.45); border-radius: 4px; overflow: hidden; border: 1px solid rgba(0,0,0,.5); box-shadow: inset 0 1px 2px rgba(0,0,0,.5); }
.need .bar i { display: block; height: 100%; width: 50%; transition: width .3s, background-color .3s; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.35); }
.needs.thin .need { grid-template-columns: 44px 1fr; font-size: 9px; }
.needs.thin .need .bar { height: 6px; }
#partnerWait { display: flex; flex-direction: column; gap: 5px; justify-content: center; font-size: 12px; }
.waitTitle { font-weight: 900; font-size: 14px; }
.code b { font-family: ui-monospace, Menlo, monospace; background: rgba(0,0,0,.3); padding: 1px 6px; border-radius: 5px; color: var(--gold); }
#partnerBody { display: flex; gap: 10px; width: 100%; }
.options { display: flex; flex-direction: column; gap: 5px; justify-content: center; border-left: 1px solid rgba(127,163,209,.35); padding-left: 10px; }
.skills { display: flex; flex-wrap: wrap; gap: 3px 6px; font-size: 11px; font-weight: 800; color: var(--dim); }
.skills span b { font-weight: 400; margin-right: 1px; }
.fw { font-size: 12px; font-weight: 800; }

/* ---- catalog ---- */
#catalog { position: absolute; left: 100px; bottom: 166px; width: 560px; max-height: 46vh; display: flex; flex-direction: column; padding: 8px; }
#catTabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
#catTabs button { font: inherit; font-size: 11px; font-weight: 800; color: var(--text); border: 1px solid var(--edge); background: linear-gradient(180deg, #3b6498, #27476f); border-radius: 7px; padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
#catTabs button span { font-size: 14px; }
#catTabs button.active { background: linear-gradient(180deg, #f6cf5e, #d9a63a); color: #2a1d06; }
#catItems { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; overflow-y: auto; padding: 2px; }
.catItem { border: 2px solid transparent; border-radius: 8px; background: rgba(0,0,0,.28); padding: 4px; cursor: pointer; text-align: center; font-size: 11px; font-weight: 800; }
.catItem:hover { border-color: var(--edge); }
.catItem.active { border-color: var(--green); background: rgba(53,211,87,.18); }
.catItem canvas { display: block; width: 100%; height: 64px; }
.catItem .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catItem .cost { color: var(--gold); }
.catItem.poor .cost { color: #ff8a80; }
.hint { font-size: 11px; color: var(--dim); margin-top: 6px; }

/* ---- chat / toasts / menu ---- */
#chat { position: absolute; right: 12px; top: 12px; width: 300px; display: flex; flex-direction: column; padding: 8px; max-height: 34vh; }
#chatLog { flex: 1; overflow-y: auto; font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; min-height: 50px; }
#chatLog .sys { color: var(--dim); font-style: italic; }
#chatLog b { color: var(--gold); }
#chatInput { width: 100%; margin-top: 6px; font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--edge); background: rgba(0,0,0,.3); color: var(--text); }
#toasts { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: linear-gradient(180deg, #2b4d7c, #1f3a5f); border: 1px solid var(--edge); color: #fff; padding: 7px 14px; border-radius: 8px; font-weight: 800; font-size: 13px; animation: toastIn .25s ease-out; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
#menu { position: absolute; min-width: 190px; background: var(--panel); border: 2px solid var(--edge); border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.45); padding: 6px; z-index: 5; }
#menu .title { font-weight: 900; font-size: 12px; padding: 4px 8px 6px; border-bottom: 1px solid rgba(127,163,209,.35); margin-bottom: 4px; color: var(--gold); }
#menu button { display: flex; width: 100%; justify-content: space-between; gap: 10px; font: inherit; font-size: 13px; font-weight: 700; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; cursor: pointer; text-align: left; color: var(--text); }
#menu button:hover { background: rgba(53,211,87,.25); }
#menu .cost { color: var(--gold); }
#status { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--panel); border: 2px solid var(--edge); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 800; }

/* ---- Create a Squirrel ---- */
.modal { position: fixed; inset: 0; background: rgba(8, 18, 34, .78); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modalCard { background: var(--panel); border: 3px solid var(--edge); border-radius: 16px; padding: 20px 26px; width: min(660px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 0 1px var(--edge-dark); max-height: 94vh; overflow: auto; }
.modalCard h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: .5px; }
.sub { margin: 0 0 14px; font-size: 13px; }
.casBody { display: flex; gap: 20px; align-items: flex-start; }
#casPreview { border-radius: 12px; background: linear-gradient(180deg, #8fc0ee, #3f7fbf 70%, #6db35c 70%); border: 2px solid var(--edge); flex: none; }
.casForm { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.casForm label { font-weight: 800; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.casForm input { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--edge); background: rgba(0,0,0,.3); color: var(--text); }
.lbl { font-weight: 800; font-size: 12px; margin-top: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(0,0,0,.3); cursor: pointer; }
.swatch.active { border-color: var(--green); transform: scale(1.1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 12px; font-weight: 800; border: 1px solid var(--edge); background: rgba(0,0,0,.25); color: var(--text); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.chip.active { background: var(--gold); color: #2a1d06; }
.err { color: #ff8a80; font-weight: 800; font-size: 13px; }
#casGo { margin-top: 6px; align-self: flex-start; }

@media (max-width: 1100px) {
  #bottom { grid-template-columns: 70px 150px 1fr 1fr; }
  .options { display: none; }
  #chat { display: none; }
}
