/* =========================================================
   BattleTyping — 디자인 토큰
   라이트가 기본, 다크는 시스템 설정 또는 data-theme="dark"
   ========================================================= */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --line: #e6e5e1;
  --line-strong: #d4d3ce;
  --text: #1b1b1f;
  --text-2: #4a4a52;
  --muted: #8a8a92;
  --faint: #b9b9c0;
  --accent: #3b6cf6;
  --on-accent: #ffffff;
  --ok: #12a150;
  --bad: #e5484d;
  --gold: #d99a00;
  --board: #fbfbfa;
  --chip: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 8px 24px rgba(20, 20, 30, .06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --type-size: 26px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d10;
    --surface: #16161a;
    --surface-2: #1d1d22;
    --line: #26262c;
    --line-strong: #34343c;
    --text: #ececf0;
    --text-2: #b4b4bd;
    --muted: #7c7c86;
    --faint: #4a4a53;
    --ok: #3ccf7e;
    --bad: #ff6369;
    --gold: #f5b82e;
    --board: #121215;
    --chip: #1d1d22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d10;
  --surface: #16161a;
  --surface-2: #1d1d22;
  --line: #26262c;
  --line-strong: #34343c;
  --text: #ececf0;
  --text-2: #b4b4bd;
  --muted: #7c7c86;
  --faint: #4a4a53;
  --ok: #3ccf7e;
  --bad: #ff6369;
  --gold: #f5b82e;
  --board: #121215;
  --chip: #1d1d22;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
/* 강조색 */
:root[data-accent="green"] { --accent: #10a37f; }
:root[data-accent="orange"] { --accent: #ea6a1c; }
:root[data-accent="violet"] { --accent: #7c5cff; }
:root[data-accent="pink"] { --accent: #e0457b; }
/* 글자 크기 */
:root[data-size="large"] { --type-size: 32px; }
:root[data-size="small"] { --type-size: 22px; }

:root {
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --bad-soft: color-mix(in srgb, var(--bad) 12%, transparent);
  --ok-soft: color-mix(in srgb, var(--ok) 12%, transparent);
  --gold-soft: color-mix(in srgb, var(--gold) 14%, transparent);
}

/* =========================================================
   기본
   ========================================================= */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* =========================================================
   헤더
   ========================================================= */
.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 60px;
  display: flex; align-items: center; gap: 28px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.3px; }
.logo .mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 800;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
}
.logo small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: -2px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 14px; transition: color .15s, background .15s; }
.top nav a:hover { color: var(--text); background: var(--surface-2); }
.top nav a.on { color: var(--text); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--text-2); transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* 설정 패널 */
.settings-pop {
  position: fixed; right: 24px; top: 66px; width: 300px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.settings-pop h4 { margin: 0 0 14px; font-size: 14px; }
.set-row { margin-bottom: 16px; }
.set-row:last-child { margin-bottom: 0; }
.set-row > label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
}
.swatch.on { box-shadow: 0 0 0 2px var(--text); }

.set-row > label { display: flex; justify-content: space-between; }
.vol-val { font-family: var(--mono); color: var(--text-2); }
.vol { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.vol svg { width: 18px; height: 18px; flex: none; }
.vol input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 6px; border-radius: 99px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--surface-2) var(--p, 50%));
  border: 1px solid var(--line);
}
.vol input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.vol input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

/* =========================================================
   공통 컴포넌트
   ========================================================= */
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 48px 24px 64px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 1.5px; color: var(--accent); font-weight: 600; margin: 0 0 10px; text-transform: uppercase; }
h1 { font-size: 34px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.8px; font-weight: 800; }
h2 { font-size: 22px; letter-spacing: -0.4px; margin: 48px 0 12px; }
.sub { color: var(--text-2); margin: 0; font-size: 16px; }
.hero { margin-bottom: 32px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card.raised { box-shadow: var(--shadow); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform .06s, opacity .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { opacity: 1; border-color: var(--line-strong); background: var(--surface-2); }
.btn.big { height: 52px; font-size: 16px; padding: 0 24px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; color: var(--text-2); background: var(--surface);
}

.field {
  height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field::placeholder { color: var(--faint); }

/* 세그먼트 버튼 */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; transition: color .15s, background .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tag.me { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.host { background: var(--gold-soft); color: var(--gold); border-color: transparent; }

.ad-slot {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--faint); font-size: 12px;
  display: flex; align-items: center; justify-content: center; min-height: 90px; margin: 28px 0;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 6px); } }

footer { border-top: 1px solid var(--line); }
.foot-in { max-width: 1120px; margin: 0 auto; padding: 22px 24px; display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.foot-in a:hover { color: var(--text); }
.foot-in .sp { flex: 1; }

/* =========================================================
   솔로 타자 측정
   ========================================================= */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .sp { flex: 1; }
.best { font-size: 13px; color: var(--muted); }
.best b { color: var(--text); font-variant-numeric: tabular-nums; }

.statbar { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.statbar > div { padding: 16px 22px; }
.statbar > div + div { border-left: 1px solid var(--line); }
.statbar .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.statbar .v { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.statbar .v small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.statbar .v.accent { color: var(--accent); }

.typing-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px 36px 26px; box-shadow: var(--shadow); }
.target { font-size: var(--type-size); line-height: 1.65; letter-spacing: .2px; min-height: 1.65em; word-break: keep-all; font-weight: 500; }
.target span { border-radius: 3px; transition: color .08s; }
.target .ok { color: var(--text); }
.target .bad { color: var(--bad); background: var(--bad-soft); }
.target .cur { color: var(--text); }
.target .rest { color: var(--faint); }
.target .caret { box-shadow: inset 2px 0 0 var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { box-shadow: inset 2px 0 0 transparent; } }
.type-input {
  width: 100%; margin-top: 22px; height: auto; padding: 14px 0; font-size: calc(var(--type-size) - 4px);
  border: 0; border-bottom: 2px solid var(--line); border-radius: 0; background: transparent; box-shadow: none !important;
}
.type-input:focus { border-color: var(--accent); }
.next-line { color: var(--faint); font-size: 15px; margin-top: 16px; min-height: 22px; }
.next-line b { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; margin-right: 8px; color: var(--muted); font-weight: 600; }
.progress { height: 3px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 18px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.hint { display: flex; gap: 16px; justify-content: center; color: var(--muted); font-size: 13px; margin-top: 16px; }

.result { text-align: center; padding: 48px 28px 32px; }
.result .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.result .speed { font-size: 88px; font-weight: 900; line-height: 1; letter-spacing: -3px; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.result .speed .u { font-size: 28px; letter-spacing: 0; color: var(--muted); margin-left: 4px; font-weight: 700; }
.result .tier { display: inline-block; font-size: 16px; font-weight: 700; padding: 6px 14px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin: 10px 0 8px; }
.result .new { color: var(--gold); font-weight: 700; margin-top: 6px; }
.result .statbar { max-width: 560px; margin: 28px auto; text-align: left; }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; text-align: left; }
.cta b { font-size: 16px; }

.content { max-width: 720px; margin-top: 64px; line-height: 1.8; color: var(--text-2); font-size: 15.5px; }
.content h2 { color: var(--text); }
.content b { color: var(--text); }
.content ul { padding-left: 20px; }
.content li { margin: 4px 0; }
.content table { border-collapse: separate; border-spacing: 0; width: 100%; margin: 14px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.content th, .content td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.content tr:last-child td { border-bottom: 0; }
.content th { background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; }
.formula { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--text); }
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 700; color: var(--text); list-style: none; }
.faq summary::after { content: '+'; float: right; color: var(--muted); }
.faq details[open] summary::after { content: '–'; }
.faq p { margin: 8px 0 0; }

/* =========================================================
   배틀
   ========================================================= */
.menu { display: grid; grid-template-columns: 400px 1fr; gap: 20px; align-items: start; }
.menu .card h3 { margin: 0 0 16px; font-size: 15px; }
.stack { display: grid; gap: 10px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 6px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; color: var(--text-2); counter-increment: s; }
.steps li::before {
  content: counter(s); width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text);
}
.steps b { color: var(--text); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.chipw { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--chip); }
.chipw.atk { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.chipw.gold { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }

.lobby { max-width: 560px; margin: 0 auto; }
.room-code { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: 6px; }
.plist { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 6px; }
.plist li { border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; display: flex; gap: 8px; align-items: center; background: var(--surface); font-weight: 600; }
.plist li .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.cd { font-size: 14px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
.cd:empty { display: none; }

.game { display: grid; grid-template-columns: 640px 1fr; gap: 24px; align-items: start; }
.hud { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.hp { flex: 1; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.hp > div { height: 100%; background: var(--ok); transition: width .2s; width: 100%; border-radius: 99px; }
.hp.low > div { background: var(--bad); }
.hud .num { font-weight: 800; min-width: 80px; font-size: 15px; }
.hud .combo { color: var(--accent); min-width: 70px; }
.board-wrap { position: relative; }
#board { display: block; width: 640px; height: 520px; background: var(--board); border: 1px solid var(--line); border-radius: var(--radius); }
.board-wrap.shake { animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.board-wrap.hurt #board { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.game .type-input { margin-top: 10px; font-size: 22px; }
.type-input.wrong { border-color: var(--bad) !important; }
.overlay-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: color-mix(in srgb, var(--board) 80%, transparent); backdrop-filter: blur(2px);
  border-radius: var(--radius); font-size: 28px; font-weight: 800;
}
.side h3 { margin: 4px 0 12px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .5px; }
.opps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opp { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; transition: border-color .2s, opacity .2s; }
.opp.dead { opacity: .4; }
.opp.flash { border-color: var(--bad); }
.opp.sent { border-color: var(--accent); }
.opp .nm { font-weight: 700; display: flex; gap: 6px; align-items: center; font-size: 14px; white-space: nowrap; overflow: hidden; }
.opp .hp { height: 6px; margin: 10px 0 8px; }
.opp .meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.feed { margin-top: 20px; display: grid; gap: 6px; font-size: 13px; }
.feed div { padding: 8px 12px; border-radius: 9px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); animation: pop2 .2s ease-out; }
@keyframes pop2 { from { opacity: 0; transform: translateY(-4px); } }
.feed .in { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.feed .outm { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.modal { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal .card { width: 520px; max-width: calc(100vw - 32px); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); padding: 28px; }
.modal h2 { margin: 0 0 4px; font-size: 28px; }
.rank-table { width: 100%; border-collapse: collapse; margin: 18px 0 0; }
.rank-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.rank-table tr.me td { color: var(--accent); font-weight: 800; }
.rank-table td.r { width: 44px; font-weight: 800; font-family: var(--mono); }
.rank-table td.s { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }


/* =========================================================
   장식 레이어 (라이트 모드에 생기를, 다크에선 은은하게)
   ========================================================= */
:root {
  --glow-a: color-mix(in srgb, var(--accent) 16%, transparent);
  --glow-b: rgba(255, 176, 92, .16);
  --dot: rgba(30, 30, 60, .07);
  --key-edge: #d9d8d2;
  --tint: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --glow-a: color-mix(in srgb, var(--accent) 10%, transparent);
    --glow-b: rgba(255, 176, 92, .04);
    --dot: rgba(255, 255, 255, .045);
    --key-edge: #0a0a0c;
    --tint: color-mix(in srgb, var(--accent) 6%, var(--surface));
  }
}
:root[data-theme="dark"] {
  --glow-a: color-mix(in srgb, var(--accent) 10%, transparent);
  --glow-b: rgba(255, 176, 92, .04);
  --dot: rgba(255, 255, 255, .045);
  --key-edge: #0a0a0c;
  --tint: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

body {
  background:
    radial-gradient(900px 420px at 88% -120px, var(--glow-a), transparent 70%),
    radial-gradient(700px 360px at -8% 80px, var(--glow-b), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
}
main { position: relative; }
main::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 340px; z-index: -1; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
}
.top { background: color-mix(in srgb, var(--surface) 72%, transparent); }

/* 헤드라인 */
.hero { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: center; }
h1 em {
  font-style: normal;
  background: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 24%, transparent) 62%);
  border-radius: 2px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px 5px 9px; border-radius: 99px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* 키캡 일러스트 */
.keys { position: relative; height: 170px; }
.key {
  position: absolute; width: 62px; height: 60px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line-strong); color: var(--text); font-weight: 800; font-size: 22px;
  box-shadow: inset 0 -5px 0 var(--key-edge), 0 10px 22px rgba(20, 20, 40, .08);
  animation: float 4.5s ease-in-out infinite; animation-delay: var(--d, 0s);
}
.key.wide { width: 128px; font-size: 14px; font-family: var(--mono); font-weight: 700; color: var(--text-2); }
.key.acc {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff), var(--accent));
  color: #fff; border-color: transparent;
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--accent) 70%, #000), 0 12px 26px color-mix(in srgb, var(--accent) 35%, transparent);
}
.key.dark { background: linear-gradient(180deg, #2b2b31, #1b1b1f); color: #f1f1f4; border-color: #111; box-shadow: inset 0 -5px 0 #0b0b0d, 0 10px 22px rgba(0, 0, 0, .18); }
.wchip {
  position: absolute; padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 17px;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 8px 20px rgba(20, 20, 40, .07);
  animation: float 5s ease-in-out infinite; animation-delay: var(--d, 0s);
}
.wchip.atk { color: var(--bad); border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.wchip.gold { color: var(--gold); border-color: var(--gold); background: color-mix(in srgb, var(--gold) 9%, var(--surface)); }
.wchip.hit { border: 2px solid var(--accent); }
.wchip.hit b { color: var(--accent); }
@keyframes float { 50% { transform: translateY(-7px); } }
@media (prefers-reduced-motion: reduce) { .key, .wchip { animation: none; } }

/* 버튼 */
.btn.accent {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn.accent:hover { opacity: 1; filter: brightness(1.05); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 36%, transparent), inset 0 1px 0 rgba(255, 255, 255, .22); }
.card { box-shadow: 0 1px 2px rgba(20, 20, 40, .03); }

/* 통계 아이콘 */
.statbar { box-shadow: 0 1px 2px rgba(20, 20, 40, .03); overflow: hidden; }
.statbar .k { display: flex; align-items: center; gap: 8px; }
.ico { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; }
.ico svg { width: 14px; height: 14px; }
.s-acc .ico { background: var(--accent-soft); color: var(--accent); }
.s-ok .ico { background: var(--ok-soft); color: var(--ok); }
.s-gold .ico { background: var(--gold-soft); color: var(--gold); }
.statbar > .s-acc { background: linear-gradient(135deg, var(--tint), var(--surface) 70%); }

/* 타이핑 카드 */
.typing-card { position: relative; overflow: hidden; }
.typing-card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #ffb05c));
}
.typing-card::after {
  content: ''; position: absolute; right: -80px; top: -80px; width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(var(--glow-a), transparent 70%); pointer-events: none; opacity: .55;
}
.seg { background: color-mix(in srgb, var(--surface-2) 80%, var(--surface)); }

/* 결과 */
.result { position: relative; overflow: hidden; }
.result::before {
  content: ''; position: absolute; left: 50%; top: -160px; width: 620px; height: 360px; transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow-a), transparent); pointer-events: none;
}
.result > * { position: relative; }
.cta {
  background:
    radial-gradient(400px 160px at 100% 0%, var(--glow-a), transparent 70%),
    radial-gradient(300px 140px at 0% 100%, var(--glow-b), transparent 70%),
    var(--surface);
}

/* 본문 */
.content h2 { display: flex; align-items: center; gap: 10px; }
.content h2::before { content: ''; width: 4px; height: 20px; border-radius: 4px; background: var(--accent); }
.content th { background: var(--tint); }
.formula { border-left: 3px solid var(--accent); background: var(--tint); }

/* 배틀 메뉴 */
.play { position: relative; overflow: hidden; }
.play::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 110px; pointer-events: none;
  background: linear-gradient(180deg, var(--tint), transparent);
}
.play > * { position: relative; }
.play-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.play-head h3 { margin: 0 !important; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.steps li::before { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* 배틀 보드 */
#board {
  background-color: var(--board);
  background-image:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 40%),
    radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px;
}
.opp .nm .av, .plist li .av { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; flex: none; }
.opp { box-shadow: 0 1px 2px rgba(20, 20, 40, .03); }
.room-code { color: var(--accent); }
footer { background: color-mix(in srgb, var(--surface) 60%, transparent); }

/* =========================================================
   모드 선택 / 레이스
   ========================================================= */
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.mode-card {
  text-align: left; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; position: relative;
}
.mode-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.mode-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: linear-gradient(180deg, var(--tint), var(--surface)); }
.mode-card .mc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mode-card .mc-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.mode-card.on .mc-ico { background: var(--accent); color: #fff; }
.mode-card .mc-ico svg { width: 16px; height: 16px; }
.mode-card b { font-size: 15px; }
.mode-card .mc-tag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--muted); font-family: var(--mono); }
.mode-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; word-break: keep-all; }
.lobby-mode { font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.mode-pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.hud .timer { color: var(--text-2); min-width: 54px; font-family: var(--mono); }
#game[data-mode="timeattack"] .hp { display: none; }
#game[data-mode="timeattack"] .hud .timer { font-size: 18px; color: var(--text); flex: 1; }

.race { max-width: 900px; margin: 0 auto; }
.race-head { display: flex; align-items: center; gap: 22px; margin-bottom: 14px; flex-wrap: wrap; }
.race-head .sp { flex: 1; }
.race-stat { font-size: 13px; display: flex; gap: 6px; align-items: baseline; }
.race-stat b { font-size: 18px; font-family: var(--mono); }
.track { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 18px; margin-bottom: 14px; }
.lane { display: grid; grid-template-columns: 150px 1fr 110px; gap: 14px; align-items: center; padding: 9px 0; }
.lane + .lane { border-top: 1px dashed var(--line); }
.lane .who { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; }
.lane .av { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; flex: none; }
.lane .road { position: relative; height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.lane .fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: color-mix(in srgb, var(--accent) 35%, transparent); transition: width .3s ease-out; }
.lane .dot { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; transform: translate(-50%, -50%); border: 3px solid var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); transition: left .3s ease-out; }
.lane .road::after { content: '🏁'; position: absolute; right: -6px; top: 50%; transform: translate(100%, -50%); font-size: 14px; }
.lane .info { text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lane .info b { color: var(--text); }
.lane.me .who { color: var(--accent); }
.lane.me .fill { background: var(--accent); }
.lane.done .info b { color: var(--ok); }
.race-card { position: relative; }
.race-card .overlay-msg { font-size: 22px; }

@media (max-width: 980px) {
  .modes { grid-template-columns: 1fr 1fr; }
  .lane { grid-template-columns: 100px 1fr 80px; }
  .hero { grid-template-columns: 1fr; }
  .keys { display: none; }
  .menu, .game { grid-template-columns: 1fr; }
  #board { width: 100%; height: auto; aspect-ratio: 640 / 520; }
  .top nav a { padding: 7px 8px; }
  .logo small { display: none; }
  .typing-card { padding: 24px 20px; }
  .statbar .v { font-size: 24px; }
  .statbar > div { padding: 12px 14px; }
}
