:root {
  --bg: #111113;
  --panel: #161619;
  --raise: #1c1c20;
  --line: #24242a;
  --line-2: #303037;
  --text: #e9e7e3;
  --muted: #a09fa7;
  --faint: #6c6b74;
  --accent: #d9643f;
  --accent-soft: rgba(217, 100, 63, 0.14);
  --ok: #8fb996;
  --bad: #d78b7a;
  --paper: #efe7d6;
  --ink: #26231e;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
h2 { font-size: 13px; letter-spacing: 0.02em; color: var(--muted); }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
b { font-weight: 500; }
.faint { color: var(--faint); }
ol, ul { list-style: none; margin: 0; padding: 0; }
p { margin: 0; }

/* ---------- buttons, fields ---------- */
.btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--raise); cursor: pointer;
  font-size: 13.5px; transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.btn:hover { border-color: #44444d; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0f0a; font-weight: 500; }
.btn.primary:hover { background: #e2724e; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raise); }
.btn.danger { color: var(--bad); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0;
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #0d0d0f; color: var(--text); font-size: 15px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--bad); font-size: 13.5px; }
.form-ok { color: var(--ok); font-size: 13.5px; }
.hint-text { color: var(--faint); font-size: 13px; }

/* ---------- brand ---------- */
/* The house keycap from the brand kit: /logo.svg is the small version, /brand/mark.svg the big one. */
.brand-mark { display: block; width: 28px; height: 28px; flex: none; }
.login-mark { display: block; width: 64px; height: 64px; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: rgba(17, 17, 19, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.clock { display: flex; align-items: center; gap: 12px; }
.clock-text { font-family: var(--mono); font-size: 15px; font-weight: 500; white-space: nowrap; }
.day { color: var(--muted); font-weight: 400; }
.sky { width: 18px; height: 18px; border-radius: 50%; flex: none; transition: background 1s, box-shadow 1s; background: #f2c66d; box-shadow: 0 0 12px rgba(242, 198, 109, 0.6); }
.sky.night { background: transparent; box-shadow: inset -5px -2px 0 0 #dfe4f2; }
.sky.dusk, .sky.dawn { background: #f09a62; box-shadow: 0 0 12px rgba(240, 154, 98, 0.55); }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status.live .dot { background: var(--ok); }
.status.thinking .dot { background: var(--accent); animation: breathe 1.4s var(--ease) infinite; }
.status.paused .dot { background: var(--bad); }
.top-right { justify-self: end; display: flex; align-items: center; gap: 6px; min-width: 0; }
.who-am-i { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--faint); white-space: nowrap; margin-left: 6px; }
.who-am-i b { color: var(--muted); }
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }

.banner { margin: 12px 24px 0; padding: 10px 14px; border: 1px solid rgba(215, 139, 122, 0.4); background: rgba(215, 139, 122, 0.08); color: var(--bad); border-radius: 10px; font-size: 14px; }

/* ---------- layout ---------- */
.layout { display: grid; gap: 28px; max-width: 1500px; margin: 0 auto; padding: 22px 24px 60px; }
/* Its own box so the sticky feed lets go before the recap underneath. */
.columns { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(330px, 1fr); gap: 28px; align-items: start; }
.stage { display: grid; gap: 18px; min-width: 0; }
.intro { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.intro p { color: var(--muted); font-size: 14.5px; max-width: 68ch; }
.intro b { color: var(--text); }
.spend { font-family: var(--mono); font-size: 12px; color: var(--faint); white-space: nowrap; }

/* ---------- keeping it running ---------- */
.coffee {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; width: fit-content; margin: 4px 0 14px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted);
  text-decoration: none; transition: color 0.2s, border-color 0.2s, transform 0.15s;
}
.coffee:hover { color: var(--text); border-color: var(--muted); }
.coffee:active { transform: translateY(1px); }
.coffee svg { flex: none; }
.coffee-handle { color: var(--faint); font-size: 12px; }
.coffee.inline { margin: 8px 0 0; }

/* ---------- the town scene ---------- */
/* The map is drawn from above, like a town plan (tools/draw-town.mjs draws it, 1600 x 1000). */
.scene {
  position: relative; aspect-ratio: 1600 / 1000; border-radius: 20px; overflow: hidden; container-type: inline-size;
  border: 1px solid var(--line); background: #2a3327;
  box-shadow: 0 24px 50px -30px rgba(0, 0, 0, 0.8);
}
.scene-art, .login-art .scene-art { position: absolute; inset: 0; }
.town-svg { display: block; width: 100%; height: 100%; }

.phase-day, .phase-dawn, .phase-dusk, .phase-night {
  --ground: #6b8650; --lawn: #78965a; --yard: #7d9a5c; --fence: rgba(240, 232, 214, 0.55);
  --field-1: #b2a964; --field-2: #8f9d58; --field-3: #a88a5e;
  --forest-floor: #3c5633; --tree: #3f6436; --tree-deep: #31502c; --willow: #6e8f4c; --street-tree: #4b7440; --shrub: #4f7a3f;
  --road: #67625a; --sidewalk: #b2a996; --stone: #bdb3a2; --parapet: #978e7c; --plaza: #c8bca7; --cobble: #aaa293; --cobble-gap: #8a8375;
  --water: #5a8fab; --bank: #8c805f; --path: #c5b791;
  --roof-a: #b2664b; --roof-b: #5d6d7e; --roof-c: #808b5b; --roof-d: #8e6b52; --roof-e: #9b5b4f; --chimney: #8a6a55;
  --awning: #b6553e; --stripe-a: #efe6d4; --stripe-b: #c25c44; --counter: #8a6a4f; --crate: #a27b52; --barrel: #7d5b3f;
  --terrace: #d8cab0; --parasol: #d9644c; --bench: #7a5d45; --board: #ebe1cb; --post: #6b4f3c; --planter: #8c6e52;
  --column: #efe7d8; --clock: #f4efe4; --jail: #8d8981; --jail-inner: #7a766f; --jail-yard: #a09a8d; --jetty: #9d7b55;
  --shade: #0b1020; --shade-o: 0; --lamps-o: 0;
  --label: #f7f3ec; --label-stroke: rgba(22, 24, 20, 0.8);
}
.phase-dawn { --shade: #e08a5c; --shade-o: 0.16; --lamps-o: 0.25; }
.phase-dusk { --shade: #5b2c4b; --shade-o: 0.36; --lamps-o: 0.8; }
.phase-night { --shade: #060a1b; --shade-o: 0.62; --lamps-o: 1; }

.town-svg .ground { fill: var(--ground); }
.town-svg .lawn { fill: var(--lawn); }
.town-svg .yard { fill: var(--yard); stroke: var(--fence); stroke-width: 1.5; }
.town-svg .field-1 { fill: var(--field-1); }
.town-svg .field-2 { fill: var(--field-2); }
.town-svg .field-3 { fill: var(--field-3); }
.town-svg .furrows { fill: url(#furrows); }
.town-svg .furrow-line { stroke: rgba(40, 34, 18, 0.16); stroke-width: 2; }
.town-svg .forest-floor { fill: var(--forest-floor); }
.town-svg .glade { fill: #5d6f45; opacity: 0.75; }
.town-svg .road { fill: var(--road); }
.town-svg .sidewalk { fill: var(--sidewalk); }
.town-svg .stone { fill: var(--stone); }
.town-svg .parapet { fill: var(--parapet); }
.town-svg .flag-path { fill: var(--sidewalk); }
.town-svg .towpath, .town-svg .gravel { fill: none; stroke: var(--path); stroke-linecap: round; }
.town-svg .towpath { stroke-width: 9; opacity: 0.8; }
.town-svg .gravel { stroke-width: 10; opacity: 0.85; }
.town-svg .bank { fill: none; stroke: var(--bank); stroke-width: 88; stroke-linecap: round; }
.town-svg .river { fill: none; stroke: var(--water); stroke-width: 64; stroke-linecap: round; }
.town-svg .river-shine { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 2; stroke-dasharray: 26 40; transform: translateY(-8px); }
.town-svg .water { fill: var(--water); }
.town-svg .pond-rim { fill: var(--stone); }
.town-svg .fountain-jet { fill: #e8f4fb; }
.town-svg .shadow { fill: rgba(16, 20, 12, 0.3); }
.town-svg .slope { fill: rgba(0, 0, 0, 0.17); }
.town-svg .ridge { stroke: rgba(255, 255, 255, 0.28); stroke-width: 2; }
.town-svg .chimney { fill: var(--chimney); }
.town-svg .roof-a { fill: var(--roof-a); }
.town-svg .roof-b { fill: var(--roof-b); }
.town-svg .roof-c { fill: var(--roof-c); }
.town-svg .roof-d { fill: var(--roof-d); }
.town-svg .roof-e { fill: var(--roof-e); }
.town-svg .facet-lit { fill: rgba(255, 255, 255, 0.1); }
.town-svg .facet-dark { fill: rgba(0, 0, 0, 0.2); }
.town-svg .facet-mid { fill: rgba(0, 0, 0, 0.09); }
.town-svg .hip-lines { fill: none; stroke: rgba(0, 0, 0, 0.18); stroke-width: 1.2; }
.town-svg .canopy { fill: var(--tree); }
.town-svg .canopy-hi { fill: rgba(255, 255, 255, 0.11); }
.town-svg .deep .canopy { fill: var(--tree-deep); }
.town-svg .willow .canopy { fill: var(--willow); }
.town-svg .street .canopy { fill: var(--street-tree); }
.town-svg .shrub { fill: var(--shrub); }
.town-svg .stump { fill: #8d6c4a; stroke: #6e5238; stroke-width: 1.5; }
.town-svg .woods-tree { transition: opacity 1.2s ease; }
.town-svg .woods-tree.felled { opacity: 0; pointer-events: none; }
/* Empty plots where the town could build. A clearing in the woods only shows once it's cleared. */
.town-svg .lot { fill: rgba(255, 255, 255, 0.05); stroke: rgba(247, 243, 236, 0.42); stroke-width: 1.5; stroke-dasharray: 6 5; }
.town-svg .plot { display: none; fill: rgba(150, 128, 82, 0.35); }
.town-svg .plot.open { display: inline; }
/* House upgrades show once bought; the hilltop estates sit on a rise across the river. */
.town-svg .upgrade { display: none; }
.town-svg .upgrade.on { display: inline; }
.town-svg .housebody.hide { display: none; }
.town-svg .homelot { display: none; }
.town-svg .homelot.empty { display: inline; }
.need.thing { display: inline-flex; align-items: center; gap: 4px; }
.thing-pic { width: 18px; height: 18px; }
.house-art { position: absolute; aspect-ratio: 1; pointer-events: none; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.35)); }
.town-svg .hedge { fill: #3f6a35; stroke: #2f5228; stroke-width: 1; }
.town-svg .hill { fill: #7fa060; opacity: 0.55; }
.town-svg .estate-lawn { fill: #84a764; }
.town-svg .estate-wall { fill: none; stroke: #cfc3a8; stroke-width: 3; }
.town-svg .drive { fill: none; stroke: var(--path); stroke-width: 8; stroke-linecap: round; }
.town-svg .terrace { fill: var(--terrace); }
.town-svg .parasol { fill: var(--parasol); }
.town-svg .parasol-ribs { stroke: rgba(255, 255, 255, 0.45); stroke-width: 1.2; }
.town-svg .awning { fill: var(--awning); }
.town-svg .column { fill: var(--column); }
.town-svg .cobbles { fill: url(#cobbles); }
.town-svg .cobble { fill: var(--cobble); }
.town-svg .cobble-gap { fill: var(--cobble-gap); }
.town-svg .plaza { fill: var(--plaza); }
.town-svg .paving-grid { fill: url(#paving); }
.town-svg .paving-line { fill: none; stroke: rgba(90, 78, 60, 0.2); stroke-width: 1; }
.town-svg .stall { fill: var(--stripe-a); }
.town-svg .stall-stripes { fill: url(#stripes); }
.town-svg .stripe { fill: var(--stripe-b); }
.town-svg .counter { fill: var(--counter); }
.town-svg .crate { fill: var(--crate); }
.town-svg .barrel { fill: var(--barrel); }
.town-svg .board { fill: var(--board); }
.town-svg .post { fill: var(--post); }
.town-svg .bench { fill: var(--bench); }
.town-svg .planter { fill: var(--planter); }
.town-svg .flowers { fill: #e6b44c; }
.town-svg .flowers:nth-of-type(odd) { fill: #d97c8f; }
.town-svg .clockface { fill: var(--clock); }
.town-svg .jail-roof { fill: var(--jail); }
.town-svg .jail-roof-inner { fill: var(--jail-inner); }
.town-svg .jail-yard { fill: var(--jail-yard); }
.town-svg .bars { fill: url(#bars); }
.town-svg .bar-line { stroke: #44423e; stroke-width: 1.4; }
.town-svg .jetty { fill: var(--jetty); }
.town-svg .planks { fill: url(#planks); }
.town-svg .plank-line { stroke: rgba(0, 0, 0, 0.28); stroke-width: 1; }
.town-svg .reeds { fill: none; stroke: #6f8a46; stroke-width: 2; stroke-linecap: round; }
.town-svg .lamp-post { fill: #3a3833; }
.town-svg .shade { fill: var(--shade); opacity: var(--shade-o); }
.town-svg .lights { opacity: var(--lamps-o); }
.town-svg .bulb { fill: #ffe2a6; }
.town-svg .porch { fill: url(#lamp-glow); }
.town-svg .porch.vacant { display: none; }
.town-svg .labels text {
  font: 600 22px var(--sans); fill: var(--label); text-anchor: middle; letter-spacing: 0.01em;
  paint-order: stroke; stroke: var(--label-stroke); stroke-width: 5px; stroke-linejoin: round;
}
.town-svg .labels text.street { font: italic 500 15px var(--sans); fill: rgba(247, 243, 236, 0.78); stroke-width: 3.5px; letter-spacing: 0.06em; }
.town-svg .labels text.water-label { fill: rgba(225, 240, 250, 0.8); }
.town-svg .shade, .town-svg .lights { transition: opacity 2.5s ease, fill 2.5s ease; }

.lots { position: absolute; inset: 0; pointer-events: none; }
.lot-name.vacant { font-style: italic; opacity: 0.6; }
.conditions { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none; z-index: 2; }
.condition { font: 500 11.5px var(--sans); padding: 4px 10px; border-radius: 999px; background: rgba(12, 12, 14, 0.78); color: #f3f0ea; box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.5); animation: pop 0.45s var(--ease) both; }
.scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 2s ease; }
.scene.weather-rain::after {
  opacity: 1;
  background-image: repeating-linear-gradient(105deg, rgba(200, 215, 235, 0.22) 0 1px, transparent 1px 14px);
  background-size: 140px 140px; animation: rain 0.6s linear infinite;
}
.scene.weather-heat::after { opacity: 1; background: radial-gradient(ellipse at 50% 0%, rgba(255, 170, 80, 0.22), transparent 70%); }
.scene.weather-cold::after { opacity: 1; background: linear-gradient(180deg, rgba(170, 200, 255, 0.16), rgba(170, 200, 255, 0.05)); }
.scene.weather-fog::after { opacity: 1; background: radial-gradient(ellipse at 30% 40%, rgba(225, 230, 232, 0.34), rgba(225, 230, 232, 0.16) 60%, rgba(225, 230, 232, 0.26)); backdrop-filter: blur(1.2px); }
.scene.weather-cloudy::after { opacity: 1; background: linear-gradient(180deg, rgba(70, 78, 92, 0.2), rgba(70, 78, 92, 0.1)); }
.scene.weather-wind::after { opacity: 1; background-image: repeating-linear-gradient(170deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 60px); background-size: 300px 300px; animation: wind 1.6s linear infinite; }
@keyframes rain { from { background-position: 0 0; } to { background-position: -40px 140px; } }
@keyframes wind { from { background-position: 0 0; } to { background-position: 300px 40px; } }
.lot-name {
  position: absolute; translate: -50% 0; font: 600 clamp(6px, 1.34cqw, 10px) / 1.2 var(--sans); color: var(--label, #f7f3ec); white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); letter-spacing: 0.01em;
}
.build {
  position: absolute; aspect-ratio: 1; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto;
  transition: transform 0.25s var(--ease); filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.35));
  animation: rise 0.8s var(--ease) both;
}
.build:hover { transform: translateY(-2px) scale(1.06); }
.build img { display: block; width: 100%; height: 100%; }
.build.pending { border: 2px dashed rgba(247, 243, 236, 0.7); border-radius: 10px; filter: none; animation: breathe 2s ease-in-out infinite; }
.phase-night .build img, .phase-dusk .build img { filter: brightness(0.72) saturate(0.85); }
/* Names grow with the map so neighbors stay clear at any width. Below 6px they stop
   shrinking, and every other one drops a little further to make up for it. */
.lot-name.low { translate: -50% max(0px, calc((6px - 1.34cqw) * 1.5)); }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.85); } to { opacity: 1; transform: none; } }
.tokens { position: absolute; inset: 0; pointer-events: none; }
.token {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  display: grid; justify-items: center; gap: 3px; background: none; border: 0; padding: 0;
  transition: transform 1.6s var(--ease);
  will-change: transform;
}
.token .face {
  position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #16130f; font-weight: 600; font-size: 16px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 14px -4px rgba(0, 0, 0, 0.55);
  transition: transform 0.2s var(--ease);
}
.token:hover .face { transform: translateY(-2px) scale(1.06); }
.token .tag {
  font-size: 11px; font-weight: 500; line-height: 1; padding: 3px 6px 4px; border-radius: 6px;
  background: rgba(12, 12, 14, 0.74); color: #f3f0ea; white-space: nowrap;
}
.token.claude .face { border-color: #f6c4ad; }
.token.thinking .face::after {
  content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid var(--accent);
  animation: ring 1.6s var(--ease) infinite;
}
.token.asleep .face { filter: saturate(0.5) brightness(0.8); }
.token .zz { position: absolute; top: -10px; right: -12px; font: 600 12px var(--mono); color: #dfe4f2; animation: float 2.4s ease-in-out infinite; }
@keyframes ring { 0% { transform: scale(0.85); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes float { 0%, 100% { transform: translateY(0); opacity: 0.9; } 50% { transform: translateY(-5px); opacity: 0.5; } }

.bubble {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform-origin: 50% 100%;
  width: max-content; max-width: 230px; padding: 7px 10px; border-radius: 12px;
  background: #f7f3ec; color: #1f1d19; font-size: 12.5px; line-height: 1.35; text-align: left;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.6);
  animation: pop 0.45s var(--ease) both;
  pointer-events: none;
  translate: -50% 0;
}
.bubble::after { content: ""; position: absolute; top: 100%; left: 50%; translate: -50% 0; border: 6px solid transparent; border-top-color: #f7f3ec; }
.bubble.dots { padding: 6px 10px; font: 600 14px var(--mono); letter-spacing: 2px; }
.bubble.dots span { animation: blink 1.2s infinite; }
.bubble.dots span:nth-child(2) { animation-delay: 0.2s; }
.bubble.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pop { from { opacity: 0; transform: scale(0.85) translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.scene.small .token .face { width: 28px; height: 28px; font-size: 13px; border-width: 1.5px; }
.scene.small .token .tag { font-size: 10px; padding: 2px 4px 3px; }
.scene.small .bubble { max-width: 150px; font-size: 11px; padding: 5px 8px; }
.scene.tiny .token .face { width: 20px; height: 20px; font-size: 10px; border-width: 1.5px; }
.scene.tiny .token .tag { font-size: 8.5px; padding: 1px 3px 2px; border-radius: 4px; }
.scene.tiny .bubble { max-width: 118px; font-size: 10px; padding: 4px 7px; border-radius: 9px; bottom: calc(100% + 7px); }
.scene.tiny .token.thinking .face::after { inset: -4px; }

/* ---------- cast cards ---------- */
.cast { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 12px; }
.citizens { display: grid; }
.citizens .cast-wrap { grid-template-rows: 0fr; opacity: 0; }
.citizens.open .cast-wrap { grid-template-rows: 1fr; opacity: 1; }
.cast-toggle {
  display: block; width: 100%; padding: 14px 16px; text-align: left; cursor: pointer; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.cast-toggle:hover { border-color: var(--line-2); background: #18181c; }
.cast-toggle:active { transform: scale(0.995); }
.cast-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cast-summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px 18px; }
.cast-title { display: grid; gap: 1px; }
.cast-title b { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.cast-title span { font: 11.5px var(--mono); color: var(--faint); }
.faces { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.face {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--c); color: #16130f; font-weight: 600; font-size: 12px;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ring, var(--line-2));
}
.face.good { --ring: var(--ok); }
.face.mid { --ring: #e2b04a; }
.face.low { --ring: var(--bad); }
.face.thinking { animation: breathe 1.4s var(--ease) infinite; }
.cast-alerts { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.alert { font: 11px var(--mono); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); white-space: nowrap; }
.alert.low { color: var(--bad); border-color: rgba(215, 139, 122, 0.45); }
.alert.mid { color: #e2b04a; border-color: rgba(226, 176, 74, 0.4); }
.alert.good { color: var(--ok); border-color: rgba(143, 185, 150, 0.4); }
.cast-more { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.cast-more svg { width: 16px; height: 16px; transition: rotate 0.3s var(--ease); }
.citizens.open .cast-more svg { rotate: 180deg; }
.card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start;
  text-align: left; padding: 14px; border-radius: 16px; cursor: pointer; min-height: 132px;
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color 0.2s, transform 0.2s var(--ease), background 0.2s;
}
.card:hover { border-color: var(--line-2); background: #18181c; transform: translateY(-1px); }
.card:active { transform: scale(0.99); }
.card.thinking { border-color: rgba(217, 100, 63, 0.55); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.ring { position: relative; width: 52px; height: 52px; flex: none; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--line-2); stroke-width: 3; }
.ring .fill { fill: none; stroke: var(--c); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring.low .fill { stroke: var(--bad); }
.ring .av { position: absolute; inset: 7px; width: auto; height: auto; font-size: 15px; }
.card-main { display: grid; gap: 6px; min-width: 0; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-name { font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; }
.coins { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.coins::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d8b45a; margin-right: 6px; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3); }
.model { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model.claude { color: var(--accent); }
.card-doing { font-size: 13.5px; color: var(--text); line-height: 1.35; }
.card-doing .where, .mood { color: var(--faint); }
.needs { display: flex; flex-wrap: wrap; gap: 4px; }
.need { font: 11px var(--mono); padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.need.warn { color: #e2b04a; border-color: rgba(226, 176, 74, 0.4); }
.need.bad { color: var(--bad); border-color: rgba(215, 139, 122, 0.45); }
.card-diary { font-size: 12.5px; color: var(--muted); font-style: italic; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.av {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--c); color: #16130f; font-weight: 600; font-size: 11px;
}
.av.lg { width: 52px; height: 52px; font-size: 21px; }
.av.pulse { animation: breathe 1.4s var(--ease) infinite; }

/* ---------- panels ---------- */
.panels { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { flex: none; height: 32px; padding: 0 12px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13.5px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.tab-panel { padding: 18px; }
.empty { color: var(--faint); font-size: 14px; }

.ties { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: center; }
.ties-graph { width: 100%; height: auto; display: block; }
.ties-graph line { stroke: #e9e7e3; stroke-linecap: round; transition: opacity 0.3s, stroke 0.3s; }
.ties-graph .node { cursor: pointer; }
.ties-graph .node circle { stroke: rgba(255, 255, 255, 0.85); stroke-width: 2; }
.ties-graph .node text { font: 600 15px var(--sans); fill: #16130f; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.ties-graph .node .name { fill: var(--muted); font-size: 12px; font-weight: 500; }
.ties-graph.focus line { opacity: 0.08 !important; }
.ties-graph.focus line.on { opacity: 0.9 !important; stroke: var(--accent); }
.ties-list { display: grid; gap: 2px; }
.ties-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ties-list .pair { display: inline-flex; }
.ties-list .pair .av + .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--panel); }
.ties-list .count { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.ties-caption { grid-column: 1 / -1; color: var(--faint); font-size: 12.5px; }

.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.note {
  position: relative; background: var(--paper); color: var(--ink); border-radius: 4px; padding: 16px 14px 12px;
  font-size: 13.5px; line-height: 1.45; box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.7); rotate: -0.8deg;
}
.note:nth-child(even) { rotate: 0.9deg; }
.note:nth-child(3n) { rotate: -0.3deg; }
.note::before { content: ""; position: absolute; top: 6px; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
.note .meta { margin-top: 8px; font-size: 11.5px; color: #6f665a; font-family: var(--mono); }

.rules { display: grid; gap: 22px; }
.rules-intro { color: var(--muted); font-size: 14px; max-width: 70ch; }
.rules-part { display: grid; gap: 12px; }
.rules-part h3 { font-size: 13px; color: var(--muted); letter-spacing: 0.02em; }
.rule-no { display: block; margin-bottom: 4px; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: #8a5a3f; }
.rule-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rule-group { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--raise); }
.rule-group h4 { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.rule-group ul { display: grid; gap: 7px; }
.rule-group li { position: relative; padding-left: 14px; color: #cfcdc8; font-size: 13.5px; line-height: 1.5; }
.rule-group li::before { content: ""; position: absolute; left: 1px; top: 0.6em; width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.rule-group b { font-family: var(--mono); font-weight: 500; color: var(--text); }
.land { display: grid; gap: 18px; }
.fund { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); font-size: 14px; }
.fund b { font: 500 18px var(--mono); }
.fund span { color: var(--faint); font-size: 12.5px; }
.land h3 { font-size: 13px; color: var(--muted); letter-spacing: 0.02em; }
/* Every house at a glance, at the top of the Land tab. */
.house-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 8px; }
.house-card { display: grid; gap: 4px; align-content: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raise); font-size: 12.5px; }
.house-card.empty { background: none; border-style: dashed; }
.house-card.tier-1 { box-shadow: inset 3px 0 0 #c9a45c; }
.house-card.tier-2 { box-shadow: inset 3px 0 0 var(--accent); }
.house-top { display: flex; justify-content: space-between; gap: 8px; }
.house-no { font: 500 11.5px var(--mono); color: var(--faint); }
.house-kind { font-size: 11.5px; color: var(--muted); }
.house-who { font-size: 14px; }
.house-meta { display: grid; gap: 2px; color: var(--muted); }
.house-builds { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.house-builds img, .house-builds .pic-pending { width: 34px; height: 34px; border-radius: 6px; background: var(--ground-ui, #2a3327); }
.builds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.built { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--raise); font-size: 13px; }
.built .pic { aspect-ratio: 1; border-radius: 10px; background: var(--ground-ui, #2a3327); display: grid; place-items: center; }
.built .pic img { width: 82%; height: 82%; }
.built .pic.pending { border: 2px dashed var(--line-2); background: transparent; color: var(--faint); font-size: 12px; text-align: center; padding: 8px; }
.built .what { font-weight: 500; }
.built .meta { font: 11px var(--mono); color: var(--faint); }
.shop-card .offer { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.shop-card .price { font-size: 13px; color: var(--muted); }
.shop-card .price b { font: 500 15px var(--mono); color: var(--text); }
.shop-card.closed { opacity: 0.55; }
.warn-text { color: #e2b04a; }
.need.shop { color: var(--accent); border-color: rgba(217, 100, 63, 0.4); }
.tag.building { color: #e2b04a; border-color: rgba(226, 176, 74, 0.4); }
.hall { display: grid; gap: 12px; }
.prop { border: 1px solid var(--line); border-radius: 14px; background: var(--raise); transition: border-color 0.2s; }
.prop:hover { border-color: var(--line-2); }
.prop details { border: 0; background: none; border-radius: 0; }
.prop summary { display: grid; gap: 8px; padding: 14px; color: inherit; font-size: inherit; border-radius: 14px; }
.prop summary::before { display: none; }
.prop summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.see-votes { justify-self: start; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.see-votes svg { width: 15px; height: 15px; transition: rotate 0.25s var(--ease); }
.prop details[open] .see-votes svg { rotate: 180deg; }
.votes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding: 0 14px 14px; animation: fade 0.25s ease; }
.vote-col { display: grid; gap: 8px; align-content: start; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.vote-col h5 { display: flex; justify-content: space-between; margin: 0; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
.vote-col h5 b { font-weight: 600; }
.vote-col.yes h5 b { color: var(--ok); }
.vote-col.no h5 b { color: var(--bad); }
.voters { display: grid; gap: 4px; }
.voter { all: unset; display: flex; align-items: center; gap: 8px; padding: 3px 4px; margin: 0 -4px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.voter:hover { background: var(--raise); }
.voter:focus-visible { outline: 2px solid var(--accent); }
.voter em { font-style: normal; font-size: 11.5px; color: var(--faint); margin-left: 4px; }
.nobody { font-size: 13px; color: var(--faint); font-style: italic; }
.prop-text { font-size: 14.5px; }
.prop-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--faint); font-family: var(--mono); flex-wrap: wrap; }
.tag { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); margin-right: 6px; }
.tag.open { color: var(--accent); border-color: rgba(217, 100, 63, 0.4); }
.tag.passed { color: var(--ok); border-color: rgba(143, 185, 150, 0.4); }
.tag.failed { color: var(--bad); border-color: rgba(215, 139, 122, 0.4); }
.votebar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--line); }
.votebar .yes { background: var(--ok); }
.votebar .no { background: var(--bad); }

/* ---------- feed ---------- */
.feed {
  position: sticky; top: 74px; max-height: calc(100dvh - 96px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
}
.feed-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.filters, .kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 6px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; cursor: pointer; font-size: 12.5px; color: var(--muted);
}
.filter.plain { padding: 0 10px; }
.filter .av { width: 18px; height: 18px; font-size: 9.5px; }
.filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.kinds .filter { height: 24px; font-size: 11.5px; padding: 0 9px; }
.feed-list { overflow-y: auto; padding: 4px 16px 16px; flex: 1; }
.hour-sep { position: sticky; top: 0; z-index: 1; padding: 10px 0 6px; font: 500 11.5px var(--mono); color: var(--faint); background: var(--panel); letter-spacing: 0.03em; }
.ev { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev.new { animation: slidein 0.6s var(--ease); }
.ev-body { min-width: 0; overflow-wrap: anywhere; }
.ev .quote { display: block; margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--line-2); color: var(--text); }
.ev.private .quote { border-left-color: #8f9ed6; }
.ev.civic .quote { border-left-color: var(--accent); }
.ev.quiet { color: var(--faint); font-size: 13px; }
.ev.news { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.ev-body > b, .ev-body .who { font-weight: 500; }
.ev .kind { display: inline-flex; align-items: center; gap: 4px; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); margin-right: 6px; }
.ev .kind svg { width: 12px; height: 12px; }
.ev-time { margin-top: 3px; font: 11px var(--mono); color: var(--faint); }
.sys-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.sys-icon svg { width: 14px; height: 14px; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- status at a glance ---------- */
.segs { display: inline-grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; }
.segs i { display: block; border-radius: 2px; background: var(--line-2); transition: background 0.5s var(--ease); }
.segs.good i.on { background: var(--ok); }
.segs.mid i.on { background: #e2b04a; }
.segs.low i.on { background: var(--bad); }
.vital { display: flex; align-items: center; gap: 6px; min-width: 0; }
.vital svg { width: 14px; height: 14px; flex: none; }
.vital.good svg { color: var(--ok); }
.vital.mid svg { color: #e2b04a; }
.vital.low svg { color: var(--bad); }
.vital .segs { flex: 1; height: 7px; }

.card-foot { grid-column: 1 / -1; display: grid; gap: 8px; min-width: 0; }
.card-stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; align-items: center; padding: 9px 10px; border-radius: 10px; background: var(--raise); }
.card-stats .vital .segs { height: 8px; }
.card-stocks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 16px; min-width: 0; }
.chip-stat { display: inline-flex; align-items: center; gap: 5px; font: 11.5px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-stat svg { width: 14px; height: 14px; flex: none; }
.chip-stat b { color: var(--text); font-weight: 600; }
.chip-stat.ok svg { color: var(--ok); }
.chip-stat.warn, .chip-stat.warn b, .chip-stat.warn svg { color: #e2b04a; }
.chip-stat.bad, .chip-stat.bad b, .chip-stat.bad svg { color: var(--bad); }

.hud { display: grid; gap: 8px; margin-top: 14px; }
.hud-bars { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.hud-bars .hud-bar:nth-child(3) { grid-column: 1 / -1; } /* happiness, full width under energy and food */
.hud-bar { display: grid; gap: 9px; padding: 11px 13px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.hud-bar-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.hud-label { display: inline-flex; align-items: center; gap: 6px; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
.hud-label svg { width: 16px; height: 16px; }
.hud-word { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-bar .segs { height: 11px; gap: 3px; }
.hud-bar.good .hud-word, .hud-bar.good .hud-label svg { color: var(--ok); }
.hud-bar.mid .hud-word, .hud-bar.mid .hud-label svg { color: #e2b04a; }
.hud-bar.low .hud-word, .hud-bar.low .hud-label svg { color: var(--bad); }
.hud-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.hud-tile {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 9px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.hud-tile svg { grid-row: span 2; width: 19px; height: 19px; color: var(--faint); }
.hud-val { font: 600 16px/1.2 var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-tile.money svg { color: #e2b04a; }
.hud-tile.ok svg { color: var(--ok); }
.hud-tile.warn svg, .hud-tile.warn .hud-val { color: #e2b04a; }
.hud-tile.bad svg, .hud-tile.bad .hud-val { color: var(--bad); }
.hud-tile.where .hud-val { font: 600 13.5px/1.25 var(--sans); }

/* ---------- recap ---------- */
.recap {
  display: grid; gap: 12px; padding: 26px 28px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
}
.recap-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
.recap-kicker { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.recap-range { font: 12px var(--mono); color: var(--faint); }
.recap-title { font-size: clamp(20px, 2.2vw, 26px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; color: var(--text); max-width: 44ch; text-wrap: balance; }
.recap-body { display: grid; gap: 10px; max-width: 72ch; }
.recap-body p { color: #cfcdc8; font-size: 15.5px; line-height: 1.65; }
.recap-meta { font: 11.5px var(--mono); color: var(--faint); }
.recap-empty { color: var(--muted); font-size: 14.5px; max-width: 62ch; }
.name-link {
  all: unset; cursor: pointer; color: var(--text); font-weight: 500;
  background: linear-gradient(var(--c), var(--c)) no-repeat 0 100% / 100% 2px; padding-bottom: 1px; transition: color 0.2s;
}
.name-link:hover { color: var(--c); }
.name-link:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; border-radius: 3px; }

/* ---------- drawers ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(8, 8, 10, 0.55); backdrop-filter: blur(2px); animation: fade 0.25s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(640px, 100vw);
  display: flex; flex-direction: column; background: #131316; border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.7); animation: drawer-in 0.35s var(--ease);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.drawer-who { display: flex; gap: 14px; min-width: 0; }
.drawer-who h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.persona { color: var(--muted); font-size: 13.5px; margin-top: 12px; max-width: 62ch; }
#drawer .drawer-head { flex-wrap: wrap; row-gap: 0; }
.drawer-more { flex-basis: 100%; }
.hud-meta { margin-top: 8px; font: 11.5px var(--mono); color: var(--faint); }
.self-view { margin-top: 10px; max-width: 62ch; font-size: 13.5px; color: var(--text); padding: 8px 12px; border-left: 2px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.self-view span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.wish { color: #e2b04a; font-size: 13px; margin-top: 4px; max-width: 52ch; }
.wish::before { content: "Secret wish: "; color: var(--faint); }
.gone-note { color: var(--bad); font-size: 13px; margin-top: 4px; }
.departed { display: flex; flex-wrap: wrap; gap: 8px; }
.departed span { font-size: 13px; color: var(--faint); padding: 4px 10px; border: 1px dashed var(--line-2); border-radius: 999px; }
.drawer-body { overflow-y: auto; overflow-x: hidden; padding: 16px 22px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
/* Reading down a diary folds the header to the name and one line; scrolling back up opens it. */
.who-text { min-width: 0; }
.fold { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.32s var(--ease), opacity 0.22s ease; }
.fold-inner { min-height: 0; overflow: hidden; }
.mini-fold { grid-template-rows: 0fr; opacity: 0; }
.mini { margin-top: 4px; display: flex; align-items: center; gap: 12px; font: 12px var(--mono); color: var(--faint); white-space: nowrap; }
.mini .vital { flex: none; }
.mini .vital .segs { width: 62px; height: 6px; flex: none; }
.mini-coins { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.mini-coins svg { width: 14px; height: 14px; color: #e2b04a; }
.drawer-head { transition: padding 0.32s var(--ease); }
.drawer-who .av.lg { transition: width 0.32s var(--ease), height 0.32s var(--ease), font-size 0.32s var(--ease); }
.drawer.compact .drawer-head { padding-top: 12px; padding-bottom: 10px; align-items: center; }
.drawer.compact .drawer-who { align-items: center; cursor: pointer; }
.drawer.compact .drawer-who .av.lg { width: 34px; height: 34px; font-size: 15px; }
.drawer.compact .more-fold { grid-template-rows: 0fr; opacity: 0; }
.drawer.compact .mini-fold { grid-template-rows: 1fr; opacity: 1; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chart { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.chart-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); font-family: var(--mono); }
.chart-label b { color: var(--text); }
.chart svg { display: block; width: 100%; height: 40px; margin-top: 6px; overflow: visible; }
.chart polyline { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--c); opacity: 0.12; }
.talks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--faint); }
.talks .pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.talks .pill .av { width: 18px; height: 18px; font-size: 9.5px; }

.notes { padding: 12px 14px; border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 13.5px; white-space: pre-wrap; line-height: 1.5; }
.notes-wrap { display: grid; gap: 10px; }
.notes.memory { background: #e9e4d6; }
.notes-label { display: block; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: #7a7064; margin-bottom: 4px; }
.turn { padding: 14px 0 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.turn-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font: 12px var(--mono); color: var(--faint); }
.turn-head .when { color: var(--text); font-weight: 500; }
.turn-diary { white-space: pre-wrap; font-size: 15px; line-height: 1.6; }
.turn-diary.none { color: var(--faint); font-style: italic; }
.turn-error { padding: 9px 12px; border-radius: 10px; background: rgba(215, 139, 122, 0.08); border: 1px solid rgba(215, 139, 122, 0.3); color: var(--bad); font-size: 13.5px; }
.turn-note { font: 12px var(--mono); color: var(--faint); }
.acts { display: grid; gap: 2px; }
.acts li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; font-size: 13.5px; padding: 3px 0; }
.acts .mark { font-family: var(--mono); font-weight: 600; text-align: center; }
.acts .ok .mark { color: var(--ok); }
.acts .bad .mark { color: var(--bad); }
.act-what { color: var(--text); }
.act-result { color: var(--faint); }
details { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
details summary { cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: -45deg; transition: rotate 0.2s; }
details[open] summary::before { rotate: 45deg; }
details pre { margin: 0; padding: 10px 12px 12px; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.55 var(--mono); color: #c9c7c2; max-height: 420px; overflow-y: auto; }
.more { justify-self: center; }

.about p { color: #cfcdc8; font-size: 14.5px; line-height: 1.65; }

.new-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 2px; align-self: flex-start; margin-top: 8px; }
.changelog { gap: 22px; }
.changelog .intro-text { color: var(--faint); font-size: 13.5px; }
.change { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.change:first-of-type { border-top: 0; padding-top: 0; }
.change-date { font: 500 11.5px var(--mono); color: var(--faint); letter-spacing: 0.03em; }
.change h4 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.change ul { display: grid; gap: 6px; }
.change li { position: relative; padding-left: 16px; color: #cfcdc8; font-size: 14px; line-height: 1.55; }
.change li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.change.latest .change-date { color: var(--accent); }
.about h4 { margin-top: 8px; font-size: 13px; color: var(--muted); letter-spacing: 0.02em; }

/* ---------- admin ---------- */
.admin-section { display: grid; gap: 12px; padding: 4px 0 18px; border-bottom: 1px solid var(--line); }
.admin-section:last-child { border-bottom: 0; }
.admin-section h4 { font-size: 14px; font-weight: 600; }
.admin-section .sub { color: var(--faint); font-size: 13px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.switch-row .label { display: grid; gap: 2px; font-size: 14px; }
.switch-row .label span { color: var(--faint); font-size: 12.5px; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; border: 0; background: var(--line-2); cursor: pointer; flex: none; transition: background 0.25s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #f1eee8; transition: transform 0.25s var(--ease); }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.users { display: grid; }
.user-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row .name { font-weight: 500; }
.user-row .meta { font: 11.5px var(--mono); color: var(--faint); }
.user-row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-row .inline { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user-row .inline input { height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: #0d0d0f; color: var(--text); min-width: 0; flex: 1; }
.role { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-left: 6px; }
.add-user { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 150px); gap: 10px; align-items: end; }
.add-user .btn, .add-user .form-error { grid-column: 1 / -1; justify-self: start; }
.town-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.news-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px); gap: 10px; align-items: end; }
.news-form .field:first-child { grid-column: 1 / -1; }

/* ---------- sign in ---------- */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); }
.login-art { position: relative; overflow: hidden; background: #2a3327; }
.login-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 60%, var(--bg)); }
.login-art .town-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-panel { display: grid; align-content: center; gap: 16px; padding: 48px clamp(24px, 6vw, 80px); max-width: 520px; }
.login-panel h1 { font-size: clamp(34px, 4vw, 48px); font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.login-lede { color: var(--muted); font-size: 15.5px; max-width: 40ch; }
.login-panel .form { margin-top: 10px; }
.login-panel .btn.primary { height: 42px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.freq { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.freq > span { font-size: 13px; color: var(--muted); }
.freq label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.field.freq input[type="radio"] { appearance: auto; width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; flex: 0 0 16px; accent-color: var(--accent); }
.freq label { justify-content: flex-start; text-align: left; }
.post-btn { border-color: var(--accent); color: var(--text); }
.banner.ok { border-color: rgba(127, 176, 140, 0.45); background: rgba(127, 176, 140, 0.1); color: var(--ok); }
.login-panel .hint-text a { color: var(--muted); text-underline-offset: 3px; }
.login-panel .hint-text a:hover { color: var(--text); }

/* ---------- loading ---------- */
.skel { position: relative; overflow: hidden; background: var(--panel); border-color: var(--line); }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.035), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- smaller screens ---------- */
@media (max-width: 1400px) {
  .who-label { display: none; }
}
@media (max-width: 1240px) {
  .top { grid-template-columns: 1fr auto; row-gap: 8px; }
  .clock { grid-column: 1 / -1; grid-row: 2; }
  .top-right { grid-column: 2; grid-row: 1; }
}
@media (max-width: 1100px) {
  .cast { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cast-summary { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cast-alerts { grid-column: 1 / -1; justify-content: flex-start; grid-row: 2; }
}
@media (max-width: 980px) {
  .layout { padding: 16px 16px 40px; gap: 18px; }
  .columns { grid-template-columns: 1fr; gap: 18px; }
  .feed { position: static; max-height: 640px; }
  .top { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .clock { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .top-right { grid-column: 2; grid-row: 1; }
  .login { grid-template-columns: 1fr; grid-template-rows: 34dvh auto; }
  .login-art::after { background: linear-gradient(180deg, transparent 55%, var(--bg)); }
  .ties { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brand-name { font-size: 15px; }
  .clock { flex-wrap: wrap; row-gap: 2px; gap: 8px; }
  .clock-text { font-size: 13.5px; }
  .status { font-size: 11.5px; }
  #about-btn, #changes-btn { display: none; }
  .who-am-i .who-name { display: none; }
  .intro { flex-direction: column; gap: 6px; }
  .scene { border-radius: 14px; }
  .cast { grid-template-columns: 1fr; }
  .cast-summary { grid-template-columns: minmax(0, 1fr) auto; }
  .faces { grid-column: 1 / -1; grid-row: 2; }
  .cast-alerts { grid-row: 3; }
  .card { min-height: 0; }
  .charts { grid-template-columns: 1fr; }
  .add-user, .news-form { grid-template-columns: 1fr; }
  .drawer-head, .drawer-body { padding-left: 16px; padding-right: 16px; }
  .recap { padding: 20px 16px; border-radius: 14px; }
  .hud-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recap-body p { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- town jobs, deals, papers, the ledger, trials ---------- */
.tag.repealed, .tag.replaced { color: var(--faint); border-style: dashed; }
.town-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.town-list li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raise); font-size: 13.5px; line-height: 1.45; }
.town-list li div { margin-top: 2px; color: var(--muted); }
.ledger-sum { display: grid; gap: 4px; margin: 0; font-size: 12.5px; color: var(--muted); font-family: var(--mono); }
/* The stock board. */
.stocks { display: grid; gap: 14px; }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.stock { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; }
.stock-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.stock-sym { font: 600 14px var(--mono); margin-right: 8px; }
.stock-name { font-size: 12.5px; color: var(--muted); }
.stock-price { font: 600 18px var(--mono); text-align: right; display: grid; }
.stock-price span { font: 500 11.5px var(--mono); }
.stock-price .in { color: var(--ok); }
.stock-price .out { color: var(--bad); }
.spark { width: 100%; height: 56px; }
.spark polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark.up polyline { stroke: var(--ok); }
.spark.down polyline { stroke: var(--bad); }
.stock-holders { font-size: 12.5px; color: var(--muted); }
.stock-nudge { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.stock-nudge .faint { margin-right: auto; }

/* The calendar: town days, each a list of times. */
.calendar { display: grid; gap: 18px; }
.cal-note { font-size: 12.5px; color: var(--faint); margin: 0; }
.cal-day h3 { margin: 0 0 8px; }
.cal-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-item { display: grid; grid-template-columns: 6.5em 1fr; gap: 12px; align-items: baseline; padding: 9px 12px; border-top: 1px solid var(--line); }
.cal-item:first-child { border-top: 0; }
.cal-time { display: grid; gap: 1px; }
.cal-time b { font: 500 13px var(--mono); }
.cal-time span { font: 11.5px var(--mono); color: var(--faint); }
.cal-what { display: grid; gap: 2px; min-width: 0; }
.cal-title { font-size: 13.5px; }
.cal-meta { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.cal-item.event .cal-title, .cal-item.fair .cal-title { font-weight: 600; }
.cal-item.arrival .cal-meta { font-style: italic; }
.cal-item.on { background: var(--accent-soft); }
.cal-item.on .cal-time b { color: var(--accent); }
.cal-day.every .cal-item { opacity: 0.8; }
.cal-item.event, .cal-item.fair { box-shadow: inset 3px 0 0 var(--accent); }
.cal-item.arrival { box-shadow: inset 3px 0 0 #7fb0b5; }
.cal-item.vote .cal-title { color: var(--muted); }
.ledger { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ledger li { display: grid; grid-template-columns: 7.5em 1fr auto 4em; gap: 10px; align-items: baseline; padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--line); }
.ledger li:first-child { border-top: 0; }
.ledger .when, .ledger .bal { font: 12px var(--mono); color: var(--faint); }
.ledger .bal { text-align: right; }
.ledger b { font: 500 13px var(--mono); text-align: right; }
.ledger b.in { color: var(--ok); }
.ledger b.out { color: var(--bad); }
@media (max-width: 520px) {
  .ledger li { grid-template-columns: 1fr auto; }
  .ledger .when { grid-column: 1 / -1; }
  .ledger .bal { display: none; }
}
.testimony { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.testimony li { font-size: 13px; padding: 8px 10px; border-left: 2px solid var(--line-2); background: var(--raise); border-radius: 0 8px 8px 0; }
.testimony .quote { display: block; margin-top: 2px; }
