:root {
  color-scheme: dark;
  --ink: #f7f8fc;
  --muted: #96a2b8;
  --panel: rgba(23, 31, 48, 0.72);
  --panel-strong: #171f30;
  --line: rgba(255, 255, 255, 0.09);
  --lime: #d9ff63;
  --cyan: #71e7ff;
  --orange: #ffad69;
  --red: #ff7184;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: #0d1320;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

.file-protocol-notice { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 13px 22px; color: #251b00; background: #ffd76a; box-shadow: 0 10px 30px rgba(0,0,0,.28); }
.file-protocol-notice[hidden] { display: none; }
.file-protocol-notice div { display: flex; align-items: baseline; gap: 12px; }
.file-protocol-notice strong { white-space: nowrap; }
.file-protocol-notice span { line-height: 1.45; }
.file-protocol-notice button { flex: 0 0 auto; border: 1px solid rgba(37,27,0,.28); border-radius: 9px; padding: 7px 12px; color: #251b00; background: rgba(255,255,255,.36); font-weight: 800; }

.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(70px); opacity: .18; }
.ambient-one { width: 460px; height: 460px; background: #7ad8ff; top: -180px; right: -80px; }
.ambient-two { width: 560px; height: 560px; background: #b6ff5e; bottom: -330px; left: -150px; }

.app-shell { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 40px; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.brand-block, .header-actions, .section-heading, .dialog-heading, .dialog-actions { display: flex; align-items: center; }
.brand-block { gap: 14px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: var(--lime); color: #101520; font-weight: 950; font-size: 24px; transform: rotate(-4deg); box-shadow: 0 10px 30px rgba(217,255,99,.2); }
.eyebrow { margin: 0 0 5px; color: var(--muted); letter-spacing: .16em; font-size: 11px; font-weight: 800; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 20px; }
.header-actions { gap: 10px; }
.deck-count { border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; color: var(--muted); font-size: 13px; }
.deck-count b { color: var(--ink); }
.icon-button, .secondary-button, .primary-button { border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.05); border-radius: 12px; min-height: 42px; padding: 0 16px; font-weight: 800; }
.icon-button { width: 42px; padding: 0; font-size: 20px; }
.primary-button { background: var(--lime); color: #111721; border-color: transparent; }
.secondary-button:hover, .icon-button:hover { background: rgba(255,255,255,.1); }
.speech-toggle[aria-pressed="true"] { border-color: rgba(113,231,255,.45); color: var(--cyan); background: rgba(113,231,255,.08); }
.full { width: 100%; }

.game-grid { display: grid; grid-template-columns: 300px minmax(440px, 1fr) 250px; gap: 26px; align-items: start; padding-top: 26px; }
.scoreboard-panel, .progress-panel, .word-card { border: 1px solid var(--line); box-shadow: var(--shadow); }
.scoreboard-panel, .progress-panel { background: var(--panel); backdrop-filter: blur(18px); border-radius: 24px; padding: 22px; }
.section-heading { justify-content: space-between; margin-bottom: 18px; }
.text-button { border: 0; background: none; color: var(--muted); padding: 8px; font-size: 12px; }
.text-button:hover { color: var(--ink); }
.scoreboard { display: grid; gap: 10px; }
.player-card { --player: #d9ff63; position: relative; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 68px; border: 1px solid var(--line); background: rgba(255,255,255,.035); color: var(--ink); border-radius: 16px; padding: 10px 12px; text-align: left; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.player-card:hover { transform: translateX(3px); background: rgba(255,255,255,.065); }
.player-card.selected { border-color: var(--player); background: color-mix(in srgb, var(--player) 11%, transparent); box-shadow: inset 3px 0 var(--player); }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; color: #101520; background: var(--player); font-weight: 950; }
.player-name { font-weight: 850; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-score { font-size: 28px; font-weight: 950; font-variant-numeric: tabular-nums; }
.player-card.bump .player-score { animation: scoreBump .42s ease; }
@keyframes scoreBump { 50% { transform: scale(1.4); color: var(--player); } }
.score-tip { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 16px 3px 0; }

.stage { min-width: 0; }
.bank-toolbar { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; align-items: center; gap: 10px; margin: 0 auto 12px; width: min(620px, 100%); }
.bank-toolbar label { color: var(--muted); font-size: 12px; font-weight: 850; }
.bank-toolbar select { min-width: 0; min-height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 36px 0 12px; color: var(--ink); background: #171f30; font-weight: 800; cursor: pointer; }
.bank-toolbar select:disabled { opacity: .55; cursor: wait; }
.bank-toolbar span { min-width: 48px; color: var(--cyan); font-size: 11px; text-align: right; }
.bank-toolbar[hidden] { display: none; }
.section-toolbar { margin-top: -4px; }
.section-toolbar select { border-color: rgba(113,231,255,.28); }
.mode-tabs { width: fit-content; display: flex; gap: 4px; padding: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 14px; margin: 0 auto 14px; }
.mode-tab { min-height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); padding: 0 15px; font-size: 13px; font-weight: 800; }
.mode-tab.active { color: #121826; background: var(--ink); }
.word-card { position: relative; overflow: hidden; min-height: 500px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(145deg, rgba(31,43,64,.95), rgba(18,24,38,.96)); border-radius: 30px; padding: 28px; }
.word-card::before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; top: -150px; left: -90px; border: 55px solid rgba(113,231,255,.05); }
.card-topline { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.question-number { color: var(--muted); font-size: 12px; letter-spacing: .14em; font-weight: 900; }
.category-pill { padding: 7px 10px; border-radius: 999px; background: rgba(113,231,255,.1); color: var(--cyan); font-size: 11px; font-weight: 800; }
.prompt-zone { text-align: center; padding: 46px 12px 32px; position: relative; z-index: 1; }
.prompt-label, .answer-label { color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.prompt-word { font-size: clamp(44px, 7vw, 88px); line-height: 1.04; letter-spacing: -.055em; overflow-wrap: anywhere; }
.prompt-word.zh { font-size: clamp(38px, 5.2vw, 66px); letter-spacing: .02em; }
.phrase-card .prompt-zone { padding-top: 34px; }
.phrase-card .prompt-word { white-space: pre-line; font-size: clamp(24px, 3.2vw, 42px); line-height: 1.35; letter-spacing: -.02em; }
.phrase-card .prompt-word::first-line { color: var(--ink); }
.phrase-card .pronunciation { font-size: 13px; letter-spacing: .06em; }
.pronunciation { color: var(--cyan); font-size: 17px; margin: 16px 0 0; min-height: 26px; }
.answer-zone { text-align: center; margin: 0 auto 22px; width: min(560px, 100%); border-top: 1px solid var(--line); padding: 22px 16px 0; animation: answerIn .28s ease both; }
@keyframes answerIn { from { opacity: 0; transform: translateY(8px); } }
.answer-label { margin-bottom: 8px; }
.answer-main { margin-bottom: 8px; font-size: 30px; font-weight: 950; }
.answer-note { color: var(--muted); line-height: 1.55; margin-bottom: 0; font-size: 14px; }
.reveal-button { position: relative; z-index: 1; width: 100%; min-height: 58px; border-radius: 16px; border: 1px solid rgba(217,255,99,.35); color: var(--lime); background: rgba(217,255,99,.08); display: flex; justify-content: center; align-items: center; gap: 12px; font-weight: 900; }
.reveal-button:hover { background: rgba(217,255,99,.14); }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; padding: 3px 7px; border-radius: 6px; color: var(--muted); font-size: 10px; }
.judgement-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.judge-button { min-height: 76px; display: flex; align-items: center; justify-content: center; gap: 14px; border-radius: 18px; color: var(--ink); text-align: left; }
.judge-button b, .judge-button small { display: block; }
.judge-button small { margin-top: 3px; color: var(--muted); }
.judge-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; font-weight: 950; }
.skip { border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.skip .judge-icon { background: rgba(255,255,255,.08); }
.correct { border: 1px solid rgba(217,255,99,.4); background: var(--lime); color: #111721; }
.correct .judge-icon { background: rgba(17,23,33,.1); }
.correct small { color: #435020; }
.correct:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(.6); }

.progress-panel { text-align: center; }
.progress-panel .section-heading { text-align: left; }
.progress-ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; margin: 22px auto; background: conic-gradient(var(--lime) var(--progress), rgba(255,255,255,.08) 0); position: relative; }
.progress-ring::after { content: ""; position: absolute; inset: 10px; border-radius: inherit; background: var(--panel-strong); }
.progress-ring div { position: relative; z-index: 1; }
.progress-ring strong, .progress-ring span { display: block; }
.progress-ring strong { font-size: 40px; }
.progress-ring span { color: var(--muted); font-size: 12px; }
.session-stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.session-stats div { padding: 16px 4px; }
.session-stats div + div { border-left: 1px solid var(--line); }
.session-stats span, .session-stats strong { display: block; }
.session-stats span, .leader-card span, .leader-card small { color: var(--muted); font-size: 11px; }
.session-stats strong { margin-top: 6px; font-size: 22px; }
.leader-card { padding: 15px; margin-bottom: 18px; border-radius: 16px; background: rgba(113,231,255,.07); border: 1px solid rgba(113,231,255,.14); }
.leader-card strong { display: block; margin: 6px 0 3px; color: var(--cyan); font-size: 18px; }

dialog { width: min(580px, calc(100% - 28px)); border: 1px solid var(--line); padding: 0; border-radius: 24px; color: var(--ink); background: #151e2e; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(3,8,16,.78); backdrop-filter: blur(6px); }
.dialog-card { padding: 26px; }
.dialog-heading { justify-content: space-between; margin-bottom: 22px; }
.close-button { font-size: 26px; }
.name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.name-field { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 14px; }
.name-dot { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: #101520; font-weight: 950; }
.name-field input { min-width: 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); padding: 8px 4px; }
.dialog-note { color: var(--muted); font-size: 12px; }
.dialog-actions { justify-content: space-between; gap: 12px; }
.toast { position: fixed; z-index: 10; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: #111721; border-radius: 999px; padding: 11px 18px; font-weight: 850; font-size: 13px; transition: .24s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .game-grid { grid-template-columns: 260px minmax(400px, 1fr); }
  .progress-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 150px 1fr 1fr; gap: 18px; align-items: center; text-align: left; }
  .progress-panel .section-heading, .progress-ring, .session-stats, .leader-card { margin: 0; }
  .progress-panel .full { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .file-protocol-notice, .file-protocol-notice div { align-items: stretch; flex-direction: column; }
  .file-protocol-notice { gap: 9px; }
  .file-protocol-notice div { gap: 4px; }
  .app-shell { width: min(100% - 24px, 620px); padding-top: 16px; }
  .topbar { align-items: flex-start; }
  .deck-count { display: none; }
  .speech-toggle { font-size: 12px; padding: 0 10px; }
  .game-grid { grid-template-columns: 1fr; gap: 18px; }
  .stage { grid-row: 1; }
  .scoreboard-panel { grid-row: 2; }
  .scoreboard { grid-template-columns: 1fr 1fr; }
  .player-card { grid-template-columns: 34px 1fr auto; gap: 8px; min-height: 58px; padding: 8px; }
  .avatar { width: 34px; height: 34px; }
  .player-score { font-size: 22px; }
  .word-card { min-height: 430px; padding: 20px; }
  .prompt-zone { padding: 38px 4px 24px; }
  .progress-panel { grid-column: auto; grid-template-columns: 1fr 1fr; }
  .progress-panel .section-heading, .progress-panel .full { grid-column: 1 / -1; }
  .progress-ring { width: 125px; height: 125px; }
  .name-fields { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  h1 { font-size: 23px; }
  .header-actions { align-self: center; }
  .secondary-button { padding: 0 12px; }
  .mode-tab { padding: 0 10px; font-size: 12px; }
  .bank-toolbar { grid-template-columns: 1fr auto; }
  .bank-toolbar label { grid-column: 1 / -1; }
  .scoreboard { grid-template-columns: 1fr; }
  .judgement-row { grid-template-columns: 1fr; }
  .judge-button { min-height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
