/* Valley pages: warm wood, parchment panels, leaf green and sky blue. Dark text on light panels. */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,800&family=Nunito:wght@500;700;800&display=swap");

:root {
  --wood-dk: #3e2a1c;
  --wood: #6e4a30;
  --wood-lt: #a8764a;
  --parch: #f8efdc;
  --parch-2: #efe2c4;
  --parch-3: #e4d2ac;
  --ink: #3a2a1c;
  --muted: #7a6650;
  --line: rgba(110, 74, 48, 0.28);
  --leaf: #5c9a3c;
  --leaf-dk: #3f7a2a;
  --sky: #74b8dc;
  --sky-dk: #2f78a8;
  --gold: #d9a53c;
  --warn: #c7801a;
  --bad: #b8433a;
  --panel: rgba(248, 239, 220, 0.94);
  --shadow: 0 6px 20px rgba(62, 42, 28, 0.28), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  --r: 14px;
  --edge: 12px;
  --display: "Fraunces", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --font: "Nunito", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 500 14px/1.5 var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #9fd0ea 0%, #cfe6d6 55%, #b7cf8e 100%);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--sky-dk); }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; }
[hidden] { display: none !important; }
.muted, .sub { color: var(--muted); }

/* ---------- Panels & buttons ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  font: 800 13px/1 var(--font); color: var(--ink); text-decoration: none; white-space: nowrap;
  /* Game style: a carved board with a dark edge and a shadow below that it presses into. */
  background: linear-gradient(180deg, #f6e8c6, #dcc391); border: 1px solid #6e4a30; border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 2px 0 #6e4a30; font-family: var(--display); letter-spacing: 0.02em;
  cursor: pointer; transition: transform .12s var(--ease), background .12s;
}
.btn:hover { background: linear-gradient(180deg, #fbf0d6, #e6cf9f); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 0 #6e4a30; }
.btn:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(47, 120, 168, 0.5); outline-offset: 2px; }
/* The main action: painted green with a gold rim. */
.btn.primary { color: #fffbea; text-shadow: 0 1px 0 #1a2e0f; background: linear-gradient(180deg, #7cbb55, #3f7a2a); border: 2px solid #d9a53c;
  box-shadow: 0 0 0 1px #2a190d, inset 0 1px 0 rgba(230, 255, 200, 0.45), 0 3px 0 1px #2a190d; }
.btn.primary:hover { background: linear-gradient(180deg, #8ac862, #468530); }
.btn.primary:active { box-shadow: 0 0 0 1px #2a190d, inset 0 1px 0 rgba(230, 255, 200, 0.3), 0 1px 0 1px #2a190d; }
.btn.wood { color: #fff6e4; text-shadow: 0 1px 0 #2a190d; background: linear-gradient(180deg, #9a6a40, #5e3d23); border: 2px solid #b8864a;
  box-shadow: 0 0 0 1px #2a190d, inset 0 1px 0 rgba(255, 220, 170, 0.35), 0 3px 0 1px #2a190d; }
.btn.wood:hover { background: linear-gradient(180deg, #ab7a4c, #6a4529); }
.btn.wood:active { box-shadow: 0 0 0 1px #2a190d, inset 0 1px 0 rgba(255, 220, 170, 0.25), 0 1px 0 1px #2a190d; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(110, 74, 48, 0.12); }
.btn.lg { min-height: 46px; padding: 0 22px; font-size: 15px; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 36px; padding: 0; }
.field, select.lang-switch {
  min-height: 38px; padding: 0 12px; font: 600 14px var(--font); color: var(--ink);
  background: #fffaf0; border: 1px solid var(--line); border-radius: 10px;
}
select.lang-switch { min-height: 32px; border-radius: 999px; padding: 0 8px; font-size: 12px; }
/* The language picker in a header: a globe button and a small menu (i18n.js globePicker). */
.lang-pick { position: relative; display: inline-flex; }
.lang-pick .lang-btn svg { display: block; }
.lang-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 9.5rem; padding: 6px; display: grid; gap: 2px; }
.lang-menu[hidden] { display: none; }
.lang-menu button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); font: 700 14px var(--font); text-align: left; cursor: pointer; }
.lang-menu button::before { content: ""; width: 1em; flex: none; }
.lang-menu button[aria-selected="true"]::before { content: "✓"; color: var(--leaf-dk); }
.lang-menu button:hover, .lang-menu button:focus-visible { background: rgba(110, 74, 48, 0.12); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.kicker { font: 800 11px/1.2 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--leaf-dk); }

.bar { height: 7px; border-radius: 7px; background: rgba(110, 74, 48, 0.15); overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--leaf), #8cc35e); border-radius: inherit; }
.bar.dmg i { background: linear-gradient(90deg, #d9644a, var(--bad)); }
.bar.gold i { background: linear-gradient(90deg, var(--gold), #f0cc6a); }

/* ---------- Toast, dialog, loading ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + var(--msg-h, 0px) + 22px); z-index: 60;
  transform: translate(-50%, 8px); max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px;
  background: var(--wood-dk); color: #fff4dc; border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.bad { background: var(--bad); }
.scrim { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(40, 26, 14, 0.5); animation: fade .15s; }
.dialog { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; background: var(--parch); }
.dialog h2 { font-size: 20px; margin: 4px 0 10px; }
.dialog p { line-height: 1.65; margin: 0 0 12px; }
.dialog .row { margin-top: 14px; }
.codebox.copyable { cursor: copy; transition: background .12s; }
.codebox.copyable:hover { background: #fff3d6; border-style: solid; }
.dialog pre, .codebox {
  margin: 0 0 10px; padding: 10px 12px; background: #fffaf0; border: 1px dashed var(--wood-lt); border-radius: 10px;
  font: 600 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all;
}
.dialog label { display: block; font: 800 12px var(--font); color: var(--muted); margin: 8px 0 4px; }
@keyframes fade { from { opacity: 0; } }

.bootscreen {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(800px 500px at 50% 35%, #fbf3e0 0%, #e9d7b0 70%, #d4bc8c 100%);
  transition: opacity .4s var(--ease);
}
.bootscreen.gone { opacity: 0; pointer-events: none; }
.bootscreen .box { width: min(360px, 100%); text-align: center; }
.bootscreen img { display: block; margin: 0 auto 6px; filter: drop-shadow(0 4px 8px rgba(62, 42, 28, .25)); }
.bootscreen .brandmark { font: 800 26px/1.1 var(--display); color: var(--wood); }
.bootscreen .t { margin: 8px 0 18px; font-weight: 700; color: var(--muted); }
.bootscreen .meter { height: 8px; border-radius: 8px; background: rgba(110, 74, 48, 0.18); overflow: hidden; }
.bootscreen .meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--leaf), var(--gold)); transition: width .25s var(--ease); }
.bootscreen .s { margin-top: 12px; min-height: 2.8em; color: var(--ink); font-size: 13px; line-height: 1.5; }
.bootscreen.note .meter i { background: var(--sky-dk); }

/* ---------- Spectator page ---------- */
body.watch { overflow: hidden; }
#view, #flat { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#flat { display: none; cursor: grab; touch-action: none; }
#flat.dragging { cursor: grabbing; }
body.flat #flat { display: block; }
body.flat #view { display: none; }
body.replaying #view, body.replaying #flat { filter: sepia(0.35) saturate(0.85); }
/* Zoom buttons for the flat map (right edge, middle). */
.mapctl { position: fixed; right: var(--edge); top: 50%; transform: translateY(-50%); z-index: 4; display: none; flex-direction: column; gap: 2px; padding: 4px; }
body.flat .mapctl { display: flex; }
.mapctl .btn { font-size: 18px; }

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }
.topbar {
  position: absolute; top: var(--edge); left: var(--edge); right: var(--edge);
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; min-width: 0; z-index: 6;
}
.brand { display: flex; align-items: center; gap: 8px; font: 800 17px/1 var(--display); color: var(--wood); text-decoration: none; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
/* The time chip (right, before the tools): one width whatever the hour, so the stats
   beside it never move; the date in full opens below it. */
.daywrap { flex: 0 0 auto; }
.dayline { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 108px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 250, 238, 0.8); font: 800 13px var(--font); color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; cursor: pointer; }
.dayline .d-icons { font-size: 13px; letter-spacing: 1px; }
.dayline .d-month { display: none; }
.dayline .clock-now:empty + .d-month, .dayline .clock-now[hidden] + .d-month, .no-clock .dayline .d-month { display: inline; }
.daypanel { min-width: 230px; gap: 0; padding: 6px 8px; }
.daypanel .d-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 4px; font: 700 13px var(--font); }
.daypanel .d-row + .d-row { border-top: 1px solid var(--line); }
.daypanel .d-row span { color: var(--muted); }
.stamina { font: 800 12.5px var(--font); padding: 4px 10px; border-radius: 999px; background: #fff6d8; border: 1px solid #e3c877; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.stats::-webkit-scrollbar { display: none; }
.stat { display: flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 10px; white-space: nowrap; background: rgba(255, 250, 238, 0.7); border: 1px solid transparent; }
.stat .i { font-size: 14px; }
.stat .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .v small { font-weight: 700; color: var(--muted); }
.stat .k { display: none; }
.stat.warn { background: #fdecc4; border-color: #e6b24f; }
.stat.bad { background: #f9d4cc; border-color: #d97a6c; color: #7a1f16; }
.tools { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.menu { background: var(--parch); position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; padding: 6px; display: grid; gap: 2px; z-index: 10; }
.menu button, .menu a { text-align: left; padding: 9px 12px; border: 0; border-radius: 10px; background: none; font: 700 14px var(--font); color: var(--ink); cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--parch-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; width: auto; }
.menuwrap { position: relative; }
.guest-tag { font: 800 11px var(--font); padding: 4px 8px; border-radius: 999px; background: #dcecf6; color: var(--sky-dk); white-space: nowrap; }

.underbar { position: absolute; top: calc(var(--edge) + var(--bar-h, 50px) + 8px); left: var(--edge); right: calc(var(--edge) + 312px); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.chips { display: contents; }
.break { display: none; }
.show-narrow { display: none !important; }
.chip { pointer-events: auto; padding: 4px 11px; border-radius: 999px; font: 800 12px var(--font); background: #fdecc4; border: 1px solid #e0ac45; color: #6a4508; box-shadow: 0 2px 6px rgba(62, 42, 28, .15); }
.chip.bad { background: #f9d4cc; border-color: #d0685a; color: #7a1f16; }
.chip.calm { background: #dcecf6; border-color: #8cbfdc; color: #1f5378; }
body.replaying .chips { display: none; }
.flatnote { padding: 4px 10px; border-radius: 999px; font: 700 11px var(--font); background: rgba(255, 250, 238, .85); color: var(--muted); display: none; }
body.flat .flatnote { display: inline-block; }
.menu-lang { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; font: 700 14px var(--font); }

/* Journal (left bottom) */
.journal {
  position: absolute; left: var(--edge); bottom: calc(var(--msg-h, 0px) + var(--edge) * 2); width: min(380px, calc(100vw - 2 * var(--edge)));
  max-height: min(56vh, calc(100vh - var(--msg-h, 0px) - 150px)); display: flex; flex-direction: column; overflow: hidden;
}
.journal .jhead { display: flex; align-items: center; gap: 4px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }
.journal .tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.journal .tabs button { padding: 7px 9px; border: 0; border-bottom: 3px solid transparent; background: none; font: 800 12.5px var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; }
.journal .tabs button.on { color: var(--ink); border-bottom-color: var(--leaf); }
.journal .fold { flex: 0 0 auto; }
.journal .jbody { overflow: auto; padding: 10px 14px 14px; overscroll-behavior: contain; }
.journal.folded .jbody { display: none; }
.journal.folded .fold { transform: rotate(180deg); }
.jbody h3 { font-size: 14px; margin: 12px 0 4px; color: var(--wood); }
.jbody h4 { font: 800 12px var(--font); color: var(--muted); margin: 10px 0 2px; }
.jbody p { margin: 4px 0; }
.jbody .lead { font-weight: 800; }
.jbody .note { padding: 8px 10px; border-radius: 10px; background: var(--parch-2); font-weight: 700; }
.jbody .note.bad, .jbody p.bad { color: var(--bad); }
.jbody .note.calm { background: #dcecf6; color: #1f5378; }
.jbody section:first-of-type h3 { margin-top: 8px; }
.jbody .help { white-space: pre-line; line-height: 1.7; }
.jobs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; }
.job { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.job b { font-variant-numeric: tabular-nums; }
ul.people, ul.events, ul.decisions, ul.graves { list-style: none; margin: 0; padding: 0; }
.settler { padding: 7px 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.settler:hover { background: var(--parch-2); }
.settler.on { background: #e8f2dc; border-color: #a8cc86; }
.settler.hero .n b::before { content: "⚔ "; color: var(--wood-lt); }
/* Name tags with a face (family, residents and workers, the expedition party): a button
   that picks the settler, plain for someone gone. */
.pchips { display: flex; flex-wrap: wrap; gap: 5px 6px; margin: 4px 0 6px; }
.pchip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 2px; border-radius: 999px; border: 1px solid rgba(110, 74, 48, 0.35); background: rgba(255, 250, 240, 0.7); font: 700 12px var(--font); color: var(--ink); cursor: pointer; }
.pchip:hover { background: #fff6e2; border-color: #6e4a30; }
.pchip.gone { cursor: default; color: var(--muted); }
.pchip > span { white-space: nowrap; }
.pf { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px #6e4a30; background: #e8d6b0; }
.kv.kin { align-items: center; }
.kv.kin .pchips { margin: 0; }
ul.graves li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* With a face: the small round portrait on the left of both lines. */
.settler:has(> .face) { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 9px; align-items: center; }
.settler > .face { grid-row: 1 / span 2; width: 34px; height: 34px; }
.settler .n { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.settler .cls { font-size: 12px; color: var(--muted); font-weight: 700; }
.settler .m { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.settler .m > span:first-child { min-width: 4.5em; }
.tag { font: 800 10.5px var(--font); padding: 1px 7px; border-radius: 999px; background: var(--parch-3); }
.tag.sick { background: #f9d4cc; color: #7a1f16; }
.tag.training { background: #e6ddf5; color: #4c3584; }
.tag.away { background: #dcecf6; color: #1f5378; }
.tag.child { background: #f6ecd0; color: #6b4e12; }
.tag.due { background: #f8dcea; color: #7a2350; }
.sex { color: #8a7a66; font-size: .9em; margin-right: 4px; }
.hpbar { display: inline-block; width: 60px; height: 6px; border-radius: 6px; background: rgba(110, 74, 48, 0.18); overflow: hidden; }
.hpbar.wide { width: auto; flex: 1; }
.hpbar i { display: block; height: 100%; background: var(--leaf); }
.hpbar i.low { background: var(--bad); }
.hpbar.mood i { background: var(--gold); }
ul.events li { padding: 3px 6px; border-radius: 6px; border-left: 3px solid transparent; }
ul.events li.t1 { border-left-color: var(--leaf); }
ul.events li.t2 { border-left-color: var(--warn); }
ul.events li.t3 { border-left-color: var(--bad); }
ul.events li.can { cursor: pointer; }
ul.events li.can:hover { background: var(--parch-2); }
ul.decisions li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
ul.decisions .d { font: 800 11px var(--font); color: var(--muted); }
ul.decisions .q { font-weight: 800; color: var(--sky-dk); }
ul.graves li { padding: 3px 0; }

/* Info panel (right top) */
.info { position: absolute; top: calc(var(--edge) + var(--bar-h, 50px) + 8px); right: var(--edge); width: min(300px, calc(100vw - 2 * var(--edge))); padding: 12px 14px; }
.info .ihead { display: flex; gap: 8px; align-items: flex-start; }
.info .ic { font-size: 22px; line-height: 1; }
/* A settler's face (art/face/) in place of the icon: a round portrait with the medal's
   wood and gold rim. */
.info .ic.has-face { flex: 0 0 64px; width: 64px; height: 64px; }
.info .ic.has-face img, .settler > .face { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px #6e4a30, 0 0 0 3px #c9a24a; background: #e8d6b0; }
.info .title { font: 800 17px/1.2 var(--display); }
.info .meta { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.info .x { margin-left: auto; flex: 0 0 auto; }
.info .body { margin-top: 8px; }
.info .body p { margin: 6px 0 0; line-height: 1.55; }
.info .body p.bad { color: var(--bad); font-weight: 800; }
.info h4 { font: 800 12px var(--font); color: var(--muted); margin: 10px 0 4px; }
.kv { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.kv > span:first-child { min-width: 3em; color: var(--muted); font-weight: 700; }
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.skill { display: flex; justify-content: space-between; font-size: 12.5px; }
.pips { color: var(--leaf-dk); letter-spacing: 1px; }
.pips i { font-style: normal; color: rgba(110, 74, 48, .3); }

/* Message window (bottom) */
.msgwin {
  position: absolute; left: 50%; bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(760px, calc(100vw - 2 * var(--edge))); display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 12px 12px 14px; --tone: var(--sky-dk);
  background: linear-gradient(180deg, #fffaf0, var(--parch)); border: 2px solid var(--wood-lt); border-radius: 16px; box-shadow: var(--shadow);
}
.msgwin.empty { display: none; }
.msgwin[data-who="steward"] { --tone: var(--sky-dk); }
.msgwin[data-who="report"] { --tone: var(--leaf-dk); }
.msgwin[data-who="elder"] { --tone: #8a5a1a; }
.msgwin[data-who="watch"] { --tone: var(--wood); }
.msgwin[data-who="alarm"] { --tone: var(--warn); }
.msgwin[data-who="alarm"][data-tone="3"] { --tone: var(--bad); border-color: var(--bad); }
.msgwin.swap .mw-main { animation: rise .22s var(--ease); }
.mw-badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 800 20px var(--font); color: #fff; background: var(--tone); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.mw-main { min-width: 0; cursor: pointer; }
.mw-head { display: flex; align-items: baseline; gap: 10px; }
.mw-who { font: 800 12px var(--font); letter-spacing: .08em; color: var(--tone); }
.mw-day { font: 700 11.5px var(--font); color: var(--muted); }
.mw-more { margin-left: auto; font: 800 11px var(--font); color: var(--muted); }
.mw-text { font: 700 15.5px/1.55 var(--font); min-height: 1.55em; overflow-wrap: anywhere; }
.mw-detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.mw-detail:empty { display: none; }
.mw-ctl { display: flex; gap: 4px; align-items: center; }
.mw-history { grid-column: 1 / -1; margin: 0; padding: 8px 0 0; list-style: none; max-height: 32vh; overflow: auto; border-top: 1px solid var(--line); font-size: 13px; }
.mw-history li { display: grid; grid-template-columns: 22px 64px 1fr; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 6px; color: var(--muted); }
/* A line about a settler: their face, small and round, in place of the speaker's mark. */
.mw-history .g { text-align: center; }
.mw-history .hf { display: block; width: 22px; height: 22px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px #6e4a30; background: #e8d6b0; }
.mw-history li.can { cursor: pointer; color: var(--ink); }
.mw-history li.can:hover { background: var(--parch-2); }
.mw-history .g { font-weight: 800; color: var(--sky-dk); }
.mw-history li[data-tone="1"] .g { color: var(--leaf-dk); }
.mw-history li[data-tone="2"] .g { color: var(--warn); }
.mw-history li[data-tone="3"] .g { color: var(--bad); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

/* The turn bar (the demo, and the play page's look back; `replayBar` in ui.js): day n / last
   and the scrub, then the page's own buttons. It keeps its place at the very bottom and the
   message window (and toasts) sit on it while it shows. */
/* Above the message window and the info panel: its menus (the demo's highlights) open
   upward over them. */
.replaybar {
  position: absolute; bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 4;
  width: min(760px, calc(100vw - 2 * var(--edge))); display: flex; align-items: center; gap: 8px; padding: 6px 10px;
}
body:has(.replaybar:not([hidden])) .msgwin { bottom: calc(var(--edge) * 2 + var(--rb-h, 46px) + env(safe-area-inset-bottom, 0px)); }
body:has(.replaybar:not([hidden])) .journal { bottom: calc(var(--msg-h, 0px) + var(--edge) * 3 + var(--rb-h, 46px)); }
@media (min-width: 1100px) { body:has(.replaybar:not([hidden])) .journal { bottom: calc(var(--edge) * 2 + var(--rb-h, 46px)); } }
@media (max-width: 860px) { body:has(.replaybar:not([hidden])) .info { bottom: calc(var(--msg-h, 0px) + var(--edge) * 3 + var(--rb-h, 46px)); } }
body:has(.replaybar:not([hidden])) .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--msg-h, 0px) + var(--rb-h, 46px) + 30px); }
.replaybar input[type=range] { flex: 1; min-width: 60px; accent-color: var(--leaf-dk); }
.replaybar .rp-day { font: 800 13px var(--font); white-space: nowrap; font-variant-numeric: tabular-nums; }
.replaybar select { min-height: 30px; border-radius: 999px; border: 1px solid var(--line); background: #fffaf0; font: 700 12px var(--font); padding: 0 6px; }
/* Speed (header): the "×N" on the left, then carved picture buttons ■ ▶ ▶▶ ▶▶▶ ▶▶▶▶
   (art/spd-*.svg); the lit one is green (red for stop). */
.topbar .speed { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.topbar .speed output { font: 800 12px var(--font); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.speed-stack { display: flex; flex-direction: column; gap: 3px; }
.spd-bar { display: block; height: 7px; border-radius: 4px; overflow: hidden; cursor: pointer; touch-action: none;
  background: rgba(20, 12, 6, 0.45); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(42, 25, 13, 0.6); }
.spd-bar i { display: block; height: 100%; width: 0; background: linear-gradient(180deg, #f6d77a, #c9952e); transition: width .12s; pointer-events: none; }
.spd-bar:hover i { background: linear-gradient(180deg, #ffe496, #d9a53c); }
.spd-bar.off { cursor: not-allowed; opacity: 0.45; }
.speed-btns { display: flex; gap: 2px; }
.speed-btns .spd { width: 20px; height: 15px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(180deg, #8a5c38, #4e321d); border: 1px solid #2a190d; border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.3), 0 1px 0 #2a190d; opacity: 0.78; transition: transform .1s, opacity .1s; }
.speed-btns .spd img { width: 16px; height: 10px; display: block; pointer-events: none; }
.speed-btns .spd:hover { opacity: 1; }
.speed-btns .spd:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.speed-btns .spd:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.2), 0 1px 0 #2a190d; }
.speed-btns .spd.on { opacity: 1; background: linear-gradient(180deg, #5e8a3a, #2f5a1e); box-shadow: inset 0 1px 0 rgba(220, 255, 180, 0.35), 0 2px 0 #1a2e0f, 0 0 8px rgba(246, 215, 122, 0.55); }
.speed-btns .spd[data-speed="0"].on { background: linear-gradient(180deg, #a8483a, #6a2418); box-shadow: inset 0 1px 0 rgba(255, 200, 180, 0.35), 0 2px 0 #3a120a, 0 0 8px rgba(246, 120, 90, 0.5); }
.dayline .clock-now[hidden], .dayline .clock-now:empty { display: none; }

/* Wide screens: journal left, info right, message window centered between. */
@media (min-width: 1100px) {
  .msgwin { width: min(700px, calc(100vw - 2 * 400px)); }
  .journal { bottom: var(--edge); }
  .stat .k { display: none; }
}
/* Mid screens: the numbers go to a second row. */
@media (max-width: 1540px) {
  .topbar { flex-wrap: wrap; row-gap: 4px; }
  .break { display: block; flex-basis: 100%; height: 0; order: 4; }
  .stamina { order: 5; }
  .stats { order: 6; flex: 1 1 200px; }
}
/* Narrow screens: share, look back and language move into the menu; journal starts folded. */
@media (max-width: 860px) {
  :root { --edge: 8px; }
  .topbar { gap: 4px 8px; padding: 6px 8px; }
  .topbar .brand span { display: none; }
  .show-narrow { display: block !important; }
  label.show-narrow { display: flex !important; }
  .underbar { right: var(--edge); }
  .stats { display: contents; }
  .stat { order: 6; padding: 2px 6px; }
  .info { top: auto; bottom: calc(var(--msg-h, 0px) + var(--edge) * 2); z-index: 3; }
  .journal { max-height: 42vh; }
  .journal.folded { width: auto; }
  .hide-narrow { display: none !important; }
  .msgwin { grid-template-columns: 34px 1fr auto; gap: 8px; padding: 9px 8px 9px 10px; }
  .mw-badge { width: 34px; height: 34px; font-size: 16px; }
  .mw-text { font-size: 14px; }
  .mw-ctl .mw-auto { display: none; }
}
@media (max-width: 480px) {
  .dayline { min-width: 0; padding: 4px 8px; }
  .speed-btns .spd { width: 19px; height: 15px; }
  .speed-btns .spd img { width: 15px; height: 9px; }
  .topbar .speed output { min-width: 34px; font-size: 11px; }
  .stamina { font-size: 11.5px; padding: 3px 8px; }
}

/* ---------- Landing ---------- */
body.lp { height: auto; min-height: 100%; background: linear-gradient(180deg, #a9d6ee 0%, #dcecd8 420px, var(--parch) 760px); }
.wrap { width: min(1080px, 100%); margin: 0 auto; padding: 0 16px; }

/* Valley list (menu → Your valleys). */
.worldlist { list-style: none; margin: 8px 0 14px; padding: 0; display: grid; gap: 8px; }
.worldlist li { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 12px; background: var(--parch-2, rgba(255, 255, 255, 0.5)); border: 1px solid rgba(110, 74, 48, 0.18); }
.worldlist li.current { border-color: rgba(70, 120, 60, 0.6); box-shadow: inset 3px 0 0 rgba(70, 120, 60, 0.8); }
.worldlist .wl-main { min-width: 0; }
.worldlist .wl-main .tag { margin-left: 6px; }
.worldlist .tag.muted { opacity: 0.75; }
.worldlist .wl-act { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.danger { color: #9b2c1c; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Settings (⚙): a small panel of rows, a label on the left and its control on the right. */
.menu.settings { min-width: 260px; gap: 0; padding: 8px 10px 10px; }
.settings h3 { margin: 2px 2px 6px; font: 800 14px var(--display); }
.settings .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 4px; border-top: 1px solid var(--line); font: 700 13px var(--font); cursor: pointer; }
.settings .set-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--leaf-dk); cursor: pointer; }
.settings .lang-btn { width: 30px; min-height: 30px; }
.settings .lang-btn svg { width: 18px; height: 18px; }
.settings .set-row select { min-height: 28px; border-radius: 8px; border: 1px solid var(--line); background: #fffaf0; font: 700 12px var(--font); }
.settings .set-note { margin: 6px 4px 0; font: 600 11px/1.5 var(--font); color: var(--muted); }
.settings .set-link { margin: 6px 4px 0; padding: 0; font: 700 11.5px var(--font); color: var(--sky-dk); }
.no-clock .dayline .clock-now { display: none; }

/* Emoji pictures (emoji.js): sized with the text around them. */
img.emoji { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin: 0 0.04em; }

/* Stock details: the numbers in the top bar open this, each with its name and use. */
.stats[role=button] { cursor: pointer; }
.statpanel { position: absolute; top: calc(var(--edge) + var(--bar-h, 50px) + 8px); left: var(--edge); z-index: 7; width: min(400px, calc(100vw - 2 * var(--edge))); max-height: calc(100vh - var(--bar-h, 50px) - 40px); overflow: auto; padding: 10px 12px; background: var(--parch); }
.statpanel h3 { margin: 6px 2px 4px; font: 800 14px var(--display); color: var(--wood); }
.statpanel .sd-row { display: grid; grid-template-columns: 22px 1fr auto; column-gap: 8px; align-items: baseline; padding: 6px 2px; border-top: 1px solid var(--line); }
.statpanel .sd-i { font-size: 15px; }
.statpanel .sd-n { font: 800 13px var(--font); }
.statpanel .sd-v { font: 800 14px var(--font); font-variant-numeric: tabular-nums; text-align: right; }
.statpanel .sd-v small { color: var(--muted); font-weight: 700; }
.statpanel .sd-note { grid-column: 2 / 4; font: 600 11.5px/1.5 var(--font); color: var(--muted); }

/* ---------- Game look: drawn wood, parchment and iron (web/art/*.svg) ----------
   The top bar and the playback bar are oak planks in a wooden frame with iron corners;
   the numbers sit in parchment sockets; the message window is a parchment sheet in the
   same frame with the speaker's portrait medallion; pop-up panels are parchment. */
:root {
  --art-wood: url("/art/wood.svg?v=realm138");
  --art-parch: url("/art/parchment.svg?v=realm138");
  --art-frame: url("/art/frame.svg?v=realm138");
  --on-wood: #f6e9c9;
  --on-wood-muted: #d9c39a;
}
.topbar, .replaybar {
  background: var(--art-wood) 0 0 / 320px 64px repeat, #6a4529;
  border: 10px solid transparent; border-image: var(--art-frame) 24 / 10px stretch;
  border-radius: 0; backdrop-filter: none;
  box-shadow: 0 6px 18px rgba(30, 18, 8, 0.45);
  color: var(--on-wood);
}
.topbar { padding: 2px 4px 2px 6px; }
.replaybar { padding: 2px 6px; }
.topbar .brand { color: #f6d77a; text-shadow: 0 1px 0 #2a190d, 0 0 6px rgba(0, 0, 0, 0.35); }
.topbar .brand img { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
/* Parchment sockets set into the wood. */
.topbar .stat, .topbar .dayline, .topbar .stamina {
  background: var(--art-parch) center / 100% 100%, var(--parch);
  border: 1px solid #2a190d; border-radius: 5px; color: var(--ink);
  box-shadow: inset 0 1px 3px rgba(60, 36, 14, 0.45), 0 1px 0 rgba(255, 230, 190, 0.25);
}
.topbar .stat.warn { background: #fdecc4; border-color: #b8862a; }
.topbar .stat.bad { background: #f9d4cc; border-color: #9b2c1c; }
.topbar .speed output, .replaybar .rp-day { color: var(--on-wood); text-shadow: 0 1px 0 #2a190d; }
.replaybar input[type=range] { accent-color: #d9a53c; }
/* Carved wooden buttons on the bars. */
.topbar .btn, .replaybar .btn, .replaybar .btn.ghost {
  background: linear-gradient(180deg, #9a6a40, #5e3d23); color: var(--on-wood);
  border: 1px solid #2a190d; border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.35), 0 2px 0 #2a190d;
  text-shadow: 0 1px 0 #2a190d;
}
.topbar .btn:hover, .replaybar .btn:hover { background: linear-gradient(180deg, #ab7a4c, #6a4529); }
.topbar .btn:active, .replaybar .btn:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.25), 0 1px 0 #2a190d; }
.replaybar select { background: var(--art-parch) center / 100% 100%, #fffaf0; border-color: #2a190d; border-radius: 5px; }

/* The message window: a parchment sheet in the frame, the speaker's portrait on the left. */
.msgwin {
  grid-template-columns: 60px 1fr auto; padding: 4px 6px 4px 4px;
  background: var(--art-parch) center / 100% 100%, var(--parch);
  border: 14px solid transparent; border-image: var(--art-frame) 24 / 14px stretch; border-radius: 0;
  box-shadow: 0 8px 22px rgba(30, 18, 8, 0.45);
}
.msgwin[data-who="alarm"][data-tone="3"] { box-shadow: 0 0 0 3px var(--bad), 0 8px 22px rgba(120, 20, 10, 0.5); }
.mw-badge { width: 60px; height: 60px; background: none; box-shadow: none; border-radius: 50%; filter: drop-shadow(0 2px 2px rgba(42, 25, 13, 0.45)); }
.mw-badge img { width: 100%; height: 100%; display: block; border-radius: 50%; object-fit: cover; }
/* A painted portrait (art/pic) is square: clipped round here, with the medal's wood and gold rim. */
.mw-badge img[src*="/art/pic/"], .mw-badge img[src*="/art/face/"] { box-shadow: 0 0 0 2px #6e4a30, 0 0 0 3px #c9a24a; }
/* A line about a settler: their face fills the medal, the speaker's medal small on its
   lower right corner. */
.mw-badge.has-face { position: relative; }
.mw-badge .mw-spk { position: absolute; right: -6px; bottom: -6px; width: 44%; height: 44%; border-radius: 50%; display: grid; place-items: center; background: #f3e6c8; font: 800 11px var(--font); color: var(--tone); }
.mw-badge .mw-spk img { width: 100%; height: 100%; }
.mw-who { font-family: var(--display); font-size: 13px; letter-spacing: 0.06em; }
.mw-ctl .btn { background: rgba(110, 74, 48, 0.12); border: 1px solid rgba(110, 74, 48, 0.35); border-radius: 6px; }
.mw-ctl .btn:hover { background: rgba(110, 74, 48, 0.22); }

/* Pop-up panels (calendar, stocks, settings, menus): parchment with a wooden edge. */
.menu, .statpanel {
  background: var(--art-parch) center / 100% 100%, var(--parch);
  border: 2px solid #6e4a30; border-radius: 8px;
  box-shadow: 0 0 0 1px #2a190d, 0 10px 24px rgba(30, 18, 8, 0.4);
}
.menu button:hover, .menu a:hover { background: rgba(110, 74, 48, 0.14); }

@media (max-width: 860px) {
  .topbar, .replaybar { border-width: 8px; border-image-width: 8px; }
  .msgwin { grid-template-columns: 42px 1fr auto; border-width: 10px; border-image-width: 10px; }
  .mw-badge { width: 42px; height: 42px; }
}

/* Panels opened from the top bar keep dark text (the bar's own text is light on wood),
   and stay open until their × is pressed. (`.menu .pop-x` outranks the menu's plain
   `.menu button` rows, which would otherwise strip the ×'s wood, border and size.) */
.topbar .menu, .statpanel { color: var(--ink); text-shadow: none; }
.pop-x, .menu .pop-x { position: absolute; top: 5px; right: 5px; z-index: 1; width: 26px; height: 26px; padding: 0; display: grid; place-items: center;
  font: 800 16px/1 var(--font); color: var(--on-wood); cursor: pointer;
  background: linear-gradient(180deg, #9a6a40, #5e3d23); border: 1px solid #2a190d; border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.35), 0 2px 0 #2a190d; text-shadow: 0 1px 0 #2a190d; }
.pop-x:hover, .menu .pop-x:hover { background: linear-gradient(180deg, #ab7a4c, #6a4529); }
.pop-x:active, .menu .pop-x:active { transform: translateY(1px); }
.daypanel { padding-top: 34px; }
.settings h3, .statpanel #statbody > h3:first-child { margin-right: 32px; }

/* The journal (bottom left) and the info panel (top right) in the same look: a parchment
   sheet in the wooden frame; the journal's tabs sit on a wooden strip. */
.journal, .info {
  background: var(--art-parch) center / 100% 100%, var(--parch);
  border: 12px solid transparent; border-image: var(--art-frame) 24 / 12px stretch; border-radius: 0;
  backdrop-filter: none; box-shadow: 0 8px 22px rgba(30, 18, 8, 0.45);
}
.journal .jhead { background: var(--art-wood) 0 0 / 320px 64px repeat, #6a4529; border-bottom: 2px solid #2a190d; padding: 4px 4px 0; }
.journal .tabs button { color: var(--on-wood-muted); text-shadow: 0 1px 0 #2a190d; border-radius: 5px 5px 0 0; border-bottom: 0; margin-top: 2px; }
.journal .tabs button:hover { color: #fff; }
.journal .tabs button.on { color: var(--ink); text-shadow: none; background: var(--art-parch) center / 100% 100%, var(--parch); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.journal .fold, .info .x {
  background: linear-gradient(180deg, #9a6a40, #5e3d23); color: var(--on-wood);
  border: 1px solid #2a190d; border-radius: 6px; width: 28px; min-height: 28px; height: 28px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, 0.35), 0 2px 0 #2a190d; text-shadow: 0 1px 0 #2a190d;
}
.journal .fold:hover, .info .x:hover { background: linear-gradient(180deg, #ab7a4c, #6a4529); }
.journal.folded .jhead { border-bottom: 0; padding-bottom: 4px; }
.info .title { color: var(--wood-dk); }
@media (max-width: 860px) {
  .journal, .info { border-width: 9px; border-image-width: 9px; }
}

/* The journal's tabs sit at its bottom edge: the window grows upward from them, so they
   stay put whatever the tab holds. */
.journal .jhead { order: 2; border-bottom: 0; border-top: 2px solid #2a190d; padding: 0 4px 4px; }
.journal .jbody { order: 1; }
.journal .tabs button { border-radius: 0 0 5px 5px; margin-top: 0; margin-bottom: 2px; }
.journal.folded .jhead { border-top: 0; padding-top: 4px; }

/* The info panel's top stays put whatever it shows (the header — picture, name, × — never
   moves); it grows down with its content up to a cap, then the body scrolls inside. On
   narrow screens it hangs below the top bar too (not above the message window, whose
   height changes). */
.info { display: flex; flex-direction: column; max-height: calc(100vh - var(--bar-h, 50px) - 120px); }
.info .ihead { flex: 0 0 auto; }
.info .body { flex: 0 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-right: 2px; }
@media (max-width: 860px) {
  .info { top: calc(var(--edge) + var(--bar-h, 50px) + 8px); bottom: auto; max-height: 45vh; }
}

/* Illustrations (art.js, web/art/pic/*.jpg). Each sits in the wooden frame; a missing
   one is left out, or with ?artslots=1 drawn as a dashed frame naming its file. */
.art-frame { position: relative; overflow: hidden; background: #3e2a1c; }
.art-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.art-frame.art-slot { display: grid; place-items: center; background: repeating-linear-gradient(45deg, rgba(110, 74, 48, .12) 0 10px, rgba(110, 74, 48, .04) 10px 20px), var(--parch);
  border: 2px dashed #8a5c38; color: var(--wood); font: 800 12px var(--font); text-align: center; }
/* Event picture: a 16:9 card over the message window while that line is up (tap to put it away). */
.mw-pic { position: absolute; left: 50%; bottom: calc(100% + 18px); transform: translateX(-50%); width: min(460px, 86vw); aspect-ratio: 16 / 9;
  border: 10px solid transparent; border-image: var(--art-frame) 24 / 10px stretch; box-shadow: 0 10px 26px rgba(30, 18, 8, 0.5); cursor: pointer; animation: rise .3s var(--ease); }
.mw-pic.art-slot { border: 2px dashed #8a5c38; }
/* Building / ruin picture: a 2:1 strip under the info panel's header. */
.info-pic { flex: 0 0 auto; margin: 8px -2px 0; aspect-ratio: 2 / 1; border: 2px solid #6e4a30; border-radius: 4px; }
/* Title picture: fills the loading screen behind its box. */
.boot-art { position: absolute; inset: 0; z-index: 0; }
.boot-art img { filter: saturate(1.05); }
.bootscreen .box { position: relative; z-index: 1; }
.bootscreen:has(.boot-art:not([hidden]):not(.art-slot)) .box { background: rgba(248, 239, 220, 0.9); padding: 18px 20px; border-radius: 10px; box-shadow: 0 10px 30px rgba(30, 18, 8, 0.45); }
@media (max-width: 860px) {
  .mw-pic { width: min(340px, 88vw); bottom: calc(100% + 10px); border-width: 7px; border-image-width: 7px; }
}


/* Fields as parchment set into wood (the buttons above are carved boards). */
.field, select.lang-switch {
  border: 1px solid #6e4a30; border-radius: 6px; background: #fffaf0;
  box-shadow: inset 0 1px 3px rgba(60, 36, 14, 0.25);
}

/* The analytics consent banner (consent.js), on top of everything until the visitor chooses. */
.consent {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 90;
  width: min(560px, calc(100% - 32px)); padding: 14px 16px; display: grid; gap: 10px;
}
.consent p { margin: 0; line-height: 1.6; }
.consent .consent-btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
