/* Spot On — 어두운 오로라 + 유리 판 + 큰 숫자. 휴대폰 세로가 기본. */
:root {
  --bg: #0b0a1f;
  --ink: #f4f3ff;
  --ink-2: #b9b6dc;
  --ink-3: #8a86b8;
  --glass: rgba(255, 255, 255, .07);
  --glass-2: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .14);
  --mint: #5ff2c8;
  --sky: #52b8ff;
  --violet: #8a6bff;
  --pink: #ff7ac6;
  --gold: #ffd166;
  --radius: 22px;
  --font: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Hiragino Sans", "Noto Sans KR", sans-serif;
  color-scheme: dark; /* 어두운 화면 하나로 정한 디자인 */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); } /* 휴대폰 위·아래 막대 피하기(비공개 페이지 틀과 같은 값) */
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
html:lang(ko) body { word-break: keep-all; overflow-wrap: anywhere; } /* 한국어는 낱말 중간에서 줄 바꾸지 않기 */
[hidden] { display: none !important; }

/* 오로라 바탕 */
.aurora { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.aurora i { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(70px); opacity: .55; animation: drift 22s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { background: radial-gradient(circle, #3b2bd6 0, transparent 65%); left: -25vmax; top: -30vmax; }
.aurora i:nth-child(2) { background: radial-gradient(circle, #0fb7a6 0, transparent 65%); right: -30vmax; top: 10vh; animation-duration: 28s; opacity: .38; }
.aurora i:nth-child(3) { background: radial-gradient(circle, #c43f9a 0, transparent 65%); left: 0; bottom: -45vmax; animation-duration: 34s; opacity: .32; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .aurora i, .spot-bob, .verdict, .reveal-in { animation: none; } }

.app {
  position: relative; z-index: 1; max-width: 560px; margin: 0 auto;
  min-height: 100%; padding-block: 10px 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column;
}

/* 머리 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 46px; flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.01em; font-size: 19px; white-space: nowrap; }
.brand-mark { display: inline-flex; width: 30px; height: 30px; }
.top-right { display: flex; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--glass); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; white-space: nowrap; line-height: 1.2; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--glass-2); }

.screen { flex: 1; display: flex; flex-direction: column; align-items: center; min-height: 0; }

/* 버튼 */
.btn { border: 0; border-radius: 16px; padding: 14px 22px; font-size: 16px; font-weight: 800; cursor: pointer; white-space: nowrap; transition: transform .12s, opacity .2s, background .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--mint), var(--sky) 55%, var(--violet)); color: #0b0a1f; box-shadow: 0 10px 30px -10px rgba(82, 184, 255, .7); }
.btn.primary:disabled { opacity: .35; cursor: default; box-shadow: none; }
.btn.ghost { background: var(--glass); border: 1px solid var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--glass-2); }
.btn.big { width: 100%; max-width: 360px; padding: 17px 22px; font-size: 17px; }
.btn:focus-visible, .chip:focus-visible, .step:focus-visible, .peek:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* 시작 화면 */
.intro { justify-content: center; text-align: center; gap: 14px; padding: 8px 0 18px; }
.intro-mascot { width: min(46vw, 210px); aspect-ratio: 1; }
.intro-mascot svg { width: 100%; height: 100%; }
.tagline { margin: 4px 0 0; font-size: clamp(30px, 8.6vw, 44px); line-height: 1.08; letter-spacing: -.03em; font-weight: 850; text-wrap: balance; }
.sub { margin: 0; color: var(--ink-2); font-size: 16px; line-height: 1.45; text-wrap: balance; }
.round-icons { display: flex; gap: 8px; justify-content: center; margin: 6px 0 8px; flex-wrap: wrap; }
.round-icons span { width: 44px; height: 44px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); display: grid; place-items: center; }
.round-icons svg { width: 26px; height: 26px; }
.hint { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.intro .btn.ghost { width: 100%; max-width: 360px; }

/* 문제 화면 */
.play { gap: 10px; padding-top: 4px; justify-content: center; }
.slot { width: 100%; min-height: 76px; display: flex; align-items: center; justify-content: center; flex: none; }
.play-head { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 22px; flex-wrap: wrap; }
.dots { display: flex; gap: 7px; }
.dots i { width: 26px; height: 7px; border-radius: 99px; background: var(--glass-2); transition: background .3s; }
.dots i.done { background: linear-gradient(90deg, var(--mint), var(--sky)); }
.dots i.now { background: var(--ink); }
.practice-tag { font-size: 12px; font-weight: 700; color: var(--gold); border: 1px solid rgba(255, 209, 102, .4); border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.prompt { margin: 0; text-align: center; font-size: clamp(19px, 5.2vw, 24px); font-weight: 800; letter-spacing: -.02em; line-height: 1.25; min-height: 2.5em; display: flex; align-items: center; justify-content: center; text-wrap: balance; }
.stage {
  position: relative; width: min(100%, calc(100dvh - 320px)); min-width: 240px; aspect-ratio: 1; flex: none;
  border-radius: var(--radius); background: linear-gradient(160deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .03));
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 24px 60px -30px rgba(0, 0, 0, .8);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); overflow: hidden;
}
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
.peek { position: absolute; inset: 0; margin: auto; width: 72%; height: 64px; border-radius: 18px; border: 1px dashed rgba(255, 255, 255, .35); background: rgba(11, 10, 31, .55); font-weight: 800; font-size: 17px; cursor: pointer; backdrop-filter: blur(6px); }

.count-ctl { display: flex; align-items: center; gap: 10px; width: min(100%, 420px); }
.count-ctl input[type=range] { flex: 1; min-width: 0; accent-color: var(--sky); height: 32px; }
.step { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); font-size: 20px; font-weight: 800; cursor: pointer; flex: none; }
.count-ctl input[type=number] { width: 76px; height: 44px; text-align: center; font: inherit; font-size: 24px; font-weight: 850; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--glass); border: 1px solid var(--line); border-radius: 12px; -moz-appearance: textfield; flex: none; }
.count-ctl input[type=number]::-webkit-inner-spin-button, .count-ctl input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.count-ctl input[type=number]::placeholder { color: var(--ink-3); }
.g-q { fill: rgba(255, 255, 255, .12); font-size: 30px; font-weight: 900; font-family: var(--font); }

.verdict { display: flex; align-items: center; gap: 12px; justify-content: center; min-height: 64px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.verdict-mascot { width: 56px; height: 56px; flex: none; }
.verdict-mascot svg { width: 100%; height: 100%; }
.verdict-num { font-size: 46px; font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; display: flex; align-items: center; gap: 6px; flex: none; white-space: nowrap; }
.verdict-num small { font-size: 26px; }
.verdict-detail { color: var(--ink-2); font-size: 15px; font-weight: 600; max-width: 170px; line-height: 1.3; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.actions { display: flex; justify-content: center; width: 100%; padding-top: 2px; flex: none; }
.actions .btn { width: 100%; max-width: 360px; }

/* 판 위 그림 */
.g-line { stroke: var(--ink); stroke-width: .9; stroke-linecap: round; fill: none; }
.g-cap { stroke: var(--ink); stroke-width: .9; stroke-linecap: round; }
.g-user { fill: var(--pink); stroke: #fff; stroke-width: .5; }
.g-user-line { stroke: var(--pink); stroke-width: .9; stroke-linecap: round; fill: none; }
.g-ans { fill: var(--mint); stroke: #0b0a1f; stroke-width: .4; }
.g-ans-line { stroke: var(--mint); stroke-width: .9; stroke-linecap: round; fill: none; }
.g-gap { stroke: var(--gold); stroke-width: .5; stroke-dasharray: 1.2 1; }
.g-dot { fill: var(--ink); }
.g-pivot { fill: var(--ink); }
.g-guide { stroke: rgba(255, 255, 255, .18); stroke-width: .5; stroke-dasharray: 1 1.4; fill: none; }
.g-handle { fill: var(--pink); stroke: #fff; stroke-width: .5; }
.g-text { fill: var(--ink-2); font-size: 4px; font-weight: 700; font-family: var(--font); }
.g-ring { fill: none; stroke: var(--mint); stroke-width: .5; opacity: .6; }
.reveal-in { animation: revealIn .5s ease-out both; }
@keyframes revealIn { from { opacity: 0; transform-origin: center; } }

/* 결과 */
.result { gap: 14px; padding: 6px 0 10px; }
.result-top { display: flex; align-items: center; gap: 14px; }
.result-mascot { width: 92px; height: 92px; flex: none; }
.result-mascot svg { width: 100%; height: 100%; }
.total { font-size: clamp(64px, 19vw, 96px); font-weight: 900; letter-spacing: -.05em; line-height: .95; font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff, var(--mint) 45%, var(--sky)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.total small { font-size: .3em; letter-spacing: 0; color: var(--ink-3); -webkit-text-fill-color: var(--ink-3); margin-left: 4px; }
.tier { font-size: 20px; font-weight: 800; margin-top: 4px; white-space: nowrap; }
.emoji-row { font-size: 34px; letter-spacing: 6px; line-height: 1; }
.round-list { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 420px; display: grid; gap: 6px; }
.round-list li { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); font-size: 14px; }
.round-list li svg { width: 22px; height: 22px; }
.round-list .rl-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.round-list b { font-variant-numeric: tabular-nums; font-size: 16px; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 420px; }
.stats div { text-align: center; padding: 10px 4px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); min-width: 0; }
.stats b { display: block; font-size: 22px; font-weight: 850; font-variant-numeric: tabular-nums; }
.stats span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-in { color: var(--ink-2); font-size: 14px; }
.next-in b { font-variant-numeric: tabular-nums; color: var(--ink); }
.result .btn.ghost { width: 100%; max-width: 360px; }

/* 도전 알림·승부·단추 두 개 */
.ch-banner { width: 100%; max-width: 380px; display: grid; gap: 10px; padding: 14px 16px; border-radius: 18px; text-align: center;
  background: linear-gradient(135deg, rgba(255, 122, 198, .18), rgba(138, 107, 255, .18)); border: 1px solid rgba(255, 122, 198, .45); }
.ch-banner p { margin: 0; font-weight: 800; font-size: 16px; line-height: 1.35; text-wrap: balance; }
.vs { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; padding: 8px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); flex-wrap: wrap; justify-content: center; text-align: center; }
.vs b { font-variant-numeric: tabular-nums; }
.vs .win { color: var(--mint); } .vs .lose { color: var(--pink); } .vs .tie { color: var(--gold); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 360px; }
.row2 .btn { width: 100%; min-width: 0; padding: 13px 10px; font-size: 15px; white-space: normal; line-height: 1.2; text-align: center; text-decoration: none; display: flex; align-items: center; justify-content: center; }

/* 결과 그림 창 */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(5, 4, 15, .78);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.sheet-box { width: 100%; max-width: 400px; display: grid; gap: 10px; justify-items: center; }
.sheet-box img { width: auto; max-width: 100%; max-height: calc(100dvh - 230px); border-radius: 16px; box-shadow: 0 20px 60px -20px #000; background: #0b0a1f; }
.sheet-box .hint { text-align: center; }
.sheet-box > .btn { width: 100%; max-width: 360px; }

.row2.one { grid-template-columns: 1fr; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 30px); opacity: 0; z-index: 30;
  background: rgba(20, 18, 48, .92); border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 14px;
  transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.spot-bob { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.spot-pupil { transition: transform .12s ease-out; }

/* 넓은 화면: 가운데 정렬은 그대로, 숫자만 조금 더 크게 */
@media (min-width: 720px) {
  .app { padding-top: 22px; }
  .stage { width: min(520px, calc(100dvh - 345px)); }
}
/* 아주 낮은 화면(가로 휴대폰 등): 판은 왼쪽, 글·단추는 오른쪽 */
@media (max-height: 560px) {
  .intro-mascot { width: 110px; }
  .prompt { min-height: 1.4em; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .app { max-width: 920px; }
  .play { display: grid; grid-template-columns: auto minmax(160px, 340px); grid-template-rows: auto auto auto auto; column-gap: clamp(12px, 3vw, 22px); row-gap: 8px; align-content: center; justify-content: center; }
  .play-head, .prompt, .slot, .actions { grid-column: 2; min-width: 0; }
  /* 판 = 화면 높이에 맞추되, 폭이 좁은 가로 창(약 420px)에서는 글 칸 최소 160px 를 남기고 줄어듦 */
  .stage { grid-column: 1; grid-row: 1 / span 4; width: max(170px, min(calc(100dvh - 76px), calc(100vw - 32px - 3vw - 160px))); min-width: 0; }
}
/* 좁은 가로 창(폭 640 이하·높이 560 이하): 오른쪽 글 칸이 160~200px 뿐 → 정답 설명은 숫자 아래 줄, 개수 입력은 두 줄 */
@media (max-height: 560px) and (orientation: landscape) and (max-width: 640px) {
  .prompt { font-size: 18px; }
  .slot { min-height: 56px; }
  .verdict { flex-wrap: wrap; gap: 2px 8px; min-height: 0; }
  .verdict-mascot { width: 38px; height: 38px; }
  .verdict-num { font-size: 36px; }
  .verdict-num small { font-size: 20px; }
  .verdict-detail { flex-basis: 100%; max-width: none; text-align: center; font-size: 13px; }
  .count-ctl { flex-wrap: wrap; justify-content: center; gap: 6px 8px; }
  .count-ctl input[type=range] { flex: 1 0 100%; order: -1; }
  .count-ctl input[type=number] { width: 60px; }
}
