/* The Midnight Museum.
 *
 * Two type families: Kenney Pixel for headings, labels and buttons (pixel art
 * to match the world), Atkinson Hyperlegible for anything she reads: stories,
 * questions, facts, hints (SPEC §13). Panels use Kenney "UI Pack - Pixel
 * Adventure" 9-slice frames (assets/ui). The tutor panel and the report stay
 * plain on purpose (SPEC §10, §11).
 */

@font-face { font-family: 'Atkinson'; src: url('assets/fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('assets/fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Pixel'; src: url('assets/fonts/kenney-pixel.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'PixelMini'; src: url('assets/fonts/kenney-mini.ttf') format('truetype'); font-display: swap; }

:root {
  --font: 'Atkinson', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --pixel: 'Pixel', 'Atkinson', monospace;
  --ink: #2a1a0c;
  --ink-soft: #5a4128;
  --gold: #ffd54a;
  --gold-dark: #b8860b;
  --p1: #ff7fc4;
  --p2: #6cb6ff;
  --night: #0b0d16;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; font-family: var(--font); }
button { font-family: var(--font); cursor: pointer; }
.pixel, h1, h2, h3, h4 { font-family: var(--pixel); font-weight: normal; letter-spacing: 0.02em; }

#stage {
  position: fixed; left: 50%; top: 50%;
  width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16));
  transform: translate(-50%, -50%); overflow: hidden;
}
#game, #game canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; margin: 0 !important; }
#hud, #overlay-root, #toast-root { position: absolute; inset: 0; pointer-events: none; }
#overlay-root > * { pointer-events: auto; }
#hud { z-index: 5; }
#overlay-root { z-index: 10; }
#fps { position: absolute; right: 6px; bottom: 6px; z-index: 30; color: #7f7; font: 12px monospace; background: #000a; padding: 2px 5px; }

/* ================================================================ frames */
.frame, .panel.parchment {
  border: 16px solid transparent;
  border-image: url('assets/ui/frame-parchment.png') 8 fill / 16px stretch;
  image-rendering: pixelated;
  padding: 4px 10px;
  color: var(--ink);
}
.frame.wood { border-image-source: url('assets/ui/frame-wood.png'); color: #fff3dc; }
.frame.stone { border-image-source: url('assets/ui/frame-stone.png'); color: #1b2230; }
.frame.slate { border-image-source: url('assets/ui/frame-slate.png'); color: #f3f1ea; }
.frame.ornate { border-image: url('assets/ui/frame-ornate.png') 10 fill / 20px stretch; }
.frame.miss { border-image-source: url('assets/ui/frame-miss.png'); color: #1b2230; }
.frame.win { border-image-source: url('assets/ui/frame-win.png'); color: #1b2230; }
.frame.info { border-image-source: url('assets/ui/frame-info.png'); color: #1b2230; }
.frame h4, .frame h3 { margin: 2px 0 6px; }
.frame h4 { font-size: 22px; }

/* ================================================================ pixel buttons */
.pbtn, .btn {
  font-family: var(--pixel); font-size: 24px; line-height: 1; padding: 10px 16px 12px; border: 3px solid #2a1a0c; border-radius: 0;
  background: #e8c15a; color: #2a1a0c; position: relative;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.22), inset 4px 4px 0 rgba(255, 255, 255, 0.35), 0 4px 0 #2a1a0c;
  transition: transform 0.05s;
}
.pbtn:hover, .btn:hover { filter: brightness(1.08); }
.pbtn:active, .btn:active { transform: translateY(3px); box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.22), inset 4px 4px 0 rgba(255, 255, 255, 0.35), 0 1px 0 #2a1a0c; }
.pbtn:disabled, .btn:disabled { filter: grayscale(0.9) brightness(0.75); cursor: not-allowed; }
.pbtn.big, .btn.big { font-size: 30px; padding: 14px 24px 16px; }
.pbtn.green, .btn.good { background: #5cc46b; color: #0f2a14; }
.pbtn.slate, .btn.secondary { background: #7d8aa0; color: #10151f; }
.pbtn.red, .btn.danger { background: #e0533b; color: #fff; }
.pbtn.gold { background: #ffd54a; }
.row-right { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.boot-loading, .boot-error { position: absolute; inset: 0; display: grid; place-items: center; color: #ffe08a; font: 34px var(--pixel); background: var(--night); }

/* ================================================================ HUD */
.hud-half { position: absolute; top: 0; width: 50%; height: 100%; }
.hud-p1 { left: 0; }
.hud-p2 { left: 50%; }
.hud-bar {
  margin: 8px; display: flex; gap: 10px; align-items: center; pointer-events: auto; width: fit-content;
  border: 12px solid transparent; border-image: url('assets/ui/frame-wood.png') 8 fill / 12px stretch; image-rendering: pixelated;
  color: #fff3dc; padding: 0 4px; font: 22px var(--pixel);
}
.hud-p1 .hud-name { color: var(--p1); text-shadow: 2px 2px 0 #2a1a0c; }
.hud-p2 .hud-name { color: var(--p2); text-shadow: 2px 2px 0 #2a1a0c; }
.hud-wing { opacity: 0.85; }
.hud-tier { width: 16px; height: 16px; display: inline-block; image-rendering: pixelated; box-shadow: inset -3px -3px 0 rgba(0,0,0,.3), inset 3px 3px 0 rgba(255,255,255,.4); border: 2px solid #2a1a0c; }
.hud-tier.bronze { background: #cd7f32; }
.hud-tier.gold { background: #ffd54a; box-shadow: 0 0 10px #ffd54a, inset -3px -3px 0 rgba(0,0,0,.3), inset 3px 3px 0 rgba(255,255,255,.5); }
.hud-clues { font: 20px var(--pixel); background: #ffd54a; color: #2a1a0c; border: 2px solid #2a1a0c; padding: 2px 8px 4px; box-shadow: inset -3px -3px 0 rgba(0,0,0,.2); }
.hud-clues.pulse { animation: pulse 0.5s ease 2; }
@keyframes pulse { 50% { transform: scale(1.25); background: #fff3a6; } }
.hud-msg {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); white-space: nowrap;
  border: 14px solid transparent; border-image: url('assets/ui/frame-parchment.png') 8 fill / 14px stretch; image-rendering: pixelated;
  color: var(--ink); padding: 0 8px; font-size: 21px; font-weight: 700; opacity: 0; transition: opacity 0.2s;
}
.hud-msg.show { opacity: 1; }
.divider { position: absolute; left: calc(50% - 3px); top: 0; width: 6px; height: 100%; background: #1a1206; box-shadow: inset 2px 0 0 #3a2a1a, inset -2px 0 0 #3a2a1a, 0 0 8px #000; }
.flying-clue {
  position: absolute; left: 50%; top: 45%; width: 100px; height: 130px; transform: translate(-50%, -50%) rotate(-6deg) scale(1.4);
  border: 16px solid transparent; border-image: url('assets/ui/frame-ornate.png') 10 fill / 16px stretch; image-rendering: pixelated;
  display: grid; place-items: center; font: 26px var(--pixel); color: #3a2a10; filter: drop-shadow(0 0 20px #ffd76a);
  transition: all 0.85s cubic-bezier(.5, -0.3, .6, 1);
}
.flying-clue.go { left: 85%; top: 22px; transform: translate(-50%, -50%) rotate(0) scale(0.25); opacity: 0.4; }
.clue-banner {
  position: absolute; left: 50%; top: 76px; transform: translateX(-50%); max-width: 780px; z-index: 6; text-align: center;
  border: 20px solid transparent; border-image: url('assets/ui/frame-ornate.png') 10 fill / 20px stretch; image-rendering: pixelated;
  color: var(--ink); padding: 2px 14px; font-size: 23px; line-height: 1.45; filter: drop-shadow(0 8px 16px #000a); transition: opacity 0.6s;
}
.clue-banner b { display: block; font: 26px var(--pixel); color: #8b1e3f; margin-bottom: 4px; }
.clue-banner.fade { opacity: 0; }

/* ================================================================ overlays */
.overlay { position: absolute; inset: 0; background: rgba(6, 7, 14, 0.8); display: flex; align-items: center; justify-content: center; color: var(--ink); }
.panel { max-height: 94%; overflow: auto; filter: drop-shadow(0 10px 30px #000c); }
.panel.parchment { padding: 10px 22px; }
.feedback { font-size: 22px; line-height: 1.45; max-width: 62ch; margin: 10px 0; padding: 6px 12px; }
.feedback h3 { margin: 0 0 4px; font-size: 32px; }
.feedback ol { margin: 6px 0 0; padding-left: 26px; }
.feedback .pbtn, .feedback .btn { margin-top: 10px; }
.feedback.miss:not(.frame) { border: 16px solid transparent; border-image: url('assets/ui/frame-miss.png') 8 fill / 16px stretch; image-rendering: pixelated; }
.feedback.win:not(.frame) { border: 16px solid transparent; border-image: url('assets/ui/frame-win.png') 8 fill / 16px stretch; image-rendering: pixelated; }
.feedback.info:not(.frame) { border: 16px solid transparent; border-image: url('assets/ui/frame-info.png') 8 fill / 16px stretch; image-rendering: pixelated; }
.situation-upfront { background: #e6eefb; border: 3px dashed #4a6fa8; padding: 8px 12px; font-size: 20px; margin: 6px 0; max-width: 62ch; color: var(--ink); }

.clue-list { width: min(780px, 92%); font-size: 21px; line-height: 1.45; }
.clue-list h2 { margin: 4px 0 10px; font-size: 34px; }
.clue-list ol { list-style: none; padding: 0; margin: 0; }
.clue-list li { padding: 7px 0; border-bottom: 2px dashed #c9a96a; }
.clue-list li.missing { opacity: 0.45; }
.clue-list li b { display: inline-block; min-width: 96px; font: 22px var(--pixel); color: #8b5a1a; }
.clue-list li.final b { min-width: 120px; color: #8b1e3f; }

/* choices (1–4 answers) */
.choices { display: grid; gap: 10px; margin: 10px 0; }
.choice {
  text-align: left; font-size: 22px; padding: 8px 14px; color: var(--ink); display: flex; gap: 12px; align-items: center;
  border: 14px solid transparent; border-image: url('assets/ui/frame-parchment.png') 8 fill / 14px stretch; image-rendering: pixelated; background: none;
}
.choice .num { font: 24px var(--pixel); background: #2a1a0c; color: #ffd54a; padding: 2px 10px 4px; }
.choice:hover { filter: brightness(1.06) drop-shadow(0 0 6px #ffd54a); }

/* ================================================================ lock screen */
.lock-overlay { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; background: rgba(6, 7, 14, 0.92); }
.lock-header {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 8px 14px 6px;
  background: linear-gradient(#1a1410, #0e0b09); border-bottom: 4px solid #000; box-shadow: inset 0 -3px 0 #3a2a1a;
}
.ribbon {
  border-style: solid; border-color: transparent; border-width: 0 40px; height: 56px;
  border-image: url('assets/ui/ribbon.png') 0 32 fill / 0 40px stretch; image-rendering: pixelated;
  display: flex; align-items: center;
  /* The ribbon's red band sits low in the middle (rows 8–28 of 32), so center the text on the band, not the box. */
  padding: 7px 6px 0;
}
.ribbon span { font: 30px/1 var(--pixel); color: #fff8e6; text-shadow: 2px 2px 0 #7a1f12; white-space: nowrap; }
.lock-sub { display: flex; gap: 12px; align-items: center; }
.problem-title { font: 32px var(--pixel); color: #ffe9b0; text-shadow: 2px 2px 0 #000; }
.tier-tag, .practice-tag { font: 18px var(--pixel); padding: 3px 8px 5px; border: 2px solid #000; }
.tier-tag.standard { background: #cd7f32; color: #2a1a0c; }
.tier-tag.challenge { background: #ffd54a; color: #2a1a0c; box-shadow: 0 0 10px #ffd54a; }
.practice-tag { background: #6cb6ff; color: #0b1d33; }

.step-track { display: flex; gap: 6px; align-items: center; }
.step-pill {
  font: 22px var(--pixel); padding: 4px 12px 6px; display: flex; align-items: center; gap: 8px;
  background: #2b2f3b; color: #8c93a5; border: 3px solid #000; box-shadow: inset -3px -3px 0 rgba(0,0,0,.3), inset 3px 3px 0 rgba(255,255,255,.08);
}
.step-pill .step-num { font: 18px var(--pixel); width: 24px; height: 24px; display: grid; place-items: center; background: #000; color: inherit; }
.step-pill.done { background: #2f6b3a; color: #c9f5cf; }
.step-pill.now { background: #ffd54a; color: #2a1a0c; transform: translateY(-2px); box-shadow: 0 0 14px #ffd54a99, inset -3px -3px 0 rgba(0,0,0,.2), inset 3px 3px 0 rgba(255,255,255,.4); }
.step-pill.now .step-num { background: #2a1a0c; color: #ffd54a; }
.step-pill.missed { background: #b3361f; color: #fff; }

.lock-split { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; }
.lock-half { padding: 10px 14px 16px; overflow-y: auto; position: relative; display: flex; flex-direction: column; gap: 8px; }
.lock-half.her { background: radial-gradient(ellipse at 30% 0%, #3a2c1e, #1c150f 70%); border-right: 6px solid #000; }
.lock-half.his { background: radial-gradient(ellipse at 70% 0%, #252c3a, #11141b 70%); }
.half-head { display: flex; align-items: center; gap: 10px; }
.who { font: 22px var(--pixel); padding: 3px 10px 5px; border: 2px solid #000; color: #fff; }
.who.p1 { background: #b8458a; }
.who.p2 { background: #2f6fbf; }
.half-role { font: 20px var(--pixel); color: #cdbb98; }
.his .half-role { color: #a9b6cc; }

/* Ollie */
.owl-says { display: flex; gap: 10px; align-items: flex-end; }
.owl-says.right { flex-direction: row; }
.owl-frame { flex: none; width: 60px; height: 60px; display: grid; place-items: center; background: radial-gradient(circle, #ffd76a44, transparent 70%); }
.owl-img { width: 48px; height: 48px; image-rendering: pixelated; animation: owl-bob 2.4s ease-in-out infinite; }
@keyframes owl-bob { 50% { transform: translateY(-3px); } }
.owl-says.sad .owl-img { animation: none; transform: rotate(-8deg); }
.owl-says.happy .owl-img { animation: owl-hop 0.5s ease-in-out infinite; }
@keyframes owl-hop { 50% { transform: translateY(-8px); } }
.owl-bubble {
  position: relative; flex: 1; font-size: 20px; line-height: 1.4; font-weight: 700; color: var(--ink);
  border: 14px solid transparent; border-image: url('assets/ui/frame-parchment.png') 8 fill / 14px stretch; image-rendering: pixelated; padding: 0 6px;
}
.owl-bubble::before { content: ''; position: absolute; left: -26px; bottom: 6px; border: 8px solid transparent; border-right: 12px solid #5c3a1a; }
.owl-name { display: block; font: 18px var(--pixel); color: #8b5a1a; font-weight: normal; }
.his .owl-bubble { font-size: 18px; }

/* her side */
.story-box { font-size: 24px; }
.story { font-size: 24px; line-height: 1.5; max-width: 58ch; margin: 0 0 8px; }
.question { font-size: 24px; line-height: 1.45; font-weight: 700; max-width: 58ch; margin: 0 0 4px; }
.claim { font-size: 25px; line-height: 1.4; font-weight: 700; background: #fffaf0; border-left: 8px solid #8b1e3f; padding: 8px 14px; margin: 4px 0 12px; max-width: 58ch; }
.claim-label { display: block; font: 18px var(--pixel); color: #8b1e3f; font-weight: normal; }
.facts-uncovered ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.facts-uncovered li { font-size: 20px; background: #fff6dc; color: var(--ink); border: 2px solid #2a1a0c; padding: 4px 10px; box-shadow: inset -2px -2px 0 rgba(0,0,0,.12); }
.facts-uncovered li b { font-size: 22px; }
.facts-uncovered .none { font-size: 18px; font-style: italic; background: transparent; border: 0; box-shadow: none; color: #f0dcc0; }
.answer-row { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.answer-label { font-size: 26px; color: #ffe9b0; }
.answer-field {
  min-width: 260px; min-height: 64px; font-size: 36px; font-weight: 700; padding: 0 12px; display: flex; align-items: center; letter-spacing: 0.03em; color: #111;
  border: 14px solid transparent; border-image: url('assets/ui/frame-parchment.png') 8 fill / 14px stretch; image-rendering: pixelated;
}
.answer-field.inactive { color: #8a7d60; }
.answer-field .caret { display: inline-block; width: 4px; height: 36px; background: #111; margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.answer-unit { font-size: 24px; font-weight: 700; color: #ffe9b0; }
.answer-help { font-size: 17px; color: #d9c7a6; }
.parse-error { color: #ff9c8a; font-size: 20px; font-weight: 700; min-height: 1.2em; }
.torches { display: flex; gap: 3px; align-items: center; font: 20px var(--pixel); }
.torch-label { margin-right: 6px; }
.torch-count { margin-left: 6px; }
.torch { width: 20px; height: 28px; image-rendering: pixelated; }
.torch.out { opacity: 0.2; filter: grayscale(1); }
.box-head { display: flex; justify-content: space-between; align-items: center; }
.box-head h4 { margin: 0; }

/* his side: cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 6px; }
.card {
  min-height: 104px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; padding: 2px 4px;
  border: 14px solid transparent; border-image: url('assets/ui/frame-wood.png') 8 fill / 14px stretch; image-rendering: pixelated;
  background: none; color: #fff3dc;
}
.card .label { font-size: 18px; line-height: 1.25; }
.card .value { font-size: 34px; font-weight: 700; color: #7a1f00; }
.card .facedown { display: flex; align-items: center; gap: 6px; font: 18px var(--pixel); color: #ffd54a; }
.card .facedown .torch { width: 14px; height: 20px; }
.card.flipped { border-image-source: url('assets/ui/frame-parchment.png'); color: var(--ink); }
.card:not(.flipped):not(.cant):hover { filter: brightness(1.12) drop-shadow(0 0 6px #ffd54a); }
.card.cant { opacity: 0.5; cursor: not-allowed; }
.card.pick:hover { filter: drop-shadow(0 0 8px #ffd54a); }
.card.flipping { animation: flip 0.4s ease; }
@keyframes flip { 0% { transform: perspective(400px) rotateY(0); } 50% { transform: perspective(400px) rotateY(90deg); } 100% { transform: perspective(400px) rotateY(0); } }

/* plan (shared by his builder and her mirror) */
.plan-wrap { position: relative; }
.plan-arrows { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.plan { display: grid; gap: 22px; padding: 4px 0 6px; }
.plan-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-row .step-name { font: 22px var(--pixel); min-width: 70px; color: var(--step-color); text-shadow: 1px 1px 0 #000; }
.plan-mirror .plan-row .step-name { text-shadow: none; }
.slot, .op-box {
  min-height: 52px; border: 3px solid #000; font-size: 22px; font-weight: 700; padding: 4px 10px;
  background: #0d1017; color: #fff; box-shadow: inset 3px 3px 0 rgba(0,0,0,.5);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
}
.slot { min-width: 100px; }
.op-box { min-width: 50px; font-size: 30px; }
.slot.filled { background: #fff6dc; color: var(--ink); box-shadow: inset -3px -3px 0 rgba(0,0,0,.15); }
.op-box.filled { background: #ffd54a; color: #2a1a0c; box-shadow: inset -3px -3px 0 rgba(0,0,0,.2); }
.slot.selected, .op-box.selected { outline: 4px solid #ffd54a; outline-offset: 2px; animation: sel 1s steps(2) infinite; }
@keyframes sel { 50% { outline-color: #fff3a6; } }
.slot.step-ref { background: color-mix(in srgb, var(--step-color) 22%, #fff6dc); border-color: var(--step-color); border-width: 4px; }
.slot .ref-name { font: 20px var(--pixel); color: var(--ink); }
.slot .ref-expr { font-size: 15px; font-weight: 400; color: var(--ink-soft); white-space: nowrap; }
.result-tag { font: 22px var(--pixel); padding: 4px 10px 6px; background: var(--step-color); color: #fff; border: 3px solid #000; text-shadow: 1px 1px 0 #000; }
.plan.locked .slot, .plan.locked .op-box { cursor: default; }
.plan-mirror .slot, .plan-mirror .op-box { min-height: 40px; font-size: 20px; padding: 2px 8px; }
.plan-mirror .slot { min-width: 76px; }
.plan-mirror .op-box { min-width: 42px; font-size: 24px; }
.plan-mirror .plan { gap: 18px; }

.plan-tools { display: grid; gap: 8px; margin-top: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chips-label { font: 20px var(--pixel); color: #a9b6cc; margin-right: 4px; }
.chip { font-size: 18px; padding: 6px 12px; border: 3px solid #000; background: #2b3242; color: #fff; box-shadow: inset -3px -3px 0 rgba(0,0,0,.3), inset 3px 3px 0 rgba(255,255,255,.1); }
.chip:hover { filter: brightness(1.2); }
.step-chip { background: var(--step-color); color: #fff; text-shadow: 1px 1px 0 #000; }
.step-chip b { font-family: var(--pixel); font-weight: normal; font-size: 20px; }
.const-chip { font: 22px var(--pixel); min-width: 54px; background: #e9e2cf; color: var(--ink); }
.levers { display: flex; gap: 8px; }
.lever-btn {
  width: 70px; height: 70px; font-size: 38px; font-weight: 700; border: 3px solid #000; background: #ffd54a; color: #2a1a0c;
  box-shadow: inset -5px -5px 0 rgba(0,0,0,.22), inset 5px 5px 0 rgba(255,255,255,.4), 0 5px 0 #000;
}
.lever-btn:active { transform: translateY(4px); box-shadow: inset -5px -5px 0 rgba(0,0,0,.22), inset 5px 5px 0 rgba(255,255,255,.4), 0 1px 0 #000; }
.plan-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.plan-buttons .pbtn { font-size: 20px; padding: 8px 12px 10px; }
.plan-flash { font: 24px var(--pixel); min-height: 1.1em; }
.plan-flash.ok { color: #7ee2a0; }
.plan-flash.warn { color: #ffcf6e; }
.big-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.lever-red {
  font: 26px var(--pixel); padding: 10px 16px 12px; border: 3px solid #000; color: #fff; background: #d23c27;
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.25), inset 4px 4px 0 rgba(255,255,255,.25), 0 4px 0 #000; display: flex; gap: 10px; align-items: center;
}
.lever-red .handle { width: 10px; height: 34px; background: #ddd; border: 2px solid #000; transform: rotate(-20deg); box-shadow: inset 0 -12px 0 #b3361f; }
.lever-red.pulled .handle { transform: rotate(20deg); }
.leave-lock { position: absolute; right: 14px; bottom: 10px; font: 16px var(--pixel); background: #0008; border: 2px solid #ffffff44; color: #cfd6e4; padding: 4px 8px; }

/* what's active now */
.dim { opacity: 0.38; filter: saturate(0.4); transition: opacity 0.25s, filter 0.25s; }
.dim:hover { opacity: 0.7; }
.guide-focus { animation: focus-glow 1.1s ease-in-out infinite; }
@keyframes focus-glow { 0%, 100% { filter: drop-shadow(0 0 0 #ffd54a); } 50% { filter: drop-shadow(0 0 10px #ffd54a) drop-shadow(0 0 3px #fff3a6); } }
.question.guide-focus { animation: none; background: #fff3a6; box-shadow: 0 0 0 4px #ffd54a; }

/* wing themes */
.theme-egypt .lock-half.her { background: radial-gradient(ellipse at 30% 0%, #4a3418, #1d150b 70%); }
.theme-egypt .lock-half.his { background: radial-gradient(ellipse at 70% 0%, #173b3a, #0b1716 70%); }
.theme-greece .lock-half.her { background: radial-gradient(ellipse at 30% 0%, #3a4152, #151821 70%); }
.theme-greece .lock-half.his { background: radial-gradient(ellipse at 70% 0%, #1d2f5a, #0c1222 70%); }

/* ================================================================ logic lock */
.logic-panel { width: min(1120px, 96%); font-size: 22px; line-height: 1.45; }
.logic-panel .lock-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.logic-panel .lock-title { font: 24px var(--pixel); color: #8b5a1a; }
.logic-panel .setup { font-size: 23px; max-width: 72ch; }
.speech { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 12px 0; }
.bubble { border: 14px solid transparent; border-image: url('assets/ui/frame-ornate.png') 10 fill / 14px stretch; image-rendering: pixelated; padding: 2px 6px; }
.bubble .speaker { display: block; font: 22px var(--pixel); color: #8b1e3f; }
.bubble .said { font-size: 24px; }
.logic-options { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.logic-options .choice { min-width: 180px; }

/* ================================================================ finale */
.finale-overlay { align-items: stretch; }
.finale-wrap { display: grid; grid-template-columns: 1fr 360px; gap: 14px; width: 100%; height: 100%; padding: 14px; }
.finale-grid-panel { overflow: auto; }
.finale-grid-panel h2, .finale-side h2 { margin: 0 0 6px; font-size: 32px; }
.grid-and-accuse { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.grid-and-accuse .accuse { min-width: 260px; margin-top: 40px; }
.grid-and-accuse .accuse h2 { margin: 0; }
.lgrid { border-collapse: collapse; font-size: 17px; margin-top: 8px; }
.lgrid th { font-weight: 700; padding: 4px; }
.lgrid th.colhead { height: 124px; vertical-align: bottom; white-space: nowrap; }
.lgrid th.colhead span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; }
.lgrid th.rowhead { text-align: right; padding-right: 8px; white-space: nowrap; }
.lgrid th.cat { font: 18px var(--pixel); color: #8b5a1a; font-weight: normal; }
.lgrid td.cell { width: 52px; height: 52px; border: 2px solid #8a6a2a; text-align: center; font-size: 28px; font-weight: 700; cursor: pointer; background: #fffaf0; user-select: none; }
.lgrid td.cell:hover { background: #fff0bf; }
.lgrid td.cell.x { color: #b3361f; }
.lgrid td.cell.check { color: #1b7a43; background: #dff3e4; }
.lgrid td.cell.auto { color: #d68a7a; }
.lgrid td.gap { border: 0; background: transparent; cursor: default; }
.lgrid td.thick-l, .lgrid th.thick-l { border-left: 4px solid #3a2a10; }
.lgrid tr.thick-t td { border-top: 4px solid #3a2a10; }
.finale-side { display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.finale-clues { list-style: none; padding: 0; margin: 0; font-size: 17px; line-height: 1.4; }
.finale-clues li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 2px dashed #c9a96a; }
.finale-clues li.used { opacity: 0.5; text-decoration: line-through; }
.finale-clues input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.accuse { display: grid; gap: 8px; font-size: 18px; }
.accuse select { font-size: 18px; padding: 6px; font-family: var(--font); border: 3px solid #2a1a0c; background: #fffaf0; }
.accuse-result { font-size: 19px; font-weight: 700; min-height: 1.4em; }
.scene-card { width: min(840px, 92%); font-size: 24px; line-height: 1.5; text-align: center; }
.scene-card h2 { font-size: 40px; margin: 4px 0; }
.scene-card .case { font-size: 60px; }
.ending { width: min(880px, 92%); text-align: center; font-size: 25px; line-height: 1.55; }
.ending h1 { font-size: 56px; margin: 0 0 10px; color: #8b1e3f; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }

/* ================================================================ plaques */
.plaque-overlay { background: rgba(6, 7, 14, 0.55); }
.plaque { width: min(720px, 90%); font-size: 24px; line-height: 1.5; text-align: center; }
.plaque h3 { margin: 4px 0 8px; font-size: 26px; color: #8b5a1a; }
.plaque p { margin: 8px 0; }
.plaque .hint { font-size: 16px; opacity: 0.7; }

/* ================================================================ storybook */
.story-overlay { background: radial-gradient(ellipse at 50% 40%, #1a1d33, #05060a 75%); }
.storybook { width: min(1100px, 94%); display: grid; grid-template-columns: 1fr 1fr; gap: 0; filter: drop-shadow(0 16px 40px #000); }
.storybook .page { min-height: 560px; display: flex; flex-direction: column; }
.storybook .page.art { align-items: center; justify-content: center; gap: 14px; background-clip: padding-box; }
.storybook .page.text { font-size: 24px; line-height: 1.55; }
.storybook .page.text h2 { font-size: 40px; margin: 6px 0 10px; color: #8b1e3f; }
.storybook .page.text p { margin: 0 0 12px; max-width: 46ch; }
.storybook .page-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.storybook .page-num { font: 22px var(--pixel); color: #8b5a1a; }
.scene { position: relative; width: 420px; height: 320px; background: #0b0d16; border: 4px solid #000; overflow: hidden; image-rendering: pixelated; }
.scene img { position: absolute; image-rendering: pixelated; }
.scene .caption { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font: 22px var(--pixel); color: #ffe9b0; text-shadow: 2px 2px 0 #000; }
.role-cards { display: grid; gap: 10px; width: 100%; }
.role-card { display: flex; gap: 12px; align-items: center; font-size: 20px; line-height: 1.35; }
.role-card img { width: 64px; height: 64px; image-rendering: pixelated; flex: none; }
.role-card b { font: 28px var(--pixel); font-weight: normal; color: #8b1e3f; }
.twinkle { animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.3; } }

/* ================================================================ tutor panel (plain, grown-up) */
.tutor-overlay { background: rgba(0, 0, 0, 0.55); }
.tutor-panel { width: 420px; background: #f7f7f7; color: #111; font-family: system-ui, sans-serif; border-radius: 6px; padding: 18px; border: 1px solid #999; box-shadow: 0 6px 30px #000a; }
.tutor-panel h2 { margin: 0 0 4px; font: 600 18px system-ui, sans-serif; }
.tutor-panel p { margin: 0 0 12px; font-size: 14px; color: #444; }
.tutor-panel button { display: block; width: 100%; margin: 6px 0; padding: 10px; font-size: 16px; font-family: system-ui, sans-serif; text-align: left; border: 1px solid #aaa; background: #fff; border-radius: 4px; }
.tutor-panel button:hover { background: #eef3ff; }
.tutor-panel button.confirm { background: #ffe9e4; border-color: #c0623f; }
.tutor-panel .meta { font-size: 13px; color: #666; margin-top: 10px; }

/* ================================================================ report (plain, printable) */
.report-overlay { background: rgba(0, 0, 0, 0.6); }
.report { width: min(1180px, 96%); height: 94%; overflow: auto; background: #fff; color: #111; font-family: system-ui, sans-serif; border-radius: 6px; padding: 18px 22px; font-size: 14px; line-height: 1.4; }
.report h1 { font: 600 22px system-ui, sans-serif; margin: 0 0 4px; }
.report h2 { font: 600 17px system-ui, sans-serif; margin: 16px 0 6px; border-bottom: 1px solid #ccc; }
.report .actions { display: flex; gap: 8px; margin: 8px 0; position: sticky; top: -18px; background: #fff; padding: 6px 0; }
.report .actions button { padding: 6px 12px; font-size: 14px; border: 1px solid #999; background: #f4f4f4; border-radius: 4px; font-family: system-ui, sans-serif; }
.report table { border-collapse: collapse; width: 100%; font-size: 13px; }
.report th, .report td { border: 1px solid #ccc; padding: 4px 6px; vertical-align: top; text-align: left; }
.report th { background: #f0f0f0; }
.report .summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 20px; }
.report ul { margin: 4px 0; }
.report .ok { color: #176b37; font-weight: 600; }
.report .bad { color: #a12a12; font-weight: 600; }

/* ================================================================ title */
.title-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #f3ead2; text-align: center; }
.title-screen h1 { font-size: 92px; margin: 0; color: #ffd54a; text-shadow: 4px 4px 0 #7a1f12, 0 0 30px #c9a24a88; }
.title-sub { font-size: 23px; margin: 0; max-width: 780px; }
.title-players { display: flex; gap: 30px; margin: 6px 0; }
.title-player { border: 18px solid transparent; border-image: url('assets/ui/frame-wood.png') 8 fill / 18px stretch; image-rendering: pixelated; padding: 2px 8px; }
.title-player h3 { margin: 0 0 8px; font-size: 24px; }
.title-player.p1 h3 { color: var(--p1); }
.title-player.p2 h3 { color: var(--p2); }
.name-input { font-size: 22px; padding: 8px 10px; border: 3px solid #2a1a0c; width: 240px; font-family: var(--font); text-align: center; background: #fff6dc; }
.char-row { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.char-pick { background: #2a2216; border: 3px solid #000; padding: 4px; }
.char-pick img { width: 64px; height: 64px; image-rendering: pixelated; display: block; }
.char-pick.on { border-color: #ffd54a; background: #5a4520; box-shadow: 0 0 10px #ffd54a; }
.title-buttons { display: flex; gap: 14px; }
.title-note { font-size: 17px; opacity: 0.8; margin: 0; min-height: 1em; }

/* ================================================================ print: only the report */
#print-root { display: none; }
@media print {
  body { overflow: visible; background: #fff; }
  #stage { display: none; }
  #print-root { display: block; color: #000; font-family: system-ui, sans-serif; font-size: 11pt; }
  #print-root table { border-collapse: collapse; width: 100%; font-size: 9pt; }
  #print-root th, #print-root td { border: 1px solid #999; padding: 3px; vertical-align: top; text-align: left; }
  #print-root .actions { display: none; }
}
.panel.parchment .answer-help, .frame.parchment .answer-help { color: var(--ink-soft); }

/* ================================================================ between the locks */
.hud-stars { font: 22px var(--pixel); color: #ffd54a; text-shadow: 2px 2px 0 #2a1a0c; }
.map-panel {
  position: absolute; top: 70px; width: calc(50% - 24px); pointer-events: none; text-align: center; color: var(--ink);
  border: 18px solid transparent; border-image: url('assets/ui/frame-ornate.png') 10 fill / 18px stretch; image-rendering: pixelated;
}
.map-panel.p1 { left: 12px; }
.map-panel.p2 { left: calc(50% + 12px); }
.map-panel canvas { width: 100%; image-rendering: pixelated; border: 3px solid #2a1a0c; }
.map-title { font: 26px var(--pixel); color: #8b1e3f; margin-bottom: 4px; }
.map-legend { font-size: 17px; margin-top: 4px; display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }
.map-legend .dot { display: inline-block; width: 12px; height: 12px; border: 2px solid #2a1a0c; }
.dot.partner { background: #ff7fc4; }
.dot.mino { background: #d23c27; }
.dot.goal { background: #ffd54a; }
.dot.exit { background: #5cc46b; }
.map-tip { font-size: 18px; font-weight: 700; margin-top: 4px; }
.pedestal-overlay { background: rgba(6, 7, 14, 0.6); }
.pedestal-panel { width: min(900px, 92%); font-size: 22px; line-height: 1.45; }
.pedestal-panel .question { font-size: 26px; margin: 10px 0; }
.choice.right { filter: drop-shadow(0 0 8px #5cc46b); }
.choice.picked { filter: drop-shadow(0 0 8px #d23c27); }
.choice.faded { opacity: 0.45; }
.finale-hint { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; max-width: 760px; }
.finale-hint .pbtn { align-self: flex-start; font-size: 20px; }

/* word help */
.gloss { border-bottom: 3px dotted #2f6fbf; cursor: help; position: relative; }
.his .gloss, .frame.wood .gloss { border-bottom-color: #ffd54a; }
.gloss:hover::after, .gloss.open::after {
  content: attr(data-def); position: absolute; left: 0; top: calc(100% + 6px); z-index: 50; width: max-content; max-width: 340px;
  font: 700 18px/1.35 var(--font); color: #1b2230; background: #e6eefb; border: 3px solid #2f6fbf; padding: 8px 10px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.35); white-space: normal; text-align: left; text-transform: none; letter-spacing: 0;
}
.gloss.open::after { background: #fff3a6; border-color: #b8860b; }
.map-overlay .museum-map { width: min(1200px, 96%); text-align: center; }
.museum-map h2 { margin: 2px 0 8px; font-size: 34px; }
.museum-map canvas { width: 100%; image-rendering: pixelated; border: 4px solid #2a1a0c; background: #05060a; }
.museum-map .hint { font-size: 17px; margin: 6px 0 0; }
