/* ============================================================================
   Horizon of Khufu — Pyramid Builder Simulator
   Stylesheet. Limestone/basalt palette; thin-stroke display type reserved for
   narrative interludes per design territory; fluid eased transitions.
   ========================================================================== */

/* ---------- Fonts (local, variable, OFL-licensed; see fonts/OFL.txt) ------ */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-latin-var.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-latin-italic-var.woff2") format("woff2");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens -------------------------------------------------------- */
:root {
  --sand-100: #f3ead6;
  --sand-200: #e9ddc0;
  --sand-300: #d9c9a3;
  --sand-500: #b79c67;
  --basalt-900: #171310;
  --basalt-800: #211a14;
  --basalt-750: #292118;
  --basalt-700: #332a1e;
  --basalt-600: #453a29;
  --line: #57462f;
  --ink: #efe6d2;
  --ink-dim: #c9bda3;
  --ink-faint: #9a8d72;
  --copper: #c98a45;
  --copper-bright: #e2a55c;
  --nile: #4f7f74;
  --warn: #cf6f4a;
  --good: #8fae83;
  --danger: #b84a3a;
  --display: "Cormorant Garamond", "Palatino", "Georgia", serif;
  --body-font: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-soft: cubic-bezier(0.22, 0.9, 0.28, 1);
  --ease-glide: cubic-bezier(0.16, 0.84, 0.22, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--basalt-900);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--display); font-weight: 340; letter-spacing: 0.04em; margin: 0; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--basalt-600); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--copper-bright);
  outline-offset: 2px;
  border-radius: 3px;
}

.screen-reader-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- App shell ----------------------------------------------------- */
#app { position: fixed; inset: 0; }

.view { position: absolute; inset: 0; opacity: 0; pointer-events: none;
        transition: opacity 520ms var(--ease-soft), transform 720ms var(--ease-glide);
        transform: scale(0.992); overflow: hidden; }
.view.active { opacity: 1; pointer-events: auto; transform: scale(1); }

/* ---------- Title screen -------------------------------------------------- */
#title-view {
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(201,138,69,0.16), transparent 60%),
    linear-gradient(to bottom, #14111c 0%, #241a2c 38%, #4d2a31 66%, #93502f 88%, #c97f3a 100%);
  display: flex; align-items: center; justify-content: center;
}
.title-inner { text-align: center; max-width: 880px; padding: 32px; }
.title-hiero { font-size: 13px; letter-spacing: 0.55em; color: var(--copper-bright); text-transform: uppercase; margin-bottom: 26px; }
.title-name {
  font-family: var(--display); font-weight: 300;
  font-size: clamp(46px, 8.5vw, 92px); line-height: 1.04; letter-spacing: 0.06em;
  background: linear-gradient(to bottom, #fdf6e4 25%, #e8c78c 75%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 22px rgba(0,0,0,0.45));
  animation: title-drift 9s ease-in-out infinite alternate;
}
@keyframes title-drift { from { letter-spacing: 0.055em; } to { letter-spacing: 0.075em; } }
.title-sub {
  margin-top: 18px; color: var(--ink-dim); font-style: italic;
  font-family: var(--display); font-size: clamp(16px, 2.4vw, 21px); letter-spacing: 0.06em;
}
.title-facts {
  margin: 34px auto 8px; display: flex; gap: 34px; justify-content: center; flex-wrap: wrap;
  color: var(--ink-faint); font-size: 12.5px; letter-spacing: 0.09em; text-transform: uppercase;
}
.title-facts strong { display: block; color: var(--sand-200); font-size: 19px; font-family: var(--display); letter-spacing: 0.05em; }
.title-actions { margin-top: 38px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.title-canvas-wrap { position: absolute; inset: 0; z-index: -1; opacity: 0.85; }
#title-scene { width: 100%; height: 100%; display: block; }

/* ---------- Buttons ------------------------------------------------------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: linear-gradient(to bottom, var(--basalt-700), var(--basalt-800));
  color: var(--sand-200); padding: 10px 20px; border-radius: 6px;
  font-size: 14px; letter-spacing: 0.08em; min-height: 44px;
  transition: border-color 240ms var(--ease-soft), transform 160ms var(--ease-soft), box-shadow 240ms var(--ease-soft);
}
.btn:hover { border-color: var(--copper); box-shadow: 0 0 0 1px rgba(201,138,69,0.25), 0 6px 18px rgba(0,0,0,0.35); }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn.primary {
  background: linear-gradient(to bottom, #a86c2f, #8a5423); border-color: #d8a15b; color: #fff8e8;
  font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 12.5px; }
.btn.danger-ghost { border-color: #7c4433; color: #e2a58a; }
.btn[disabled] { opacity: 0.42; cursor: not-allowed; box-shadow: none; }

/* ---------- Sim layout ---------------------------------------------------- */
#sim-view { display: flex; flex-direction: column; background: #100d0a; }

.topbar {
  display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid var(--basalt-700);
  background: linear-gradient(to bottom, var(--basalt-800), var(--basalt-900));
  padding: 6px 12px; z-index: 5; flex: 0 0 auto;
}
.clockblock { display: flex; align-items: center; gap: 14px; padding-right: 14px; border-right: 1px solid var(--basalt-700); }
.regnal-year { text-align: center; min-width: 96px; }
.regnal-year .ry-num { font-family: var(--display); font-size: 30px; line-height: 1; color: var(--copper-bright); font-weight: 380; }
.regnal-year .ry-label { font-size: 10px; letter-spacing: 0.22em; color: var(--ink-faint); text-transform: uppercase; }
.season-pill {
  font-family: var(--display); font-size: 17px; letter-spacing: 0.14em; padding: 5px 16px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--sand-200); transition: background 600ms var(--ease-soft), color 600ms var(--ease-soft);
}
.season-akhet { background: rgba(63,103,126,0.28); color: #bcd6ea; border-color: #46647d; }
.season-peret  { background: rgba(110,124,74,0.24); color: #d4ddb0; border-color: #5c6b41; }
.season-shemu  { background: rgba(158,104,52,0.24); color: #ecd2a8; border-color: #83602f; }

.speed-controls { display: flex; gap: 4px; align-items: center; }
.speed-controls .btn { min-width: 44px; }
.speed-controls .btn.speed-on { border-color: var(--copper-bright); color: #ffe6bd; background: linear-gradient(to bottom, #6b4a22, #54381a); }

.reign-meter { flex: 1; min-width: 130px; padding: 4px 16px 4px 18px; }
.meter-label-row { display: flex; justify-content: space-between; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 3px; }
.meter { height: 7px; border-radius: 4px; background: var(--basalt-700); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(to right, #6f5426, #caa05a); transition: width 480ms var(--ease-soft); }
.scaffold-stat { padding: 2px 14px; border-left: 1px solid var(--basalt-700); min-width: 108px; }
.scaffold-stat .sv { font-family: var(--display); font-size: 21px; color: var(--sand-100); }
.scaffold-stat .sl { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }
.iconbtns { display: flex; gap: 6px; align-items: center; padding-left: 8px; border-left: 1px solid var(--basalt-700); }

.main-strip { flex: 1 1 auto; display: flex; min-height: 0; }

.canvas-col { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; position: relative; }
.scene-stage { flex: 1 1 auto; position: relative; min-height: 220px; }
#pyramid-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#pyramid-scene.dragging { cursor: grabbing; }

.stage-overlays { position: absolute; left: 12px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 3; }
.chip {
  border: 1px solid var(--line); background: rgba(23,19,16,0.82); backdrop-filter: blur(3px);
  color: var(--ink-dim); font-size: 12px; padding: 7px 12px; border-radius: 999px; letter-spacing: 0.06em;
  min-height: 34px; transition: border-color 200ms var(--ease-soft), color 200ms var(--ease-soft);
}
.chip[aria-pressed="true"] { border-color: var(--copper); color: #ffe3ba; background: rgba(70,48,22,0.85); }
.phase-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  font-family: var(--display); font-size: 15px; letter-spacing: 0.3em; text-transform: uppercase;
  color: rgba(243,234,214,0.72); background: rgba(20,16,12,0.55); padding: 7px 22px; border-radius: 999px;
  border: 1px solid rgba(87,70,47,0.6); pointer-events: none; white-space: nowrap;
}
.objective-note {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  color: rgba(233,221,192,0.85); font-size: 13px; font-style: italic; text-align: center;
  background: rgba(20,16,12,0.45); padding: 5px 16px; border-radius: 10px; max-width: min(72vw, 640px); pointer-events: none;
}

/* ticker */
.tickerbar {
  flex: 0 0 auto; border-top: 1px solid var(--basalt-700); background: var(--basalt-900);
  font-size: 12.5px; color: var(--ink-dim); padding: 6px 14px; display: flex; gap: 20px; align-items: center;
  overflow: hidden; white-space: nowrap;
}
.ticker-item b { color: var(--copper-bright); font-weight: normal; }

/* ---------- Side panel ---------------------------------------------------- */
.sidepanel {
  flex: 0 0 clamp(320px, 26vw, 396px); border-left: 1px solid var(--basalt-700); background: var(--basalt-800);
  display: flex; flex-direction: column; min-height: 0; transition: margin-right 460ms var(--ease-glide);
}
.panel-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--basalt-700); background: var(--basalt-900); }
.panel-tab {
  flex: 1 1 auto; white-space: nowrap; appearance: none; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--ink-faint); padding: 9px 6px; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase;
  font-family: var(--body-font); min-height: 40px; transition: color 200ms, border-color 200ms;
}
.panel-tab[aria-selected="true"] { color: var(--copper-bright); border-bottom-color: var(--copper); }
.panel-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 14px 26px; min-height: 0; }

.panel-section { margin-bottom: 18px; }
.panel-section > h3 {
  font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--sand-500);
  border-bottom: 1px dotted var(--line); padding-bottom: 5px; margin-bottom: 10px; font-weight: 400;
}
.hint-text { color: var(--ink-faint); font-size: 12.5px; font-style: italic; margin: 6px 0 10px; }

/* stat rows */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.stat-cell { background: var(--basalt-750); border: 1px solid var(--basalt-700); border-radius: 7px; padding: 8px 10px; }
.stat-cell .v { font-family: var(--mono); font-size: 15.5px; color: var(--sand-100); }
.stat-cell .u { font-size: 10.5px; color: var(--ink-faint); margin-left: 2px; }
.stat-cell .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-top: 2px; }

/* allocation */
.alloc-row { display: grid; grid-template-columns: 1fr; gap: 3px; padding: 10px 8px 12px; border: 1px solid transparent; border-radius: 9px; outline: none; }
.alloc-row.focused { border-color: var(--line); background: var(--basalt-750); }
.alloc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.alloc-name { font-size: 13.5px; color: var(--sand-200); letter-spacing: 0.03em; }
.alloc-count { font-family: var(--mono); font-size: 13px; color: var(--copper-bright); }
.alloc-desc { font-size: 11.5px; color: var(--ink-faint); font-style: italic; }
.alloc-slider-row { display: flex; align-items: center; gap: 8px; }
input[type="range"].alloc {
  flex: 1; appearance: none; -webkit-appearance: none; height: 26px; background: transparent; min-width: 60px;
}
input[type="range"].alloc::-webkit-slider-runnable-track {
  height: 5px; background: linear-gradient(to right, #6d5936 var(--fill, 50%), var(--basalt-600) var(--fill, 50%)); border-radius: 3px;
}
input[type="range"].alloc::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; margin-top: -6.5px;
  background: radial-gradient(circle at 35% 30%, #eec98a, #a3743a 65%, #6b4a22); border: 1px solid #3a2c17;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
input[type="range"].alloc::-moz-range-track { height: 5px; background: var(--basalt-600); border-radius: 3px; }
input[type="range"].alloc::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #c99954; border: 1px solid #3a2c17; }
.alloc-note { font-size: 11px; color: var(--ink-faint); }
.alloc-flow { margin-top: 12px; border: 1px dashed var(--line); border-radius: 9px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-dim); }
.alloc-flow b { color: var(--copper-bright); font-weight: normal; font-family: var(--mono); }

/* morale / provision bars */
.bar-stack { display: flex; flex-direction: column; gap: 8px; }
.kbar { display: grid; grid-template-columns: 92px 1fr 64px; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-dim); }
.kbar .meter { height: 8px; }
.kbar .val { font-family: var(--mono); font-size: 12px; text-align: right; }

/* tabs content generic */
.card-list { display: flex; flex-direction: column; gap: 8px; }
.gang-card {
  border: 1px solid var(--basalt-700); background: var(--basalt-750); border-radius: 9px; padding: 9px 11px; cursor: default;
  transition: border-color 200ms var(--ease-soft); outline: none;
}
.gang-card:focus-visible, .gang-card.selected { border-color: var(--copper); }
.gang-card h4 { margin: 0 0 3px; font-size: 13.5px; font-family: var(--display); font-weight: 420; letter-spacing: 0.06em; color: var(--sand-100); }
.gang-card .g-sub { font-size: 11.5px; color: var(--ink-faint); font-style: italic; }
.gang-card .g-meta { margin-top: 5px; font-size: 12px; color: var(--ink-dim); display: flex; gap: 12px; flex-wrap: wrap; }
.gang-card .g-graffiti { margin-top: 6px; font-size: 12px; color: #cf9a5d; font-style: italic; }
.gang-status-chip { font-size: 10px; padding: 2px 8px; border-radius: 999px; border: 1px solid; letter-spacing: 0.06em; }
.gs-quarrying { color: #cbb791; border-color: #77643e; }
.gs-hauling { color: #a9c4bb; border-color: #48705f; }
.gs-setting { color: #e3b58a; border-color: #8a5c2f; }
.gs-resting { color: #a89c86; border-color: #5a5040; }
.gs-interior { color: #cabce4; border-color: #5d5182; }

/* scholars */
.debate-card { border: 1px solid var(--basalt-700); border-radius: 10px; padding: 12px 14px; background: var(--basalt-750); margin-bottom: 12px; }
.debate-card h4 { margin: 0; font-family: var(--display); font-weight: 430; font-size: 14.5px; letter-spacing: 0.05em; color: #dfc790; }
.debate-positions { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.position { font-size: 12.5px; color: var(--ink-dim); padding-left: 10px; border-left: 2px solid var(--line); }
.position b { color: var(--sand-200); font-weight: normal; }
.certainty-tag { display: inline-block; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; border: 1px solid #5a5040; color: #b3a687; border-radius: 999px; padding: 1px 8px; margin-left: 6px; }

/* chronicle */
.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-entry { display: grid; grid-template-columns: 86px 1fr; gap: 8px; padding: 7px 6px; border-bottom: 1px dotted rgba(87,70,47,0.4); font-size: 12.8px; }
.log-entry time { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); padding-top: 2px; }
.log-entry.le-event { background: rgba(207,111,74,0.08); border-radius: 6px; }
.log-entry.le-milestone { background: rgba(201,138,69,0.09); border-radius: 6px; }
.log-entry .lx { color: var(--ink-dim); }

/* stockpile/resources */
.res-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 7px 4px; border-bottom: 1px dotted rgba(87,70,47,0.4); font-size: 13px; align-items: baseline; }
.res-line .rv { font-family: var(--mono); font-size: 13.5px; color: var(--sand-100); }
.res-line .delta-up { color: var(--good); font-size: 11px; margin-left: 5px; }
.res-line .delta-down { color: var(--warn); font-size: 11px; margin-left: 5px; }
.projects-list { display: flex; flex-direction: column; gap: 9px; }
.project-row { border: 1px solid var(--basalt-700); border-radius: 9px; padding: 10px 12px; background: var(--basalt-750); }
.project-row h4 { margin: 0 0 2px; font-size: 13px; font-family: var(--body-font); letter-spacing: 0.05em; color: var(--sand-200); font-weight: normal; }
.project-row .p-sub { font-size: 11.5px; color: var(--ink-faint); font-style: italic; }
.project-row .p-bar { margin-top: 7px; }
.pct-done { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); float: right; }
.switchable { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Modals / dialogs --------------------------------------------- */
.modal-veil {
  position: fixed; inset: 0; background: rgba(10,8,6,0.66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 380ms var(--ease-soft);
}
.modal-veil.open { opacity: 1; pointer-events: auto; }
.modal-card {
  max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(to bottom, var(--basalt-750), var(--basalt-800));
  border: 1px solid var(--line); border-radius: 14px; padding: 24px 26px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
  transform: translateY(14px) scale(0.985); transition: transform 420ms var(--ease-glide);
}
.modal-veil.open .modal-card { transform: translateY(0) scale(1); }
.modal-kicker { font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--copper); margin-bottom: 8px; }
.modal-title { font-family: var(--display); font-weight: 330; font-size: 27px; letter-spacing: 0.03em; margin-bottom: 10px; color: #f6edd9; }
.modal-body { color: var(--ink-dim); font-size: 14px; }
.modal-body p { margin: 8px 0; }
.modal-history-note { margin-top: 12px; padding: 10px 12px; background: rgba(79,127,116,0.1); border-left: 3px solid var(--nile); border-radius: 0 8px 8px 0; font-size: 12.5px; color: #b7cdc2; font-style: italic; }
.choice-list { margin-top: 16px; display: flex; flex-direction: column; gap: 9px; }
.choice-btn {
  text-align: left; appearance: none; background: var(--basalt-900); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; color: var(--sand-200); font-size: 13.5px; line-height: 1.4; transition: border-color 200ms, background 200ms;
  min-height: 48px;
}
.choice-btn:hover:not([disabled]) { border-color: var(--copper-bright); background: #2a2214; }
.choice-btn .eff { display: block; margin-top: 3px; font-size: 11.5px; color: var(--ink-faint); }
.choice-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ramp choice modal */
.ramp-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 14px; }
.ramp-option {
  position: relative; text-align: left; background: var(--basalt-900); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 13px 11px; transition: border-color 220ms var(--ease-soft), transform 220ms var(--ease-soft); outline: none;
}
.ramp-option:hover, .ramp-option:focus-visible { border-color: var(--copper-bright); transform: translateY(-2px); }
.ramp-option.selected { border-color: var(--copper); box-shadow: 0 0 0 1px var(--copper), 0 8px 22px rgba(201,138,69,0.12); }
.ramp-option svg { width: 100%; height: 54px; display: block; margin-bottom: 8px; }
.ramp-option h4 { margin: 0 0 4px; font-family: var(--display); font-weight: 430; font-size: 15.5px; color: #ecd9ae; letter-spacing: 0.04em; }
.ramp-option .r-stats { font-size: 11.5px; color: var(--ink-dim); margin-top: 6px; display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); }
.ramp-option .r-flavor { font-size: 11.5px; color: var(--ink-faint); font-style: italic; margin-top: 6px; line-height: 1.35; }
.ramp-certainty { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: #a08f6d; border: 1px solid #5a5040; padding: 1px 7px; border-radius: 999px; margin-left: 4px; }

/* ---------- Interlude panorama ------------------------------------------- */
#interlude-view { background: #14101d; }
.pan-wrap { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: pan-y; }
.pan-wrap.dragging { cursor: grabbing; }
.pan-scroll-proxy { position: absolute; left: -200vw; top: 0; width: 400vw; height: 10px; }
.pan-progress {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; z-index: 6;
}
.pan-progress i { width: 7px; height: 7px; border-radius: 50%; background: rgba(243,234,214,0.28); transition: background 300ms, transform 300ms; }
.pan-progress i.on { background: #ecc687; transform: scale(1.35); }
.pan-continue {
  position: absolute; right: 26px; bottom: 20px; z-index: 6;
}
.pan-beat {
  position: absolute; z-index: 4; max-width: min(520px, 74vw); opacity: 0; transform: translateY(18px);
  transition: opacity 700ms var(--ease-soft), transform 900ms var(--ease-glide); pointer-events: none;
}
.pan-beat.shown { opacity: 1; transform: translateY(0); }
.pan-beat h3 {
  font-family: var(--display); font-weight: 300; font-size: clamp(23px, 3.4vw, 34px); letter-spacing: 0.12em;
  color: #f7ecd4; text-shadow: 0 2px 26px rgba(10,8,20,0.8); line-height: 1.22;
}
.pan-beat p {
  font-family: var(--display); font-weight: 340; font-style: italic; font-size: clamp(15px, 1.9vw, 18.5px);
  color: #e4d3b4; line-height: 1.55; text-shadow: 0 1px 16px rgba(10,8,20,0.85); margin-top: 10px;
}
.pan-beat .beat-fact { font-style: normal; font-size: 12.5px; color: #cdb58c; border-top: 1px dotted rgba(205,181,140,0.4); margin-top: 10px; padding-top: 8px; letter-spacing: 0.02em; }
.pan-season-tag {
  position: absolute; top: 22px; left: 28px; z-index: 5; font-family: var(--display); font-size: 13px;
  letter-spacing: 0.42em; text-transform: uppercase; color: rgba(247,236,212,0.66);
}

/* ---------- Survey phase widgets ------------------------------------------ */
.survey-opt {
  text-align: left; background: var(--basalt-900); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  width: 100%; margin-bottom: 8px; font-size: 13px; color: var(--sand-200); transition: border-color 200ms;
}
.survey-opt:hover, .survey-opt:focus-visible { border-color: var(--copper-bright); }
.survey-opt.sel { border-color: var(--copper); background: #2b2213; }
.survey-opt .so-eff { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; font-family: var(--mono); }
.survey-opt .so-note { display: block; font-size: 11.5px; color: #a89a7c; font-style: italic; margin-top: 3px; }

/* ---------- Reckoning ----------------------------------------------------- */
#reckoning-view {
  background:
    radial-gradient(110% 80% at 50% 115%, rgba(190,120,60,0.2), transparent 62%),
    linear-gradient(to bottom, #120e18 0%, #221830 42%, #472a3b 70%, #7d4630 92%, #b06f38 100%);
  overflow-y: auto; display: block;
}
.reckon-inner { max-width: 860px; margin: 0 auto; padding: 7vh 26px 90px; }
.reckon-kicker { font-size: 12px; letter-spacing: 0.44em; text-transform: uppercase; color: #dba662; text-align: center; }
.reckon-title { text-align: center; font-family: var(--display); font-weight: 300; font-size: clamp(38px, 6vw, 64px); letter-spacing: 0.05em; color: #fbf3dd; margin: 12px 0 6px; }
.reckon-verdict {
  text-align: center; font-family: var(--display); font-style: italic; font-size: clamp(17px, 2.6vw, 23px);
  color: #e7cf9e; margin-bottom: 30px; letter-spacing: 0.04em;
}
.reckon-grade { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 34px; }
.grade-card {
  min-width: 128px; text-align: center; border: 1px solid rgba(232,199,140,0.35); border-radius: 12px; padding: 13px 10px;
  background: rgba(20,14,10,0.45); backdrop-filter: blur(2px);
}
.grade-card .gv { font-family: var(--display); font-size: 30px; color: #f4dfa9; }
.grade-card .gl { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: #bfa173; margin-top: 2px; }
.grade-card.perfect { border-color: #e9c76c; box-shadow: 0 0 24px rgba(233,199,108,0.16); }
.reckon-narrative { color: #d9c8a4; font-size: 15px; line-height: 1.65; max-width: 640px; margin: 0 auto 30px; text-align: center; font-style: italic; }
.reckon-ledger { max-width: 640px; margin: 0 auto; }
.ledger-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ledger-table td { padding: 8px 10px; border-bottom: 1px dotted rgba(232,199,140,0.25); color: #dccfab; }
.ledger-table td:last-child { text-align: right; font-family: var(--mono); color: #f1e3bf; }
.reckon-footnote { max-width: 640px; margin: 26px auto 0; font-size: 12px; color: #ad9a78; font-style: italic; text-align: center; }
.reckon-actions { text-align: center; margin-top: 40px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Help overlay --------------------------------------------------- */
kbd {
  font-family: var(--mono); font-size: 11px; background: var(--basalt-700); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; color: var(--sand-200);
}
.key-help-grid { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13px; color: var(--ink-dim); margin-top: 12px; }

/* ---------- Toasts --------------------------------------------------------- */
.toast-zone { position: fixed; bottom: 56px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(28,22,15,0.94); border: 1px solid var(--line); border-radius: 999px; padding: 9px 20px;
  font-size: 13px; color: var(--sand-200); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toast-in 420ms var(--ease-glide); transition: opacity 500ms var(--ease-soft);
}
.toast.gone { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ----------------------------------------------------- */
@media (max-width: 1020px) {
  .sidepanel { flex-basis: 300px; }
}
@media (max-width: 820px) {
  body { font-size: 14px; }
  #sim-view .main-strip { flex-direction: column; }
  .sidepanel {
    flex: 0 0 auto; order: 2; border-left: none; border-top: 1px solid var(--basalt-700);
    height: 46vh; min-height: 300px;
  }
  .canvas-col { order: 1; flex: 1 1 auto; min-height: 34vh; }
  .panel-tab { padding: 10px 4px; font-size: 10.5px; }
  .topbar { flex-wrap: wrap; row-gap: 6px; padding: 6px 8px; }
  .reign-meter { order: 5; flex-basis: 100%; padding: 2px 8px; }
  .clockblock { padding-right: 8px; }
  .regnal-year { min-width: 72px; }
  .regnal-year .ry-num { font-size: 24px; }
  .objective-note { display: none; }
  .phase-banner { font-size: 11px; letter-spacing: 0.2em; padding: 5px 14px; }
  .tickerbar { font-size: 11.5px; gap: 12px; }
  .chip { font-size: 11px; padding: 7px 10px; }
  .modal-card { padding: 18px 16px; }
  .pan-beat h3 { letter-spacing: 0.08em; }
}
@media (max-width: 560px) {
  .topbar { padding: 5px 6px; row-gap: 4px; }
  .clockblock { gap: 7px; border-right: none; padding-right: 2px; }
  .regnal-year { min-width: 58px; }
  .regnal-year .ry-num { font-size: 19px; }
  .regnal-year .ry-label { letter-spacing: 0.14em; font-size: 9px; }
  .season-pill { font-size: 13px; padding: 4px 10px; letter-spacing: 0.08em; }
  .speed-controls { gap: 2px; }
  .speed-controls .btn { min-width: 34px; padding: 6px 6px; min-height: 34px; font-size: 11px; }
  /* keep two headline numbers only; height figure hides to avoid crowding */
  .scaffold-stat { min-width: 84px; padding: 1px 8px; }
  .scaffold-stat .sv { font-size: 15px; }
  .scaffold-stat.s-height { display: none; }
  .iconbtns { padding-left: 4px; gap: 4px; }
  .iconbtns .btn { min-height: 34px; padding: 6px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
