:root {
  color-scheme: light;
  --ink: #10283d;
  --muted: #597083;
  --paper: #fffdf6;
  --line: #d7e2e4;
  --coral: #ff6257;
  --gold: #ffd447;
  --teal: #21b7a5;
  --blue: #287ee0;
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 22px 18px 30px;
  color: var(--ink);
  background-color: #e4f2eb;
  background-image: radial-gradient(#82bcaa 0.8px, transparent 0.8px), linear-gradient(135deg, #f8f2d9 0%, #d7efe5 58%, #b8dce2 100%);
  background-size: 15px 15px, auto;
}
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #ee633f; outline-offset: 3px; }
[hidden] { display: none !important; }

.arcade { position: relative; width: min(1050px, 100%); margin: 0 auto; overflow: hidden; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); box-shadow: 0 8px 0 #87aa9d, 0 18px 38px #31554826; }
.topline { display: flex; height: 58px; align-items: center; justify-content: space-between; padding: 0 22px; background: #fffdf6; }
.wordmark { display: inline-flex; gap: 9px; align-items: center; color: var(--ink); font-family: "Bungee", "Trebuchet MS", sans-serif; font-size: 13px; text-decoration: none; }
.wordmark b { color: var(--coral); font-weight: inherit; }
.wordmark-icon { display: grid; width: 30px; height: 30px; place-items: center; border: 2px solid var(--ink); border-radius: 8px; background: var(--gold); font: 700 20px "Fredoka", sans-serif; transform: rotate(-6deg); }
.battle-mode .topline { position: absolute; z-index: 5; top: 0; left: 0; right: 0; height: 0; padding: 0; background: none; pointer-events: none; }
.battle-mode .wordmark { display: none; }
.battle-mode .setup-toggle { position: absolute; top: 7px; left: 12px; pointer-events: auto; }
.battle-mode .sound-toggle { position: absolute; top: 7px; left: 84px; pointer-events: auto; }
.sound-toggle { display: inline-flex; min-height: 35px; align-items: center; gap: 7px; padding: 5px 10px; border: 1.5px solid var(--line); border-radius: 7px; color: var(--ink); background: white; font-size: 13px; font-weight: 600; cursor: pointer; }
.sound-toggle span:first-child { color: #268d83; font-size: 19px; line-height: 1; }
.sound-toggle[aria-pressed="true"] span:first-child { color: var(--coral); }
.setup-toggle { display: inline-flex; min-height: 35px; align-items: center; gap: 6px; padding: 5px 9px; border: 1.5px solid var(--line); border-radius: 7px; color: var(--ink); background: white; font-size: 12px; font-weight: 700; cursor: pointer; }
.setup-toggle span:first-child { color: #287ee0; font-size: 18px; }

.stage { position: relative; overflow: hidden; border-block: 2px solid var(--ink); background: #74c8e7; isolation: isolate; }
#arena { display: block; width: 100%; aspect-ratio: 2 / 1; }
.arena-title { position: absolute; z-index: 2; top: 6px; left: 50%; width: max-content; max-width: 52%; color: #ffe34f; font: 22px/1 "Bungee", sans-serif; text-align: center; text-shadow: 3px 3px 0 #18283a, -2px -2px 0 #18283a, 2px -2px 0 #18283a, -2px 2px 0 #18283a; transform: translateX(-50%); }
.arena-title span { color: #ff9a3e; }
.arena-title small { display: block; margin-top: 2px; color: white; font: 14px/1 "Fredoka", sans-serif; text-shadow: 2px 2px 0 #18283a, -1px -1px 0 #18283a, 1px -1px 0 #18283a, -1px 1px 0 #18283a; }
.hud { position: absolute; z-index: 1; top: 51px; left: 14px; right: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fighter-hud { display: flex; width: min(31%, 310px); align-items: center; gap: 8px; padding: 5px 7px; border: 3px solid var(--ink); border-radius: 8px; background: #fffdf2ed; box-shadow: 0 3px 0 #10283d66; }
.cpu-hud { justify-content: flex-end; }
.portrait { width: 45px; height: 45px; flex: 0 0 45px; overflow: hidden; border: 2px solid var(--ink); border-radius: 6px; background: #bce6e6; }
.portrait canvas { width: 100%; height: 100%; }
.health-info { width: 100%; min-width: 0; }
.health-label { display: flex; justify-content: space-between; gap: 5px; font-size: 12px; font-weight: 700; }
.health-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-track, .combo-track { height: 10px; overflow: hidden; border: 1.5px solid var(--ink); border-radius: 99px; background: #d5dcdb; }
.health-track span { display: block; width: 100%; height: 100%; border-right: 1px solid #10283d55; background: linear-gradient(90deg, #ec4f51, #ffc943 52%, #48ca71 100%); transition: width 350ms ease; }
.score-label { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .5px; }
.score-label b { margin-left: 4px; color: var(--ink); font-size: 11px; }
.coin-icon { display: inline-grid; width: 14px; height: 14px; place-items: center; border: 1px solid #a87b00; border-radius: 50%; color: #875f00; background: var(--gold); font-size: 9px; vertical-align: -2px; }
.match-clock { position: absolute; z-index: 3; top: 8px; right: 14px; display: flex; align-items: center; gap: 5px; padding: 4px 8px; border: 2px solid var(--ink); border-radius: 7px; color: var(--ink); background: var(--gold); font-family: "Bungee", sans-serif; font-size: 14px; line-height: 1; white-space: nowrap; box-shadow: 0 3px 0 #10283d66; }
.match-clock span { font-size: 19px; }
.stage-callout { position: absolute; top: 46%; left: 50%; z-index: 2; color: #fff; font-family: "Bungee", sans-serif; font-size: clamp(20px, 4vw, 40px); line-height: 1.05; text-align: center; text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); transform: translate(-50%, -50%) scale(.75); opacity: 0; pointer-events: none; white-space: pre-line; }
.stage-callout.show { animation: callout-pop 900ms ease-out both; }
@keyframes callout-pop { 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -62%) scale(.9); } }

.menu-panel, .battle-panel, .result-panel { padding: 21px 28px 19px; }
.setup-intro { margin-bottom: 15px; text-align: center; }
.eyebrow { margin: 0 0 5px; color: #27897e; font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: "Bungee", "Trebuchet MS", sans-serif; }
h1 { font-size: clamp(18px, 3vw, 27px); line-height: 1.25; }
h1 span { color: var(--coral); }
.intro-copy { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.setup-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.setup-group legend { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.step-number { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: white; background: var(--ink); font-size: 10px; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented button, .fighter-choice { min-height: 34px; padding: 5px 10px; border: 1.5px solid #b9c9cc; border-radius: 6px; color: var(--ink); background: white; font-size: 12px; font-weight: 600; cursor: pointer; transition: background-color 140ms, transform 140ms, border-color 140ms; }
.segmented button:hover, .fighter-choice:hover { border-color: var(--ink); transform: translateY(-1px); }
.segmented button[aria-pressed="true"] { border-color: var(--ink); color: white; background: var(--blue); box-shadow: 0 2px 0 #10283d44; }
.difficulty-options button[data-value="Easy"][aria-pressed="true"] { background: #248e76; }
.difficulty-options button[data-value="Hard"][aria-pressed="true"] { background: var(--coral); }
.fighter-group { grid-column: 1 / -1; }
.fighter-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.fighter-choice { display: flex; min-height: 58px; align-items: center; gap: 8px; padding: 5px 8px; text-align: left; }
.fighter-choice[aria-pressed="true"] { border: 2px solid var(--ink); background: #dff3ea; box-shadow: 0 2px 0 #10283d35; }
.fighter-chip { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; overflow: hidden; border: 1.5px solid var(--ink); border-radius: 5px; background: #bee8e8; }
.fighter-chip canvas { width: 100%; height: 100%; }
.fighter-copy { min-width: 0; }
.fighter-copy b, .fighter-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fighter-copy b { font-size: 12px; }
.fighter-copy small { color: var(--muted); font-size: 10px; }
.menu-footer, .result-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.opponent-note { color: var(--muted); font-size: 12px; font-weight: 600; }
.opponent-note span { color: #e7a500; font-size: 16px; }
.primary-button, .secondary-button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 10px; padding: 8px 17px; border: 2px solid var(--ink); border-radius: 7px; color: white; background: var(--coral); box-shadow: 0 3px 0 var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; transition: transform 120ms, box-shadow 120ms; }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
.primary-button:active, .secondary-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.primary-button span { font-size: 20px; line-height: 12px; }
.secondary-button { color: var(--ink); background: white; }

.battle-panel { position: absolute; z-index: 2; top: 108px; left: 50%; width: min(68%, 690px); padding: 0; transform: translateX(-50%); }
.question-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.question-kicker { display: flex; align-items: center; gap: 7px; padding: 2px 7px; border: 2px solid var(--ink); border-radius: 5px; color: var(--ink); background: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #30b87e; box-shadow: 0 0 0 3px #30b87e26; }
.question-card { display: flex; min-height: 60px; align-items: center; justify-content: space-between; gap: 20px; padding: 7px 13px; border: 3px solid var(--ink); border-radius: 11px; background: #fffefa; box-shadow: inset 0 0 0 3px #a8c4ca, 0 4px 0 #10283d; }
.question-prompt { display: flex; align-items: center; gap: 12px; }
.question-prompt > span { color: var(--ink); font-family: "Bungee", sans-serif; font-size: 16px; }
.question-prompt p { margin: 0; font-size: clamp(19px, 3vw, 29px); font-weight: 700; line-height: 1.2; }
.question-meters { display: flex; width: min(270px, 42%); flex: 0 0 auto; align-items: center; gap: 12px; }
.question-timer { flex: 0 0 auto; color: var(--coral); font-family: "Bungee", sans-serif; font-size: 15px; }
.question-timer span + span { font-size: 9px; }
.combo-wrap { width: 100%; }
.combo-caption { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 10px; font-weight: 700; }
.combo-track { height: 13px; background: #d6dfdf; }
.combo-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), #9dd637, var(--gold)); transition: width 250ms; }
.answer-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
.answer-button { position: relative; display: flex; min-height: 55px; align-items: center; justify-content: center; gap: 9px; padding: 8px; border: 3px solid var(--ink); border-radius: 8px; color: white; background: #287ee0; box-shadow: 0 4px 0 #10283d; font-size: clamp(19px, 3vw, 27px); font-weight: 700; text-shadow: 1px 2px 0 #10283d; cursor: pointer; transition: transform 120ms, background-color 120ms, box-shadow 120ms; }
.answer-button:hover:not(:disabled) { background: #24ad99; transform: translateY(-2px); box-shadow: 0 6px 0 #10283d, 0 0 15px #fff59a; }
.answer-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #9eafb2; }
.answer-button:disabled { cursor: default; }
.answer-button kbd { position: absolute; top: 4px; left: 6px; padding: 0; border: 0; color: #f8e874; background: none; font: 600 10px "Fredoka", sans-serif; }
.answer-button.correct { color: var(--ink); background: #a7e794; text-shadow: none; }
.answer-button.wrong { color: var(--ink); background: #ffc0ad; text-shadow: none; }
.battle-footer { display: flex; min-height: 22px; align-items: end; justify-content: space-between; gap: 8px; color: white; font-size: 11px; font-weight: 700; text-shadow: 1px 1px 2px #10283d; }
.keyboard-hint { display: flex; align-items: center; gap: 3px; }
kbd { padding: 1px 4px; border: 1px solid #becbce; border-radius: 3px; background: white; font: inherit; }
#battle-status { color: #fff; }

.result-panel { padding-block: 27px; text-align: center; }
.result-panel h2 { color: var(--coral); font-size: clamp(27px, 5vw, 42px); }
.result-copy { margin: 6px 0 17px; color: var(--muted); font-size: 15px; }
.result-stats { display: flex; justify-content: center; gap: 35px; }
.result-stats div { display: grid; gap: 3px; }
.result-stats span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.result-stats b { font-family: "Bungee", sans-serif; font-size: 20px; }
.result-actions { justify-content: center; }
.arcade-footer { display: flex; min-height: 32px; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 20px; border-top: 1px solid var(--line); color: #68808c; background: #f7f8ef; font-size: 9px; font-weight: 700; letter-spacing: .7px; }
.shake { animation: screen-shake 280ms linear; }
@keyframes screen-shake { 20% { transform: translate(4px, -2px); } 40% { transform: translate(-4px, 2px); } 60% { transform: translate(3px, 1px); } 80% { transform: translate(-2px, -1px); } }

@media (max-width: 720px) {
  body { padding: 10px 8px 18px; }
  .topline { height: 49px; padding-inline: 12px; }
  .wordmark { gap: 6px; font-size: 10px; }
  .wordmark-icon { width: 27px; height: 27px; }
  .sound-label { display: none; }
  .arena-title { top: 5px; font-size: 16px; }
  .arena-title small { font-size: 11px; }
  .hud { top: 48px; left: 7px; right: 7px; gap: 5px; }
  .fighter-hud { width: 37%; gap: 5px; padding: 4px; }
  .portrait { width: 32px; height: 32px; flex-basis: 32px; }
  .health-label { font-size: 9px; }
  .health-track { height: 8px; }
  .score-label { font-size: 7px; }
  .score-label b { font-size: 8px; }
  .match-clock { top: 5px; right: 7px; gap: 3px; padding: 3px 5px; font-size: 10px; }
  .match-clock span { font-size: 13px; }
  .menu-panel, .battle-panel, .result-panel { padding: 17px 14px; }
  .setup-grid { gap: 12px; }
  .setup-group legend { font-size: 12px; }
  .segmented { gap: 4px; }
  .segmented button { padding-inline: 7px; font-size: 11px; }
  .fighter-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fighter-choice { min-height: 49px; gap: 5px; padding: 4px; }
  .fighter-chip { width: 30px; height: 30px; flex-basis: 30px; }
  .fighter-copy b { font-size: 10px; }
  .fighter-copy small { font-size: 9px; }
}
@media (max-width: 480px) {
  .setup-grid { grid-template-columns: 1fr; }
  .fighter-group { grid-column: auto; }
  .year-group .segmented button { flex: 1; }
  .fighter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fighter-choice:last-child { grid-column: 1 / -1; }
  .menu-footer { align-items: flex-start; flex-direction: column; }
  .menu-footer .primary-button { width: 100%; }
  .question-card { min-height: 68px; gap: 8px; padding: 8px; }
  .question-prompt { align-items: flex-start; flex-direction: column; gap: 1px; }
  .question-prompt > span { font-size: 9px; }
  .question-prompt p { font-size: 20px; }
  .question-meters { width: 40%; gap: 5px; }
  .question-timer { font-size: 12px; }
  .combo-wrap { width: 100%; }
  .combo-caption { font-size: 8px; }
  .answer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 9px; }
  .answer-button { min-height: 49px; font-size: 21px; }
  .battle-footer { align-items: center; font-size: 10px; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .arcade-footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 2px; padding-inline: 12px; font-size: 8px; }
}
@media (max-width: 600px) {
  .battle-panel { position: relative; top: auto; left: auto; width: 100%; padding: 10px 12px 8px; border-top: 2px solid var(--ink); background: var(--paper); transform: none; }
  .question-kicker { font-size: 9px; }
  .question-timer { font-size: 14px; }
  .battle-footer { color: var(--muted); text-shadow: none; }
  #battle-status { color: #247e73; }
  .stage-callout { top: 24%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}