:root {
  --bg: rgba(12, 16, 28, 0.74);
  --bg-strong: rgba(10, 13, 24, 0.92);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8eef6;
  --muted: #93a0b4;
  --accent: #6ff3ff;
  --warm: #ffb454;
  --ok: #69db7c;
  --bad: #ff8787;
  --dream: #b197fc;
  --panel-w: 380px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #5aa4dc; }
button, input, select { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
code { font-family: var(--mono); font-size: 0.9em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.err { color: var(--bad); font-size: 12.5px; margin: 6px 0 0; }

#world { position: fixed; inset: 0; width: calc(100vw - var(--panel-w)); height: 100vh; display: block; cursor: grab; touch-action: none; }
#world:active { cursor: grabbing; }

.glass {
  background: var(--bg);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

#topbar {
  position: fixed; top: 12px; left: 12px; right: calc(var(--panel-w) + 12px);
  display: flex; align-items: center; gap: 14px; padding: 8px 12px; flex-wrap: wrap; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.02em; min-width: 0; }
#world-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.logo { color: var(--accent); text-shadow: 0 0 10px rgba(111, 243, 255, 0.7); }
.clock { font-variant-numeric: tabular-nums; color: #cfd8e6; white-space: nowrap; }
.clock .paused { color: var(--warm); font-weight: 600; }
.controls { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.controls button, .seg button {
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; cursor: pointer; min-width: 32px;
}
.controls button:hover { background: rgba(255, 255, 255, 0.12); }
.controls button.on { border-color: rgba(111, 243, 255, 0.6); box-shadow: inset 0 0 0 1px rgba(111, 243, 255, 0.25); }
.controls button.off { opacity: 0.45; }
.controls button:disabled { opacity: 0.3; cursor: default; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; font-size: 12px; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: rgba(111, 243, 255, 0.18); }
.views button { position: relative; font-size: 13px; }
.views button sup { font-size: 9px; margin-left: 1px; color: var(--accent); }

.ai-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); max-width: 100%; min-width: 0; }
.ai-status .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #888; flex: none; }
.ai-status.s-ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.ai-status.s-unknown .dot { background: #adb5bd; }
.ai-status.s-degraded .dot { background: #ffd43b; }
.ai-status.s-down .dot, .ai-status.s-auth-error .dot, .ai-status.s-offline .dot { background: var(--bad); }
.ai-status.s-instinct .dot, .ai-status.s-paused .dot, .ai-status.s-budget .dot { background: var(--warm); }
.ai-status .leak { color: var(--warm); font-weight: 600; }

#banner {
  position: fixed; top: 64px; left: calc((100vw - var(--panel-w)) / 2); transform: translateX(-50%); z-index: 6;
  background: rgba(60, 30, 10, 0.85); border: 1px solid rgba(255, 180, 84, 0.4); color: #ffe3bf; padding: 8px 14px; border-radius: 10px; font-size: 13px; max-width: 70vw;
}

#toasts { position: fixed; bottom: 18px; left: calc((100vw - var(--panel-w)) / 2); transform: translateX(-50%); z-index: 12; display: flex; flex-direction: column-reverse; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; cursor: default; padding: 8px 14px; border-radius: 10px; font-size: 13px; max-width: min(520px, 80vw);
  background: var(--bg-strong); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0; transform: translateY(6px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast.at { cursor: pointer; }
.toast.k-milestone { border-color: rgba(255, 214, 102, 0.55); }
.toast.k-omen { border-color: rgba(177, 151, 252, 0.6); }
.toast.k-art { border-color: rgba(111, 243, 255, 0.55); }
.toast.k-error { border-color: rgba(255, 135, 135, 0.6); }

#perf {
  position: fixed; top: 64px; left: 12px; z-index: 9; margin: 0; padding: 8px 10px; border-radius: 10px;
  font: 11px/1.45 var(--mono); color: #cfe; background: rgba(0, 0, 0, 0.62); pointer-events: none;
}

#minimap-wrap { position: fixed; left: 12px; bottom: 12px; padding: 8px; z-index: 5; }
#minimap { display: block; width: 200px; height: 110px; cursor: pointer; }

#tooltip { position: fixed; z-index: 10; padding: 8px 10px; font-size: 12px; line-height: 1.45; pointer-events: none; max-width: 280px; border-radius: 10px; background: var(--bg-strong); }

#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); border-radius: 0; border-width: 0 0 0 1px;
  display: flex; flex-direction: column; z-index: 5; background: rgba(11, 15, 26, 0.88);
}
#chips { display: flex; gap: 6px; padding: 10px 14px 0; flex-wrap: wrap; flex: none; }
#chips button { display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); cursor: pointer; font-size: 12px; }
#chips button.on { border-color: var(--accent); background: rgba(111, 243, 255, 0.12); }
#chips .sw { width: 9px; height: 9px; border-radius: 50%; background: #888; }

#card { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.card-head { display: flex; gap: 12px; align-items: center; }
#portrait svg { display: block; border-radius: 50%; box-shadow: 0 0 0 2px rgba(111, 243, 255, 0.35); }
#av-name { font-size: 18px; font-weight: 700; }
#av-sub { font-size: 12px; }
.activity { margin-top: 10px; font-size: 13px; padding: 6px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); }
.activity .ic { margin-right: 4px; }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 6px; background: rgba(255, 180, 84, 0.2); color: var(--warm); }
.goal { margin-top: 8px; font-size: 13px; line-height: 1.4; padding: 7px 9px; border-radius: 8px; background: rgba(111, 243, 255, 0.07); border: 1px solid rgba(111, 243, 255, 0.15); }
.goal .plan { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: pre-wrap; }
.lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-right: 6px; font-weight: 600; }
#needs { margin-top: 10px; display: grid; gap: 4px; }
.need { display: grid; grid-template-columns: 64px 1fr 26px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.need b { text-align: right; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.need.low b { color: var(--bad); }
.bar { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.6s ease; }
.need.n-health .bar i { background: #ff5d6c; }
.need.n-satiety .bar i { background: #ffa94d; }
.need.n-hydration .bar i { background: #4dabf7; }
.need.n-energy .bar i { background: #ffd43b; }
.need.n-mood .bar i { background: #b197fc; }
.need.n-air .bar i { background: #c8f0ff; }

#tabs { display: flex; padding: 0 8px; border-bottom: 1px solid var(--line); flex: none; }
#tabs button { flex: 1; background: none; border: none; padding: 10px 4px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
#tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.tab { display: none; flex: 1 1 0; overflow-y: auto; padding: 10px 14px; min-height: 140px; }
.tab.on { display: block; }
.tab::-webkit-scrollbar, #chatlog::-webkit-scrollbar { width: 8px; }
.tab::-webkit-scrollbar-thumb, #chatlog::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
.filters { display: flex; gap: 14px; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.filters input { vertical-align: -2px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 62px 20px 1fr; gap: 4px; font-size: 12.5px; line-height: 1.4; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.feed li .t, .mem .t, .chron .t, .thought .t, .reflection .t, .referee .t { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.feed li.imp .tx { color: #fff; font-weight: 600; }
.feed li.f-speech .tx { color: #c5f6fa; }
.feed li.f-catastrophe .tx { color: #ffc9c9; }
.feed li.f-discovery .tx { color: #ffe8a3; }
.feed li.f-omen .tx { color: #d9ccff; }
.feed li.f-milestone .tx { color: #ffe08a; }
.feed li.f-system .tx { color: var(--muted); }
.feed li.at { cursor: pointer; }
.feed li.at:hover .tx { text-decoration: underline dotted; }

#mind .thought, #mind .reflection { padding: 8px 10px; margin-bottom: 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
#mind .thought.instinct { opacity: 0.7; border-style: dashed; }
#mind .say { margin: 3px 0 6px; font-size: 13.5px; line-height: 1.45; font-style: italic; color: #f1f5fb; }
.reasoning summary { cursor: pointer; font-size: 11px; color: var(--muted); }
.reasoning p { font-size: 12px; color: #aab6c8; line-height: 1.45; white-space: pre-wrap; margin: 4px 0; }
.hide-reasoning .reasoning, .hide-results .results { display: none; }
.calls { display: flex; flex-wrap: wrap; gap: 4px; }
.call { font-size: 11px; font-family: var(--mono); padding: 2px 6px; border-radius: 6px; background: rgba(111, 243, 255, 0.08); color: #bdf6fb; max-width: 100%; overflow-wrap: anywhere; }
.call b { color: var(--accent); }
.results { margin-top: 6px; display: grid; gap: 3px; }
.res { font-size: 11.5px; line-height: 1.4; color: #c3ccd9; white-space: pre-wrap; overflow-wrap: anywhere; }
.res.ok b { color: var(--ok); }
.res.bad b { color: var(--bad); }
#mind .reflection { background: rgba(177, 151, 252, 0.08); border-color: rgba(177, 151, 252, 0.25); }
#mind .reflection p { font-size: 13px; line-height: 1.5; margin: 4px 0; }
#mind .reflection ul { margin: 4px 0 0 16px; padding: 0; font-size: 12px; color: #d0c4ff; }
.echo { color: var(--dream); font-weight: 700; margin-right: 3px; }
#mind .referee { padding: 8px 10px; margin-bottom: 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 180, 84, 0.07); }
#mind .referee.ok { background: rgba(105, 219, 124, 0.08); border-color: rgba(105, 219, 124, 0.25); }
#mind .referee.bad { background: rgba(255, 135, 135, 0.07); border-color: rgba(255, 135, 135, 0.22); }
#mind .referee p { font-size: 12.5px; line-height: 1.45; margin: 4px 0; }
.empty { text-align: center; margin-top: 30px; }

.sect { margin-bottom: 14px; }
.sect h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); display: inline-block; }
details.sect summary { cursor: pointer; list-style: none; }
details.sect summary::-webkit-details-marker { display: none; }
details.sect summary h4::before { content: '▸ '; }
details.sect[open] summary h4::before { content: '▾ '; }
.count { color: var(--accent); margin-left: 4px; }
.sect p { margin: 4px 0; font-size: 13px; line-height: 1.45; }
.story-text { white-space: pre-wrap; }
.recap { color: #c9d3e1; }
.lore-name { font-size: 16px; font-weight: 700; color: #fff; }
.lore-tag { font-style: italic; color: #c9d3e1; }
.gen-banner { font-size: 11.5px; padding: 4px 8px; border-radius: 8px; background: rgba(255, 180, 84, 0.12); border: 1px solid rgba(255, 180, 84, 0.3); color: #ffd8a8; margin: 6px 0; }
.region { font-size: 12.5px; margin: 3px 0; }
.inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; }
.item { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 2px 4px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.item span { font-size: 20px; }
.item b { position: absolute; top: 3px; right: 6px; font-size: 11px; }
.item small { font-size: 9.5px; color: var(--muted); text-align: center; line-height: 1.15; margin-top: 2px; }
.skill { display: grid; grid-template-columns: 92px 1fr 26px; gap: 8px; align-items: center; font-size: 12px; margin: 3px 0; text-transform: capitalize; }
.skill .bar i { background: linear-gradient(90deg, #6ff3ff, #b197fc); }
.skill b { font-size: 11px; color: var(--accent); }
.routine { font-size: 12.5px; margin: 5px 0; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; margin: 2px 1px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); }
.pill.custom { border-color: rgba(255, 180, 84, 0.5); color: #ffd8a8; }
.mem { font-size: 12px; line-height: 1.45; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.mem.imp8, .mem.imp9, .mem.imp10 { color: #fff; }
.mem.sealed { color: var(--muted); font-style: italic; }
.peek { display: block; font-size: 11px; color: var(--warm); margin: 2px 0 6px; }
.chron { font-size: 12.5px; line-height: 1.45; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.lm { display: block; width: 100%; text-align: left; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 5px; cursor: pointer; font-size: 12.5px; }
.lm:hover { background: rgba(255, 255, 255, 0.08); }
.invention, .plugin { padding: 8px 10px; margin-bottom: 7px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.plugin.disabled { opacity: 0.55; }
.inv-head { font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inv-head .muted { font-size: 11px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: #888; }
.invention p, .plugin p { margin: 4px 0; font-size: 12.5px; }
.fx { color: #bdf6fb; font-size: 12px !important; }
pre.code { max-height: 260px; overflow: auto; font-size: 11px; line-height: 1.4; background: rgba(0, 0, 0, 0.35); padding: 8px; border-radius: 8px; white-space: pre; }
.pl-btns, .cp-btns { display: flex; gap: 6px; margin-top: 6px; }
.pl-btns button, .cp-btns button, .cp-form button { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); cursor: pointer; font-size: 12px; }
.cp-btns button:disabled { opacity: 0.35; cursor: not-allowed; }
.site { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.site .ok { color: #7ee2a8; }
.site .bad { color: #ff8d8d; }

#chat { flex: none; border-top: 1px solid rgba(255, 255, 255, 0.16); padding: 8px 12px 12px; background: rgba(8, 11, 20, 0.96); box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.28); }
#chatlog { max-height: clamp(48px, 16vh, 150px); overflow-y: auto; margin-bottom: 8px; display: flex; flex-direction: column; gap: 5px; mask-image: linear-gradient(to bottom, transparent 0, #000 14px); }
.msg { font-size: 12.5px; line-height: 1.4; padding: 5px 9px; border-radius: 10px; max-width: 92%; }
.msg b { display: block; font-size: 10px; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.msg.me { align-self: flex-end; background: rgba(111, 243, 255, 0.12); }
.msg.them { align-self: flex-start; background: rgba(255, 255, 255, 0.08); }
.msg.sys { align-self: center; background: none; color: var(--muted); font-style: italic; }
#chat-form { display: flex; gap: 6px; }
#chat-input { flex: 1; min-width: 0; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); outline: none; }
#chat-input:focus { border-color: rgba(111, 243, 255, 0.5); }
#chat-form button { padding: 0 14px; border-radius: 10px; border: 1px solid rgba(111, 243, 255, 0.4); background: rgba(111, 243, 255, 0.15); cursor: pointer; font-weight: 600; }

dialog { color: var(--text); padding: 20px 22px; max-width: 440px; background: var(--bg-strong); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h3 { margin: 0 0 6px; }
dialog .radio { display: block; font-size: 13px; margin: 10px 0; line-height: 1.4; }
dialog .seed { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 12px 0; }
dialog .seed input, dialog .seed select { flex: 1; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); }
dialog .seed select option { background: #141a2a; }
dialog .seed input:invalid { border-color: rgba(255, 135, 135, 0.6); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog .row button { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); cursor: pointer; }
dialog .row button.danger { background: rgba(255, 107, 107, 0.2); border-color: rgba(255, 107, 107, 0.5); }
dialog .row button.primary { background: rgba(111, 243, 255, 0.15); border-color: rgba(111, 243, 255, 0.45); font-weight: 600; }
/* Sign-in splash: the backdrop is a generated painting of the island; the card floats over it. */
#login {
  width: min(380px, 92vw); padding: 30px 28px 22px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 26, 0.62); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  margin: auto 8vw auto auto;
}
#login::backdrop {
  background: linear-gradient(90deg, rgba(6, 9, 18, 0.05) 0%, rgba(6, 9, 18, 0.25) 55%, rgba(6, 9, 18, 0.7) 100%), url('/splash.jpg') center / cover no-repeat, #070a14;
}
#login .brand { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 700; letter-spacing: 0.04em; margin: 0; }
#login .brand .mark { color: var(--accent); font-size: 18px; filter: drop-shadow(0 0 8px rgba(111, 243, 255, 0.7)); }
#login .tagline { margin: 6px 0 22px; color: #c3cee0; font-size: 14px; line-height: 1.45; }
#login label { display: block; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 12px; }
#login-token, #login-user {
  width: 100%; margin-top: 6px; padding: 11px 13px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07); transition: border-color 0.15s, background 0.15s;
}
#login-token:focus, #login-user:focus { border-color: rgba(111, 243, 255, 0.6); background: rgba(255, 255, 255, 0.1); outline: none; }
#login .row { margin-top: 20px; }
#login .row button.primary { width: 100%; padding: 11px; font-size: 15px; border-radius: 10px; }
#login .foot { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { #login { margin: auto; } }
#time-dialog { width: min(560px, 92vw); }
.cp-form { display: flex; gap: 6px; margin: 10px 0; }
.cp-form input { flex: 1; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); }
#cp-list { max-height: 50vh; overflow-y: auto; }
.cp { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cp.auto b { font-weight: 500; color: #c9d3e1; }
.cp .kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-left: 6px; }
.cp-btns { margin-top: 0; }

#story .sect .bar { margin: 6px 0; }
#story input { width: 100%; padding: 7px 9px; margin: 4px 0 6px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); outline: none; }
#story input:focus { border-color: rgba(111, 243, 255, 0.5); }
#story button { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); cursor: pointer; font-size: 12px; }
#story button:hover { background: rgba(255, 255, 255, 0.12); }
#story .seg button { border-radius: 0; margin-left: -1px; }
#story .seg button:first-child { border-radius: 8px 0 0 8px; }
#story .seg button:last-child { border-radius: 0 8px 8px 0; }
#story .seg button.on { background: rgba(111, 243, 255, 0.18); border-color: rgba(111, 243, 255, 0.45); }
#story .st-rewind { margin-left: 6px; padding: 1px 8px; font-size: 11px; }
#story .st-branch.on > p b { color: var(--accent); }
#story li { margin: 3px 0; }
#story details summary { cursor: pointer; }

@media (max-width: 860px) {
  :root { --panel-w: 0px; }
  #world { width: 100vw; height: 56vh; }
  #panel { top: 56vh; width: 100vw; border-width: 1px 0 0 0; overflow-y: auto; }
  #panel > * { flex: none; }
  #card { overflow: visible; }
  .tab.on { height: 40vh; min-height: 160px; }
  #topbar { right: 12px; left: 12px; gap: 8px; padding: 6px 8px; }
  .ai-status { display: none; }
  #minimap-wrap { display: none; }
  #banner { top: 110px; left: 50%; }
  #toasts { left: 50%; bottom: calc(44vh + 12px); }
}

/* View-only accounts: hide what the server would refuse. */
body.viewer #btn-pause, body.viewer #speed, body.viewer #btn-ai, body.viewer #btn-time, body.viewer #btn-reset, body.viewer #chat-form { display: none !important; }
