:root {
  --bg: #18191b; --surface: #222427; --surface-2: #2b2d31; --line: #34373c;
  --ink: #eff0f1; --muted: #a4a8ae; --accent: #ff4a1f; --accent-ink: #fff;
  --good: #3fcf8e; --bad: #ff5d5d; --gold: #ffd23f;
  --r: 10px; --r-sm: 6px;
  --display: 'Archivo', system-ui, sans-serif; --mono: 'Martian Mono', ui-monospace, monospace;
}
* { box-sizing: border-box }
html, body { height: 100% }
body { margin: 0; background: #0e0f10; color: var(--ink); font-family: var(--display); -webkit-font-smoothing: antialiased }
button { font: inherit; color: inherit }
.mono { font-family: var(--mono) }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0) }

.app { position: relative; max-width: 440px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; background: var(--bg) }
@media (min-width: 600px) {
  body { display: flex; align-items: center; justify-content: center }
  .app { width: 440px; height: min(100dvh - 32px, 900px); border-radius: 24px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0, 0, 0, .5) }
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; font-size: 11px; color: var(--muted); flex: none; padding-top: max(6px, env(safe-area-inset-top)) }
.topbar b { color: var(--ink); font-weight: 500 }
.brand { background: none; border: 0; padding: 0 10px; min-height: 44px; font-family: var(--mono); font-size: 11px; color: var(--muted); cursor: pointer; border-radius: var(--r-sm); text-align: left }
.brand:hover { background: var(--surface) }
.tag { font-family: var(--mono); font-size: 10px; color: var(--gold); border: 1px solid #5a4b17; padding: 2px 6px; border-radius: 999px; margin-right: 4px }

.scene-wrap { flex: none; width: 100%; height: min(calc(min(100vw, 440px) * 0.75), 36dvh); background: #111315; overflow: hidden }
.scene-wrap svg { width: 100%; height: 100%; display: block }
.bob { animation: bob 1.2s steps(2) infinite }
@keyframes bob { 50% { transform: translateY(-1px) } }

.view { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; padding-bottom: max(16px, env(safe-area-inset-bottom)); animation: enter .45s cubic-bezier(.2, .7, .2, 1) both }
.spacer { flex: 1; min-height: 4px }
@keyframes enter { from { opacity: 0; transform: translateY(8px) } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r) }
.btn { display: flex; align-items: center; justify-content: center; min-height: 52px; width: 100%; border-radius: var(--r); background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 16px; border: 0; cursor: pointer; box-shadow: 0 3px 0 #b02d0c; transition: transform .12s, box-shadow .12s; flex: none }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 #b02d0c }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 #b02d0c }
.btn.ghost { background: var(--surface-2); color: var(--ink); box-shadow: 0 3px 0 #0b0b0c; min-height: 46px; font-weight: 500; font-size: 15px }
.btn.ghost:active { box-shadow: none }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px }

/* home */
.title { font-size: 32px; line-height: 1; font-weight: 500; font-stretch: 118%; letter-spacing: -.035em; margin: 2px 0 0 }
.title span { color: var(--accent) }
.genre { color: var(--muted); font-size: 15px; margin: 6px 0 0; line-height: 1.4 }
.fact { font-size: 11px; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; align-self: flex-start }
.steps { margin: 0; padding: 10px 12px 10px 32px; font-size: 14px; line-height: 1.45 }
.steps li::marker { font-family: var(--mono); color: var(--accent); font-size: 12px }
.stats { display: flex; gap: 8px }
.stat { flex: 1; padding: 8px 12px }
.stat small { display: block; font-size: 10px; color: var(--muted) }
.stat strong { font-size: 20px; font-weight: 500 }
.note { padding: 12px 14px; font-size: 14px; line-height: 1.45; color: var(--muted) }

/* game */
.ask { font-size: 11px; color: var(--muted) }
.pips { display: flex; gap: 6px }
.pip { flex: 1; min-height: 44px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); padding: 0 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0 }
.pip.used { color: var(--ink); display: block; line-height: 42px; text-align: center }
.pip.now { border-color: var(--accent); color: var(--accent) }
.pip.locked { border-style: dashed; opacity: .6 }
.clue { padding: 18px 12px; text-align: center }
.clue small { display: block; font-size: 10px; color: var(--muted); margin-bottom: 8px }
.clue div { font-size: 34px; font-weight: 600; font-stretch: 118%; letter-spacing: -.02em; line-height: 1.05; overflow-wrap: anywhere }
.miss { font-size: 14px; color: var(--muted) }
.miss s { color: var(--bad); text-decoration-thickness: 2px }
.timer { display: flex; align-items: center; gap: 10px }
.timer .mono { font-size: 13px; width: 40px; color: var(--gold) }
.bar { flex: 1; display: flex; gap: 2px; height: 12px }
.bar i { flex: 1; background: var(--surface-2); border-radius: 1px }
.bar i.on { background: var(--gold) }
.bar.low i.on { background: var(--accent) }
.stake { font-size: 13px; color: var(--muted); text-align: right; margin-top: -4px; min-height: 18px }
.stake b { color: var(--ink); font-weight: 500 }
.input { display: flex; gap: 8px }
.field { flex: 1; min-height: 52px; display: flex; align-items: center; padding: 0 14px }
.field:focus-within { border-color: var(--accent) }
.field input { width: 100%; background: transparent; border: 0; outline: none; color: var(--ink); font: inherit; font-size: 17px; padding: 14px 0 }
.field input::placeholder { color: #6f747b }
.go { width: 92px }
.shake { animation: shake .35s }
@keyframes shake { 20%, 60% { transform: translateX(-5px) } 40%, 80% { transform: translateX(5px) } }

/* between categories */
.solved, .missed { padding: 18px 16px; text-align: center }
.solved { border-color: #2f6b4f; background: #1d2a24 }
.missed { border-color: #6b2f2f; background: #2a1d1d }
.solved small { color: var(--good); font-size: 10px }
.missed small { color: var(--bad); font-size: 10px }
.solved h2, .missed h2 { margin: 8px 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1 }
.solved p, .missed p { margin: 0; color: var(--muted); font-size: 14px }
.solved p b { color: var(--ink); font-weight: 500 }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center }
.chip { font-family: var(--mono); font-size: 11px; padding: 7px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line) }
.chip.hit { border-color: var(--good); color: var(--good) }

/* results */
.result { text-align: center }
.result small { font-size: 11px; color: var(--good) }
.result small.short { color: var(--gold) }
.result .score { font-size: 56px; font-weight: 600; font-stretch: 115%; letter-spacing: -.04em; line-height: 1; margin-top: 4px }
.result .score span { font-size: 18px; color: var(--muted); font-weight: 400 }
.answers { padding: 4px 12px; font-size: 14px }
.answers div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line) }
.answers div:last-child { border: none }
.answers em { font-style: normal; font-size: 10px; color: var(--muted); white-space: nowrap }
.split { display: flex; gap: 8px }
.share { flex: 1; padding: 10px; font-size: 11px; text-align: center; color: var(--muted); line-height: 1.5 }
.grid { font-family: system-ui, sans-serif; font-size: 22px; line-height: 1.1; margin-top: 4px; white-space: pre; color: var(--ink) }
.side { display: flex; flex-direction: column; gap: 8px; width: 136px; flex: none }
.next { padding: 10px; text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center }
.next small { display: block; font-size: 10px; color: var(--muted) }
.next strong { font-size: 14px; font-weight: 500 }
.row2 { display: flex; gap: 8px }

/* archive */
.alist { display: flex; flex-direction: column; gap: 8px }
.arow { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 14px; cursor: pointer; text-align: left; font-size: 15px; transition: transform .12s, border-color .12s }
.arow:hover { transform: translateY(-2px); border-color: #4a4e55 }
.arow b { font-weight: 600 }
.arow .mono { font-size: 12px; color: var(--muted) }
.arch { color: var(--gold) }

.toast { position: absolute; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s }
.toast.show { opacity: 1; transform: translate(-50%, 0) }

@media (prefers-reduced-motion: reduce) {
  .bob, .view, .shake { animation: none }
  .btn, .arow, .toast { transition: none }
}
