:root {
  --bg: oklch(0.15 0.012 260);
  --bg-2: oklch(0.19 0.014 260);
  --panel: oklch(0.22 0.016 260);
  --line: oklch(0.32 0.02 260);
  --ink: oklch(0.95 0.005 80);
  --muted: oklch(0.75 0.015 260);
  --p1: oklch(0.74 0.19 40);
  --p1-deep: oklch(0.52 0.19 35);
  --p2: oklch(0.80 0.12 205);
  --p2-deep: oklch(0.58 0.13 210);
  --gold: oklch(0.86 0.16 85);
  --danger: oklch(0.66 0.2 25);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --display: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Impact, "Arial Black", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100vh;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.screen { position: relative; z-index: 2; min-height: 100vh; padding: clamp(16px, 3vw, 40px) clamp(16px, 4vw, 56px); }

/* 场地：左右斜切色块 */
.arena-tint { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity .6s; }
body.in-battle .arena-tint { opacity: 1; }
.arena-tint.left { background: linear-gradient(135deg, color-mix(in oklch, var(--p1) 22%, transparent), transparent 55%); clip-path: polygon(0 0, 58% 0, 42% 100%, 0 100%); }
.arena-tint.right { background: linear-gradient(315deg, color-mix(in oklch, var(--p2) 22%, transparent), transparent 55%); clip-path: polygon(100% 0, 100% 100%, 42% 100%, 58% 0); }
body.shake { animation: shake .32s; }
@keyframes shake {
  0%,100% { transform: translate(0,0); } 15% { transform: translate(-9px,3px); } 30% { transform: translate(8px,-4px); }
  45% { transform: translate(-6px,-2px); } 60% { transform: translate(5px,3px); } 80% { transform: translate(-3px,1px); }
}
.fx { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.fx .dmg { position: absolute; font: 800 clamp(28px, 4vw, 46px)/1 var(--display); letter-spacing: .02em;
  animation: dmg 1s ease-out forwards; text-shadow: 0 2px 0 oklch(0.2 0.1 40 / .8); }
.fx .dmg.hit1 { color: var(--p1); } .fx .dmg.hit2 { color: var(--p2); }
.fx .dmg.miss { color: var(--muted); font-size: clamp(18px, 2.2vw, 24px); }
.fx .label { position: absolute; font: 900 clamp(22px, 3vw, 34px)/1 var(--display); color: var(--gold); letter-spacing: .14em;
  animation: dmg 1s ease-out forwards; text-shadow: 0 2px 0 oklch(0.3 0.1 85 / .7); }
@keyframes dmg { 0% { opacity: 0; transform: translateY(14px) scale(.7); } 15% { opacity: 1; transform: translateY(0) scale(1.12); } 30% { transform: scale(1); } 100% { opacity: 0; transform: translateY(-46px) scale(1); } }

/* ── 设置页 ── */
.logo { text-align: center; margin: 8px 0 28px; }
.logo-sub { color: var(--muted); letter-spacing: .3em; font-size: 12px; text-transform: uppercase; }
.logo h1 { margin: 6px 0 0; font: 900 clamp(48px, 9vw, 104px)/1 var(--display); letter-spacing: -.02em; }
.logo h1 em { font-style: normal; background: linear-gradient(90deg, var(--p1), var(--gold), var(--p2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-en { display: block; font: 800 clamp(14px, 2vw, 20px)/1 var(--display); letter-spacing: .5em; color: var(--muted); margin-top: 10px; padding-left: .5em; }

.setup-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; max-width: 1120px; margin: 0 auto; }
.block { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; }
.block-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.block-title.mt { margin-top: 20px; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--bg); font: 800 12px/1 var(--mono); }

.books { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.book { position: relative; text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px; min-height: 132px; display: flex; flex-direction: column; gap: 4px; transition: transform .12s, border-color .12s; }
.book:hover { transform: translateY(-2px); border-color: var(--muted); }
.book .bn { font: 900 26px/1.1 var(--display); }
.book .bc { color: var(--muted); font: 12px/1 var(--mono); }
.book .bs { margin-top: auto; font-size: 12px; color: var(--muted); line-height: 1.45; }
.book .bs b { color: var(--ink); font-weight: 600; }
.book.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: color-mix(in oklch, var(--gold) 10%, var(--bg-2)); }
.book.on .bn { color: var(--gold); }

.speeds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.speed { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; transition: border-color .12s; }
.speed:hover { border-color: var(--muted); }
.speed .sn { font-weight: 800; font-size: 15px; }
.speed .sc { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.speed.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.speed.on .sn { color: var(--gold); }

.names { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.names label { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.names label:focus-within { border-color: var(--muted); }
.names input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--ink); font: inherit; }
.names input::placeholder { color: var(--muted); }
.vs-mini { font: 900 14px/1 var(--display); color: var(--muted); letter-spacing: .1em; }
.tag { display: inline-grid; place-items: center; min-width: 34px; height: 24px; padding: 0 7px; border-radius: 6px; font: 800 12px/1 var(--mono); color: oklch(0.18 0.02 260); }
.tag.p1 { background: var(--p1); } .tag.p2 { background: var(--p2); }

.howto { max-width: 1120px; margin: 18px auto 0; display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px 20px; color: var(--muted); font-size: 13.5px; }
.howto b { color: var(--ink); margin-right: 8px; }
.keys { display: flex; flex-direction: column; gap: 6px; }
.keys span { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.k { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 5px; font: 700 12px/1 var(--mono); font-style: normal; background: var(--bg-2); border: 1px solid var(--line); border-bottom-width: 3px; }
.k.p1k { border-color: var(--p1-deep); color: var(--p1); } .k.p2k { border-color: var(--p2-deep); color: var(--p2); }

.setup-foot { display: flex; align-items: center; gap: 12px; max-width: 1120px; margin: 18px auto 0; }
.record { flex: 1; color: var(--muted); font: 13px/1.4 var(--mono); }
.record b { color: var(--ink); }
.go { background: linear-gradient(90deg, var(--p1), var(--p1-deep)); border: 0; border-radius: 14px; padding: 16px 54px; font: 900 22px/1 var(--display); letter-spacing: .2em; color: oklch(0.18 0.05 40); box-shadow: 0 10px 30px color-mix(in oklch, var(--p1) 40%, transparent); transition: transform .12s, filter .12s; }
.go:hover { transform: translateY(-2px); filter: brightness(1.08); }
.go:active { transform: translateY(1px); }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; color: var(--muted); }
.ghost:hover { border-color: var(--muted); color: var(--ink); }
.ghost.small { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

/* ── 对战页 ── */
.battle { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.hud { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; }
.fighter { min-width: 0; }
.fname { font: 900 clamp(18px, 2.4vw, 26px)/1.2 var(--display); letter-spacing: .04em; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p1 .fname { color: var(--p1); } .p2 .fname { color: var(--p2); text-align: right; }
.hp { position: relative; height: 22px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; transform: skewX(-14deg); }
.hp-fill, .hp-ghost { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transform-origin: left; transition: transform .25s ease-out; }
.hp-fill { z-index: 2; } .hp-ghost { z-index: 1; }
.p2 .hp-fill, .p2 .hp-ghost { left: auto; right: 0; transform-origin: right; }
.hp-ghost { background: oklch(0.97 0.1 90 / .85); transition: transform .9s ease-out .25s; }
.p1 .hp-fill { background: linear-gradient(180deg, var(--p1), var(--p1-deep)); }
.p2 .hp-fill { background: linear-gradient(180deg, var(--p2), var(--p2-deep)); }
.hp-fill.low { background: linear-gradient(180deg, var(--danger), oklch(0.45 0.18 25)); }
.fmeta { display: flex; justify-content: space-between; margin-top: 4px; font: 700 13px/1 var(--mono); }
.p2 .fmeta { flex-direction: row-reverse; }
.hpnum { color: var(--muted); }
.combo { color: var(--gold); font-weight: 800; opacity: 0; transition: opacity .15s; }
.combo.show { opacity: 1; animation: pop .3s; }
.fighter.hitflash .hp { box-shadow: 0 0 0 3px var(--ink); }
.fighter.locked .fname { opacity: .45; }
.mid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.round { font: 900 14px/1 var(--display); letter-spacing: .3em; color: var(--muted); padding-left: .3em; }

.stage { flex: 1; display: grid; grid-template-columns: minmax(230px, 320px) minmax(300px, 1fr) minmax(230px, 320px); gap: 18px; align-items: stretch; }
.pad { display: flex; flex-direction: column; gap: 10px; }
.pad-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 700 12px/1 var(--mono); letter-spacing: .2em; }
.p2 .pad-label, .p2pad .pad-label { justify-content: flex-end; }
.opts { flex: 1; display: grid; grid-template-rows: repeat(4, 1fr); gap: 10px; }
.opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  text-align: left; font-size: clamp(16px, 1.7vw, 21px); font-weight: 600; line-height: 1.25; transition: transform .08s, border-color .12s, background .12s; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.opt:hover { border-color: var(--muted); }
.opt:active { transform: scale(.98); }
.opt .idx { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; font: 800 13px/1 var(--mono); color: var(--bg); background: var(--muted); flex: none; }
.p1pad .opt .idx { background: var(--p1); } .p2pad .opt .idx { background: var(--p2); }
.opt.correct { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: color-mix(in oklch, var(--gold) 16%, var(--panel)); }
.opt.wrong { border-color: var(--danger); background: color-mix(in oklch, var(--danger) 18%, var(--panel)); color: var(--muted); text-decoration: line-through; }
.opt.dim { opacity: .38; }
.opt.enter { animation: optin .28s ease-out backwards; }
.pad.locked .opt { pointer-events: none; }
@keyframes optin { from { opacity: 0; transform: translateX(var(--from, -18px)); } to { opacity: 1; transform: none; } }
.p2pad .opt.enter { --from: 18px; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: none; } }

.question { position: relative; display: grid; place-items: center; min-height: 340px; }
.ring { position: absolute; width: min(340px, 100%); aspect-ratio: 1; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--bg-2); }
.ring-fg { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 326.7; transition: stroke .2s; }
.ring-fg.urgent { stroke: var(--danger); }
.q-inner { position: relative; text-align: center; padding: 0 20px; max-width: 100%; }
.prompt { color: var(--muted); letter-spacing: .3em; font-size: 12px; padding-left: .3em; }
.word { font: 900 clamp(40px, 7vw, 92px)/1.05 var(--display); letter-spacing: -.01em; overflow-wrap: anywhere; animation: pop .25s ease-out; }
.phonetic { color: var(--muted); font: 15px/1.4 var(--mono); margin-top: 6px; min-height: 21px; }
.question.enter .word { animation: pop .3s ease-out; }
.banner { position: absolute; left: 0; right: 0; top: 8%; text-align: center; font: 900 clamp(26px, 4vw, 46px)/1 var(--display); letter-spacing: .16em; color: var(--gold); pointer-events: none; animation: pop .3s ease-out; text-shadow: 0 3px 0 oklch(0.3 0.1 85 / .6); }

/* ── 结算页 ── */
.over { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 980px; margin: 0 auto; }
.ko { font: 900 clamp(64px, 14vw, 160px)/1 var(--display); letter-spacing: -.02em; margin-top: 10px; background: linear-gradient(180deg, var(--gold), var(--p1)); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop .5s ease-out; }
.winner { font: 900 clamp(24px, 4vw, 40px)/1.2 var(--display); }
.result-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; column-gap: 56px; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 22px; }
.result-grid::before { content: ""; position: absolute; left: 50%; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.rp { display: flex; flex-direction: column; gap: 6px; }
.rp h3 { margin: 0 0 4px; font: 900 22px/1.2 var(--display); }
.rp.p1 h3 { color: var(--p1); } .rp.p2 h3 { color: var(--p2); }
.rp .row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); }
.rp { position: relative; }
.rp .row b { font-family: var(--mono); color: var(--p1); }
.rp.p2 .row b { color: var(--p2); }
.rp .row.lead b { font-weight: 800; }
.rp .row.lead span { color: var(--ink); }
.rp.win h3::after { content: "WINNER"; display: inline-block; margin-left: 10px; font: 800 10px/1 var(--mono); letter-spacing: .2em; color: var(--bg); background: var(--gold); padding: 3px 6px; border-radius: 4px; vertical-align: middle; }
.rvs { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font: 900 16px/1 var(--display); color: var(--muted); letter-spacing: .08em; padding-left: .08em; background: var(--panel); border: 1px solid var(--line); }
.review { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px 22px; }
.review ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 22px; font-size: 14px; }
.review li { display: grid; grid-template-columns: minmax(8em, auto) 1fr auto; align-items: baseline; gap: 10px; color: var(--muted); border-bottom: 1px dashed var(--line); padding: 7px 0; }
.review li b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.review li .marks { white-space: nowrap; font-size: 12px; color: var(--ink); }
.review li .tag { min-width: 28px; height: 20px; font-size: 11px; margin-right: 2px; vertical-align: 1px; }
.review li.clean b { color: var(--gold); }
.review li.fail b { color: var(--danger); }
.legend { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.lg { display: inline-block; padding: 1px 7px; border-radius: 5px; margin-right: 4px; color: var(--bg); font-weight: 700; }
.lg.fail { background: var(--danger); } .lg.clean { background: var(--gold); }

/* ── 遮罩 ── */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: color-mix(in oklch, var(--bg) 82%, transparent); backdrop-filter: blur(6px); }
.overlay-text { font: 900 clamp(64px, 16vw, 200px)/1 var(--display); letter-spacing: .06em; animation: pop .35s ease-out; text-align: center; padding: 0 20px; }
.overlay-text.small { font-size: clamp(32px, 6vw, 64px); letter-spacing: .3em; padding-left: calc(.3em + 20px); }
.overlay-text.gold { color: var(--gold); }

@media (max-width: 980px) {
  .setup-grid, .howto { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 1fr; gap: 10px; }
  .opts { grid-template-rows: none; grid-template-columns: repeat(2, 1fr); }
  .p1pad { order: 1; } .question { order: 2; min-height: 250px; } .p2pad { order: 3; }
  .question .ring { width: min(250px, 90%); }
  .hud { gap: 8px; }
  .round { font-size: 12px; letter-spacing: .2em; }
  .result-grid { grid-template-columns: 1fr; row-gap: 10px; }
  .result-grid::before, .rvs { display: none; }
  .review ul { grid-template-columns: 1fr; }
  .books { grid-template-columns: repeat(2, 1fr); }
  .pad-label span:last-child { display: none; }   /* 触屏布局下按键提示无意义 */
}
/* ── 对战方式 / 远程房间 / PWA ── */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 1120px; margin: 0 auto 18px; }
.mode { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; transition: border-color .12s, background .12s; }
.mode b { font-size: 16px; } .mode span { color: var(--muted); font-size: 12.5px; }
.mode:hover { border-color: var(--muted); }
.mode.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: color-mix(in oklch, var(--gold) 10%, var(--panel)); }
.mode.on b { color: var(--gold); }
body.local .remote-only { display: none; } body.remote .local-only { display: none; }
.net-panel { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.go.wide { width: 100%; padding: 14px; letter-spacing: .3em; padding-left: calc(.3em + 54px); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; } .or i { flex: 1; height: 1px; background: var(--line); }
.joinrow { display: flex; gap: 8px; }
.joinrow input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .4em; font: 700 18px/1 var(--mono); text-align: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--ink); outline: none; }
.joinrow input:focus { border-color: var(--gold); }
.btn2 { background: var(--p2); color: oklch(0.18 0.04 210); border: 0; border-radius: 12px; padding: 0 22px; font-weight: 800; }
.btn2:hover { filter: brightness(1.06); }
.btn2.wide { padding: 10px 22px; margin: 4px 0; }
.btn2:disabled { filter: none; opacity: .6; cursor: default; }
.ready-done { display: inline-block; color: var(--gold); font-weight: 700; padding: 10px 0 4px; }
.net-status .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.net-status { font-size: 13px; color: var(--muted); line-height: 1.5; }
.net-status .code { font: 800 26px/1 var(--mono); color: var(--gold); letter-spacing: .2em; }
.net-status .err { color: var(--danger); }
.fstat { display: none; font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 18px; }
body.net .fstat { display: block; } .p2 .fstat { text-align: right; }
body.net .stage { grid-template-columns: minmax(230px, 320px) 1fr; }
.rematch-note { min-height: 22px; color: var(--gold); font-size: 14px; text-align: center; }
.screen { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
.types { display: flex; flex-wrap: wrap; gap: 8px; }
.type { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; color: var(--muted); transition: border-color .12s, color .12s; }
.type:hover { border-color: var(--muted); }
.type.on { color: var(--gold); border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: color-mix(in oklch, var(--gold) 10%, var(--bg-2)); }
.type.off { opacity: .45; cursor: not-allowed; } .type i { font-style: normal; font-size: 11px; margin-left: 4px; }
.word.long { font-size: clamp(22px, 3.2vw, 40px); line-height: 1.3; font-weight: 700; letter-spacing: 0; max-width: 30em; }
.opt.latin span:last-child { font-family: var(--mono); font-weight: 700; letter-spacing: .01em; }
@media (max-width: 980px) {
  .modes { grid-template-columns: 1fr; }
  body.net .stage { grid-template-columns: 1fr; }
  body.net .question { order: 1; } body.net .p1pad { order: 2; }   /* 单人对战：单词在上，选项在下 */
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
