@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');
:root {
  --ink: #100d19;
  --ink-soft: #171326;
  --ink-card: rgba(34, 28, 55, .82);
  --paper: #fff7e8;
  --paper-muted: #d8cbb7;
  --amber: #f2b35b;
  --amber-dark: #a9672f;
  --violet: #30264f;
  --violet-light: #7666a4;
  --mint: #9ee1c1;
  --plum: #d9a4d5;
  --line: rgba(255, 247, 232, .14);
  --shadow: 0 20px 70px rgba(0, 0, 0, .32);
  --serif: Fraunces, Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 18% 12%, rgba(118, 102, 164, .23), transparent 29rem),
    radial-gradient(circle at 85% 84%, rgba(242, 179, 91, .12), transparent 25rem),
    linear-gradient(125deg, #0e0b17 0%, #171127 48%, #100d19 100%);
  font-family: var(--sans);
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: screen;
  z-index: 4;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.night-window { position: fixed; inset: 0; pointer-events: none; overflow: hidden; opacity: .28; }
.night-window::before, .night-window::after {
  content: '';
  position: absolute;
  top: 16%;
  width: 1px;
  height: 68%;
  background: linear-gradient(transparent, rgba(242, 179, 91, .24), transparent);
}
.night-window::before { left: 7%; }
.night-window::after { right: 7%; }
.night-window span { position: absolute; height: 1px; width: 70vw; background: rgba(242, 179, 91, .16); transform: rotate(-13deg); filter: blur(.3px); }
.night-window span:nth-child(1) { top: 24%; left: -10%; animation: train-light 12s ease-in-out infinite; }
.night-window span:nth-child(2) { top: 61%; right: -20%; animation: train-light 17s ease-in-out infinite reverse; }
.night-window span:nth-child(3) { top: 80%; left: -12%; opacity: .4; animation: train-light 20s ease-in-out infinite; }
@keyframes train-light { 0%, 100% { opacity: 0; transform: translateX(-10%) rotate(-13deg); } 45%, 60% { opacity: 1; } 80% { opacity: 0; transform: translateX(22%) rotate(-13deg); } }

.app-shell { position: relative; z-index: 1; width: min(100%, 760px); margin: 0 auto; padding: 20px 18px 52px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--paper); text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--amber); border-radius: 9px 9px 12px 12px; color: var(--amber); font-size: 19px; box-shadow: inset 0 -5px 0 rgba(242, 179, 91, .08); }
.logo-text { font: 700 18px/1 var(--serif); letter-spacing: -.02em; }
.logo-sub { display: block; margin-top: 4px; color: var(--paper-muted); font: 10px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.language-toggle { display: inline-flex; gap: 3px; padding: 4px; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 999px; }
.lang-btn { border: 0; border-radius: 999px; background: transparent; color: var(--paper-muted); padding: 6px 9px; font: 500 11px var(--mono); letter-spacing: .08em; }
.lang-btn.is-active { background: var(--amber); color: var(--ink); }

.hero { padding: 26px 0 20px; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--amber); font: 500 11px var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.eyebrow::before { content: ''; width: 28px; height: 1px; background: var(--amber); }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 650px; margin: 13px 0 14px; font: 700 clamp(42px, 12vw, 76px)/.93 var(--serif); letter-spacing: -.055em; }
h2 { margin: 0 0 12px; font: 700 clamp(29px, 8vw, 50px)/.98 var(--serif); letter-spacing: -.045em; }
h3 { margin: 0 0 7px; font: 600 18px/1.1 var(--serif); }
.lede { max-width: 620px; margin-bottom: 0; color: var(--paper-muted); font-size: 16px; line-height: 1.55; }
.hero-stamp { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid rgba(242,179,91,.35); color: var(--amber); font: 500 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; transform: rotate(-2deg); }
.hero-stamp::before { content: '✦'; font-size: 14px; }

.form-card { position: relative; overflow: hidden; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(140deg, rgba(49, 38, 79, .91), rgba(23, 18, 38, .92)); box-shadow: var(--shadow); }
.form-card::after { content: '13'; position: absolute; right: -2px; bottom: 14px; color: rgba(242,179,91,.17); font: 500 10px var(--mono); letter-spacing: .1em; transform: rotate(-90deg); }
.form-intro { margin-bottom: 20px; color: var(--paper-muted); font-size: 14px; line-height: 1.55; }
.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--paper-muted); font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.field input { width: 100%; border: 1px solid rgba(255,247,232,.2); border-radius: 11px; padding: 13px 14px; color: var(--paper); background: rgba(9,7,15,.42); transition: border-color .2s, background .2s; }
.field input::placeholder { color: rgba(216,203,183,.5); }
.field input:focus { border-color: var(--amber); background: rgba(9,7,15,.65); outline: none; }
.primary-btn, .secondary-btn, .choice-btn, .continue-btn { border: 0; border-radius: 12px; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.primary-btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; margin-top: 5px; padding: 15px 18px; color: var(--ink); background: var(--amber); font-weight: 700; box-shadow: 0 9px 24px rgba(242,179,91,.18); }
.primary-btn:hover, .continue-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(242,179,91,.24); }
.form-note { margin: 13px 0 0; color: rgba(216,203,183,.65); font-size: 11px; line-height: 1.4; }
.form-note::before { content: '⌁ '; color: var(--amber); }

.game-top { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.game-top .topbar { margin-bottom: 16px; }
.progress-wrap { display: grid; gap: 9px; }
.progress-meta { display: flex; align-items: end; justify-content: space-between; gap: 12px; color: var(--paper-muted); font: 500 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.progress-meta strong { color: var(--amber); font-weight: 500; }
.progress-dots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.progress-dot { position: relative; height: 7px; border-radius: 999px; background: rgba(255,247,232,.13); overflow: hidden; }
.progress-dot::after { content: ''; position: absolute; inset: 0; background: var(--amber); transform: scaleX(0); transform-origin: left; transition: transform .35s ease; }
.progress-dot.is-done::after { transform: scaleX(1); }

.chapter-card { position: relative; margin-top: 22px; padding: 23px 0 0; }
.chapter-kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--amber); font: 500 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.chapter-kicker::before { content: '▸'; color: var(--plum); }
.chapter-copy { max-width: 670px; color: var(--paper-muted); font-size: 16px; line-height: 1.62; }
.chapter-copy em { color: var(--paper); font-style: normal; }
.personal-note { color: var(--paper); }
.personal-note strong { color: var(--amber); }
.evidence-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 11px; color: var(--paper-muted); font: 500 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.evidence-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.clue-list { display: grid; gap: 10px; }
.clue-btn { position: relative; width: 100%; padding: 15px 44px 15px 15px; border: 1px solid rgba(255,247,232,.15); border-radius: 13px; color: var(--paper); text-align: left; background: rgba(41,34,69,.72); }
.clue-btn::after { content: '＋'; position: absolute; top: 50%; right: 15px; color: var(--amber); font-size: 20px; transform: translateY(-50%); transition: transform .18s; }
.clue-btn:hover { border-color: rgba(242,179,91,.55); background: rgba(51,42,82,.9); }
.clue-btn.is-open { border-color: rgba(242,179,91,.45); background: rgba(66,49,78,.82); }
.clue-btn.is-open::after { content: '−'; transform: translateY(-50%) rotate(180deg); }
.clue-title { display: block; font: 600 16px/1.2 var(--serif); }
.clue-body { display: none; margin: 9px 0 0; padding-top: 9px; border-top: 1px dashed rgba(255,247,232,.2); color: var(--paper-muted); font-size: 13px; line-height: 1.55; }
.clue-btn.is-open .clue-body { display: block; }

.choice-list { display: grid; gap: 10px; }
.choice-btn { width: 100%; padding: 14px 15px; border: 1px solid rgba(217,164,213,.3); color: var(--paper); text-align: left; background: rgba(87,59,91,.2); }
.choice-btn:hover { border-color: var(--plum); background: rgba(87,59,91,.43); transform: translateX(3px); }
.choice-btn.is-selected { border-color: var(--amber); background: rgba(242,179,91,.13); box-shadow: inset 4px 0 var(--amber); }
.choice-btn strong { display: block; margin-bottom: 4px; font: 600 16px/1.2 var(--serif); }
.choice-btn span { display: block; color: var(--paper-muted); font-size: 12px; line-height: 1.45; }

.mini-card { margin-top: 18px; padding: 16px; border-left: 2px solid var(--amber); border-radius: 0 12px 12px 0; background: rgba(242,179,91,.09); }
.mini-card p { margin: 0; color: var(--paper-muted); font-size: 13px; line-height: 1.55; }
.mini-card strong { color: var(--paper); }
.hint { margin: 12px 0 0; color: var(--plum); font-size: 12px; line-height: 1.45; }
.hint button { border: 0; padding: 0; color: var(--plum); background: none; text-decoration: underline; text-underline-offset: 3px; }
.feedback { min-height: 20px; margin: 12px 0 0; color: var(--mint); font-size: 13px; line-height: 1.45; }
.feedback.is-wrong { color: var(--plum); }

.code-panel { margin-top: 16px; padding: 17px; border: 1px solid rgba(242,179,91,.22); border-radius: 14px; background: rgba(10,8,17,.28); }
.code-display { display: flex; justify-content: center; gap: 9px; margin-bottom: 15px; }
.code-slot { display: grid; place-items: center; width: 45px; height: 52px; border-bottom: 2px solid var(--amber); color: var(--amber); font: 500 25px var(--mono); }
.digit-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.digit-btn { min-height: 42px; border: 1px solid var(--line); border-radius: 9px; color: var(--paper); background: rgba(255,255,255,.05); }
.digit-btn:hover { border-color: var(--amber); color: var(--amber); }
.digit-btn.clear { color: var(--paper-muted); }

.sort-panel { display: grid; gap: 9px; margin-top: 16px; }
.sort-instruction { color: var(--paper-muted); font-size: 12px; line-height: 1.45; }
.sort-list { display: grid; gap: 8px; }
.sort-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--paper); text-align: left; background: rgba(255,255,255,.05); }
.sort-item::before { content: '⠿'; color: var(--amber); font-size: 18px; }
.sort-item.is-selected { border-color: var(--amber); background: rgba(242,179,91,.13); transform: translateX(5px); }
.sort-number { margin-left: auto; color: var(--paper-muted); font: 11px var(--mono); }

.hidden-scene { position: relative; min-height: 235px; margin-top: 16px; overflow: hidden; border: 1px solid rgba(242,179,91,.22); border-radius: 15px; background: linear-gradient(160deg, #28203d 0%, #120e1d 72%); }
.hidden-scene::before { content: ''; position: absolute; left: 10%; right: 10%; bottom: 22px; height: 4px; border-radius: 50%; background: rgba(242,179,91,.2); box-shadow: 0 -38px 0 rgba(242,179,91,.04), 0 -76px 0 rgba(242,179,91,.03); }
.scene-window { position: absolute; top: 26px; left: 50%; width: 124px; height: 91px; border: 7px solid #4e3a53; border-radius: 15px 15px 6px 6px; background: radial-gradient(circle at 60% 25%, rgba(255,205,125,.45), transparent 7%), linear-gradient(160deg, #16172d, #3b2a5c); transform: translateX(-50%); box-shadow: 0 0 28px rgba(242,179,91,.11); }
.scene-seat { position: absolute; left: 13%; bottom: 25px; width: 74%; height: 63px; border: 2px solid #583d58; border-radius: 10px 10px 4px 4px; background: #3d293f; box-shadow: inset 0 11px 0 rgba(255,247,232,.04); }
.hotspot { position: absolute; z-index: 2; width: 42px; height: 42px; border: 1px dashed var(--amber); border-radius: 50%; color: var(--amber); background: rgba(242,179,91,.11); font-size: 18px; animation: pulse 2s ease-in-out infinite; }
.hotspot:hover { background: rgba(242,179,91,.28); transform: scale(1.08); }
.hotspot.is-found { border-style: solid; color: var(--mint); border-color: var(--mint); background: rgba(158,225,193,.14); animation: none; }
.hotspot.moth { top: 42px; left: 21%; }
.hotspot.key { right: 17%; bottom: 40px; }
.hotspot.photo { top: 135px; left: 53%; }
.scene-caption { position: absolute; right: 12px; bottom: 10px; color: rgba(255,247,232,.46); font: 9px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,179,91,.16); } 50% { box-shadow: 0 0 0 8px rgba(242,179,91,0); } }

.continue-wrap { display: grid; gap: 10px; margin: 30px 0 0; }
.continue-btn { width: 100%; padding: 16px 18px; color: var(--ink); background: var(--amber); font-weight: 700; }
.continue-btn[disabled] { cursor: not-allowed; opacity: .36; transform: none; box-shadow: none; }
.secondary-btn { padding: 12px 16px; border: 1px solid var(--line); color: var(--paper-muted); background: transparent; }
.secondary-btn:hover { border-color: var(--paper-muted); color: var(--paper); }
.end-note { padding: 15px; border: 1px solid rgba(158,225,193,.25); border-radius: 12px; color: var(--mint); background: rgba(158,225,193,.08); font-size: 13px; line-height: 1.55; }
.solution { margin-top: 18px; padding: 22px; border: 1px solid rgba(242,179,91,.38); border-radius: 15px; background: linear-gradient(150deg, rgba(76,53,70,.86), rgba(33,26,50,.88)); box-shadow: var(--shadow); }
.solution h3 { color: var(--amber); font-size: 24px; }
.solution p { color: var(--paper-muted); font-size: 14px; line-height: 1.63; }
.recap { display: grid; gap: 8px; margin-top: 15px; }
.recap-line { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; color: var(--paper-muted); font-size: 12px; line-height: 1.45; }
.recap-line::before { content: '✓'; color: var(--mint); font: 500 13px var(--mono); }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); color: rgba(216,203,183,.58); font: 10px var(--mono); letter-spacing: .05em; }

@media (min-width: 620px) {
  .app-shell { padding: 32px 32px 70px; }
  .topbar { margin-bottom: 33px; }
  .hero { padding-top: 32px; padding-bottom: 29px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field:nth-child(3), .field:nth-child(4), .primary-btn, .form-note { grid-column: 1 / -1; }
  .form-card { padding: 27px; }
  .clue-list, .choice-list { grid-template-columns: repeat(2, 1fr); }
  .choice-btn:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
