:root {
  --night: #07111f;
  --navy: #0c1b2e;
  --deep: #13263d;
  --ice: #7dd3fc;
  --snow: #f5f9fc;
  --signal: #ff6a33;
  --kr: "Pretendard Variable", Pretendard, system-ui, sans-serif;
  --en: "Barlow Condensed", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--night); overscroll-behavior: none; }
body { font-family: var(--kr); color: var(--snow); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

/* The slope is a phone-shaped column; on desktop it sits centred on the night backdrop. */
.stage {
  position: relative; height: 100dvh; width: min(100vw, 480px); margin: 0 auto; overflow: hidden;
  background: #eaf1f8; touch-action: none; user-select: none; -webkit-user-select: none;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ── HUD ── */
.hud { position: absolute; inset: 0; pointer-events: none; padding: max(14px, env(safe-area-inset-top)) 16px 0; }
.hud__score { position: absolute; left: 16px; top: max(12px, env(safe-area-inset-top)); color: var(--night); font-family: var(--en); line-height: 0.9; }
.hud__score b { font-size: 56px; font-weight: 800; letter-spacing: -0.01em; }
.hud__score span { font-family: var(--kr); font-weight: 800; font-size: 16px; margin-left: 4px; }
.hud__right { position: absolute; right: 12px; top: max(12px, env(safe-area-inset-top)); display: flex; align-items: flex-start; gap: 10px; }
.hud__speed { text-align: right; color: var(--night); font-family: var(--en); line-height: 0.9; }
.hud__speed b { font-size: 30px; font-weight: 700; }
.hud__speed span { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.18em; opacity: 0.6; margin-top: 4px; }
.hud__btn {
  pointer-events: auto; width: 36px; height: 36px; border-radius: 10px; font-size: 16px; font-weight: 800;
  background: rgba(7, 17, 31, 0.82); color: var(--snow); display: grid; place-items: center;
}
.hud__btn.is-off { opacity: 0.45; text-decoration: line-through; }
.hud__combo {
  position: absolute; left: 50%; top: 86px; transform: translateX(-50%);
  background: var(--signal); color: var(--night); font-family: var(--en); font-weight: 800; font-size: 22px;
  letter-spacing: 0.06em; padding: 6px 12px 4px; white-space: nowrap;
}
.hud__combo.pop { animation: pop 0.22s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(1.35); } to { transform: translateX(-50%) scale(1); } }

/* ── panels ── */
.panel {
  position: absolute; inset: 0; z-index: 3; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: max(20px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(7, 17, 31, 0.96) 0%, rgba(12, 27, 46, 0.94) 60%, rgba(19, 38, 61, 0.92) 100%);
  display: flex; flex-direction: column; gap: 14px;
  animation: panelIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.panel__home { color: rgba(245, 249, 252, 0.6); font-family: var(--en); font-weight: 700; letter-spacing: 0.16em; font-size: 13px; text-decoration: none; }
.kicker { font-family: var(--en); font-weight: 700; letter-spacing: 0.22em; font-size: 13px; color: var(--ice); display: flex; gap: 10px; align-items: center; }
.kicker span { background: var(--signal); color: var(--night); padding: 4px 8px 3px; letter-spacing: 0.1em; font-weight: 800; }
.kicker em { font-style: normal; color: rgba(245, 249, 252, 0.7); }
.title { font-size: clamp(64px, 21vw, 96px); font-weight: 900; line-height: 0.95; letter-spacing: -0.05em; }
.lead { font-size: 16px; color: rgba(245, 249, 252, 0.8); line-height: 1.5; }

.form { display: grid; gap: 10px; margin-top: 4px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; font-weight: 700; color: rgba(245, 249, 252, 0.6); }
.field input {
  width: 100%; height: 52px; padding: 0 14px; border-radius: 12px; font: 800 18px var(--kr); color: var(--snow);
  background: rgba(255, 255, 255, 0.06); border: 1.5px solid rgba(255, 255, 255, 0.16); outline: none;
}
.field input:focus { border-color: var(--ice); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team {
  height: 64px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.04);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform 0.12s;
}
.team b { font-size: 18px; font-weight: 900; }
.team span { font-family: var(--en); font-size: 11px; letter-spacing: 0.2em; opacity: 0.6; font-weight: 700; }
.team[aria-checked="true"] { transform: scale(1.02); color: var(--night); }
.team--ski[aria-checked="true"] { background: var(--ice); border-color: var(--ice); }
.team--board[aria-checked="true"] { background: var(--signal); border-color: var(--signal); }
.btn { height: 54px; border-radius: 14px; font-weight: 900; font-size: 18px; padding: 0 18px; }
.btn--go { background: var(--signal); color: var(--night); box-shadow: 0 10px 30px rgba(255, 106, 51, 0.35); }
.btn--go:active { transform: translateY(1px); }
.btn--ghost { border: 1.5px solid rgba(255, 255, 255, 0.2); font-size: 15px; font-weight: 800; height: 48px; }
.form__err { min-height: 18px; font-size: 13px; color: #ffb199; }
.row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; }
.link { color: rgba(245, 249, 252, 0.6); font-size: 13px; text-decoration: underline; padding: 6px; align-self: center; }

.howto { display: grid; gap: 6px; font-size: 13px; line-height: 1.5; color: rgba(245, 249, 252, 0.7); border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 12px; }
.howto b { font-family: var(--en); letter-spacing: 0.1em; color: var(--ice); margin-right: 8px; }

/* ── ski vs board ── */
.battle { display: grid; gap: 6px; }
.battle__head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 900; font-size: 14px; }
.battle__head span:first-child { color: var(--ice); }
.battle__head span:last-child { color: var(--signal); }
.battle__head em { font-style: normal; font-family: var(--en); font-weight: 700; letter-spacing: 0.16em; font-size: 11px; color: rgba(245, 249, 252, 0.55); }
.battle__bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.battle__bar i { display: block; height: 100%; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.battle__bar i:first-child { background: var(--ice); width: 50%; }
.battle__bar i:last-child { background: var(--signal); width: 50%; }
.battle__nums { display: flex; justify-content: space-between; font-family: var(--en); font-weight: 800; font-size: 22px; }
.battle--big .battle__bar { height: 22px; border-radius: 11px; }
.battle--big .battle__nums { font-size: 30px; }

/* ── result ── */
.panel--over { justify-content: center; }
.result { font-family: var(--en); line-height: 0.85; }
.result b { font-size: clamp(96px, 32vw, 150px); font-weight: 800; letter-spacing: -0.02em; }
.result span { font-family: var(--kr); font-weight: 900; font-size: 26px; margin-left: 6px; }
.result__sub { font-size: 15px; font-weight: 800; color: var(--ice); min-height: 20px; }
.result__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result__grid div { background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 10px 12px; }
.result__grid span { display: block; font-size: 11px; color: rgba(245, 249, 252, 0.55); font-weight: 700; }
.result__grid b { font-family: var(--en); font-size: 24px; font-weight: 700; }
.rank { font-size: 16px; font-weight: 800; min-height: 22px; }
.rank b { color: var(--signal); font-family: var(--en); font-size: 24px; }

/* ── leaderboard ── */
.board__top { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 4px; }
.tab { height: 38px; border-radius: 9px; font-weight: 800; font-size: 14px; color: rgba(245, 249, 252, 0.6); }
.tab.is-on { background: var(--snow); color: var(--night); }
.list { list-style: none; display: grid; gap: 6px; }
.list li {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05);
}
.list li.is-me { outline: 2px solid var(--signal); background: rgba(255, 106, 51, 0.12); }
.list .n { font-family: var(--en); font-weight: 800; font-size: 22px; color: rgba(245, 249, 252, 0.5); }
.list li:nth-child(1) .n { color: #ffd166; }
.list li:nth-child(2) .n { color: #d5dde8; }
.list li:nth-child(3) .n { color: #e2a66c; }
.list .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.list .who b { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .tag { font-family: var(--en); font-weight: 800; font-size: 11px; letter-spacing: 0.1em; padding: 3px 6px 2px; color: var(--night); border-radius: 4px; flex: none; }
.list .tag.ski { background: var(--ice); }
.list .tag.board { background: var(--signal); }
.list .pts { font-family: var(--en); font-weight: 800; font-size: 24px; }
.board__note { font-size: 12px; color: rgba(245, 249, 252, 0.5); line-height: 1.5; }
.list .empty { display: block; text-align: center; color: rgba(245, 249, 252, 0.55); font-size: 14px; padding: 22px 12px; }

.toast {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 9;
  background: var(--snow); color: var(--night); font-weight: 800; font-size: 14px; padding: 10px 16px; border-radius: 999px;
  white-space: nowrap; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

@media (min-width: 481px) {
  body { background: radial-gradient(ellipse at 50% 0%, #13263d 0%, #07111f 70%); }
  .stage { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 30px 80px rgba(0, 0, 0, 0.5); }
}
