:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  --ink: #f6f4e8;
  --muted: #9ca6ba;
  --panel: rgba(9, 12, 25, .92);
  --cyan: #6fe7ff;
  --orange: #ff8a3d;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #02030a; color: var(--ink); }
body { display: grid; place-items: center; }
button, select { font: inherit; }
#app { width: 100vw; height: 100vh; height: 100dvh; position: relative; isolation: isolate; overflow: hidden; background: radial-gradient(circle at 50% 45%, #172143, #050711 70%); }
#app[data-aspect="portrait"] { width: min(100vw, 56.25vh); width: min(100vw, 56.25dvh); height: min(100vh, 177.78vw); height: min(100dvh, 177.78vw); }
#app[data-aspect="landscape"] { width: min(100vw, 177.78vh); width: min(100vw, 177.78dvh); height: min(100vh, 56.25vw); height: min(100dvh, 56.25vw); }
#app[data-aspect="square"] { width: min(100vw, 100vh); width: min(100vw, 100dvh); height: min(100vw, 100vh); height: min(100vw, 100dvh); }
canvas { position: absolute; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.scanlines { pointer-events: none; position: absolute; inset: 0; opacity: .1; z-index: 30; background: repeating-linear-gradient(0deg, transparent 0 3px, #000 4px); }
.panel { position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(740px, calc(100% - 40px)); max-height: calc(100% - 24px); overflow: auto; padding: 42px; border: 1px solid rgba(111,231,255,.28); background: linear-gradient(135deg, rgba(15,20,42,.96), rgba(6,8,18,.96)); box-shadow: 0 24px 90px #000b, inset 0 0 70px rgba(111,231,255,.04); clip-path: polygon(18px 0,100% 0,100% calc(100% - 18px),calc(100% - 18px) 100%,0 100%,0 18px); scrollbar-color: #45617e #0b1020; }
.menu-panel { width: min(680px, calc(100% - 40px)); text-align: center; }
.compact { width: min(430px, calc(100% - 40px)); text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); letter-spacing: .25em; font-weight: 900; font-size: 12px; }
.main-logo { display: block; width: min(100%, 600px); margin: -15px auto -28px; filter: drop-shadow(0 12px 28px #000a); }
h2 { margin: 0 0 24px; font-size: clamp(32px, 5vw, 58px); letter-spacing: -.055em; font-style: italic; }
.lede { color: var(--muted); margin: 28px 0; }
.legal { color: #6f7789; font-size: 11px; margin: 24px 0 0; }
button { display: block; width: 100%; border: 1px solid #3b4663; color: var(--ink); background: #151a2b; padding: 13px 20px; margin-top: 10px; cursor: pointer; font-weight: 900; letter-spacing: .08em; transition: .12s ease; }
button:hover, button:focus-visible { transform: translateY(-2px); border-color: var(--cyan); outline: none; }
button.primary { color: #061018; border-color: var(--cyan); background: var(--cyan); box-shadow: 0 0 24px rgba(111,231,255,.22); }

.panel-heading { text-align: center; }
.selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.format-selector { max-width: 360px; margin: 16px auto 0; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .15em; }
select { width: 100%; margin-top: 8px; padding: 12px; color: var(--ink); border: 1px solid #39445f; background: #0b1020; }
.character-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 24px 0; }
.fighter-card { min-height: 150px; padding: 18px; border: 1px solid #29334a; background: #090d1a; }
.fighter-card h3 { margin: 0 0 4px; font-size: 24px; }
.fighter-card small { color: var(--cyan); font-weight: 800; text-transform: uppercase; }
.fighter-card p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.kit-list { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; padding: 12px 0 0; margin: 12px 0 0; border-top: 1px solid #202b42; list-style: none; color: #dce5f5; font-size: 11px; }
.kit-list li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kit-list em { display: inline-block; min-width: 54px; color: #687994; font-size: 8px; font-style: normal; font-weight: 900; text-transform: uppercase; }
.type-guide { margin: 0 0 18px; border: 1px solid #29334a; background: #080c18; }
.type-guide summary { padding: 12px 15px; cursor: pointer; color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .13em; }
#type-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: #202a40; border-top: 1px solid #29334a; }
#type-list article { min-height: 118px; padding: 12px; background: #090e1c; }
#type-list strong { color: #f5f1e6; text-transform: uppercase; font-size: 12px; }
#type-list p { min-height: 43px; margin: 6px 0; color: #8e9ab0; font-size: 10px; line-height: 1.4; }
#type-list small { color: #d07956; font-size: 9px; line-height: 1.3; }
.swatch { width: 46px; height: 46px; float: right; border-radius: 50%; box-shadow: 0 0 22px currentColor; }
.simulation-note { color: #77829a; text-align: center; font-size: 10px; font-weight: 900; letter-spacing: .14em; margin: 2px 0 18px; }
.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.control-grid > div { background: #090d1a; border: 1px solid #29334a; padding: 18px; }
.control-grid p, .how-panel > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }

.hud { pointer-events: none; position: absolute; z-index: 10; inset: 22px 30px auto; display: grid; grid-template-columns: 1fr 180px 1fr; gap: 20px; text-shadow: 1px 2px 2px #000; }
.player-hud { min-width: 0; }
.identity { display: flex; justify-content: space-between; align-items: center; height: 28px; }
.identity strong { font-size: clamp(16px, 1.7vw, 21px); letter-spacing: .01em; }
.p2-hud { text-align: right; }
.player-chip { background: var(--class-color, var(--cyan)); color: #071019; padding: 3px 8px; font-size: 10px; text-shadow: none; }
.meter { height: 18px; position: relative; overflow: hidden; border: 2px solid #e8edf7; background: #131727; transform: skewX(-10deg); box-shadow: 0 3px 12px #0008; }
.meter i, .meter b { position: absolute; inset: 0; transform-origin: left; transition: transform .12s linear; }
.p2-hud .meter i, .p2-hud .meter b { transform-origin: right; }
.health i { z-index: 2; background: linear-gradient(90deg, #44e4c1, #cdf776); }
.health b { z-index: 1; background: #ff4c5e; transition-duration: .5s; }
.energy { height: 9px; margin-top: 5px; border-color: #53627e; }
.energy i { background: linear-gradient(90deg, #37a9ff, #aef6ff); box-shadow: 0 0 12px #68dfff; }
.p2-hud .energy i { background: linear-gradient(90deg, #ffcc59, #ff7939); box-shadow: 0 0 12px #ff934b; }
.match-hud { text-align: center; font-weight: 900; }
#round-label { font-size: 11px; letter-spacing: .18em; color: var(--muted); }
#timer { font-size: 42px; line-height: 40px; font-style: italic; }
#score { display: flex; align-items: center; justify-content: center; gap: 8px; height: 22px; font-size: 20px; line-height: 1; }
#score b { min-width: 16px; font-style: italic; }
#p1-score { color: var(--p1-class-color, var(--cyan)); }
#p2-score { color: var(--p2-class-color, var(--orange)); }
#score span { color: #667188; font-size: 14px; }
.score-caption { margin-top: 1px; color: #7f899e; font-size: 7px; font-weight: 1000; letter-spacing: .18em; }
.score-pop { animation: score-pop .3s ease-out; }
.status { height: 18px; padding-top: 4px; color: var(--cyan); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.p2-hud .status { color: var(--orange); }

.announcement { position: absolute; z-index: 15; inset: 0; display: grid; place-items: center; pointer-events: none; }
.announcement span { padding: 8px 34px; font-size: clamp(48px, 9vw, 100px); font-weight: 1000; font-style: italic; letter-spacing: -.06em; color: white; text-shadow: 5px 5px 0 #26335c, 0 0 36px #70e8ff; animation: slam .26s ease-out; }
.subtitles { position: absolute; z-index: 12; bottom: 46px; left: 50%; transform: translateX(-50%); max-width: 600px; padding: 8px 14px; background: #050712d9; border-left: 3px solid var(--cyan); font-weight: 700; }
.spectator-tools { position: absolute; z-index: 13; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 5px; background: #070b16dd; border: 1px solid #2f3b55; }
.spectator-tools span { padding: 0 10px; color: #ff7950; font-size: 10px; font-weight: 1000; letter-spacing: .16em; }
.spectator-tools button { width: auto; min-width: 94px; padding: 7px 12px; margin: 0; font-size: 10px; }
@keyframes slam { from { transform: scale(2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes score-pop { 50% { transform: scale(1.2); filter: brightness(1.5); } }

/* A forced 9:16 preview can be narrow even when the browser viewport is wide. */
#app[data-aspect="portrait"] .panel { width: calc(100% - 20px); padding: 24px 16px; max-height: calc(100% - 16px); }
#app[data-aspect="portrait"] h2 { font-size: clamp(30px, 10cqw, 44px); overflow-wrap: anywhere; }
#app[data-aspect="portrait"] .selectors,
#app[data-aspect="portrait"] .character-preview,
#app[data-aspect="portrait"] .control-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
#app[data-aspect="portrait"] .fighter-card { min-width: 0; min-height: 110px; }
#app[data-aspect="portrait"] .kit-list { grid-template-columns: minmax(0, 1fr); }
#app[data-aspect="portrait"] #type-list { grid-template-columns: 1fr 1fr; }
#app[data-aspect="portrait"] .hud { inset: max(8px, env(safe-area-inset-top)) 8px auto; grid-template-columns: minmax(0, 1fr) 68px minmax(0, 1fr); gap: 6px; }
#app[data-aspect="portrait"] .identity strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
#app[data-aspect="portrait"] #timer { font-size: 30px; }
#app[data-aspect="portrait"] .spectator-tools { bottom: max(8px, env(safe-area-inset-bottom)); }
#app[data-aspect="portrait"] .spectator-tools span { display: none; }
#app[data-aspect="portrait"] .subtitles { bottom: calc(52px + env(safe-area-inset-bottom)); width: calc(100% - 24px); font-size: 12px; }

@media (max-width: 720px) {
  .panel { width: calc(100% - 20px); padding: 24px 16px; max-height: calc(100% - 16px); }
  .hud { inset: max(8px, env(safe-area-inset-top)) 8px auto; grid-template-columns: 1fr 68px 1fr; gap: 6px; }
  .identity strong { font-size: 16px; }
  #timer { font-size: 30px; }
  .control-grid, .selectors, .character-preview { grid-template-columns: 1fr; }
  #type-list { grid-template-columns: 1fr 1fr; }
  .fighter-card { min-height: 110px; }
  .kit-list { grid-template-columns: 1fr; }
  .spectator-tools { bottom: max(8px, env(safe-area-inset-bottom)); }
  .spectator-tools span { display: none; }
  .subtitles { bottom: calc(52px + env(safe-area-inset-bottom)); width: calc(100% - 24px); font-size: 12px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .panel { padding: 18px 24px; }
  .main-logo { width: 390px; margin: -25px auto -35px; }
  .lede { margin: 10px 0; }
  .legal { margin-top: 10px; }
  .hud { top: 5px; }
  .spectator-tools { left: auto; right: 10px; transform: none; }
}
