:root {
  color-scheme: dark;
  --bg: #07101f;
  --surface: rgba(12,24,43,.96);
  --surface2: #15233b;
  --line: rgba(167,195,255,.2);
  --text: #f6f8ff;
  --muted: #a4b1c8;
  --blue: #28b6ff;
  --red: #ff5075;
  --cell-blue: #116fa6;
  --cell-red: #ac294b;
  --capital-blue: #063b60;
  --capital-red: #641126;
  --neutral: #2e3d56;
  --cell-stroke: rgba(166,192,230,.28);
  --stage-blue-edge: rgba(9,79,139,.34);
  --stage-red-cross: rgba(123,24,58,.23);
  --stage-red-edge: rgba(147,26,65,.33);
  --stage-blue-cross: rgba(11,75,132,.23);
  --grid-line: rgba(104,158,214,.11);
  --bronze: #c98c54;
  --silver: #d8e0ec;
  --gold: #f7c84c;
  --shadow: 0 12px 40px rgba(0,0,0,.25);
  font-family: Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #e9f0f8;
  --surface: rgba(255,255,255,.97);
  --surface2: #f1f5fa;
  --line: rgba(31,57,97,.2);
  --text: #14223a;
  --muted: #5d6c83;
  --blue: #087fbb;
  --red: #c92a50;
  --cell-blue: #0c6798;
  --cell-red: #9e2949;
  --capital-blue: #074366;
  --capital-red: #71182f;
  --neutral: #8293aa;
  --cell-stroke: rgba(25,49,81,.48);
  --stage-blue-edge: rgba(15,105,164,.22);
  --stage-red-cross: rgba(159,42,78,.15);
  --stage-red-edge: rgba(183,42,78,.21);
  --stage-blue-cross: rgba(12,91,151,.15);
  --grid-line: rgba(43,68,102,.16);
  --shadow: 0 12px 36px rgba(32,54,88,.14);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); overflow: hidden; }
button,select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible,select:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.arena-information { display: contents; }
.app-shell { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto auto minmax(0,1fr); }

.arena-header { display: grid; grid-template-columns: minmax(235px,1fr) auto minmax(235px,1fr); align-items: center; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 10; }
.team-score { display: flex; align-items: center; gap: 16px; }
.team-score.red { justify-content: flex-end; text-align: right; }
.team-score strong { display: block; font-size: clamp(1.1rem,2vw,1.65rem); font-weight: 950; letter-spacing: .05em; }
.team-score.blue strong,.blue-text { color: var(--blue); }
.team-score.red strong,.red-text { color: var(--red); }
.team-score span { display: block; margin-top: 3px; color: var(--muted); font-size: .8rem; }
.team-score b { font-size: 2.2rem; font-variant-numeric: tabular-nums; }
.team-score small { font-size: .92rem; font-weight: 800; }
.match-center { text-align: center; padding: 0 18px; border-inline: 1px solid var(--line); }
.phase-line { display: flex; align-items: center; justify-content: center; gap: 12px; }
.phase-line>span:first-child { font-size: .75rem; letter-spacing: .08em; font-weight: 900; color: #07101f; background: #91efff; padding: 5px 8px; border-radius: 6px; }
.phase-line>span:first-child[data-phase="results"] { background: var(--gold); }
.phase-line strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.phase-line strong.is-urgent { border-radius: 5px; animation: urgencyBlink 1s steps(1,end) infinite; }
@keyframes urgencyBlink { 0%,100% { color: #fff; background: #bb193b; box-shadow: 0 0 0 4px #bb193b; } 50% { color: #bb193b; background: #fff; box-shadow: 0 0 0 4px #fff; } }
.phase-line>span:last-child { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.live-line { display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.live-line i { width: 6px; height: 6px; border-radius: 50%; background: #45df8a; }
.territory-row { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 9px 20px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 9; }
.territory-track { width: min(620px,55vw); height: 8px; border-radius: 99px; display: flex; overflow: hidden; background: var(--neutral); }
.territory-track span,.territory-track i { display: block; transition: width .5s ease; }
.territory-track span:first-child { background: var(--blue); }
.territory-track span:last-child { background: var(--red); }
.territory-track i { background: var(--neutral); }
.territory-row>span { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.territory-row .trend-text { padding-left: 14px; border-left: 1px solid var(--line); font-weight: 800; }
.territory-row .blue-trend { color: var(--blue); }
.territory-row .red-trend { color: var(--red); }

.arena-stage { position: relative; overflow: hidden; background: var(--bg); }
.stage-grid { position: absolute; inset: 0; background-image:
  linear-gradient(90deg,var(--stage-blue-edge) 0%,var(--stage-red-cross) 43%,transparent 51%),
  linear-gradient(270deg,var(--stage-red-edge) 0%,var(--stage-blue-cross) 43%,transparent 51%),
  linear-gradient(var(--grid-line) 1px,transparent 1px),
  linear-gradient(90deg,var(--grid-line) 1px,transparent 1px);
  background-size: 100% 100%,100% 100%,42px 42px,42px 42px;
}
.arena-toolbar { position: relative; z-index: 10; display: grid; grid-template-columns: 135px minmax(0,1fr) auto; align-items: center; gap: 16px; padding: 12px 18px; background: var(--bg); border-bottom: 1px solid var(--line); }
.round-status { min-height: 110px; display: grid; align-items: center; }
.brand-chip { display: flex; align-items: center; gap: 9px; font-weight: 900; letter-spacing: .08em; }
.brand-chip>b { display: grid; place-items: center; width: 34px; height: 34px; color: #07101f; background: #90eaff; clip-path: polygon(25% 6%,75% 6%,100% 50%,75% 94%,25% 94%,0 50%); }
.brand-chip small { color: var(--muted); font-size: .75rem; }
.utility-bar { display: flex; align-items: end; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.utility-bar label { display: grid; gap: 3px; font-size: .75rem; color: var(--muted); }
.utility-bar select { border: 1px solid var(--line); border-radius: 6px; background: var(--surface2); padding: 6px; font-size: .82rem; }
.utility-bar button,.utility-bar .lab-link,.map-controls button { border: 1px solid var(--line); border-radius: 7px; background: var(--surface2); min-width: 36px; min-height: 36px; padding: 5px 9px; font-size: .82rem; }
.utility-bar button { display: grid; place-items: center; }
.utility-bar .lab-link { display:grid;place-items:center;text-decoration:none;font-weight:800;white-space:nowrap; }
.utility-bar button svg { width: 20px; height: 20px; }

#arenaMap { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; cursor: grab; }
#arenaMap.dragging { cursor: grabbing; }
.hex { cursor: pointer; outline: none; }
.hex .cell-fill { stroke: var(--cell-stroke); stroke-width: .7; transition: fill .55s ease,filter .2s; }
.hex.available .cell-fill { stroke: rgba(145,239,255,.65); stroke-width: .95; }
.arena-stage:not(.is-results) .hex:hover .cell-fill,.arena-stage:not(.is-results) .hex:focus-visible .cell-fill { filter: brightness(1.25); stroke: #fff; stroke-width: 1.2; }
.hex .cell-border { pointer-events: none; }
.castle-icon { fill: #f2f6ff; stroke: none; pointer-events: none; }
.hex.capital .cell-fill { stroke: rgba(206,224,255,.7); stroke-width: 1.1; }
.selection-ring { fill: none; stroke: #66f0a9; stroke-width: 1.1; pointer-events: none; display: none; }
.hex.selected .selection-ring { display: block; }
.selection-icon { color: #fff; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.8)); }
.is-analysis .hex .cell-fill { filter: saturate(.72) brightness(.72); }
.heat-ring { display: none; pointer-events: none; transform-box: fill-box; transform-origin: center; }
.hex.heat-active .heat-ring { fill: rgba(184,219,255,.12); stroke: rgba(220,235,255,.9); stroke-width: 1.05; }
.hex.heat-contested .heat-ring { fill: rgba(255,189,89,.2); stroke: #ffbd59; stroke-width: 1.65; filter: drop-shadow(0 0 2px rgba(255,189,89,.9)); animation: heatPulse 1.7s ease-in-out infinite; }
.hex.heat-critical .heat-ring { fill: rgba(255,74,62,.28); stroke: #ff5d48; stroke-width: 2.15; filter: drop-shadow(0 0 3px rgba(255,80,62,.95)); animation: heatCritical 1.05s ease-in-out infinite; }
.analysis-icon { display: none; color: #fff; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.95)); }
.heat-arrow { display: none; pointer-events: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 1px rgba(0,0,0,.9)); }
.heat-arrow.source-team-0 { stroke: #7bd7ff; }
.heat-arrow.source-team-1 { stroke: #ff7391; }
.is-analysis .player-marker { opacity: .62; }
.player-marker { pointer-events: none; transition: transform .65s ease; }
.player-disc { fill: #102c24; stroke: #87ffd0; stroke-width: .65; }
.player-person { fill: #fff; }
.outcome-icon { color: #fff; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.8)); }
.breach-mark{display:none;pointer-events:none;stroke:#fff2a8;stroke-width:1.35;stroke-linecap:round;stroke-linejoin:round;filter:drop-shadow(0 0 1.6px rgba(255,84,65,.95))}
.hex.revealed .cell-fill { animation: revealPulse 1.1s ease-out; }
@keyframes revealPulse { 0% { filter: brightness(1); } 35% { filter: brightness(1.7); } 100% { filter: brightness(1); } }
@keyframes heatPulse { 0%,100% { opacity: .55; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.04); } }
@keyframes heatCritical { 0%,100% { opacity: .7; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.065); } }

.map-controls { position: absolute; z-index: 6; left: 50%; bottom: 17px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; max-width: calc(100% - 20px); padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.map-controls .analysis-toggle { min-width: 148px; white-space: nowrap; font-weight: 800; }
.map-controls .analysis-toggle[aria-pressed="true"] { color: #101722; border-color: #ffbd59; background: #ffbd59; }
.legend { position: absolute; z-index: 5; bottom: 20px; left: 14px; display: flex; gap: 12px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: .8rem; color: var(--muted); white-space: nowrap; }
.legend span { display: flex; gap: 5px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--neutral); }
.legend .bronze { background: var(--bronze); }
.legend .silver { background: var(--silver); }
.legend .gold { background: var(--gold); }
.rights-hud,.selection-hud { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 14px; }
.rights-hud { position: absolute; z-index: 6; bottom: 16px; right: 14px; width: 200px; }
.rights-hud>span,.selection-hud>span { font-size: .75rem; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.rights-hud>strong { font-size: 1.6rem; margin-left: 8px; }
.rights-hud>strong.is-low { display: inline-block; border-radius: 4px; animation: urgencyBlink 1.4s steps(1,end) infinite; }
.rights-hud>strong.is-empty { color: var(--red); }
.rights-hud>div { display: grid; grid-template-columns: repeat(10,1fr); gap: 3px; margin: 7px 0; }
.rights-hud i { aspect-ratio: 1; border-radius: 50%; background: var(--neutral); }
.rights-hud i.on { background: var(--blue); }
.rights-hud small,.selection-hud small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.rights-hud button { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface2); padding: 7px; font-size: .8rem; font-weight: 800; }
.selection-hud { width: 100%; text-align: center; padding: 9px 12px; }
.selection-hud strong { display: flex; justify-content: center; align-items: center; gap: 7px; margin: 5px 0; font-size: .95rem; }
.selection-hud svg { width: 21px; height: 21px; flex-shrink: 0; }
.selection-hud[aria-hidden="true"] { display: none; }

.cell-sheet { position: absolute; z-index: 12; left: 50%; bottom: 154px; transform: translateX(-50%); width: min(620px,calc(100% - 24px)); display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 16px 42px 16px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.sheet-close { position: absolute; right: 10px; top: 7px; border: 0; background: transparent; font-size: 1.5rem; color: var(--muted); width: 28px; height: 28px; }
.sheet-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 11px; background: var(--surface2); color: var(--blue); }
.sheet-icon svg { width: 30px; height: 30px; }
.sheet-copy span { display: block; color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .05em; }
.sheet-copy strong { display: block; margin: 3px 0; font-size: 1rem; }
.sheet-copy small { color: var(--muted); font-size: .875rem; line-height: 1.4; }
.sheet-actions { display: flex; gap: 9px; grid-column: 1/-1; }
.sheet-actions:empty { display: none; }
.sheet-actions button { display: flex; justify-content: center; align-items: center; gap: 8px; flex: 1; border: 1px solid var(--line); border-radius: 9px; background: var(--surface2); padding: 11px 14px; font-size: .92rem; font-weight: 800; }
.sheet-actions svg { width: 23px; height: 23px; }
.sheet-actions .primary { color: #062337; background: #91eaff; border-color: transparent; }
.sheet-actions .primary:disabled { opacity: .65; color: var(--muted); background: var(--surface2); }
.sheet-actions .danger { color: var(--red); }
.sheet-actions .danger:hover { background: rgba(255,80,117,.08); }

.result-ribbon { width: 100%; text-align: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.result-ribbon>span { display: block; color: var(--muted); font-size: .75rem; letter-spacing: .07em; font-weight: 850; }
.result-ribbon>strong { display: block; font-size: 1.12rem; line-height: 1.4; margin: 3px 0; }
.result-ribbon>small { display: block; color: var(--muted); font-size: .85rem; line-height: 1.35; }
.result-ribbon>small:empty { display: none; }
.result-numbers { display: flex; justify-content: center; gap: 18px; font-size: .9rem; margin-top: 5px; }
.result-numbers:empty { display: none; }
.cell-result { position: absolute; z-index: 9; pointer-events: none; transform: translate(-50%,-100%); min-width: 180px; padding: 9px 13px; text-align: center; border: 1px solid #62e3ac; border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.cell-result::after { content: ''; position: absolute; top: 100%; left: calc(50% - 5px); border-top: 6px solid #62e3ac; border-inline: 5px solid transparent; }
.cell-result>span { display: block; font-weight: 900; font-size: .82rem; color: #62e3ac; letter-spacing: .04em; }
.cell-result small { display: block; margin-top: 3px; font-size: .875rem; }
.cell-result[data-verdict="loss"] { border-color: var(--red); }
.cell-result[data-verdict="loss"]>span { color: var(--red); }
.cell-result[data-verdict="loss"]::after { border-top-color: var(--red); }
.cell-result[data-verdict="tie"] { border-color: var(--gold); }
.cell-result[data-verdict="tie"]>span { color: var(--gold); }
.cell-result[data-verdict="tie"]::after { border-top-color: var(--gold); }
html[data-theme="light"] .cell-result[data-verdict="success"]>span { color: #097547; }

.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3,8,17,.86); }
.team-modal { width: min(680px,100%); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); text-align: center; box-shadow: var(--shadow); }
.eyebrow { font-size: .82rem; letter-spacing: .12em; font-weight: 900; color: var(--blue); }
.team-modal h1,.team-modal h2 { margin: 9px 0 12px; font-size: clamp(1.8rem,5vw,2.55rem); line-height: 1.18; }
.team-modal>p { color: var(--muted); margin: 0 auto 23px; max-width: 520px; line-height: 1.55; font-size: 1rem; }
.team-modal>p.gameplay-note { font-size: .9rem; padding: 12px; background: var(--surface2); border-radius: 10px; }
.team-options { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.team-option { padding: 27px 10px; border: 2px solid var(--line); border-radius: 15px; background: var(--surface2); }
.team-option span { display: block; font-size: 1.45rem; font-weight: 950; letter-spacing: .045em; }
.team-option.blue span { color: var(--blue); }
.team-option.red span { color: var(--red); }
.team-option.blue.selected { border-color: var(--blue); background: rgba(32,173,243,.12); }
.team-option.red.selected { border-color: var(--red); background: rgba(240,68,104,.12); }
.versus { font-weight: 950; color: var(--muted); font-size: .875rem; }
.choice-confirm { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.choice-confirm p { margin: 0 0 12px; line-height: 1.5; }
.choice-confirm small { color: var(--muted); font-size: .9rem; }
.choice-confirm button,.end-modal button { border: 0; border-radius: 10px; padding: 13px 17px; color: #062337; background: #91eaff; font-weight: 900; font-size: .9rem; }
#enterArenaBtn[data-team="0"]{background:var(--blue);color:var(--bg)}
#enterArenaBtn[data-team="1"]{background:var(--red);color:var(--bg)}
.prototype-note { display: block; color: var(--muted); margin-top: 18px; font-size: .8rem; }
.welcome-overlay { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--text); text-align: center; }
.welcome-overlay span { font-size: clamp(2.5rem,9vw,6rem); font-weight: 950; letter-spacing: .04em; }
.welcome-overlay p { margin: 4px 0; color: var(--muted); font-size: 1.1rem; }
.end-modal #finalScore { font-size: 1.25rem; line-height: 1.8; margin: 18px 0; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translate(-50%,18px); opacity: 0; width: max-content; max-width: calc(100% - 30px); text-align: center; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface2); box-shadow: var(--shadow); transition: .2s; pointer-events: none; font-size: .875rem; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media(max-width:960px) {
  .arena-header { grid-template-columns: 1fr 1fr; padding: 11px 15px; gap: 10px; }
  .match-center { grid-row: 2; grid-column: 1/-1; border-inline: 0; border-top: 1px solid var(--line); padding: 8px 0 0; }
  .team-score { gap: 12px; }
  .team-score b { font-size: 1.8rem; }
  .team-score strong { font-size: 1.1rem; }
  .territory-row { flex-direction: column; gap: 5px; padding: 7px 14px; }
  .territory-track { width: 100%; }
  .territory-row>span { font-size: .78rem; }
  .territory-row .trend-text { padding-left: 0; border-left: 0; }
  .arena-toolbar { grid-template-columns: 1fr auto; gap: 8px; padding: 10px 14px; }
  .round-status { grid-column: 1/-1; grid-row: 1; min-height: 110px; }
  .brand-chip { grid-column: 1; grid-row: 2; }
  .utility-bar { grid-column: 2; grid-row: 2; }
  .legend { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; bottom: 16px; }
}
@media(max-width:600px) {
  .app-shell { height: 100dvh; min-height: 720px; }
  body { overflow-y: auto; }
  .arena-header { padding: 8px 11px; }
  .team-score { gap: 7px; }
  .team-score span { font-size: .75rem; }
  .team-score b { font-size: 1.65rem; }
  .team-score small { font-size: .8rem; }
  .arena-toolbar { display: grid; grid-template-columns: 1fr; padding: 8px 10px; gap: 7px; }
  .round-status { min-height: 110px; }
  .brand-chip { display: none; }
  .utility-bar { grid-column: 1; grid-row: 2; justify-content: center; gap: 5px; padding: 5px; }
  .utility-bar label { font-size: .7rem; }
  .utility-bar label>select { padding: 6px 3px; font-size: .75rem; width: 90px; }
  .utility-bar label:first-child>select { width: 67px; }
  .utility-bar button { font-size: .75rem; padding: 5px 6px; min-width: 28px; }
  .utility-bar .lab-link { min-height:32px;padding:5px 6px;font-size:.72rem; }
  .utility-bar #resetBtn { font-size: 1rem; }
  .rights-hud { right: 10px; bottom: 57px; width: min(154px,calc(50% - 16px)); padding: 9px 10px; }
  .rights-hud>span { font-size: .7rem; }
  .rights-hud>strong { font-size: 1.25rem; }
  .rights-hud small { font-size: .75rem; }
  .rights-hud button { font-size: .75rem; padding: 6px 3px; }
  .selection-hud { padding: 8px 10px; text-align: center; }
  .selection-hud>span { font-size: .7rem; }
  .selection-hud strong { font-size: .85rem; }
  .selection-hud small { font-size: .75rem; }
  .map-controls { bottom: 10px; }
  .map-controls button { min-height: 32px; min-width: 29px; padding: 5px 7px; font-size: .75rem; }
  .map-controls .analysis-toggle { flex-basis: 100%; min-width: 0; }
  .legend { left: 10px; bottom: 60px; width: calc(50% - 16px); padding: 7px; gap: 7px; font-size: .68rem; }
  .legend i { width: 8px; height: 8px; }
  .legend span { gap: 4px; }
  .cell-sheet { bottom: 192px; padding: 12px 38px 12px 12px; gap: 9px; max-height: calc(100% - 205px); overflow-y: auto; }
  .sheet-icon { width: 37px; height: 37px; }
  .sheet-copy small { font-size: .85rem; }
  .sheet-actions button { padding: 10px 7px; font-size: .85rem; }
  .result-ribbon { padding: 8px 10px; }
  .result-ribbon>strong { font-size: 1rem; }
  .result-ribbon>small { font-size: .8rem; }
  .result-numbers { gap: 10px; font-size: .8rem; }
  .team-modal { padding: 24px 16px; }
  .team-options { gap: 8px; }
  .team-option { padding: 24px 6px; }
  .team-option span { font-size: 1.15rem; }
}

.brand-chip { color: inherit; text-decoration: none; }
.team-score { min-width: 0; }
.team-score > div { min-width: 0; }
.team-score strong { overflow-wrap: anywhere; }
