
:root {
  color-scheme: dark;
  --background: #f4f0e8;
  --panel: #242120;
  --line: #4d413a;
  --muted: #d4beb0;
  --ink: #f6f0e7;
  --rust: #923b20;
  --accent: #ffc85a;
  --mint: #59e6c6;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
[hidden] { display: none !important; }
.site-head {
  min-height: 63px; padding: 10px max(24px, calc((100vw - 1370px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 4px solid var(--rust); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand span { text-transform: uppercase; font-size: 10px; line-height: 1.18; font-weight: 800; letter-spacing: .12em; }
.build { color: var(--muted); font-weight: 700; font-size: 11px; letter-spacing: .16em; }
.build b { color: var(--accent); margin-left: 6px; }
.head-actions { display: flex; align-items: center; gap: clamp(8px, 2vw, 18px); }
#open-keys, #mute-sound, .dialog-actions button, .key-options button, .victory-card button {
  background: #45332a; color: var(--ink); border: 1px solid #957257; border-radius: 3px;
  font-size: 13px; font-weight: 750; padding: 8px 13px;
}
#open-keys:hover, #mute-sound:hover, .dialog-actions button:hover, .key-options button:hover { background: #654531; }
#mute-sound[aria-pressed="true"] { background: #2c2725; color: var(--muted); }
main { width: min(1370px, calc(100% - 48px)); margin: 25px auto 30px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 14px; color: #26211f; }
.eyebrow { color: var(--accent); letter-spacing: .18em; font-size: 11px; font-weight: 850; margin: 0 0 6px; }
.page-head h1 { margin: 0; }
.page-head h1 img { display: block; width: clamp(155px, 15.5vw, 212px); height: auto; border: 2px solid #744424; border-radius: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.mode-tag { color: #5f5550; font-size: 13px; font-weight: 650; margin: 0 0 2px; }
.mode-tag span { color: var(--rust); padding: 0 4px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 372px); gap: 17px; align-items: start; }
.game, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; }
.arena-bar {
  display: grid; grid-template-columns: minmax(245px, 1.7fr) .7fr 1.08fr .55fr; align-items: center; gap: 10px;
  padding: 9px 13px; min-height: 59px; font-size: 13px; font-weight: 800;
}
.energy { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; }
.energy label { color: #ffe6af; }
.energy meter { flex: 1 1 auto; min-width: 0; width: 100%; max-width: 280px; height: 30px; }
.energy meter::-webkit-meter-bar { background: #493831; border: 1px solid #a68b73; border-radius: 0; }
.energy meter::-webkit-meter-optimum-value { background: repeating-linear-gradient(90deg, #80e3a2 0 10px, #5ec887 10px 12px); }
.energy meter::-webkit-meter-suboptimum-value { background: repeating-linear-gradient(90deg, #ffce60 0 10px, #d59a32 10px 12px); }
.energy meter::-webkit-meter-even-less-good-value { background: repeating-linear-gradient(90deg, #f4816b 0 10px, #d15d4b 10px 12px); }
#health { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
#round { text-align: center; }
#status { text-align: center; color: var(--accent); }
#remaining { text-align: right; color: var(--mint); }
.stage { position: relative; overflow: hidden; background: #6e492e; }
.radar {
  position: absolute; left: 10px; bottom: 10px; width: clamp(96px, 17%, 166px);
  padding: 4px; color: #fff0ca; border: 1px solid #806345; background: #2a211be8;
}
.radar span { display: block; padding: 0 3px 3px; font-size: 10px; font-weight: 800; }
#minimap { display: block; width: 100%; height: auto; background: #44382e; cursor: crosshair; }
#arena { display: block; width: 100%; height: clamp(410px, calc(100svh - 382px), 690px); touch-action: none; cursor: crosshair; }
#arena:focus-visible { outline-offset: -3px; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(155deg, #1e110d44, #1a161780);
}
.match-card {
  width: min(380px, 100%); border: 1px solid #5d5352; border-top: 3px solid var(--accent);
  border-radius: 4px; background: #28201cf5; padding: clamp(17px, 4vw, 27px);
  box-shadow: 0 18px 60px #1a0b0ec2;
}
.match-card h2 { margin: 5px 0 9px; font-size: clamp(26px, 4vw, 37px); line-height: 1.05; letter-spacing: -.04em; }
#overlay-copy { color: #bfccd7; line-height: 1.45; min-height: 2.75em; margin: 0 0 16px; font-size: 14px; }
#round-picker { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; font-size: 14px; font-weight: 700; }
select { border: 1px solid #4b5b69; border-radius: 6px; color: var(--ink); background: #253542; padding: 4px 13px; }
#match-action {
  width: 100%; color: #20221e; background: var(--accent); border: 0; border-radius: 7px;
  padding: 10px 13px; display: flex; justify-content: space-between; align-items: center; font-weight: 900;
}
#match-action:hover { background: #ffdc8c; }
#open-keys { width: 100%; margin-top: 8px; }
.arena-notice {
  position: absolute; left: 50%; bottom: 12px; translate: -50%; max-width: calc(100% - 20px);
  padding: 6px 12px; border-radius: 7px; border: 1px solid #697d82; text-align: center;
  pointer-events: none; background: #16212af0; font-size: 12px; font-weight: 700; color: var(--ink);
}
.controls { display: grid; grid-template-columns: .9fr 1.12fr 1fr 1fr; min-height: 56px; }
.controls button, .move {
  color: var(--ink); background: none; border: 0; border-inline-start: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 6px;
  white-space: nowrap; font-size: 13px; font-weight: 700; min-width: 0;
}
.move { border: 0; }
.controls button:last-child { border-end-end-radius: 5px; }
.controls button:hover { background: #46322a; }
.controls button:disabled { cursor: default; }
.controls button:disabled:hover { background: none; }
kbd { background: #0e1720; color: #e4e9ee; border: 1px solid #415363; border-radius: 4px; padding: 3px 5px; font: 750 11px "Segoe UI", system-ui, sans-serif; }
.controls small { color: var(--mint); font-size: 9px; font-variant-numeric: tabular-nums; font-weight: 800; }
.controls button:disabled small { color: var(--muted); }
.side { display: grid; gap: 14px; }
.panel { padding: 15px; min-width: 0; }
.league { border: 2px solid #8e5730; background: #28201b; }
.league-banner { overflow: hidden; aspect-ratio: 3.35; border-bottom: 2px solid #a16a34; }
.league-banner img, .victory-banner img { display: block; width: 100%; height: auto; }
.leader { display: flex; justify-content: space-between; font-size: 14px; background: #423128; border-radius: 3px; padding: 8px; margin: 10px 0 3px; }
.leader span { color: var(--muted); }
.leader strong { display: flex; align-items: center; gap: 5px; }
table { width: 100%; border-collapse: collapse; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
th, td { text-align: right; padding: 6px 7px; border-bottom: 1px solid #493b35; }
th:first-child, td:first-child { text-align: left; }
td:first-child { display: flex; align-items: center; gap: 8px; min-height: 24px; }
td:last-child { font-weight: 800; color: var(--accent); }
abbr[title] { text-decoration: none; }
.player td { background: #1b3b3d; font-weight: 750; }
.dot { width: 9px; height: 9px; display: inline-block; border-radius: 3px; flex: 0 0 9px; background: #fff; }
.dot-0 { background: #4ce9ca; } .dot-1 { background: #ff6c53; } .dot-2 { background: #ffcc53; } .dot-3 { background: #bb90ff; }
.dot-4 { background: #ff86bb; } .dot-5 { background: #59b8ff; } .dot-6 { background: #b9ea60; } .dot-7 { background: #ff9c4a; }
.score-rule { margin: 12px 0 0; padding: 9px 10px; border: 1px solid #956235; background: #493021; color: #fff0cc; font-size: 14px; font-weight: 800; line-height: 1.42; }
#event { color: var(--muted); font-size: 12px; margin: 10px 0 0; line-height: 1.45; }
#event { color: var(--ink); border-top: 1px solid #493b35; padding-top: 9px; min-height: 3em; }
dialog { color: var(--ink); background: var(--panel); border: 1px solid #a47858; }
dialog::backdrop { background: #21150ed4; }
#keys-dialog { width: min(390px, calc(100% - 25px)); border-top: 4px solid var(--accent); padding: 20px; }
#keys-dialog h2 { margin: 0; color: var(--accent); }
#keys-dialog p { color: var(--muted); font-size: 13px; }
.key-options, .dialog-actions { display: grid; gap: 7px; }
.key-options button { display: flex; align-items: center; justify-content: space-between; }
#keys-message { min-height: 2.4em; }
.dialog-actions { grid-template-columns: 1fr 1fr; }
.dialog-actions button:last-child, .victory-card button { color: #261b13; background: var(--accent); }
#victory { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #231a16fa; }
#victory[open] { display: grid; place-items: center; isolation: isolate; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.victory-card {
  position: relative; text-align: center; width: min(740px, calc(100% - 24px));
  max-height: calc(100% - 24px); overflow: auto; padding: 0 0 20px; z-index: 1;
  background: #322018; border: 2px solid #da8f38; box-shadow: 0 0 28px #67270d;
}
.victory-banner { overflow: hidden; aspect-ratio: 3.52; margin-bottom: 13px; }
.victory-card h2 { margin: 0 12px; color: #ffde89; font-size: clamp(30px, 6.5vw, 64px); line-height: 1; text-shadow: 3px 3px #793a25; }
.victory-card p { font: 750 clamp(14px, 2vw, 21px) ui-monospace, monospace; }
.victory-card button { font-size: 15px; padding: 12px 20px; }
@media (min-width: 1190px) {
  .panel { padding: 15px 15px 13px; }
  th, td { padding-block: 7px; }
}
@media (max-width: 850px) {
  main { width: calc(100% - 30px); margin-top: 20px; }
  .site-head { padding-inline: 15px; }
  .layout { grid-template-columns: minmax(0, 1fr) 252px; gap: 11px; }
  .side { gap: 11px; }
  .controls button, .move { gap: 5px; font-size: 11px; }
  .arena-bar { grid-template-columns: minmax(156px, 1.35fr) .8fr 1.2fr .7fr; gap: 6px; font-size: 12px; }
}
@media (max-width: 680px) {
  .site-head { min-height: 50px; }
  .brand img { width: 29px; height: 29px; }
  .mode-tag { display: none; }
  .page-head { margin-bottom: 14px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: 1fr; }
  #arena { height: clamp(340px, 56svh, 490px); }
  .controls { grid-template-columns: .8fr 1.2fr 1fr 1fr; }
  .controls button:focus-visible { outline-offset: -3px; }
}
@media (max-width: 430px) {
  .arena-bar { grid-template-columns: auto 1fr auto; padding: 7px 9px; font-size: 11px; }
  .energy { grid-column: 1 / -1; }
  .energy meter { max-width: none; }
  .radar { left: 5px; bottom: 7px; width: 91px; }
  .arena-notice { left: auto; right: 5px; translate: none; max-width: calc(100% - 107px); }
  .controls button, .move { flex-wrap: wrap; gap: 3px 5px; align-content: center; padding: 5px 2px; }
  .controls small { flex-basis: 100%; text-align: center; }
}
