/* Inter (SIL OFL, assets/fonts/OFL-Inter.txt). cyrillic-ext carries ө ү. */
@font-face { font-family: Inter; font-style: normal; font-display: swap; font-weight: 100 900; src: url(assets/fonts/inter-cyrillic-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Inter; font-style: normal; font-display: swap; font-weight: 100 900; src: url(assets/fonts/inter-cyrillic-wght-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; font-style: normal; font-display: swap; font-weight: 100 900; src: url(assets/fonts/inter-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --night: #0b1f3a; --night2: #16396a; --lane: #ffd23f; --go: #16a36a; --stop: #e5484d; --blue: #2f6fe4;
  --ink: #eef3fb; --ink2: #b9c6da; --ink3: #8495b0;
  --panel: rgba(11, 31, 58, 0.92); --line: rgba(160, 190, 240, 0.22);
  --font: Inter, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05080f; color: var(--ink); font-family: var(--font); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
  word-break: keep-all; overflow-wrap: break-word; }   /* Korean terms in (...) wrap at spaces, not mid-word */
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font-family: inherit; }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 10px) 12px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; pointer-events: none; z-index: 5; }
.hud-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 5px 10px; border-radius: 999px; background: rgba(47, 111, 228, .9); color: #fff; white-space: nowrap; box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.badge.test { background: rgba(229, 72, 77, .92); }
.step { font-size: 13px; font-weight: 600; color: var(--ink); text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: nowrap; }
.dots { display: flex; gap: 5px; }
.dots i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.22); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); transition: background .25s, transform .25s; }
.dots i.on { background: var(--go); }
.dots i.cur { background: var(--lane); transform: scaleY(1.35); }
.score { display: flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 12px; background: rgba(5, 10, 20, .72); border: 1px solid var(--line); }
.score-k { font-size: 11px; color: var(--ink2); font-weight: 600; }
.score-v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: right; transition: color .2s; }
.score-v.hit { color: var(--stop); animation: hit .5s ease; }
@keyframes hit { 30% { transform: scale(1.35); } }
.icon-btn { pointer-events: auto; width: 44px; min-width: 44px; flex: none; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(5,10,20,.72); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(22,57,106,.85); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible { outline: 2px solid var(--lane); outline-offset: 2px; }
.icon-btn.muted #soundWaves { opacity: .15; }

a.icon-btn { text-decoration: none; }
.hub-btn { width: 34px; height: 34px; flex: none; }
.back-link { display: inline-block; margin: -4px 0 10px; font-size: 13px; font-weight: 700; color: var(--ink2); text-decoration: none; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.back-link:hover { color: var(--ink); background: rgba(255,255,255,.1); }
.back-link:focus-visible { outline: 2px solid var(--lane); outline-offset: 2px; }
a.btn { text-decoration: none; }
.res-btns a.btn { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- guide card */
.guide { position: fixed; left: 50%; top: calc(var(--safe-t) + 58px); transform: translateX(-50%); width: min(94vw, 600px); display: flex; align-items: center; gap: 12px;
  padding: 10px 16px 10px 10px; border-radius: 16px; background: linear-gradient(180deg, rgba(16, 42, 80, .95), rgba(8, 24, 48, .95)); border: 1px solid rgba(255, 210, 63, .55);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08); pointer-events: none; z-index: 4; font-size: 15px; font-weight: 600; line-height: 1.3; min-height: 54px; }
.guide.test { border-color: var(--line); color: var(--ink2); font-weight: 500; }
.guide-num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--lane); color: #1a1400; font-weight: 800; font-size: 15px; }
.guide.test .guide-num { background: rgba(255,255,255,.12); color: var(--ink2); }
.guide.swap { animation: swap .35s ease; }
@keyframes swap { from { opacity: .2; transform: translateX(-50%) translateY(-6px); } }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; left: 50%; top: calc(var(--safe-t) + 190px); transform: translateX(-50%); width: min(92vw, 460px); display: flex; flex-direction: column; gap: 8px; pointer-events: none; z-index: 6; }
.toast { padding: 10px 14px; border-radius: 14px; background: rgba(8, 16, 30, .94); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: tin .28s cubic-bezier(.2,1.4,.4,1); }
.toast.out { animation: tout .35s ease forwards; }
.toast b { display: block; font-size: 15px; line-height: 1.3; }
.toast span { display: block; font-size: 13px; color: var(--ink2); margin-top: 3px; line-height: 1.35; }
.toast.bad { border-color: rgba(229,72,77,.8); background: linear-gradient(180deg, rgba(60, 14, 20, .96), rgba(30, 8, 12, .96)); }
.toast.bad b { color: #ffd0d1; }
.toast .pts { float: right; font-style: normal; margin-left: 10px; color: #fff; background: var(--stop); border-radius: 8px; padding: 1px 7px; font-size: 13px; font-weight: 800; }
.toast.ok { border-color: rgba(22,163,106,.7); padding: 8px 14px; }
.toast.ok b { font-size: 14px; color: #a9f0cb; }
.toast.info { border-color: rgba(47,111,228,.8); }
@keyframes tin { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes tout { to { opacity: 0; transform: translateY(-12px); } }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); z-index: 10;
  background: radial-gradient(120% 80% at 50% 0%, rgba(22,57,106,.55), rgba(5,8,15,.82) 70%); overflow-y: auto; }
#result { background: rgba(5, 8, 15, .55); }
.card { width: min(100%, 560px); border-radius: 24px; padding: 24px; background: linear-gradient(180deg, rgba(18, 46, 88, .97), rgba(9, 25, 50, .97));
  border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.1); animation: cardin .45s cubic-bezier(.2,1.2,.4,1); }
@keyframes cardin { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--lane); text-transform: uppercase; }
h1 { margin: 6px 0 4px; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
h2 { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--ink3); letter-spacing: .04em; text-transform: uppercase; }
.sub { margin: 0; color: var(--ink2); font-size: 15px; line-height: 1.4; }
.rule { margin-top: 16px; padding: 12px 14px 12px 44px; border-radius: 14px; background: rgba(229,72,77,.14); border: 1px solid rgba(229,72,77,.6); font-weight: 700; font-size: 15px; line-height: 1.35; position: relative; }
.rule::before { content: "!"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--stop); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 14px; }
.order { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; counter-reset: o; }
.order li { counter-increment: o; display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 1.3; color: var(--ink); }
.order li::before { content: counter(o); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,210,63,.14); color: var(--lane); font-weight: 800; font-size: 12px; border: 1px solid rgba(255,210,63,.45); }
.order li.opt { color: var(--ink2); }
.modes { display: grid; gap: 10px; margin-top: 20px; }
.btn { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 13px 18px; border-radius: 16px; cursor: pointer;
  font-size: 16px; font-weight: 700; color: var(--ink); border: 1px solid var(--line); background: rgba(255,255,255,.05); transition: transform .08s, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: rgba(255,255,255,.1); border-color: rgba(160,190,240,.45); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }
.btn-primary { background: linear-gradient(180deg, #3b7cf0, #2559c4); border-color: rgba(255,255,255,.25); box-shadow: 0 6px 18px rgba(47,111,228,.4), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-primary:hover { background: linear-gradient(180deg, #4a88f5, #2c63d4); }
.btn-t { font-size: 17px; }
.btn-d { font-size: 13px; font-weight: 500; color: rgba(238,243,251,.78); line-height: 1.35; }
.keys { margin: 16px 0 0; font-size: 12px; color: var(--ink3); line-height: 1.5; }
@media (pointer: coarse) { .keys { display: none; } }

/* result */
.result-card { width: min(100%, 520px); }
.res-head { display: flex; align-items: center; gap: 14px; }
.res-icon { flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 900; color: #fff; }
.pass .res-icon { background: var(--go); box-shadow: 0 0 0 6px rgba(22,163,106,.2); }
.fail .res-icon { background: var(--stop); box-shadow: 0 0 0 6px rgba(229,72,77,.22); }
.res-head h1 { margin: 0; font-size: 30px; }
.pass .res-head h1 { color: #9ff0c6; }
.fail .res-head h1 { color: #ffb8ba; }
.res-sub { margin: 4px 0 0; color: var(--ink2); font-size: 14px; font-weight: 600; }
.fail .res-sub { color: #fff; background: var(--stop); display: inline-block; padding: 2px 10px; border-radius: 8px; font-size: 13px; }
.pass .res-sub { color: var(--ink2); }
.res-score { display: flex; align-items: baseline; gap: 8px; margin-top: 18px; padding: 12px 16px; border-radius: 16px; background: rgba(0,0,0,.25); border: 1px solid var(--line); flex-wrap: wrap; }
.res-score .big { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.res-score .of { font-size: 18px; color: var(--ink3); font-weight: 700; }
.res-score .line { margin-left: auto; font-size: 13px; color: var(--ink2); font-weight: 600; }
.res-reason { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(229,72,77,.14); border: 1px solid rgba(229,72,77,.6); }
.res-reason b { display: block; font-size: 16px; line-height: 1.35; }
.res-reason span { display: block; margin-top: 4px; font-size: 14px; color: var(--ink2); line-height: 1.4; }
.ded { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ded li { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.ded li b { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; line-height: 1.3; }
.ded li b em { flex: none; font-style: normal; color: #fff; background: var(--stop); border-radius: 7px; padding: 1px 7px; font-size: 12px; height: fit-content; }
.ded li span { display: block; margin-top: 3px; font-size: 13px; color: var(--ink2); line-height: 1.4; }
.ded li.none { color: #a9f0cb; font-weight: 600; font-size: 14px; }
.mirror-line { margin: 12px 0 0; font-size: 13px; color: var(--ink2); }
.mirror-line.yes { color: #a9f0cb; }
.res-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.res-btns .btn { align-items: center; text-align: center; padding: 13px 10px; }
.res-btns .btn-primary { grid-column: 1 / -1; }
.res-btns.two .btn { grid-column: 1 / -1; }

@media (max-width: 520px) { .dots { display: none; } #hud { grid-template-columns: 1fr auto; } }
@media (min-width: 900px) and (min-height: 640px) {
  .toasts { top: calc(var(--safe-t) + 250px); }
  .guide { font-size: 18px; top: calc(var(--safe-t) + 64px); min-height: 60px; }
  .guide-num { width: 36px; height: 36px; font-size: 17px; }
  .step { font-size: 15px; }
  .badge { font-size: 13px; }
  .dots i { width: 22px; height: 7px; }
  .score-v { font-size: 24px; }
  h1 { font-size: 34px; }
}
@media (max-height: 700px) and (max-width: 500px) { .card { padding: 18px; } h1 { font-size: 24px; } .order li { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- hub */
html:has(body.hub-page), body.hub-page { overflow: auto; height: auto; min-height: 100%; }
body.hub-page { background: radial-gradient(120% 60% at 50% 0%, #16396a 0%, #0b1f3a 55%, #05080f 100%) fixed; -webkit-user-select: auto; user-select: auto; }
.hub { width: min(100%, 640px); margin: 0 auto; padding: calc(var(--safe-t) + 80px) 16px calc(var(--safe-b) + 32px); }
.hub-head h1 { font-size: 30px; margin: 8px 0 6px; }
.hub-head .sub { font-size: 15px; }
.hub-list { display: grid; gap: 12px; margin-top: 20px; }
.hub-card { position: relative; display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; gap: 4px 14px; align-items: center; padding: 16px 16px 14px; border-radius: 20px; text-decoration: none; color: var(--ink);
  background: linear-gradient(180deg, rgba(22, 57, 106, .9), rgba(11, 31, 58, .95)); border: 1px solid var(--line); box-shadow: 0 10px 28px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08); transition: transform .12s, border-color .15s, box-shadow .15s; }
.hub-card:hover { border-color: rgba(255,210,63,.6); box-shadow: 0 14px 34px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.1); }
.hub-card:active { transform: scale(.985); }
.hub-card:focus-visible { outline: 3px solid var(--lane); outline-offset: 3px; }
.hub-card.done { border-color: rgba(22,163,106,.6); }
.hub-num { position: absolute; top: 12px; right: 14px; font-size: 12px; font-weight: 800; color: var(--ink3); }
.hub-icon { grid-row: 1 / 3; width: 56px; height: 56px; border-radius: 16px; background: rgba(0,0,0,.28); display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.hub-icon svg { width: 44px; height: 44px; }
.hub-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-right: 18px; }
.hub-body b { font-size: 17px; line-height: 1.25; }
.hub-desc { font-size: 13.5px; color: var(--ink2); line-height: 1.4; }
.hub-prog { font-size: 12.5px; color: var(--ink3); font-weight: 600; }
.hub-prog em { font-style: normal; padding: 1px 8px; border-radius: 7px; background: rgba(255,255,255,.1); color: var(--ink2); margin-right: 4px; }
.hub-prog em.ok { background: rgba(22,163,106,.25); color: #a9f0cb; }
.hub-go { grid-column: 2; justify-self: start; margin-top: 6px; font-size: 14px; font-weight: 800; padding: 8px 16px; border-radius: 12px; background: linear-gradient(180deg, #3b7cf0, #2559c4); box-shadow: 0 4px 12px rgba(47,111,228,.35), inset 0 1px 0 rgba(255,255,255,.3); }
.hub-note { margin-top: 18px; padding: 12px 14px; border-radius: 14px; background: rgba(229,72,77,.12); border: 1px solid rgba(229,72,77,.5); font-size: 14px; font-weight: 600; line-height: 1.4; }

/* ---------------------------------------------------------------- navigation (top bar, back, language, quit sheet) */
.topnav { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 8px; background: rgba(8, 22, 44, .94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.topnav[hidden] { display: none !important; }
.navback { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 10px; border-radius: 12px; font-family: inherit; font-size: 15px; font-weight: 800; color: var(--ink); text-decoration: none; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.05)); border: 1px solid rgba(160,190,240,.4); white-space: nowrap; transition: background .15s, transform .08s; }
.navback:hover { background: rgba(255,255,255,.18); }
.navback:active { transform: scale(.97); }
.navback:focus-visible, .langpill button:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }
.brand { justify-self: center; max-width: 100%; min-height: 44px; display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 15px; letter-spacing: .01em; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--lane); background: radial-gradient(circle, var(--lane) 0 3px, transparent 4px); }
.langpill { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
.langpill button { min-width: 44px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--ink2); font-family: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.langpill button.on { background: var(--lane); color: #1a1400; }
.hudback { pointer-events: auto; min-height: 44px; font-size: 14px; padding: 0 12px 0 8px; background: rgba(5,10,20,.82); }
body.has-topnav .screen { padding-top: calc(var(--safe-t) + 74px); }
@media (max-width: 420px) { .navback { font-size: 14px; padding: 0 10px 0 6px; } .brand { font-size: 13px; gap: 6px; } .hudback { font-size: 13px; } }

.sheet-bg { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(2, 6, 14, .6); animation: fadein .2s; }
.sheet-bg[hidden] { display: none !important; }
.sheet { width: min(100%, 460px); display: grid; gap: 10px; padding: 10px 18px calc(var(--safe-b) + 18px); border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, rgba(20, 50, 94, .99), rgba(9, 25, 50, .99)); border: 1px solid var(--line); box-shadow: 0 -16px 40px rgba(0,0,0,.5); animation: sheetin .28s cubic-bezier(.2,1.1,.4,1); }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); justify-self: center; margin-bottom: 4px; }
.sheet h2 { margin: 2px 0 0; font-size: 20px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.sheet p { margin: 0 0 6px; color: var(--ink2); font-size: 14px; }
.sheet .btn { align-items: center; text-align: center; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; padding-bottom: 20px; } }
@keyframes sheetin { from { transform: translateY(40px); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }

@media (max-width: 420px) { #hud:not(.dhud) .badge { display: none; } }
