:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #6b6b6b;
  --line: #d9d9d9;
  --accent: #ff5a3c;
  --hand: 'Gaegu', 'Gowun Dodum', cursive;
  --body: 'Gowun Dodum', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; max-width: 960px; margin: 0 auto; }
.home-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.icon-btn { border: 0; background: none; font-size: 24px; padding: 4px 8px; }
.main { max-width: 960px; margin: 0 auto; padding: 0 16px 40px; text-align: center; }
h1 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: clamp(40px, 8vw, 72px); line-height: 1; }
.level { margin: 8px 0 0; font-family: var(--hand); font-size: clamp(22px, 4vw, 30px); }

.scene { margin: 8px auto 0; max-width: 900px; }
.scene svg { width: 100%; height: auto; display: block; overflow: visible; }
.ink { stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ties { fill: none; stroke: #8a7a66; stroke-width: 28; stroke-dasharray: 4 14; }
.rail-a { fill: none; stroke: var(--ink); stroke-width: 18; }
.rail-b { fill: none; stroke: #fff; stroke-width: 13; }
.track:not(.active) .rail-a { stroke: #9a9a9a; }
.track.active .rail-a { stroke: var(--ink); }
.tram-text { font-family: var(--hand); font-size: 15px; font-weight: 700; fill: var(--ink); stroke: none; }
.you-label { font-family: var(--hand); font-size: 20px; font-weight: 700; fill: var(--accent); stroke: none; }
.emoji { font-size: 34px; stroke: none; dominant-baseline: auto; }
.track-label { font-family: var(--hand); font-size: 28px; font-weight: 700; fill: var(--ink); stroke: #fff; stroke-width: 5px; paint-order: stroke; }
.target { transition: none; }
.target > .wobble { animation: wobble 0.9s ease-in-out infinite alternate; transform-origin: 0 10px; transform-box: fill-box; }
@keyframes wobble { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.target.hit > .wobble { animation: fly .8s ease-out forwards; }
@keyframes fly { to { transform: translate(60px, -140px) rotate(540deg); opacity: 0; } }
.bonk { font-family: var(--hand); font-weight: 700; font-size: 28px; fill: var(--accent); animation: bonk .9s ease-out forwards; }
@keyframes bonk { to { transform: translateY(-30px); opacity: 0; } }

.text { font-family: var(--hand); font-size: clamp(22px, 3.6vw, 32px); line-height: 1.35; margin: 12px auto 22px; max-width: 820px; text-align: left; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 820px; margin: 0 auto; }
.choices[hidden], .after[hidden], .result[hidden] { display: none; }
.choice { border: 2.5px solid var(--ink); background: #fff; border-radius: 14px; padding: 16px 10px; font-family: var(--hand); font-size: clamp(22px, 3.4vw, 30px); font-weight: 700; box-shadow: 4px 4px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.choice:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.choice:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
#btn-pull { background: #fff4e8; }
.after { max-width: 820px; margin: 0 auto; }
.outcome { font-family: var(--hand); font-size: clamp(22px, 3.4vw, 30px); line-height: 1.35; background: #fafafa; border: 2px dashed var(--line); border-radius: 14px; padding: 14px 18px; text-align: left; margin: 0 0 16px; }
.next { border: 0; background: var(--ink); color: #fff; border-radius: 14px; padding: 14px 24px; font-family: var(--hand); font-size: 26px; font-weight: 700; }
.next.ghost { background: #fff; color: var(--ink); border: 2.5px solid var(--ink); }
.choice:focus-visible, .next:focus-visible, .icon-btn:focus-visible { outline: 3px solid #3b6fe0; outline-offset: 3px; }

.result { max-width: 640px; margin: 24px auto 0; }
.eyebrow { font-family: var(--hand); font-size: 24px; margin: 0; color: var(--muted); }
.result h2 { font-family: var(--hand); font-size: clamp(42px, 8vw, 64px); margin: 4px 0 8px; line-height: 1.1; }
#verdict-text { font-size: 18px; line-height: 1.6; }
.pulls { font-family: var(--hand); font-size: 24px; }
.history { text-align: left; padding: 0; list-style: none; display: grid; gap: 6px; margin: 16px 0 24px; counter-reset: h; }
.history li { counter-increment: h; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding: 6px 4px; font-size: 16px; }
.history li span::before { content: counter(h) '. '; color: var(--muted); }
.history b.pull { color: var(--accent); }
.history b.stay { color: var(--muted); }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
footer { margin-top: 48px; font-size: 13px; font-weight: 700; color: var(--muted); }

@media (max-width: 640px) {
  .choices { grid-template-columns: 1fr; gap: 10px; }
  .choice { padding: 12px 10px; }
  .scene { margin-left: -16px; margin-right: -16px; }
}
@media (prefers-reduced-motion: reduce) { .target > .wobble { animation: none; } }
