:root {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
  color: #e7edf7;
  background: #090e18;
  line-height: 1.5;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
summary { cursor: pointer; }
button { border: 1px solid transparent; border-radius: 10px; padding: 12px 20px; color: #10191e; background: #8aead0; font-weight: 750; cursor: pointer; transition: background 150ms, transform 150ms; }
button:hover:not(:disabled) { background: #b0f5e2; transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary { background: #162134d9; border-color: #39485e; color: #e7edf7; }
button.secondary:hover:not(:disabled) { background: #27344b; }
button[aria-pressed="true"] { border-color: #8aead0; }
button.quiet { background: transparent; color: #a6b4c8; }
button.quiet:hover:not(:disabled) { background: #ffffff0a; color: white; }
button.icon-button { padding: 2px 12px; background: transparent; color: #a6b4c8; font-size: 1.8rem; }
button.wide { width: 100%; }
:focus-visible { outline: 2px solid #8aead0; outline-offset: 4px; }
h1, h2, h3, p { margin: 0 0 16px; }
h2 { font-size: 1.55rem; letter-spacing: -0.035em; line-height: 1.2; }
.muted { color: #8f9fb5; }
.eyebrow { display: block; color: #8f9fb5; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.wordmark { font-weight: 850; letter-spacing: -0.07em; line-height: 1; }
.wordmark > span { color: #ffad77; }
.room-code { font-family: ui-monospace, monospace; letter-spacing: 0.16em; user-select: all; }
kbd { display: inline-block; font: inherit; font-size: 0.85em; color: #c8d6e7; border: 1px solid #47556c; border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; }
.panel { background: #131c2beF; border: 1px solid #2a374d; border-radius: 20px; box-shadow: 0 24px 90px #0005; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.panel-heading p, .panel-heading h2 { margin: 0; }
.panel-heading .eyebrow { margin-bottom: 6px; }
.error { padding: 12px 16px; background: #512c34; border: 1px solid #a66571; color: #ffe4e9; border-radius: 10px; }
.waiting { color: #8f9fb5; font-size: 0.85rem; text-align: center; margin: 14px 0 0; }

.entry-page { min-height: 100dvh; padding: 55px 20px 30px; background: radial-gradient(ellipse at 50% 0, #24304b 0, transparent 65%); }
.entry-heading { text-align: center; margin-bottom: 32px; }
.entry-heading .wordmark { font-size: clamp(3.2rem, 8vw, 5.5rem); margin: 18px 0; }
.entry-heading > p:last-child { color: #a6b4c8; }
.entry-panel { max-width: 510px; margin: 0 auto; padding: 30px; }
.entry-panel h2.room-code { color: #8aead0; font-size: 1.9rem; }
.connection-count { color: #8f9fb5; font-size: 0.85rem; white-space: nowrap; }
.lobby-actions { display: flex; justify-content: space-between; margin-top: 8px; }
.ability-selector { min-width: 0; margin: 0 0 24px; padding: 0; border: 0; }
.ability-selector legend { font-size: 0.85rem; font-weight: 650; margin-bottom: 10px; }
.ability-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ability-options button { flex: 1; padding: 10px 12px; white-space: nowrap; font-size: 0.8rem; }
.ability-options button[aria-pressed="true"] { background: #274a46; color: #b0f5e2; }
.ability-selector p { font-size: 0.75rem; margin: 10px 0 0; }
.ability-lock { font-size: 0.7rem; color: #a6b4c8; margin: 0; }
form { display: grid; gap: 9px; margin-top: 26px; }
label { font-size: 0.85rem; font-weight: 650; }
input { width: 100%; min-width: 0; color: #e7edf7; background: #0c1422; border: 1px solid #3b4a60; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
input::placeholder { color: #687991; }
.entry-instructions { color: #7e90a9; text-align: center; line-height: 2; font-size: 0.8rem; margin: 25px auto 0; }
.roster { list-style: none; padding: 0; margin: 20px 0 26px; }
.roster li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #29364b; }
.roster-name { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.roster strong { color: var(--player-color); overflow-wrap: anywhere; }
.tag { display: inline-block; color: #9dacbf; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.player-status { color: #8f9fb5; font-size: 0.75rem; }
.roster .player-status > * { display: block; }
.holder { color: #ffcf86; }
.player-ability, .player-effects { font-size: 0.7rem; }
.avatar-swatch { display: inline-block; width: 19px; height: 26px; flex: 0 0 19px; border-radius: 6px; background: var(--player-color); box-shadow: inset 0 3px #ffffff40, 0 3px 10px #0003; position: relative; }
.avatar-swatch::after { content: ""; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #142030; top: 10px; left: 9px; box-shadow: 5px 0 #142030; }
.out { opacity: 0.4; }

.game-page { position: fixed; inset: 0; height: 100dvh; overflow: hidden; background: #090e18; }
.arena { position: absolute; inset: 0; }
.arena:focus-visible { outline: none; }
.arena:focus-visible ~ .game-controls { color: #b1dbcf; }
.arena-world { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(100vw, calc(100dvh * var(--arena-ratio))); aspect-ratio: var(--arena-ratio); overflow: hidden; container-type: inline-size; }
.arena canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.arena-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.player-label { position: absolute; transform: translate(-50%, -100%); font-size: clamp(9px, 0.875cqw, 14px); line-height: 1.3; white-space: nowrap; color: var(--player-color); background: #090e18b8; border-radius: 0.3cqw; padding: 0.15cqw 0.4cqw; text-shadow: 0 1px 3px #000; }
.holder-label { display: block; color: #fff; text-align: center; letter-spacing: 0.08em; }
.player-effect-label { display: block; color: #e7edf7; text-align: center; }
.ability-label { display: block; color: #b8f4ff; text-align: center; font-weight: 700; border-top: 1px solid #78dfffa0; margin-top: 3px; padding-top: 2px; }
.environment-label { position: absolute; transform: translate(-50%, -100%); color: #e7edf7; background: #090e18dc; padding: 0.1cqw 0.4cqw; font-size: clamp(8px, 0.85cqw, 14px); white-space: nowrap; }
.arena.smooth .player-label:not(.out) { transition: left var(--movement-duration) linear, top var(--movement-duration) linear; }
.game-hud { position: absolute; inset: 24px 28px auto; z-index: 3; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.hud-room { display: grid; gap: 7px; }
.hud-room .wordmark { font-size: 1.6rem; }
.hud-room .room-code { font-size: 0.75rem; color: #a6b4c8; }
.hud-room .eyebrow { margin-top: 4px; }
.hud-actions { display: flex; gap: 5px; pointer-events: auto; }
.hud-actions button { font-size: 0.75rem; padding: 8px 12px; }
.hud-actions kbd { margin-left: 4px; }
.match-timer { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); z-index: 2; width: min(360px, 45vw); text-align: center; pointer-events: none; color: #f1f4fc; }
.match-timer .eyebrow { color: currentColor; opacity: 0.65; margin: 0; }
.timer-value { display: block; font-size: clamp(2.8rem, 5.5vw, 5rem); font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -0.055em; line-height: 1.05; transform-origin: center; animation: timer-tick 220ms ease-out; }
.timer-value small { font-size: 0.3em; font-weight: 600; letter-spacing: 0; margin-left: 3px; }
.timer-holder { display: block; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 7px; }
.match-timer.warm { color: #ffe28a; }
.match-timer.hot { color: #ffab69; }
.match-timer.critical { color: #ff647c; }
.match-timer.hot .timer-value { animation: urgent-pulse 800ms ease-in-out infinite; }
.match-timer.critical .timer-value { animation: urgent-pulse 380ms ease-in-out infinite; text-shadow: 0 0 28px #ff526b70; }
.match-status, .arena-info { position: absolute; z-index: 3; bottom: 58px; color: #e7edf7; background: #101929ee; border: 1px solid #39485e; border-radius: 12px; padding: 12px 16px; font-size: 0.75rem; max-height: 45dvh; overflow: auto; }
.match-status { left: 20px; top: 150px; bottom: auto; width: 260px; }
.ability-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ability-status h2 { font-size: 0.95rem; margin: 0; }
.ability-cooldown { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 10px; }
.ability-cooldown > span { color: #c8d6e7; font-weight: 700; }
.ability-cooldown > strong { color: #b8f4ff; font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cooldown-meter { display: block; width: 100%; height: 10px; margin-top: 6px; border: 1px solid #78dfff; border-radius: 5px; overflow: hidden; background: #20344c; accent-color: #78dfff; appearance: none; }
.cooldown-meter::-webkit-progress-bar { background: #20344c; }
.cooldown-meter::-webkit-progress-value { background: #78dfff; }
.cooldown-meter::-moz-progress-bar { background: #78dfff; }
.ability-charge { font-size: 1.05rem; color: #b8f4ff; font-weight: 750; }
.ability-status p { margin: 6px 0; }
.ability-state { color: #8aead0; font-weight: 750; }
.ability-resources { display: flex; gap: 18px; margin: 10px 0; font-variant-numeric: tabular-nums; }
.ability-resources dt { color: #a6b4c8; font-size: 0.65rem; }
.ability-resources dd { margin: 0; font-weight: 750; }
.ability-help { color: #a6b4c8; font-size: 0.7rem; }
.match-roster { border-top: 1px solid #39485e; padding-top: 8px; margin-top: 10px; }
.match-roster .roster { margin: 0; }
.match-roster .roster li { align-items: flex-start; flex-direction: column; gap: 6px; padding: 10px 0; }
.arena-info { right: 20px; top: 82px; bottom: auto; max-width: 290px; }
.arena-info p { margin: 10px 0 0; }
.arena-legend { list-style: none; margin: 12px 0; padding: 0; }
.arena-legend li { margin: 4px 0; }
.arena-legend span { display: inline-block; width: 20px; text-align: center; }
.game-controls { position: absolute; bottom: 16px; left: 0; right: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 20px; color: #7c8ba1; font-size: 0.7rem; pointer-events: none; }
.spectator-banner { position: absolute; bottom: 62px; left: 50%; transform: translateX(-50%); white-space: nowrap; margin: 0; color: #bdc9da; background: #172237ed; border: 1px solid #354660; padding: 8px 18px; border-radius: 30px; font-size: 0.85rem; }
.game-notice { position: absolute; z-index: 7; top: 145px; left: 50%; transform: translateX(-50%); max-width: min(550px, 90vw); }
.phase-overlay, .scoreboard-overlay { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 24px; background: #090e1860; backdrop-filter: blur(3px); }
.phase-card { max-width: 620px; text-align: center; padding: 34px; }
.phase-card > h2 { font-size: clamp(2.2rem, 5vw, 4rem); margin-bottom: 12px; }
.phase-card > p { color: #b2c0d3; }
.phase-card > .eyebrow { color: #8aead0; }
.phase-card > .muted { font-size: 0.8rem; }
.countdown-number { display: block; font-size: clamp(5rem, 14vw, 9rem); font-weight: 850; line-height: 1.1; letter-spacing: -0.06em; color: #8aead0; margin: 10px 0 20px; animation: countdown-pop 350ms ease-out; }
.result-card { width: min(750px, 100%); max-width: 750px; max-height: 100%; overflow: auto; }
.result-card .result-title { color: var(--player-color); overflow-wrap: anywhere; font-size: clamp(1.8rem, 4vw, 3rem); }
.result-card .scoreboard { width: 100%; max-height: none; margin: 22px auto 0; text-align: left; box-shadow: none; }
.result-card .scoreboard td { padding-top: 12px; padding-bottom: 12px; }
.result-card button { display: block; margin: 18px auto 0; }
.scoreboard-overlay { position: fixed; z-index: 5; background: #090e18a0; backdrop-filter: blur(6px); }
.scoreboard { width: min(660px, 100%); max-height: calc(100dvh - 48px); overflow: auto; padding: 28px; }
.scoreboard table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scoreboard th { font-size: 0.68rem; font-weight: 650; letter-spacing: 0.04em; color: #8193ac; padding: 12px 6px; border-bottom: 1px solid #33415a; }
.scoreboard td { text-align: center; padding: 18px 6px; border-bottom: 1px solid #26344a; }
.scoreboard th:first-child, .scoreboard td:first-child { text-align: left; }
.scoreboard td:not(:first-child) { width: 12%; }
.score-player { display: flex; align-items: center; gap: 12px; }
.score-player strong { color: var(--player-color); font-size: 0.9rem; overflow-wrap: anywhere; }
.score-player .tag { margin-left: 5px; }
.score-player .player-status { display: block; margin-top: 3px; }
.scoreboard .local-row { background: color-mix(in srgb, var(--player-color) 7%, transparent); }
.scoreboard .wins { color: #8aead0; font-weight: 750; }
.scoreboard-note { color: #7e90a9; font-size: 0.7rem; margin: 18px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; z-index: 10; width: 100%; padding: 16px; background: #512c34; }
#blazor-error-ui a { color: white; }

.high-contrast { color: #fff; background: #000; }
.high-contrast :is(.panel, .phase-card, .spectator-banner, input, .error) { color: #fff; background: #000; border: 1px solid #fff; box-shadow: none; }
.high-contrast .player-label { background: #000; }
.high-contrast :is(.match-status, .arena-info, .environment-label) { color: #fff; background: #000; border-color: #fff; }
.high-contrast :is(.ability-state, .ability-help, .ability-resources dt, .player-effect-label) { color: #fff; }
.high-contrast .match-roster { border-color: #fff; }
.high-contrast :is(.ability-label, .ability-charge, .ability-cooldown > strong) { color: #ff0; border-color: #ff0; }
.high-contrast .ability-cooldown > span { color: #fff; }
.high-contrast .cooldown-meter { background: #000; border-color: #ff0; accent-color: #ff0; }
.high-contrast .cooldown-meter::-webkit-progress-bar { background: #000; }
.high-contrast .cooldown-meter::-webkit-progress-value { background: #ff0; }
.high-contrast .cooldown-meter::-moz-progress-bar { background: #ff0; }
.high-contrast :is(.muted, .eyebrow, .tag, .player-status, .waiting, .connection-count, .entry-instructions, .game-controls, .scoreboard-note, .scoreboard th, .hud-room .room-code, .entry-heading > p, .phase-card > p) { color: #fff; }
.high-contrast :is(.wordmark > span, .entry-panel h2.room-code, .countdown-number, .scoreboard .wins, .holder, .holder-label, .match-timer) { color: #ff0; }
.high-contrast :is(.out, .match-timer .eyebrow) { opacity: 1; }
.high-contrast :is(.roster li, .scoreboard th, .scoreboard td, kbd) { border-color: #fff; }
.high-contrast kbd, .high-contrast input::placeholder, .high-contrast .ability-lock { color: #fff; }
.high-contrast .scoreboard .local-row { background: #222; }
.high-contrast :is(.phase-overlay, .scoreboard-overlay) { background: #000b; }
.high-contrast .match-timer.critical .timer-value { text-shadow: none; }
.high-contrast button { color: #000; background: #fff; border-color: #fff; }
.high-contrast button kbd { color: inherit; border-color: currentColor; }
.high-contrast button:hover:not(:disabled), .high-contrast button[aria-pressed="true"] { background: #ff0; color: #000; }
.high-contrast button:disabled { opacity: 1; color: #bbb; background: #000; border-style: dashed; }
.high-contrast :focus-visible { outline-color: #ff0; }

@media (max-width: 900px) {
  .hud-actions { flex-direction: column; align-items: flex-end; }
  .arena-info { top: 150px; }
}

@keyframes timer-tick { from { transform: scale(1.1); } to { transform: scale(1); } }
@keyframes urgent-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1) rotate(-1deg); } }
@keyframes countdown-pop { from { opacity: 0; transform: scale(1.3); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 650px) {
  .entry-page { padding: 32px 16px 24px; }
  .entry-panel { padding: 24px 20px; }
  .entry-heading .eyebrow { font-size: 0.6rem; }
  .game-hud { inset: 14px 12px auto; }
  .hud-room .wordmark { font-size: 1.1rem; }
  .hud-room .room-code { font-size: 0.65rem; }
  .hud-actions { flex-direction: column; align-items: flex-end; }
  .hud-actions button { font-size: 0.65rem; padding: 6px 8px; }
  .hud-actions kbd { display: none; }
  .match-timer { top: 15px; width: 42vw; }
  .match-timer .eyebrow { font-size: 0.55rem; }
  .timer-holder { font-size: 0.5rem; }
  .match-status, .arena-info { top: auto; bottom: 90px; padding: 8px; font-size: 0.65rem; }
  .match-status { left: 8px; width: 46vw; }
  .ability-resources { gap: 10px; margin: 6px 0; }
  .ability-status p { margin: 4px 0; }
  .match-roster { margin-top: 6px; padding-top: 6px; }
  .ability-status h2 { font-size: 0.8rem; }
  .ability-cooldown > strong { font-size: 1.4rem; }
  .ability-charge { font-size: 0.85rem; }
  .ability-help { font-size: 0.6rem; }
  .arena-info { right: 8px; max-width: 46vw; }
  .game-controls { gap: 7px 14px; padding: 0 12px; font-size: 0.6rem; }
  .phase-card { padding: 16px; }
  .phase-card > p { font-size: 0.85rem; }
  .scoreboard-overlay { padding: 12px; }
  .scoreboard { padding: 18px 12px; }
  .score-player { gap: 7px; }
  .score-player strong { font-size: 0.75rem; }
  .score-player .player-status { font-size: 0.6rem; }
  .scoreboard th { font-size: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}
