/* AI Village: a paper ledger beside a pixel-art map. Plain borders, ink and parchment, no gradients or glow. */
:root {
  --paper: #f1e7cf;
  --paper-2: #e8dcc0;
  --paper-3: #fbf6e8;
  --ink: #2a1e14;
  --ink-2: #6a5844;
  --rule: #cdbd9a;
  --rust: #9a3b22;
  --moss: #4a6a38;
  --blue: #2f5f8a;
  --plum: #8a3f62;
  --bar: #2b2118;
  --bar-ink: #f3e9d0;
  --good: #4a6a38;
  --warn: #b07a1e;
  --bad: #9a3b22;
  --font-label: "Pixelify Sans", ui-monospace, "Cascadia Mono", monospace;
  --font-body: "Newsreader", Georgia, "Times New Roman", serif;
  --panel-w: 380px;
  --top-h: 48px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #221c15; --paper-2: #2b231a; --paper-3: #30271c; --ink: #eadfc6; --ink-2: #b3a280; --rule: #43372a;
    --rust: #e58f66; --moss: #94bd77; --blue: #84b6e2; --plum: #d887ab; --bar: #120e09; --bar-ink: #eadfc6;
    --good: #94bd77; --warn: #e0b14e; --bad: #e58f66;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bar); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.42; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
.num, .coins, #c-time { font-variant-numeric: tabular-nums; }

#app {
  height: 100%; height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w); grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas: "top top" "view panel";
}

/* ------------------------------------------------------------ top bar */
#top {
  grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 14px;
  background: var(--bar); color: var(--bar-ink); border-bottom: 2px solid #000;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--bar-ink); text-decoration: none; font-family: var(--font-label); font-weight: 700; font-size: 21px; letter-spacing: 0.04em; white-space: nowrap; }
.mark { width: 20px; height: 20px; image-rendering: pixelated; background-size: contain; display: inline-block; }
.clock { display: flex; align-items: center; gap: 10px; font-family: var(--font-label); font-size: 15px; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; }
.sep { width: 1px; height: 14px; background: rgba(243,233,208,0.35); display: inline-block; }
.figures { display: flex; align-items: center; gap: 16px; font-family: var(--font-label); font-size: 13px; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; min-width: 0; }
.figures span { display: inline-flex; flex-direction: column; line-height: 1.05; }
.figures label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(243,233,208,0.62); }
.figures b { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.right { display: flex; align-items: center; gap: 14px; font-family: var(--font-label); font-size: 14px; white-space: nowrap; min-width: 0; }
.pip { display: inline-block; width: 8px; height: 8px; background: var(--moss); margin-right: 7px; vertical-align: middle; }
#mind { display: flex; align-items: center; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
#mind .pip { background: #7fb2e0; }
#mind.rules .pip { background: #b3a280; }
#live .pip { background: #86c46c; animation: blink 2s steps(2) infinite; }
#live.off .pip { background: #e0b14e; animation: none; }
@keyframes blink { 50% { opacity: 0.35; } }
#btn-voice { display: inline-flex; align-items: center; gap: 7px; background: transparent; color: var(--bar-ink); border: 1px solid rgba(243,233,208,0.5); padding: 4px 10px; font-family: var(--font-label); font-size: 14px; }
#btn-voice img { width: 16px; height: 16px; image-rendering: pixelated; }
#btn-voice[aria-pressed="true"] { background: var(--bar-ink); color: var(--bar); }
#btn-voice[hidden] { display: none; }
#btn-influence { background: var(--bar-ink); color: var(--bar); border: 1px solid var(--bar-ink); padding: 4px 10px; font-family: var(--font-label); font-size: 14px; }
#btn-influence[data-wait="1"] { background: transparent; color: var(--bar-ink); border-color: rgba(243,233,208,0.5); }
#influence { max-width: min(480px, calc(100vw - 24px)); width: 100%; padding: 18px 20px 16px; background: var(--paper-3); color: var(--ink); border: 2px solid var(--ink); }
#influence::backdrop { background: rgba(20,14,8,0.6); }
#influence h2 { margin: 0 0 6px; font-family: var(--font-label); font-size: 20px; }
#influence h3 { margin: 16px 0 6px; font-family: var(--font-label); font-size: 14px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.inf-lead, .inf-help { margin: 0 0 10px; color: var(--ink-2); font-size: 14.5px; line-height: 1.4; }
.inf-mode { display: flex; gap: 8px; margin-bottom: 10px; }
.inf-mode label { flex: 1; }
.inf-mode input { position: absolute; opacity: 0; pointer-events: none; }
.inf-mode span { display: block; padding: 7px 8px; text-align: center; border: 1px solid var(--ink); font-family: var(--font-label); font-size: 14px; cursor: pointer; }
.inf-mode input:checked + span { background: var(--ink); color: var(--paper-3); }
.inf-mode input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.inf-field { display: block; margin-bottom: 8px; font-family: var(--font-label); font-size: 13px; color: var(--ink-2); }
.inf-field select, .inf-field textarea { display: block; width: 100%; margin-top: 3px; padding: 7px 8px; background: var(--paper); color: var(--ink); border: 1px solid var(--ink); font: 15px var(--font-body); box-sizing: border-box; }
.inf-field textarea { resize: vertical; }
.inf-count { margin: 0 0 6px; text-align: right; font-size: 12px; color: var(--ink-2); }
.inf-msg { min-height: 1.4em; margin: 0 0 8px; font-size: 14.5px; }
.inf-msg.bad { color: var(--bad); }
.inf-msg.ok { color: var(--good); }
.inf-actions { display: flex; justify-content: flex-end; gap: 8px; }
.inf-actions button { padding: 7px 16px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-family: var(--font-label); font-size: 14px; }
.inf-actions button.primary { background: var(--ink); color: var(--paper-3); }
.inf-actions button:disabled { opacity: 0.45; }
.inf-log { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); line-height: 1.4; }
.inf-log li { margin-bottom: 4px; }

/* ------------------------------------------------------------ map */
#viewport { grid-area: view; position: relative; min-width: 0; min-height: 0; background: #2f5a2f; overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; image-rendering: pixelated; }
#hover-tip { position: absolute; z-index: 3; pointer-events: none; max-width: 340px; padding: 6px 10px; background: var(--paper-3); color: var(--ink); border: 1px solid var(--ink); font-size: 14px; }
#offline { position: absolute; z-index: 6; top: 10px; left: 50%; transform: translateX(-50%); max-width: min(92%, 560px); padding: 8px 14px; background: var(--paper-3); color: var(--ink); border: 2px solid var(--ink); font-size: 14.5px; text-align: center; }
#offline b { font-family: var(--font-label); font-weight: 600; }
#tools { position: absolute; left: 10px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; z-index: 4; }
#tools button { min-width: 40px; height: 32px; padding: 0 10px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); font-family: var(--font-label); font-size: 14px; text-align: center; }
#tools button:hover { background: var(--ink); color: var(--paper); }
#tools button.on, #tools button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#hint { position: absolute; left: 76px; bottom: 14px; z-index: 2; max-width: 60%; font-size: 13.5px; color: #fff; background: rgba(42,30,20,0.72); padding: 4px 10px; pointer-events: none; transition: opacity 1s; }
#hint.gone { opacity: 0; }
#toasts { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(92%, 520px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; background: var(--paper-3); color: var(--ink); border: 2px solid var(--ink); padding: 7px 12px; font-size: 15px; animation: rise 0.25s ease-out; }
.toast img { width: 16px; height: 16px; image-rendering: pixelated; flex: none; }
.toast.out { opacity: 0; transition: opacity 0.5s; }
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } }

/* ------------------------------------------------------------ panel */
#panel { grid-area: panel; display: flex; flex-direction: column; min-height: 0; background: var(--paper); border-left: 2px solid #000; }
#sheet-handle { display: none; }
#tabs { display: flex; padding: 0 12px; background: var(--paper-2); border-bottom: 2px solid var(--ink); }
#tabs button { flex: 1; padding: 10px 2px 8px; background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--ink-2); font-family: var(--font-label); font-size: 14px; letter-spacing: 0.02em; white-space: nowrap; }
#tabs button.active { color: var(--ink); border-bottom-color: var(--rust); }
#tabs button:hover:not(.active) { color: var(--ink); }
.tabpane { display: none; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px 18px; }
.tabpane.active { display: block; }
.tabpane::-webkit-scrollbar { width: 10px; }
.tabpane::-webkit-scrollbar-thumb { background: var(--rule); border: 2px solid var(--paper); }

.group { margin: 14px 0 2px; font-family: var(--font-label); font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.person { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: start; width: 100%; text-align: left; padding: 10px 6px 10px 8px; background: transparent; border: 0; border-bottom: 1px solid var(--rule); border-left: 3px solid transparent; }
.person:hover { background: var(--paper-2); }
.person.sel { background: var(--paper-2); border-left-color: var(--rust); }
.face { width: 44px; height: 54px; image-rendering: pixelated; background: #7bb765; border: 1px solid var(--ink); }
.nm { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 17px; line-height: 1.2; }
.nm b { font-weight: 600; }
.tag { font-family: var(--font-label); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 0 5px; border: 1px solid currentColor; color: var(--rust); }
.tag.visitor { color: var(--blue); }
.tag.child { color: var(--plum); }
.sub { color: var(--ink-2); font-size: 14px; }
.gender-tag { display: inline-block; margin: 2px 0 5px; padding: 2px 7px; border: 1px solid var(--plum); color: var(--plum); font: 12px var(--font-label); animation: tag-arrive 0.35s ease-out; }
@keyframes tag-arrive { from { opacity: 0; transform: translateY(-3px) scale(0.92); } to { opacity: 1; transform: none; } }
.villager-tabs { display: flex; gap: 6px; margin: 12px 0 4px; border-bottom: 1px solid var(--rule); }
.villager-tabs button { padding: 6px 12px; color: var(--ink-2); background: transparent; border: 0; border-bottom: 2px solid transparent; font: 14px var(--font-label); }
.villager-tabs button.active { color: var(--ink); border-bottom-color: var(--rust); }
.villager-page { animation: none; }
@keyframes page-in { from { opacity: 0; transform: translateX(4px); } to { opacity: 1; transform: none; } }
.health-explanation { min-height: 2.5em; padding: 9px 10px; border-left: 3px solid var(--blue); background: var(--paper-2); line-height: 1.4; }
.health-writing { animation: health-pulse 1.1s ease-in-out infinite alternate; }
@keyframes health-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.health-page .sec { color: var(--ink); }
.health-page .sec h3 { color: #cf855d; }
.health-page .kv span:first-child, .health-page .line, .health-page .sec small { color: var(--ink); }
.health-page .health-explanation { color: var(--ink); }
.health-page .back { color: var(--ink); border-color: var(--ink-2); }
.doing { font-size: 15px; }
.thought { margin-top: 3px; color: var(--ink-2); font-style: italic; font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thought::before { content: "\201C"; } .thought::after { content: "\201D"; }
.thought:empty { display: none; }
.coins { text-align: right; font-size: 15px; white-space: nowrap; }
.coins small { display: block; color: var(--ink-2); font-size: 12px; }

.filters { display: flex; gap: 6px; margin: 10px 0 8px; }
.filters button { padding: 3px 10px; background: transparent; border: 1px solid var(--ink-2); font-family: var(--font-label); font-size: 13px; color: var(--ink-2); }
.filters button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#feed { list-style: none; margin: 0; padding: 0; }
#feed li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--rule); font-size: 15.5px; }
#feed li.clickable { cursor: pointer; }
#feed li.clickable:hover { background: var(--paper-2); }
#feed li img { width: 16px; height: 16px; image-rendering: pixelated; margin-top: 3px; }
#feed time { display: block; color: var(--ink-2); font-family: var(--font-label); font-size: 12px; letter-spacing: 0.05em; margin-top: 1px; }
.empty { color: var(--ink-2); font-style: italic; padding: 18px 4px; }

.sec { padding: 12px 0 8px; border-bottom: 1px solid var(--rule); }
.sec h3 { margin: 0 0 6px; font-family: var(--font-label); font-weight: 600; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--rust); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 15.5px; }
.kv span:first-child { color: var(--ink-2); }
.kv span:last-child { text-align: right; }
.law { padding: 5px 0; }
.law b { display: block; font-weight: 600; }
.law small { display: block; color: var(--ink-2); font-size: 14px; line-height: 1.3; }
.bar { height: 6px; background: var(--paper-2); border: 1px solid var(--ink-2); margin: 3px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--good); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.banner { margin: 10px 0 2px; padding: 7px 10px; border: 1px solid var(--rust); background: var(--paper-3); font-size: 15px; }
.stone { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 5px 0; border-top: 1px solid var(--rule); font-size: 15px; }
.stone:first-of-type { border-top: 0; }
.stone small { grid-column: 1 / -1; color: var(--ink-2); font-style: italic; font-size: 14px; }

.back { margin: 10px 0 8px; padding: 3px 10px; background: transparent; border: 1px solid var(--ink-2); font-family: var(--font-label); font-size: 13px; color: var(--ink-2); }
.back:hover { background: var(--ink); color: var(--paper); }
.vhead { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; margin: 4px 0 10px; }
.vhead canvas { width: 64px; height: 79px; image-rendering: pixelated; background: #7bb765; border: 2px solid var(--ink); }
.vhead h2 { margin: 0; font-family: var(--font-label); font-size: 22px; font-weight: 600; line-height: 1.15; }
.vhead p { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.mind { margin: 4px 0 10px; padding: 8px 12px; border-left: 3px solid var(--rust); background: var(--paper-3); font-style: italic; font-size: 17px; line-height: 1.35; }
.mind small { display: block; margin-top: 4px; font-style: normal; font-family: var(--font-label); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.line { color: var(--ink-2); font-size: 15px; margin: 0 0 6px; }
.need { display: grid; grid-template-columns: 74px 1fr 28px; gap: 10px; align-items: center; font-size: 14.5px; }
.need .bar { margin: 0; }
.need span:last-child { text-align: right; color: var(--ink-2); }
.rel { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 5px 0; border-top: 1px solid var(--rule); font-size: 15.5px; align-items: baseline; }
.rel:first-of-type { border-top: 0; }
.rel button { background: none; border: 0; padding: 0; text-align: left; font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.rel .st { color: var(--ink-2); font-size: 14px; }
.rel .aff { grid-column: 1 / -1; height: 4px; background: var(--paper-2); position: relative; }
.rel .aff i { position: absolute; top: 0; bottom: 0; }
.mem { padding: 5px 0; border-top: 1px solid var(--rule); font-size: 15px; }
.mem:first-of-type { border-top: 0; }
.mem time { color: var(--ink-2); font-family: var(--font-label); font-size: 12px; letter-spacing: 0.05em; margin-right: 8px; }
.mem.diary { font-style: italic; }

.hist { max-height: 320px; overflow-y: auto; border: 1px solid var(--rule); padding: 2px 10px; background: var(--paper-3); }
.hist .mem.thot { font-style: italic; }
.conv { padding: 8px 0; border-top: 1px solid var(--rule); }
.conv:first-child { border-top: 0; }
.conv time { display: block; margin-bottom: 3px; color: var(--ink-2); font-family: var(--font-label); font-size: 12px; letter-spacing: 0.05em; }
.conv p { margin: 1px 0; font-size: 15px; }
.conv p.self b { color: var(--rust); }
.conv p b { font-weight: 600; }

.spark { display: block; width: 100%; height: 46px; margin: 2px 0 8px; image-rendering: pixelated; }
.big { font-family: var(--font-label); font-size: 30px; line-height: 1.1; font-weight: 600; margin: 2px 0; }
.big small { font-size: 14px; color: var(--ink-2); font-weight: 500; margin-left: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: baseline; border: 1px solid var(--ink); }
.party { padding: 7px 0; border-top: 1px solid var(--rule); }
.party:first-of-type { border-top: 0; }
.party b { font-weight: 600; }
.party small { display: block; color: var(--ink-2); font-style: italic; font-size: 14px; }
.sector { display: grid; grid-template-columns: 112px 1fr 44px; gap: 8px; align-items: center; font-size: 14.5px; }
.sector .bar { margin: 0; }
.sector span:last-child { text-align: right; color: var(--ink-2); }
.note { color: var(--ink-2); font-size: 14px; font-style: italic; margin: 2px 0 6px; }

#tile .stonebox { margin: 6px 0 10px; padding: 10px 12px; border: 2px solid var(--ink); background: var(--paper-3); text-align: center; }
#tile .stonebox h2 { margin: 0 0 2px; font-family: var(--font-label); font-size: 21px; font-weight: 600; }
#tile .stonebox p { margin: 2px 0; font-size: 15px; }
#tile .stonebox .epi { font-style: italic; color: var(--ink-2); margin-top: 6px; }
.person-chip { display: inline-block; margin: 2px 6px 2px 0; padding: 1px 8px; background: transparent; border: 1px solid var(--ink-2); font-size: 14px; }
.person-chip:hover { background: var(--ink); color: var(--paper); }

/* ------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  :root { --top-h: 44px; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top-h) minmax(0, 1fr) auto; grid-template-areas: "top" "view" "panel"; }
  .brand { font-size: 18px; }
  .clock { font-size: 13.5px; gap: 7px; }
  #c-weather, #mind, .figures { display: none; }
  #panel { border-left: 0; border-top: 2px solid #000; height: 44dvh; max-height: 44dvh; padding-bottom: env(safe-area-inset-bottom); }
  #panel:not(.open) { height: auto; }
  #panel:not(.open) .tabpane, #panel:not(.open) #tabs { display: none; }
  #sheet-handle { display: grid; place-items: center; height: 22px; background: var(--paper-2); border: 0; width: 100%; }
  #sheet-handle span { width: 44px; height: 4px; background: var(--ink-2); }
  #hint { display: none; }
  #tools { flex-direction: row; bottom: 8px; left: 8px; }
  #tools button { height: 36px; padding: 0 9px; }
}
@media (max-width: 1180px) { .figures span:nth-child(n+4) { display: none; } }
@media (max-width: 520px) { #live-text { display: none; } #btn-voice span { display: none; } #btn-influence { padding: 4px 8px; } .right { gap: 10px; } }
@media (prefers-reduced-motion: reduce) { #live .pip { animation: none; } .toast { animation: none; } }

/* ------------------------------------------------------------ calendar */
#btn-calendar { background: transparent; color: var(--bar-ink); border: 1px solid rgba(243,233,208,0.5); padding: 4px 10px; font-family: var(--font-label); font-size: 14px; }
#calendar { width: min(760px, calc(100vw - 20px)); max-height: calc(100vh - 24px); overflow: auto; padding: 16px 18px 14px; background: var(--paper-3); color: var(--ink); border: 2px solid var(--ink); }
#calendar::backdrop { background: rgba(20,14,8,0.6); }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head button { padding: 6px 12px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-family: var(--font-label); font-size: 15px; }
.cal-head #cal-prev, .cal-head #cal-next { font-size: 20px; line-height: 1; padding: 4px 12px; }
.cal-title { flex: 1; text-align: center; }
.cal-title h2 { margin: 0; font-family: var(--font-label); font-size: 22px; }
.cal-title p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-family: var(--font-label); font-size: 12px; color: var(--ink-2); padding: 2px 0; text-transform: uppercase; letter-spacing: 0.05em; }
.cal-cell { position: relative; min-height: 68px; padding: 5px 6px; text-align: left; vertical-align: top; background: var(--paper); border: 1px solid var(--rule); color: var(--ink); font: 13px var(--font-body); cursor: pointer; overflow: hidden; }
.cal-cell.blank { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.today { border: 2px solid var(--rust); background: var(--paper-2); }
.cal-cell.sel { outline: 2px solid var(--blue); outline-offset: 1px; }
.cal-cell.past b { color: var(--ink-2); }
.cal-cell b { display: block; font-family: var(--font-label); font-size: 15px; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cal-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-2); display: block; }
.cal-dots i.k-birthday { background: #a8527a; } .cal-dots i.k-election { background: #b4533d; border-radius: 0; } .cal-dots i.k-party, .cal-dots i.k-festival { background: #c99a1e; }
.cal-dots i.k-death { background: #444; } .cal-dots i.k-family { background: #d9768f; } .cal-dots i.k-disaster, .cal-dots i.k-health { background: #c8453f; }
.cal-dots i.k-business, .cal-dots i.k-build { background: #6f9a54; } .cal-dots i.k-law, .cal-dots i.k-council, .cal-dots i.k-politics { background: #2f5f8a; } .cal-dots i.k-rest { background: #8a7a64; }
.cal-dots i.future { background: transparent; border: 2px solid currentColor; box-sizing: border-box; }
.cal-more { font-size: 11px; color: var(--ink-2); margin-left: 2px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 4px; font-size: 13px; color: var(--ink-2); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-detail { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rule); }
.cal-detail h3 { margin: 0 0 6px; font-family: var(--font-label); font-size: 16px; }
.cal-detail ul { margin: 0; padding: 0; list-style: none; }
.cal-detail li { display: flex; gap: 8px; padding: 4px 0; font-size: 15px; line-height: 1.4; }
.cal-detail li em { font-style: normal; flex: none; font-family: var(--font-label); font-size: 12px; padding: 1px 6px; border: 1px solid var(--rule); color: var(--ink-2); height: fit-content; margin-top: 2px; }
.cal-detail .none { color: var(--ink-2); }
@media (max-width: 560px) { .cal-cell { min-height: 52px; padding: 3px 4px; } #btn-calendar { padding: 4px 8px; } .cal-head button { padding: 5px 8px; } }

.btn-whisper { display: block; width: 100%; margin: 10px 0; padding: 10px 12px; background: var(--paper-3); color: var(--ink); border: 1px solid var(--ink); font-family: var(--font-label); font-size: 15px; cursor: pointer; }
.btn-whisper:hover:not(:disabled) { background: var(--ink); color: var(--paper-3); }
.btn-whisper:disabled { opacity: 0.6; cursor: default; }

/* ============================================================ readability and roomier layout (same parchment-and-ink look) */
:root { --panel-w: clamp(400px, 34vw, 480px); --top-h: 60px; --ink-2: #584733; }
@media (prefers-color-scheme: dark) { :root { --ink-2: #c4b393; } }
html, body { font-size: 17px; line-height: 1.55; }
#top { padding: 0 22px; gap: 24px; }
.brand { font-size: 24px; gap: 12px; }
.mark { width: 24px; height: 24px; }
.clock { font-size: 17px; gap: 12px; }
.figures { gap: 24px; font-size: 14px; }
.figures label { font-size: 11px; letter-spacing: 0.1em; }
.figures b { font-size: 18px; }
.right { gap: 12px; font-size: 15px; }
#btn-calendar, #btn-influence, #btn-voice { min-height: 40px; padding: 7px 16px; font-size: 16px; letter-spacing: 0.02em; }
#mind { max-width: 260px; }

#tabs { padding: 0 16px; gap: 2px; }
#tabs button { padding: 15px 4px 12px; font-size: 16px; }
#tabs button.active { font-weight: 700; }
.tabpane { padding: 8px 20px 34px; }
.group { margin: 22px 0 6px; font-size: 14px; letter-spacing: 0.12em; }

.person { grid-template-columns: 54px 1fr auto; gap: 16px; padding: 16px 10px 16px 12px; }
.face { width: 54px; height: 66px; }
.nm { font-size: 20px; gap: 8px; }
.tag { font-size: 12px; padding: 1px 6px; }
.sub { font-size: 16px; }
.doing { font-size: 17px; margin-top: 3px; }
.thought { margin-top: 6px; font-size: 16.5px; line-height: 1.45; }
.coins { font-size: 17px; }
.coins small { font-size: 13px; }

.filters { gap: 8px; margin: 14px 0 12px; }
.filters button { padding: 7px 16px; font-size: 15px; }
#feed li { grid-template-columns: 22px 1fr; gap: 14px; padding: 14px 6px; font-size: 17px; line-height: 1.5; }
#feed li img { width: 20px; height: 20px; margin-top: 3px; }
#feed time { font-size: 13.5px; margin-top: 3px; }
.empty { font-size: 17px; padding: 24px 6px; }

.sec { margin: 16px 0; padding: 18px 20px 14px; background: var(--paper-3); border: 1px solid var(--rule); box-shadow: 3px 3px 0 var(--rule); }
.newspaper { background: var(--paper); border: 2px double var(--rust); box-shadow: 4px 4px 0 var(--rule); }
.paper-deck { margin: -2px 0 12px; color: var(--ink-2); font-style: italic; }
.paper-story { padding: 8px 0; border-top: 1px solid var(--rule); }
.paper-story h4 { margin: 0 0 4px; color: var(--rust); font: 600 15px var(--font-label); }
.paper-story p { margin: 0; line-height: 1.45; }
.mayor-history { padding: 10px 0; border-top: 1px solid var(--rule); }
.mayor-history:first-child { border-top: 0; }
.mayor-history .mayor-vote { margin-top: 4px; color: var(--ink-2); }
.town-history-list { max-height: 560px; overflow: auto; padding: 2px 10px; background: var(--paper-3); border: 1px solid var(--rule); }
.town-history-item { padding: 8px 0; border-top: 1px solid var(--rule); }
.town-history-item:first-child { border-top: 0; }
.town-history-item time { color: var(--ink-2); font: 13px var(--font-label); text-transform: capitalize; }
.town-history-item p { margin: 4px 0 0; font-size: 15.5px; line-height: 1.45; }
.sec h3 { margin: 0 0 12px; padding-bottom: 9px; border-bottom: 1px dashed var(--rule); font-size: 15px; letter-spacing: 0.1em; }
.kv { padding: 6px 0; font-size: 17px; gap: 16px; }
.law { padding: 8px 0; }
.law b { font-size: 17px; }
.law small { font-size: 15.5px; line-height: 1.45; margin-top: 2px; }
.bar { height: 9px; margin: 5px 0 10px; }
.banner { padding: 12px 14px; font-size: 16.5px; margin: 14px 0 4px; }
.stone { padding: 9px 0; font-size: 16.5px; }
.stone small { font-size: 15.5px; }
.back { padding: 8px 16px; font-size: 15px; margin: 14px 0 12px; }
.vhead { grid-template-columns: 76px 1fr; gap: 18px; margin: 8px 0 16px; }
.vhead canvas { width: 76px; height: 94px; }
.vhead h2 { font-size: 27px; }
.vhead p { font-size: 16.5px; }
.mind { margin: 8px 0 16px; padding: 14px 18px; font-size: 19px; line-height: 1.5; }
.mind small { font-size: 12.5px; margin-top: 8px; }
.line { font-size: 16.5px; margin: 0 0 9px; line-height: 1.5; }
.need { grid-template-columns: 90px 1fr 34px; gap: 14px; font-size: 16px; padding: 3px 0; }
.rel { padding: 10px 0; font-size: 17px; }
.rel .st { font-size: 15px; }
.rel .aff { height: 5px; }
.mem { padding: 10px 0; font-size: 16.5px; line-height: 1.5; }
.mem time { font-size: 13px; display: block; margin: 0 0 2px; }
.hist { max-height: 380px; padding: 6px 14px; }
.conv { padding: 12px 0; }
.conv time { font-size: 13px; margin-bottom: 6px; }
.conv p { font-size: 16.5px; margin: 3px 0; line-height: 1.5; }
.big { font-size: 36px; }
.big small { font-size: 16px; }
.spark { height: 56px; margin: 6px 0 12px; }
.party { padding: 11px 0; }
.party small { font-size: 15.5px; }
.sector { grid-template-columns: 124px 1fr 50px; font-size: 16px; padding: 3px 0; }
.note { font-size: 15.5px; }
.person-chip { padding: 5px 12px; font-size: 15.5px; margin: 4px 8px 4px 0; }
.btn-whisper { padding: 13px 16px; font-size: 16.5px; }

#tools button { min-width: 48px; height: 42px; font-size: 16px; }
#tools { gap: 6px; left: 14px; bottom: 16px; }
#hover-tip { font-size: 16px; padding: 9px 14px; max-width: 380px; }
#hint { font-size: 15px; padding: 7px 14px; left: 90px; }
.toast { font-size: 16.5px; padding: 11px 16px; }
.toast img { width: 20px; height: 20px; }

/* dialogs */
#influence, #calendar { font-size: 17px; }
#influence { max-width: min(540px, calc(100vw - 24px)); padding: 24px 26px 20px; }
#influence h2 { font-size: 24px; margin-bottom: 10px; }
.inf-lead, .inf-help { font-size: 16.5px; line-height: 1.5; margin-bottom: 14px; }
.inf-field select, .inf-field textarea { font-size: 17px; padding: 11px 12px; }
.inf-msg { font-size: 16.5px; }
.inf-actions button { padding: 10px 20px; font-size: 16px; }
.inf-log { font-size: 15.5px; line-height: 1.5; }
.inf-log li { margin-bottom: 7px; }
#calendar { width: min(860px, calc(100vw - 20px)); padding: 22px 24px 20px; }
.cal-title h2 { font-size: 26px; }
.cal-title p { font-size: 16px; }
.cal-head button { padding: 9px 16px; font-size: 16px; }
.cal-grid { gap: 6px; }
.cal-dow { font-size: 13.5px; padding: 4px 0; }
.cal-cell { min-height: 86px; padding: 8px 9px; }
.cal-cell b { font-size: 18px; }
.cal-dots i { width: 11px; height: 11px; }
.cal-legend { font-size: 15px; gap: 6px 18px; }
.cal-detail h3 { font-size: 19px; margin-bottom: 8px; }
.cal-detail li { font-size: 17px; padding: 6px 0; }
.cal-detail li em { font-size: 13px; padding: 2px 8px; }
dialog button:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

@media (max-width: 1180px) { .figures { gap: 18px; } }
@media (max-width: 900px) {
  :root { --top-h: 54px; }
  .brand { font-size: 20px; }
  .clock { font-size: 15px; }
  #btn-calendar, #btn-influence { padding: 6px 12px; font-size: 15px; }
  #tabs button { padding: 12px 2px 10px; font-size: 15px; }
  .tabpane { padding: 4px 14px 28px; }
  .sec { padding: 14px 16px 10px; }
  .person { gap: 12px; }
  #panel { height: 50dvh; max-height: 50dvh; }
}
@media (max-width: 520px) { #btn-calendar, #btn-influence { padding: 6px 10px; font-size: 14px; } .cal-cell { min-height: 56px; padding: 4px 5px; } }
.clock { min-width: 0; flex: 0 1 auto; }
.figures { flex: 1 1 0; justify-content: flex-start; padding-left: 8px; }
@media (max-width: 1700px) { #m-label { display: none; } .figures span:nth-child(n+6) { display: none; } }
@media (max-width: 1500px) { .figures span:nth-child(n+5) { display: none; } #mind { max-width: 40px; } }
@media (max-width: 1320px) { .figures span:nth-child(n+4) { display: none; } .figures { gap: 16px; } }
@media (max-width: 1180px) { .figures span:nth-child(n+3) { display: none; } }
@media (max-width: 640px) {
  #top { padding: 0 12px; gap: 10px; }
  .brand span { display: none; }
  #c-day, .clock .sep:first-of-type { display: none; }
  .clock { font-size: 15px; }
  #btn-calendar span, #btn-influence span { white-space: nowrap; }
  .right { gap: 8px; }
  #live-text { display: none; }
}

/* the header figures shrink to whatever fits; JS hides the ones that would be cut off */
.figures { overflow: hidden; min-width: 0; }
.figures span { flex: none; }
@media (max-width: 1700px) { .figures span:nth-child(n+6) { display: inline-flex; } }
@media (max-width: 1500px) { .figures span:nth-child(n+5) { display: inline-flex; } }
@media (max-width: 1320px) { .figures span:nth-child(n+4) { display: inline-flex; } }
@media (max-width: 1180px) { .figures span:nth-child(n+3) { display: inline-flex; } }
@media (max-width: 1900px) { #m-label { display: none; } }
