@import url('assets/fonts.css');

:root {
  --cyan: #00e5ff;
  --gold: #ffd24a;
  /* Fallbacks for data/ui_theme.json touch_controls; the shell overrides them. */
  --touch-dpad-size: 160px;
  --touch-action-size: 64px;
  --touch-action-gap: 10px;
  --touch-edge: 18px;
  --touch-action-inset: 18px;
  --touch-helper-size: 52px;
  --touch-opacity: 0.72;
  --touch-active-opacity: 0.95;
  --touch-bg: #060b16b8;
  --touch-border: #38bdf8aa;
  --touch-active-color: #00e5ff;
  --touch-active-text: #04121e;
  --touch-text: #eaf7ff;
  --touch-muted: #7dd3fc;
  --touch-light-color: #38bdf8;
  --touch-heavy-color: #ffd24a;
  --touch-ult-color: #f472b6;
  /* Fallbacks for data/ui_theme.json main_menu.select_panel; the shell
     overrides these at boot so the CSS never owns select geometry/colour. */
  --select-preview-width: 288px;
  --select-preview-height: 224px;
  --select-p1-preview-left: 156px;
  --select-p1-preview-top: 266px;
  --select-p2-preview-left: 836px;
  --select-p2-preview-top: 266px;
  --select-name-top: 176px;
  --select-p1-text-x: 120px;
  --select-p2-text-inset: 120px;
  --select-name-font-size: 30px;
  --select-role-font-size: 15px;
  --select-tag-font-size: 14px;
  --select-p1-color: #38e8ff;
  --select-p2-color: #ffd24a;
  --select-cards-top: 488px;
  --select-card-width: 212px;
  --select-card-height: 158px;
  --select-card-gap: 20px;
  --select-card-title-font-size: 17px;
  --select-card-sub-font-size: 12px;
  --select-card-bg: #0a1628e6;
  --select-card-border: #1e3a5f;
  --select-card-active: #00e5ff;
  --select-card-glow: #00d8ff66;
  font-family: PipilabuThai, PipilabuLatin, system-ui, sans-serif;
  color: #eaf7ff;
  background: #04070f;
}

:root:lang(en) { font-family: PipilabuLatin, PipilabuThai, system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { height: 100%; height: 100vh; height: 100dvh; margin: 0; background: #04070f; }
body { display: grid; place-items: center; overflow: hidden; }
button { font: inherit; cursor: pointer; }

.stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #060b16;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}
/* Nearest-neighbour scaling in every browser that supports it. */
#canvas, .preview { image-rendering: -moz-crisp-edges; }

/* ---------------------------------------------------------------------------
   Menus. Geometry and colours come from res://data/ui_theme.json
   (main_menu) and are laid out in the game's 1280x720 design space.
   ------------------------------------------------------------------------- */
.overlay { position: absolute; inset: 0; overflow: hidden; }
.overlay[hidden] { display: none; }
.menu-dim { position: absolute; inset: 0; background: #03070f; opacity: 0.72; }
.menu-scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, #00e5ff12 0 1px, transparent 1px 4px);
}
.menu-layer {
  position: absolute; left: 0; top: 0; width: 1280px; height: 720px;
  transform-origin: 0 0;
}
.screen { position: absolute; inset: 0; }
.screen[hidden] { display: none; }

.panel, .title-panel, .options-panel, .keybind-panel, .howto-panel, .pause-panel {
  position: absolute;
  background: #081527e8;
  border: 2.4px solid #00e5ff;
  box-shadow: 0 0 18px #00d8ff55;
}
.chamfer-lg { clip-path: polygon(38px 0, calc(100% - 38px) 0, 100% 38px, 100% calc(100% - 38px), calc(100% - 38px) 100%, 38px 100%, 0 calc(100% - 38px), 0 38px); }

/* --- title screen -------------------------------------------------------- */
.title-panel {
  left: 300px; top: 74px; width: 680px; height: 182px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  clip-path: polygon(38px 0, calc(100% - 38px) 0, 100% 38px, 100% calc(100% - 38px), calc(100% - 38px) 100%, 38px 100%, 0 calc(100% - 38px), 0 38px);
}
.title-panel .subtitle { margin: 0; font-size: 19px; color: #7dd3fc; }
.game-title {
  margin: 6px 0 8px; font-size: 56px; line-height: 1.05; font-weight: 900;
  letter-spacing: 0.03em; color: #eaf7ff;
}
.game-title::after { content: "."; color: #ffd24a; }
.title-panel .tagline { margin: 0; font-size: 14px; color: #5a87a8; }

/* --- shared menu list (title + pause) ------------------------------------ */
.menu-list {
  position: absolute; left: 440px; top: 320px; width: 400px;
  display: flex; flex-direction: column; gap: 12px;
}
.menu-list button {
  height: 50px; padding: 0 18px;
  font-size: 22px; letter-spacing: 0.03em;
  color: #bce6ff; background: #03070e99; border: 1.6px solid #1e3a5f;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.menu-list button:hover,
.menu-list button.selected {
  color: #04121e; background: #00e5ff; border-color: #00e5ff;
  box-shadow: 0 0 16px #00e5ff66;
}
.menu-list button:focus-visible { outline: 3px solid #ffd24a; outline-offset: 2px; }

.lang-toggle {
  position: absolute; right: 24px; top: 24px;
  padding: 7px 14px; font-size: 14px;
  color: #bce6ff; background: #03070e99; border: 1.6px solid #1e3a5f;
}
.lang-toggle:hover { border-color: #00e5ff; color: #eaf7ff; }

.hint-line {
  position: absolute; left: 0; top: 664px; width: 1280px;
  margin: 0; text-align: center; font-size: 14px; color: #7dd3fc;
}

.screen-title {
  position: absolute; left: 0; top: 96px; width: 1280px; margin: 0;
  text-align: center; font-size: 30px; font-weight: 800; color: #ffd24a;
}
.screen-subtitle {
  position: absolute; left: 0; top: 140px; width: 1280px; margin: 0;
  text-align: center; font-size: 15px; color: #8fc7e8;
}

/* --- mode cards ---------------------------------------------------------- */
.mode-cards {
  position: absolute; left: 104px; top: 236px;
  display: flex; gap: 26px;
}
.mode-card {
  width: 340px; height: 250px; padding: 22px 20px;
  text-align: left; background: #0a1628e6; border: 1.8px solid #1e3a5f;
}
.mode-card h4 { margin: 0 0 12px; font-size: 25px; color: #eaf7ff; }
.mode-card p { margin: 0; font-size: 15px; line-height: 1.75; color: #8fc7e8; }
.mode-card .card-tag {
  display: inline-block; margin-top: 14px; font-size: 13px; color: #38bdf8;
}
.mode-card:hover, .mode-card.selected {
  background: #0d2138f2; border-color: #00e5ff; box-shadow: 0 0 18px #00d8ff66;
}

/* --- character select ---------------------------------------------------- */
.select-name { position: absolute; top: var(--select-name-top); display: flex; flex-direction: column; gap: 6px; }
.select-name.p1 { left: var(--select-p1-text-x); }
.select-name.p2 {
  left: auto; right: var(--select-p2-text-inset); width: 380px;
  align-items: flex-end; text-align: right;
}
.select-name .select-tag { font-size: var(--select-tag-font-size); color: #7dd3fc; }
.select-name strong { font-size: var(--select-name-font-size); color: #eaf7ff; }
.select-name .select-role { font-size: var(--select-role-font-size); color: #8fc7e8; }
.select-name.p1 strong { color: var(--select-p1-color); }
.select-name.p2 strong { color: var(--select-p2-color); }
.select-previews { display: contents; }
.preview {
  position: absolute;
  width: var(--select-preview-width); height: var(--select-preview-height);
  image-rendering: pixelated;
  pointer-events: none;
}
.preview.p1 { left: var(--select-p1-preview-left); top: var(--select-p1-preview-top); }
.preview.p2 { left: var(--select-p2-preview-left); top: var(--select-p2-preview-top); }

.select-cards {
  position: absolute; left: 50%; top: var(--select-cards-top);
  transform: translateX(-50%);
  display: flex; gap: var(--select-card-gap);
}
.fighter-card {
  width: var(--select-card-width); height: var(--select-card-height); padding: 12px;
  text-align: left; background: var(--select-card-bg); border: 1.8px solid var(--select-card-border);
}
.fighter-card strong { display: block; font-size: var(--select-card-title-font-size); color: #eaf7ff; }
.fighter-card span { display: block; margin-top: 6px; font-size: var(--select-card-sub-font-size); color: #8fc7e8; }
.fighter-card .chip {
  display: inline-block; margin-top: 10px; padding: 3px 8px; font-size: 11px;
  color: #04121e; background: #38bdf8;
}
.fighter-card.selected { border-color: var(--select-card-active); box-shadow: 0 0 18px var(--select-card-glow); }
.fighter-card.ready { border-color: #ffd24a; box-shadow: 0 0 18px #ffd24a55; }

/* --- VS splash ----------------------------------------------------------- */
.vs-name { position: absolute; top: 300px; font-size: 32px; font-weight: 800; }
.vs-name.p1 { left: 200px; color: #38e8ff; }
.vs-name.p2 { right: 200px; color: #ffd24a; }
.vs-title {
  position: absolute; left: 0; top: 270px; width: 1280px;
  text-align: center; font-size: 44px; font-weight: 900; color: #eaf7ff;
}

/* --- pause --------------------------------------------------------------- */
.pause-panel {
  left: 410px; top: 132px; width: 460px; height: 456px;
  clip-path: polygon(26px 0, calc(100% - 26px) 0, 100% 26px, 100% calc(100% - 26px), calc(100% - 26px) 100%, 26px 100%, 0 calc(100% - 26px), 0 26px);
}
.pause-title {
  position: absolute; left: 0; top: 56px; width: 460px; margin: 0;
  text-align: center; font-size: 34px; color: #ffd24a;
}
.pause-list { left: 60px; top: 104px; width: 340px; }
.pause-list button { height: 50px; font-size: 19px; }
.pause-panel .hint-line { top: 412px; }

/* --- options ------------------------------------------------------------- */
.options-panel {
  left: 296px; top: 168px; width: 688px; height: 356px;
  background: #081527f2;
  clip-path: polygon(26px 0, calc(100% - 26px) 0, 100% 26px, 100% calc(100% - 26px), calc(100% - 26px) 100%, 26px 100%, 0 calc(100% - 26px), 0 26px);
}
.options-title {
  position: absolute; left: 0; top: 28px; width: 688px; margin: 0;
  text-align: center; font-size: 30px; color: #ffd24a;
}
.options-section { position: absolute; left: 44px; top: 92px; font-size: 15px; color: #7fa8c4; letter-spacing: 0.08em; }
.options-section.second { top: 176px; }
.options-rows { position: absolute; left: 0; top: 0; width: 688px; }
.options-row { position: absolute; height: 30px; display: flex; align-items: center; }
.options-row .label { position: absolute; left: 44px; font-size: 19px; color: #dceeff; }
.options-row .value { position: absolute; left: 300px; width: 240px; font-size: 19px; color: #38e8ff; }
.options-row .slider {
  position: absolute; left: 404px; width: 240px; height: 14px;
  background: #070d19; border: 1px solid #1e3a5f;
}
.options-row .slider i { display: block; height: 100%; background: #38e8ff; }
.options-row.active .label, .options-row.active .value { color: #ffd24a; }
.options-row.active .slider { border-color: #ffd24a; }
.options-panel .hint-line { top: 322px; }

/* --- key bindings -------------------------------------------------------- */
.keybind-panel {
  left: 200px; top: 116px; width: 880px; height: 436px;
  background: #081527f2;
  clip-path: polygon(24px 0, calc(100% - 24px) 0, 100% 24px, 100% calc(100% - 24px), calc(100% - 24px) 100%, 24px 100%, 0 calc(100% - 24px), 0 24px);
}
.keybind-title {
  position: absolute; left: 0; top: 24px; width: 880px; margin: 0;
  text-align: center; font-size: 28px; color: #ffd24a;
}
.keybind-columns { position: absolute; left: 34px; top: 100px; width: 812px; display: flex; gap: 38px; }
.keybind-column { width: 410px; }
.keybind-column h3 { margin: 0 0 12px; font-size: 16px; color: #7dd3fc; }
.bind-row {
  height: 34px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; border-bottom: 1px solid #1e3a5f;
}
.bind-row .action { font-size: 16px; color: #dceeff; }
.bind-row .key {
  min-width: 96px; padding: 3px 10px; text-align: center; font-size: 15px;
  color: #7fa8c4; background: #081527; border: 1px solid #1e3a5f;
}
.bind-row .key.custom { color: #38e8ff; border-color: #38e8ff; }
.bind-row.active { background: #123252; }
.bind-row.active .action, .bind-row.active .key { color: #ffd24a; }
.keybind-panel .hint-line { top: 402px; }

/* --- move list / how to play -------------------------------------------- */
.howto-panel {
  left: 120px; top: 140px; width: 1040px; height: 452px;
  background: #081527f2;
  clip-path: polygon(24px 0, calc(100% - 24px) 0, 100% 24px, 100% calc(100% - 24px), calc(100% - 24px) 100%, 24px 100%, 0 calc(100% - 24px), 0 24px);
}
.howto-title {
  position: absolute; left: 0; top: 22px; width: 1040px; margin: 0;
  text-align: center; font-size: 28px; color: #ffd24a;
}
.howto-rows {
  position: absolute; left: 34px; top: 78px; width: 972px; height: 300px;
  overflow: auto;
}
.howto-row { display: flex; gap: 24px; margin-bottom: 30px; }
.howto-row .cmd { width: 340px; font-size: 15px; color: #ffd24a; }
.howto-row .desc { font-size: 15px; color: #e2f4ff; line-height: 1.7; }
.howto-panel .hint-line { top: 408px; }

/* --- loading ------------------------------------------------------------ */
.loading-title { margin: 52px 0 10px; text-align: center; font-size: 30px; color: #eaf7ff; }
.loading-detail { margin: 0; text-align: center; font-size: 15px; color: #7fa8c4; }

/* ---------------------------------------------------------------------------
   In-match HUD. Geometry and colours come straight from res://data/ui_theme.json
   and are laid out in the game's 1280x720 design space, scaled to the player.
   ------------------------------------------------------------------------- */
.hud { position: absolute; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; }
.hud[hidden] { display: none; }
.hud-inner { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; }

.top-bar {
  position: absolute; left: 0; top: 0; width: 1280px; height: 28px;
  background: #060b16d8; border-bottom: 1.5px solid #1e3a5f;
  display: flex; align-items: center; justify-content: center; gap: 26px;
  font-size: 13px; color: #bce6ff;
}
.top-bar .keycap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 18px; padding: 0 7px; margin-right: 4px;
  background: #11223b; border: 1.4px solid #38bdf8; border-radius: 3.5px;
  color: #e0f2fe; font-size: 12px;
}

/* --- health bars: angled metallic frame, trough, damage trail and fill ---- */
.health { position: absolute; top: 37px; width: 528px; height: 36px; }
.health.p1 { left: 32px; }
.health.p2 { left: 720px; }
.health .bar-frame {
  position: absolute; inset: 0;
  background: #1b2e4b; border: 2.2px solid #00e5ff;
  box-shadow: 0 0 12px #00d8ff44;
}
.health.p1 .bar-frame { clip-path: polygon(0 18px, 28px 0, 523px 0, 509px 36px, 21px 36px); }
.health.p2 .bar-frame { clip-path: polygon(5px 0, 500px 0, 528px 18px, 507px 36px, 5px 36px); }
.health .bar-wing { position: absolute; top: 2px; width: 30px; height: 32px; border: 2.8px solid #00e5ff; border-radius: 2px; }
.health.p1 .bar-wing { left: -4px; clip-path: polygon(100% 0, 100% 100%, 0 50%); }
.health.p2 .bar-wing { right: -4px; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.health .bar-trough {
  position: absolute; overflow: hidden; background: #070d19;
  border: 1.2px solid #67e8f9;
}
.health.p1 .bar-trough { left: 44px; top: 5px; width: 474px; height: 26px; clip-path: polygon(0 0, 474px 0, 460px 26px, 0 26px); }
.health.p2 .bar-trough { left: 10px; top: 5px; width: 474px; height: 26px; clip-path: polygon(14px 0, 474px 0, 474px 26px, 0 26px); }
.health .bar-red, .health .bar-hp { position: absolute; top: 0; height: 26px; }
.health.p1 .bar-red, .health .bar-hp { left: 0; }
.health.p2 .bar-red, .health .bar-hp { right: 0; }
.bar-red { background: #e11d48; }
.bar-hp { background: linear-gradient(180deg, #5cff9d, #00c864); }
.bar-hp.low { background: linear-gradient(180deg, #fde047, #f97316); }

/* --- nameplates ---------------------------------------------------------- */
.plate {
  position: absolute; top: 74px; height: 30px; width: 472px;
  display: flex; align-items: baseline; gap: 8px; padding: 6px 22px 0;
  background: #0b1629cc; border-top: 1.6px solid #00e5ffaa;
}
.plate.p1 { left: 34px; clip-path: polygon(0 0, 452px 0, 440px 30px, 12px 30px); }
.plate.p2 { left: 738px; justify-content: flex-end; clip-path: polygon(32px 0, 472px 0, 460px 30px, 20px 30px); }
.plate .tag { font-size: 11px; color: #93c5fd; }
.plate .name { font-size: 16px; color: #fff; font-weight: 700; }
.plate .sub { font-size: 15px; color: #7dd3fc; }

/* --- round-win orbs ------------------------------------------------------ */
.orbs { position: absolute; top: 86px; left: 640px; width: 0; height: 0; }
.orb {
  position: absolute; top: 0; width: 13px; height: 13px; border-radius: 50%;
  background: #152238; border: 1.6px solid #38bdf8;
  transform: translate(-50%, -50%);
}
.orb.p1.on { background: #67e8f9; box-shadow: 0 0 8px #00e5ff66; }
.orb.p2.on { background: #67e8f9; box-shadow: 0 0 8px #00e5ff66; }

/* --- timer shield -------------------------------------------------------- */
.timer-shield {
  position: absolute; left: 594px; top: 29px; width: 92px; height: 58px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #162642, #091120);
  border: 2.2px solid #00e5ff; border-radius: 8px; box-shadow: 0 0 12px #00e5ff40;
}
.timer-shield span {
  font-size: 30px; font-weight: 800; color: #ffb830; text-shadow: 0 0 12px #ff7a0066;
}

/* --- power gauges -------------------------------------------------------- */
/* The gauge root is never clipped: the label sits above the bar, like
   `_draw_bottom_power_gauges()` draws it (my - 9), so only the bar is shaped. */
.gauge { position: absolute; top: 678px; width: 376px; height: 18px; }
.gauge.p1 { left: 54px; }
.gauge.p2 { left: 850px; }
.gauge-bar {
  position: absolute; inset: 0; display: block;
  background: #081120e8; border: 1.6px solid #00e5ff; box-shadow: 0 0 10px #00e5ff44;
}
.gauge.p1 .gauge-bar { clip-path: polygon(14px 0, 376px 0, 362px 18px, 0 18px); }
.gauge.p2 .gauge-bar { clip-path: polygon(14px 0, 376px 0, 362px 18px, 0 18px); }
.gauge-bar i {
  position: absolute; top: 1px; height: 14px;
  background: linear-gradient(90deg, #0284c7, #38e8ff);
}
.gauge.p1 .gauge-bar i { left: 1px; }
.gauge.p2 .gauge-bar i { right: 1px; background: linear-gradient(90deg, #f59e0b, #fde047); }
.gauge.max .gauge-bar i { background: linear-gradient(90deg, #f59e0b, #fde047); }
.gauge .meta {
  position: absolute; top: -22px; display: flex; align-items: baseline;
  font-size: 15px; line-height: 15px; white-space: nowrap;
}
.gauge.p1 .meta { left: 4px; }
.gauge.p2 .meta { right: 4px; }
.gauge .meta .power { min-width: 70px; color: #fff; }
.gauge .meta .value { font-size: 16px; color: #38e8ff; }
.gauge.max .meta .value { color: #fde047; }

/* --- centre banner, hit counters and floating callouts ------------------- */
.banner {
  position: absolute; left: 64px; top: 275px; width: 1152px; height: 96px;
  display: grid; place-items: center; align-content: center; gap: 6px;
  background: #060d1cd8; border-top: 2px solid #00e5ff; border-bottom: 2px solid #00e5ff;
  clip-path: polygon(24px 0, 1128px 0, 1152px 48px, 1128px 96px, 24px 96px, 0 48px);
}
.banner strong { font-size: 38px; font-weight: 900; letter-spacing: 0.06em; color: #ffd24a; text-shadow: 0 0 18px #ffd24a55; }
.banner span { font-size: 20px; color: #fff; }
.banner[hidden] { display: none; }

/* P2 (the left player) counts on the left, P1 on the right, like Godot. */
.combo {
  position: absolute; top: 176px; font-size: 24px; line-height: 24px;
  font-weight: 800; color: #ffd24a; white-space: nowrap;
  text-shadow: 0 2px 0 #00101f, 0 0 18px #ffd24a55;
}
.combo.p1 { left: 970px; }
.combo.p2 { left: 76px; }
.combo[hidden] { display: none; }

/* The engine sends each callout's text and colour, still fading upward. */
.callouts { position: absolute; inset: 0; }
.callout {
  position: absolute; left: 90px; font-size: 20px; line-height: 20px;
  font-weight: 800; white-space: nowrap; text-shadow: 0 2px 0 #00101f;
}
.callout.p2 { left: 950px; }

/* --- P1 quick-command strip (quick_command_banner) ----------------------- */
.quick-banner {
  position: absolute; left: 64px; top: 108px; width: 1152px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--qc-bg, #081224d8);
  border: 1.8px solid var(--qc-border, #00e5ff);
  box-shadow: 0 0 12px var(--qc-glow, #00e5ff33);
  font-size: 13px; color: var(--qc-text, #e2f4ff); white-space: pre;
}
.quick-banner .label { color: var(--qc-prefix, #7dd3fc); }
.quick-banner .text { color: var(--qc-text, #e2f4ff); }
.quick-banner > span { flex: 0 0 auto; white-space: pre; }
.quick-banner .keycap {
  display: inline-flex; align-items: center; height: 19px; padding: 0 7px;
  margin: 0 2px; border-radius: 3.5px; font-size: 13px;
  background: var(--qc-key-bg, #152642);
  border: 1.4px solid var(--qc-key-border, #38bdf8);
  color: var(--qc-key-text, #fde047);
}

/* ---------------------------------------------------------------------------
   Touch shell. The pad is a native-size overlay on the game canvas; menus are
   reflowed to the real viewport instead of scaling the 1280x720 design space.
   Geometry and colours come from ui_theme.touch_controls.
   ------------------------------------------------------------------------- */
.touch-controls,
.touch-menu-nav { display: none; }

.touch-mode .overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #03070f;
  -webkit-overflow-scrolling: touch;
}
.touch-mode .menu-dim,
.touch-mode .menu-scanlines { position: fixed; }
.touch-mode .menu-layer {
  position: relative;
  left: auto;
  top: auto;
  width: 100%;
  height: auto;
  min-height: 100%;
  transform: none !important;
}

.touch-mode .screen {
  position: relative;
  inset: auto;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: max(18px, calc(env(safe-area-inset-top) + 14px)) 16px
    calc(env(safe-area-inset-bottom) + 110px);
}
.touch-mode .screen[hidden] { display: none; }
.touch-mode .screen > * {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: 100% !important;
  max-width: 760px;
  height: auto !important;
  margin-left: auto;
  margin-right: auto;
  transform: none !important;
}
.touch-mode .screen > .lang-toggle {
  width: auto !important;
  min-width: 56px;
  min-height: 44px;
  margin-left: auto;
  margin-right: 0;
  align-self: flex-end;
  order: -1;
}

.touch-mode .panel,
.touch-mode .title-panel,
.touch-mode .pause-panel,
.touch-mode .options-panel,
.touch-mode .keybind-panel,
.touch-mode .howto-panel {
  padding: 18px;
  clip-path: none;
}
.touch-mode .title-panel { text-align: center; }
.touch-mode .game-title { font-size: clamp(32px, 9vw, 46px); }
.touch-mode .title-panel .subtitle { font-size: 17px; }
.touch-mode .title-panel .tagline { font-size: 14px; line-height: 1.5; }
.touch-mode .menu-list { gap: 10px; }
.touch-mode .menu-list button {
  min-height: 54px;
  height: auto;
  padding: 10px 16px;
  font-size: 18px;
}
.touch-mode .lang-toggle {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 16px;
}
.touch-mode .hint-line {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--touch-muted);
}
.touch-mode .screen-title { font-size: 24px; }
.touch-mode .screen-subtitle { font-size: 15px; line-height: 1.5; }

.touch-mode .mode-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.touch-mode .mode-card {
  width: 100%;
  min-height: 86px;
  height: auto;
  padding: 15px 16px;
}
.touch-mode .mode-card h4 { font-size: 20px; }
.touch-mode .mode-card p { font-size: 15px; line-height: 1.6; }
.touch-mode .mode-card .card-tag { font-size: 14px; margin-top: 8px; }

.touch-mode .select-name {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding-left: 10px;
  border-left: 3px solid #1e3a5f;
  text-align: left;
}
.touch-mode .select-name.p1 { border-left-color: var(--select-p1-color); }
.touch-mode .select-name.p2 { border-left-color: var(--select-p2-color); }
.touch-mode .select-name .select-tag { font-size: 14px; }
.touch-mode .select-name strong { font-size: 22px; }
.touch-mode .select-name .select-role { font-size: 15px; }
.touch-mode .select-previews {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.touch-mode .preview {
  position: static !important;
  left: auto !important;
  top: auto !important;
  width: min(42vw, 148px) !important;
  height: auto !important;
  max-width: var(--select-preview-width);
  flex: 0 0 auto;
}
.touch-mode .select-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.touch-mode .fighter-card {
  width: 100%;
  min-height: 78px;
  height: auto;
  padding: 12px 16px;
}
.touch-mode .fighter-card strong { font-size: 19px; }
.touch-mode .fighter-card span { font-size: 15px; margin-top: 4px; }
.touch-mode .fighter-card .chip { font-size: 14px; padding: 4px 10px; }

.touch-mode .vs-name {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  width: 100%;
  text-align: center;
  font-size: 28px;
}
.touch-mode .vs-name.p1 { color: #38e8ff; }
.touch-mode .vs-name.p2 { color: #ffd24a; }
.touch-mode .vs-title { font-size: 40px; }

.touch-mode .pause-panel { text-align: center; }
.touch-mode .pause-title {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin: 0 0 16px;
}
.touch-mode .pause-list {
  position: static;
  left: auto;
  top: auto;
  width: 100%;
  gap: 10px;
}
.touch-mode .pause-list button { min-height: 54px; height: auto; font-size: 18px; }
.touch-mode .pause-panel .hint-line {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin-top: 12px;
}

.touch-mode .options-panel { text-align: left; }
.touch-mode .options-title {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin: 0 0 12px;
}
.touch-mode .options-section {
  position: static;
  left: auto;
  top: auto;
  margin-top: 8px;
  font-size: 15px;
}
.touch-mode .options-section.second { margin-top: 18px; }
.touch-mode .options-rows {
  position: static;
  left: auto;
  top: auto;
  width: 100%;
}
.touch-mode .options-row {
  position: relative;
  top: auto !important;
  height: auto;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #1e3a5f;
}
.touch-mode .options-row .label { position: static; font-size: 16px; }
.touch-mode .options-row .value { position: static; width: auto; min-width: 48px; text-align: right; font-size: 16px; }
.touch-mode .options-row .slider { display: none; }
.touch-mode .options-panel .hint-line {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin-top: 14px;
}
.touch-mode .option-touch { display: flex; align-items: center; gap: 8px; }
.touch-mode .option-touch-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 11px;
  font-size: 18px;
  color: var(--touch-text);
  background: var(--touch-bg);
  border: 1.5px solid var(--touch-border);
  border-radius: 8px;
}
.touch-mode .option-touch-button:active,
.touch-mode .option-touch-button:focus-visible { border-color: var(--gold); color: var(--gold); }

.touch-mode .keybind-panel { text-align: left; }
.touch-mode .keybind-title {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin: 0 0 14px;
}
.touch-mode .keybind-columns {
  position: static;
  left: auto;
  top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.touch-mode .keybind-column { width: 100%; }
.touch-mode .bind-row { min-height: 44px; }
.touch-mode .bind-row .key { min-height: 44px; }
.touch-mode .bind-row .key:disabled { opacity: 0.72; cursor: default; }
.touch-mode .keybind-panel .hint-line {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin-top: 12px;
}

.touch-mode .howto-panel { text-align: left; }
.touch-mode .howto-title {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin: 0 0 14px;
  font-size: 20px;
  line-height: 1.4;
}
.touch-mode .howto-rows {
  position: static;
  left: auto;
  top: auto;
  width: 100%;
  height: auto;
  overflow: visible;
}
.touch-mode .howto-row {
  flex-direction: column;
  gap: 5px;
  margin-bottom: 18px;
}
.touch-mode .howto-row .cmd { width: auto; font-size: 14px; }
.touch-mode .howto-row .desc { font-size: 15px; line-height: 1.55; }
.touch-mode .howto-panel .hint-line {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  margin-top: 12px;
}

.touch-mode .loading-title { font-size: 25px; line-height: 1.35; }

.touch-mode .touch-menu-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom) + 10px) max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #03070f00, #03070ff2 28%);
}
.touch-menu-nav[hidden],
.touch-menu-confirm[hidden] { display: none !important; }
.touch-menu-button {
  min-height: 56px;
  padding: 10px 18px;
  font-size: 17px;
  font-weight: 700;
  color: var(--touch-text);
  background: var(--touch-bg);
  border: 1.8px solid var(--touch-border);
  border-radius: 10px;
}
.touch-menu-back {
  flex: 0 0 34%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.touch-menu-confirm {
  flex: 1;
  color: var(--touch-active-text);
  background: var(--gold);
  border-color: var(--gold);
}
.touch-menu-glyph { font-size: 24px; line-height: 1; }
.touch-menu-button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.touch-mode {
  --touch-dpad-live: min(var(--touch-dpad-size), 42vh);
  --touch-action-live: clamp(48px, 17vh, var(--touch-action-size));
}
.touch-mode .touch-controls {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-controls[hidden],
#touch-pad[hidden] { display: none !important; }
.touch-mode .hud { z-index: 3; }

.touch-pad { position: absolute; inset: 0; pointer-events: none; }

#touch-dpad {
  position: absolute;
  left: calc(env(safe-area-inset-left) + var(--touch-edge));
  bottom: calc(env(safe-area-inset-bottom) + var(--touch-edge));
  width: var(--touch-dpad-live);
  height: var(--touch-dpad-live);
  border-radius: 50%;
  border: 2px solid var(--touch-border);
  background:
    radial-gradient(circle at 50% 50%, #060b1640 0 30%, var(--touch-bg) 31% 100%);
  box-shadow: 0 0 18px #00e5ff22, inset 0 0 24px #00e5ff12;
  opacity: var(--touch-opacity);
  pointer-events: auto;
  transition: opacity 0.08s, border-color 0.08s, box-shadow 0.08s;
}
#touch-dpad[data-dir]:not([data-dir=""]) {
  opacity: var(--touch-active-opacity);
  border-color: var(--touch-active-color);
  box-shadow: 0 0 22px #00e5ff55, inset 0 0 24px #00e5ff22;
}
.touch-dpad-face {
  position: absolute;
  inset: 5%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  color: var(--touch-muted);
  font-size: calc(var(--touch-dpad-live) * 0.115);
  line-height: 1;
}
.touch-dir { opacity: 0.72; }
.dir-up-left { grid-area: 1 / 1; }
.dir-up { grid-area: 1 / 2; }
.dir-up-right { grid-area: 1 / 3; }
.dir-left { grid-area: 2 / 1; }
.dir-right { grid-area: 2 / 3; }
.dir-down-left { grid-area: 3 / 1; }
.dir-down { grid-area: 3 / 2; }
.dir-down-right { grid-area: 3 / 3; }
.touch-dpad-center {
  grid-area: 2 / 2;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.5;
}
#touch-dpad[data-dir~="up"] .dir-up,
#touch-dpad[data-dir~="down"] .dir-down,
#touch-dpad[data-dir~="left"] .dir-left,
#touch-dpad[data-dir~="right"] .dir-right,
#touch-dpad[data-dir~="up"][data-dir~="left"] .dir-up-left,
#touch-dpad[data-dir~="up"][data-dir~="right"] .dir-up-right,
#touch-dpad[data-dir~="down"][data-dir~="left"] .dir-down-left,
#touch-dpad[data-dir~="down"][data-dir~="right"] .dir-down-right {
  color: var(--touch-active-color);
  opacity: 1;
  text-shadow: 0 0 10px var(--touch-active-color);
}

.touch-actions {
  position: absolute;
  right: calc(env(safe-area-inset-right) + var(--touch-action-inset));
  bottom: calc(env(safe-area-inset-bottom) + var(--touch-action-inset));
  display: grid;
  grid-template-columns: repeat(2, var(--touch-action-live));
  grid-template-rows: repeat(2, var(--touch-action-live));
  gap: var(--touch-action-gap);
  pointer-events: none;
}
.touch-action {
  width: var(--touch-action-live);
  height: var(--touch-action-live);
  min-width: 0;
  padding: 1px;
  overflow: hidden;
  border-radius: 50%;
  border: 2px solid var(--touch-action-color, var(--touch-border));
  background: var(--touch-bg);
  color: var(--touch-text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
  opacity: var(--touch-opacity);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.06s, transform 0.06s, background 0.06s, color 0.06s;
}
.touch-action-light { grid-area: 2 / 1; --touch-action-color: var(--touch-light-color); }
.touch-action-heavy { grid-area: 2 / 2; --touch-action-color: var(--touch-heavy-color); }
.touch-action-ult { grid-area: 1 / 2; --touch-action-color: var(--touch-ult-color); }
.touch-action[aria-pressed="true"] {
  opacity: var(--touch-active-opacity);
  transform: scale(0.95);
  background: var(--touch-action-color);
  border-color: #fff;
  color: var(--touch-active-text);
}
.touch-action:focus-visible,
.touch-helper:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.touch-helpers {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--touch-edge));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.touch-helper {
  min-width: 68px;
  min-height: var(--touch-helper-size);
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--touch-text);
  background: var(--touch-bg);
  border: 1.6px solid var(--touch-border);
  border-radius: 10px;
  opacity: var(--touch-opacity);
  font-size: 14px;
  line-height: 1.05;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-helper:active { opacity: var(--touch-active-opacity); border-color: var(--touch-active-color); }
.touch-helper-glyph { font-size: 16px; line-height: 1; }
.touch-rotate-hint {
  display: none;
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--touch-muted);
  text-align: center;
  text-shadow: 0 1px 2px #000;
}

/* Portrait: arena above a dock, so no button covers the fighters. */
.touch-mode.touch-portrait {
  --touch-dpad-live: min(var(--touch-dpad-size), 40vw);
  --touch-action-live: clamp(60px, 15vw, var(--touch-action-size));
  --touch-dock-height: calc(max(
    var(--touch-dpad-live),
    var(--touch-action-live) + var(--touch-action-live) + var(--touch-action-gap)
  ) + 100px + env(safe-area-inset-bottom));
  grid-template-rows: 1fr auto;
  align-items: stretch;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
}
.touch-mode.touch-portrait .stage {
  align-self: center;
  justify-self: center;
  width: min(100vw, max(220px, calc((100dvh - var(--touch-dock-height) - env(safe-area-inset-top)) * 16 / 9)));
  max-height: calc(100dvh - var(--touch-dock-height) - env(safe-area-inset-top));
}
.touch-mode.touch-portrait .touch-controls {
  position: relative;
  inset: auto;
  height: auto;
  width: 100%;
  justify-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px max(12px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom) + 8px) max(12px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #03070f00, #03070fe6 18%);
  pointer-events: auto;
}
.touch-mode.touch-portrait .touch-controls[hidden] { display: none !important; }
.touch-mode.touch-portrait .touch-pad {
  position: relative;
  inset: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.touch-mode.touch-portrait #touch-dpad,
.touch-mode.touch-portrait .touch-actions {
  position: relative;
  inset: auto;
  left: auto;
  right: auto;
  bottom: auto;
}
.touch-mode.touch-portrait .touch-actions { pointer-events: auto; }
.touch-mode.touch-portrait .touch-helpers {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  order: -1;
  align-self: center;
  justify-content: center;
}
.touch-mode.touch-portrait .touch-rotate-hint {
  display: block;
  order: -2;
}

@media (orientation: landscape) and (max-height: 430px) {
  .touch-mode .touch-helpers { --touch-helper-size: 44px; }
  .touch-mode .touch-helper { min-width: 58px; font-size: 14px; }
  .touch-mode .preview { width: min(28vw, 124px) !important; }

  /* Short landscape: keep both player previews on the first screen and the
     roster above the fixed touch footer. The DOM stays in reading order; CSS
     grid only rearranges the existing name/preview/cards blocks. */
  .touch-mode.touch-landscape #screen-select:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "title title"
      "name1 name2"
      "view1 view2"
      "cards cards";
    align-content: start;
    gap: 6px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: calc(env(safe-area-inset-bottom) + 96px);
  }
  .touch-mode.touch-landscape #screen-select .screen-title {
    grid-area: title;
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
  }
  .touch-mode.touch-landscape #screen-select .screen-subtitle { display: none; }
  .touch-mode.touch-landscape #screen-select .select-name {
    gap: 0;
    padding-left: 8px;
  }
  .touch-mode.touch-landscape #screen-select .select-name.p1 { grid-area: name1; }
  .touch-mode.touch-landscape #screen-select .select-name.p2 { grid-area: name2; }
  .touch-mode.touch-landscape #screen-select .select-name .select-tag {
    font-size: 10px;
    line-height: 1.15;
  }
  .touch-mode.touch-landscape #screen-select .select-name strong {
    font-size: 18px;
    line-height: 1.1;
  }
  .touch-mode.touch-landscape #screen-select .select-name .select-role {
    font-size: 12px;
    line-height: 1.25;
  }
  .touch-mode.touch-landscape #screen-select .select-previews { display: contents; }
  .touch-mode.touch-landscape #screen-select .preview.p1 {
    grid-area: view1;
    justify-self: center;
    align-self: center;
  }
  .touch-mode.touch-landscape #screen-select .preview.p2 {
    grid-area: view2;
    justify-self: center;
    align-self: center;
  }
  .touch-mode.touch-landscape #screen-select .select-cards {
    grid-area: cards;
    flex-direction: row;
    gap: 8px;
  }
  .touch-mode.touch-landscape #screen-select .fighter-card {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 64px;
    padding: 6px 10px;
  }
  .touch-mode.touch-landscape #screen-select .fighter-card strong {
    font-size: 15px;
    line-height: 1.2;
  }
  .touch-mode.touch-landscape #screen-select .fighter-card span {
    font-size: 11px;
    line-height: 1.2;
    margin-top: 2px;
  }
  .touch-mode.touch-landscape #screen-select .fighter-card .chip {
    font-size: 10px;
    line-height: 1.1;
    margin-top: 3px;
    padding: 2px 6px;
  }
  .touch-mode.touch-landscape #screen-select .hint-line { display: none; }
}

/* A short landscape viewport scrolls; start the menu at the top so the
   selected previews and the first 44px+ card are reachable. */
.touch-mode.touch-landscape .screen { justify-content: flex-start; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------------
   Character select. Every geometry, colour and type value arrives as a CSS
   custom property from ui_theme.main_menu.character_select; style.css only
   arranges the returned values inside the shared 1280x720 design space.
   ------------------------------------------------------------------------- */
.selection-screen { position: absolute; inset: 0; }
/* Desktop replaces the legacy picker; touch keeps its direct-child flex
   reflow untouched. The legacy nodes stay in the DOM for that path. */
#screen-select.selection-mounted > :not(.selection-screen) { display: none; }

.cs {
  position: relative;
  width: var(--cs-w);
  height: var(--cs-h);
  overflow: hidden;
  isolation: isolate;
  background: var(--cs-bg);
  color: var(--cs-text);
  font-family: var(--cs-font);
  font-weight: 700;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
.cs *,
.cs *::before,
.cs *::after { box-sizing: border-box; }
.cs img,
.cs canvas { display: block; }
.cs :where(button) {
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.cs :where(button):focus-visible { outline: var(--cs-focus-w) solid var(--cs-focus); outline-offset: 2px; }

/* --- backdrop ------------------------------------------------------------ */
.cs-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}
.cs-backdrop-img {
  position: absolute;
  inset: -2%;
  width: 104%;
  height: 104%;
  object-fit: cover;
  object-position: center 40%;
  filter: brightness(var(--cs-backdrop-brightness)) saturate(var(--cs-backdrop-saturation));
  pointer-events: none;
}
.cs-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: var(--cs-veil-alpha);
  background:
    radial-gradient(130% 92% at 50% 40%, transparent 22%, color-mix(in srgb, var(--cs-veil) 90%, transparent) 100%),
    linear-gradient(180deg,
      color-mix(in srgb, var(--cs-veil) 88%, transparent) 0%,
      color-mix(in srgb, var(--cs-veil) 32%, transparent) 40%,
      color-mix(in srgb, var(--cs-veil) 94%, transparent) 100%);
}
.cs-veil::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    180deg,
    var(--cs-scanline) 0 1px,
    transparent 1px var(--cs-scanline-gap)
  );
}

/* --- header -------------------------------------------------------------- */
.cs-head {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cs-w);
  height: var(--cs-header-h);
  z-index: 6;
}
.cs-slot {
  position: absolute;
  left: var(--cs-slot-x);
  top: var(--cs-slot-y);
  width: var(--cs-slot-w);
  height: var(--cs-slot-h);
  padding: 4px var(--cs-slot-pad);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  text-align: left;
  background: color-mix(in srgb, var(--cs-panel) 78%, transparent);
  border: 1px solid var(--cs-border);
  transition: border-color var(--cs-transition) ease-out, background-color var(--cs-transition) ease-out;
}
.cs-slot[data-side="right"] { text-align: right; align-items: flex-end; }
.cs-slot:hover { border-color: var(--cs-border-bright); }
.cs-slot.is-active {
  border-color: var(--seat-color);
  background: color-mix(in srgb, var(--seat-color) 9%, var(--cs-panel));
  box-shadow: inset 0 -2px 0 var(--seat-color), 0 0 14px var(--seat-glow);
}
.cs-slot.is-ready { border-color: var(--seat-color); }
.cs-slot-line {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cs-slot[data-side="right"] .cs-slot-line { justify-content: flex-end; }
.cs-slot-tag {
  font-size: var(--cs-slot-tag-size);
  letter-spacing: 0.12em;
  color: var(--seat-bright);
  white-space: nowrap;
}
.cs-slot-state {
  font-size: var(--cs-slot-state-size);
  letter-spacing: 0.1em;
  color: var(--cs-muted);
  white-space: nowrap;
}
.cs-slot.is-ready .cs-slot-state { color: var(--seat-bright); }
.cs-slot-keys {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cs-slot[data-side="right"] .cs-slot-keys { justify-content: flex-end; }
.cs-key-label {
  font-size: var(--cs-key-label-size);
  letter-spacing: 0.1em;
  color: var(--cs-dim);
  white-space: nowrap;
}
.cs-key-label--confirm { margin-left: 4px; }
.cs-key {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: var(--cs-keycap-size);
  line-height: 1;
  color: var(--cs-keycap-text);
  background: var(--cs-keycap-bg);
  border: 1px solid var(--cs-keycap-border);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--cs-bg) 70%, transparent);
}
.cs-key--confirm { border-color: var(--seat-color); color: var(--seat-bright); }

.cs-title {
  position: absolute;
  left: var(--cs-grid-x);
  top: var(--cs-title-y);
  width: var(--cs-title-w);
  text-align: center;
  pointer-events: none;
}
.cs-title-main {
  margin: 0;
  font-size: var(--cs-title-size);
  line-height: 1.05;
  letter-spacing: var(--cs-title-track);
  color: var(--cs-text);
  text-transform: uppercase;
  text-shadow: 0 2px 10px color-mix(in srgb, var(--cs-bg) 80%, transparent);
}
.cs-title-sub {
  margin: 4px 0 0;
  font-size: var(--cs-subtitle-size);
  line-height: 1.2;
  letter-spacing: var(--cs-subtitle-track);
  color: var(--cs-muted);
  text-transform: uppercase;
}
.cs-title::after {
  content: "";
  display: block;
  width: 172px;
  height: 1px;
  margin: 7px auto 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--cs-seat-1-color) 18%,
    var(--cs-border-bright) 50%,
    var(--cs-seat-2-color) 82%,
    transparent
  );
  opacity: 0.7;
}
.cs[data-ready="true"] .cs-title-main { color: var(--cs-focus); }
.cs[data-ready="true"] .cs-title::after { opacity: 1; }

/* --- portrait grid -------------------------------------------------------- */
.cs-grid {
  position: absolute;
  left: var(--cs-grid-x);
  top: var(--cs-grid-y);
  display: grid;
  grid-template-columns: repeat(var(--cs-cols), var(--cs-tile-w));
  gap: var(--cs-gap-y) var(--cs-gap-x);
  background: color-mix(in srgb, var(--cs-bg) 62%, transparent);
  box-shadow:
    0 0 0 1px var(--cs-border),
    0 0 42px color-mix(in srgb, var(--cs-bg) 65%, transparent);
  z-index: 4;
}
.cs-row { display: contents; }
.cs-cell { width: var(--cs-tile-w); height: var(--cs-tile-h); }
.cs-tile {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: var(--cs-panel);
  border: 0;
  box-shadow: inset 0 0 0 var(--cs-tile-border) var(--cs-border);
  transition: box-shadow var(--cs-transition) ease-out, background-color var(--cs-transition) ease-out;
}
.cs-tile:hover { box-shadow: inset 0 0 0 var(--cs-tile-border) var(--cs-border-bright); background: var(--cs-panel-alt); }
.cs-tile:focus-visible { box-shadow: inset 0 0 0 var(--cs-tile-border) var(--cs-focus); z-index: 5; }
.cs-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.cs-tile-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--cs-bg) 38%, transparent) 0%,
    transparent 26%,
    transparent 70%,
    color-mix(in srgb, var(--cs-bg) 58%, transparent) 100%);
}
.cs-tile.is-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dashed var(--preview-color, var(--cs-accent));
  opacity: 0.9;
  pointer-events: none;
  z-index: 2;
}
.cs-tile.is-portrait-missing { background: var(--cs-panel-alt); }

.cs-cursor {
  position: absolute;
  border: 2px solid var(--seat-color);
  box-shadow:
    0 0 10px var(--seat-glow),
    inset 0 0 14px color-mix(in srgb, var(--seat-color) 16%, transparent);
  pointer-events: none;
  z-index: 3;
}
.cs-cursor[hidden] { display: none; }
.cs-cursor.is-ready {
  border-width: 3px;
  box-shadow:
    0 0 14px var(--seat-glow),
    inset 0 0 0 1px var(--seat-bright);
}
.cs-badge {
  position: absolute;
  left: 2px;
  top: 2px;
  padding: 1px 4px;
  font-size: var(--cs-badge-size);
  line-height: 1.25;
  letter-spacing: 0.06em;
  color: var(--seat-on);
  background: var(--seat-color);
  box-shadow: 0 0 8px var(--seat-glow);
  pointer-events: none;
  z-index: 4;
}
.cs-badge[data-side="right"] { left: auto; right: 2px; }
.cs-badge[hidden] { display: none; }

/* --- flanking player panels ---------------------------------------------- */
.cs-panel {
  position: absolute;
  left: var(--cs-panel-x);
  top: var(--cs-panel-y);
  width: var(--cs-panel-w);
  height: calc(var(--cs-avail-y) + var(--cs-avail-h));
  z-index: 3;
}
.cs-art {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cs-portrait-w);
  height: var(--cs-portrait-h);
  overflow: hidden;
  border: 0;
  box-shadow: inset 0 0 0 1px var(--cs-border);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--cs-panel-alt) 38%, transparent) 0%,
      color-mix(in srgb, var(--cs-bg) 64%, transparent) 100%);
  transition: box-shadow var(--cs-transition) ease-out;
}
.cs-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(78% 52% at 50% 86%, var(--seat-dim), transparent 72%);
}
.cs-panel.is-active .cs-art {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--seat-color) 78%, var(--cs-border)),
    0 0 20px color-mix(in srgb, var(--seat-glow) 65%, transparent);
}
.cs-panel.is-ready .cs-art {
  box-shadow:
    inset 0 0 0 2px var(--seat-color),
    0 0 24px var(--seat-glow);
}
.cs-portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 10px 22px color-mix(in srgb, var(--cs-bg) 85%, transparent));
}
.cs-panel.is-portrait-missing .cs-portrait { display: none; }
.cs-bracket {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--seat-color);
  border-style: solid;
  z-index: 3;
  pointer-events: none;
}
.cs-bracket--top { left: 6px; top: 6px; border-width: 2px 0 0 2px; }
.cs-bracket--bottom { right: 6px; bottom: 6px; border-width: 0 2px 2px 0; }
.cs-art-missing {
  position: absolute;
  left: 0;
  top: 44%;
  width: 100%;
  text-align: center;
  font-size: var(--cs-avail-size);
  letter-spacing: 0.08em;
  color: var(--cs-dim);
  text-transform: uppercase;
}
.cs-nameplate {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--cs-nameplate-h);
  padding: 0 12px 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  background: linear-gradient(180deg,
    transparent 0%,
    color-mix(in srgb, var(--cs-bg) 86%, transparent) 42%,
    var(--cs-bg) 100%);
  z-index: 2;
}
.cs-panel[data-side="right"] .cs-nameplate { align-items: flex-end; text-align: right; }
.cs-panel-tag {
  font-size: var(--cs-seat-tag-size);
  letter-spacing: 0.16em;
  color: var(--seat-bright);
  white-space: nowrap;
}
.cs-name {
  max-width: 100%;
  font-size: var(--cs-name-size);
  line-height: 1;
  letter-spacing: 0.01em;
  color: #fff;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  text-shadow:
    0 2px 0 var(--cs-bg),
    1px 0 0 var(--cs-bg),
    -1px 0 0 var(--cs-bg),
    0 -1px 0 var(--cs-bg),
    0 6px 16px color-mix(in srgb, var(--cs-bg) 92%, transparent);
}

.cs-idle-stage {
  position: absolute;
  left: calc((var(--cs-panel-w) - var(--cs-idle-w)) / 2);
  top: var(--cs-idle-y);
  width: var(--cs-idle-w);
  height: var(--cs-idle-h);
}
.cs-floor {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: var(--cs-floor-offset, 8px);
  height: 30px;
  transform: translateY(50%);
  background: radial-gradient(52% 50% at 50% 50%, var(--seat-dim), transparent 74%);
  border-bottom: 1px solid color-mix(in srgb, var(--seat-color) 42%, transparent);
}
.cs-idle {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
/* Runtime mirror only: the approved sheet stays a single right-facing set. */
.cs-idle[data-flip-x="true"] { transform: translateX(-50%) scaleX(-1); }
.cs-idle-missing {
  position: absolute;
  left: 0;
  top: 46%;
  width: 100%;
  text-align: center;
  font-size: var(--cs-avail-size);
  letter-spacing: 0.06em;
  color: var(--cs-dim);
}
.cs-avail {
  position: absolute;
  left: 0;
  top: var(--cs-avail-y);
  width: 100%;
  height: var(--cs-avail-h);
  margin: 0;
  display: flex;
  align-items: center;
  font-size: var(--cs-avail-size);
  letter-spacing: 0.07em;
  color: var(--cs-muted);
  text-transform: uppercase;
}
.cs-avail::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 7px;
  background: var(--seat-color);
  flex: none;
}
.cs-panel[data-availability="art_preview"] .cs-avail { color: var(--cs-dim); }
.cs-panel[data-availability="art_preview"] .cs-avail::before { background: var(--cs-dim); }
.cs-panel[data-side="right"] .cs-avail { justify-content: flex-end; }
.cs-panel[data-side="right"] .cs-avail::before { order: 1; margin-right: 0; margin-left: 7px; }

/* --- footer --------------------------------------------------------------- */
.cs-foot {
  position: absolute;
  left: var(--cs-grid-x);
  top: var(--cs-foot-y);
  width: var(--cs-title-w);
  height: var(--cs-foot-h);
  display: flex;
  align-items: center;
  gap: var(--cs-foot-gap);
  z-index: 5;
}
.cs-note {
  margin: 0;
  font-size: var(--cs-note-size);
  letter-spacing: 0.05em;
  line-height: 1.25;
  color: var(--cs-dim);
  text-transform: uppercase;
  white-space: nowrap;
}
.cs-count {
  margin-left: auto;
  font-size: var(--cs-note-size);
  letter-spacing: 0.05em;
  color: var(--cs-muted);
  text-transform: uppercase;
  white-space: nowrap;
}
.cs-lang {
  margin-left: auto;
  width: var(--cs-lang-w);
  font-family: PipilabuThai, PipilabuLatin, system-ui, sans-serif;
  height: var(--cs-lang-h);
  flex: none;
  border: 1px solid var(--cs-border);
  background: color-mix(in srgb, var(--cs-panel) 82%, transparent);
  color: var(--cs-text);
  font-size: var(--cs-lang-size);
  letter-spacing: 0;
}
.cs-lang:hover { border-color: var(--cs-accent); color: var(--cs-accent); }

.cs-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

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

/* ---------------------------------------------------------------------------
   Online friend rooms. Geometry, colours and type are applied from
   ui_theme.main_menu.online_lobby by online-lobby.js; this stylesheet only
   arranges the returned values and shares the menu's design space.
   ------------------------------------------------------------------------- */
.online-screen { color-scheme: dark; }
.online-screen [hidden] { display: none !important; }
.online-back {
  position: absolute;
  left: var(--online-back-x);
  top: var(--online-back-y);
  width: var(--online-back-w);
  height: var(--online-back-h);
  z-index: 2;
  padding: 0;
  border: 1px solid var(--online-button-border);
  background: var(--online-button-bg);
  color: var(--online-button-text);
  font-size: var(--online-back-font);
  font-weight: 600;
}
.online-back:hover { border-color: var(--online-mode-active-border); color: var(--online-title-color); }
.online-heading {
  position: absolute;
  left: 0;
  top: var(--online-heading-y);
  width: var(--online-heading-w);
  text-align: center;
}
.online-title {
  margin: 0;
  color: var(--online-text-title);
  font-size: var(--online-title-size);
  font-weight: 800;
  line-height: 1.15;
}
.online-subtitle {
  margin: 4px 0 0;
  color: var(--online-text-subtitle);
  font-size: var(--online-subtitle-size);
  line-height: 1.4;
}
.online-shell {
  position: absolute;
  left: var(--online-panel-x);
  top: var(--online-panel-y);
  width: var(--online-panel-w);
  height: var(--online-panel-h);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: var(--online-padding);
  background: var(--online-panel-bg);
  border: var(--online-panel-border-width) solid var(--online-panel-border);
  box-shadow: 0 0 18px var(--online-panel-glow);
  clip-path: polygon(
    var(--online-panel-chamfer) 0,
    calc(100% - var(--online-panel-chamfer)) 0,
    100% var(--online-panel-chamfer),
    100% calc(100% - var(--online-panel-chamfer)),
    calc(100% - var(--online-panel-chamfer)) 100%,
    var(--online-panel-chamfer) 100%,
    0 calc(100% - var(--online-panel-chamfer)),
    0 var(--online-panel-chamfer)
  );
}
.online-statusbar {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: var(--online-status-height);
  font-size: var(--online-status-font);
  line-height: 1.35;
}
.online-status-pill {
  flex: none;
  padding: 0 var(--online-status-padding);
  border: 1px solid var(--online-button-border);
  color: var(--online-text-subtitle);
  font-weight: 700;
  white-space: nowrap;
}
.online-status-pill[data-state="open"] { color: var(--online-start-ok); border-color: var(--online-start-ok); }
.online-status-pill[data-state="failed"] { color: var(--online-text-error); border-color: var(--online-text-error); }
.online-status-pill[data-state="reconnecting"] { color: var(--online-start-blocked); border-color: var(--online-start-blocked); }
.online-status-detail {
  flex: 1;
  min-width: 0;
  color: var(--online-text-muted);
}
.online-status-actions { display: flex; gap: 6px; margin-left: auto; }
.online-button {
  height: var(--online-button-height);
  padding: 0 var(--online-button-padding);
  border: 1px solid var(--online-button-border);
  background: var(--online-button-bg);
  color: var(--online-button-text);
  font-size: var(--online-button-font);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.online-button:hover:not(:disabled) { border-color: var(--online-list-active); color: var(--online-title-color); }
.online-button-primary {
  border-color: var(--online-button-primary-bg);
  background: var(--online-button-primary-bg);
  color: var(--online-button-primary-text);
}
.online-button-primary:hover:not(:disabled) { color: var(--online-button-primary-text); filter: brightness(1.08); }
.online-button:disabled { color: var(--online-button-disabled); border-color: var(--online-button-border); cursor: not-allowed; opacity: 0.55; }
.online-feedback {
  min-height: 0;
  margin: 0;
  padding: 0 2px;
  font-size: var(--online-room-phase-size);
  line-height: 1.4;
}
.online-error { color: var(--online-text-error); }
.online-notice { color: var(--online-text-subtitle); }
.online-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--online-left-width) minmax(0, 1fr);
  gap: var(--online-column-gap);
}
.online-left {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--online-section-gap);
  overflow: hidden;
}
.online-section { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.online-rooms-section { flex: 1; }
.online-section-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.online-section-title {
  margin: 0;
  color: var(--online-section-title-color);
  font-size: var(--online-section-title-size);
  font-weight: 700;
  line-height: 1.3;
}
.online-section-subtitle {
  margin: 0;
  color: var(--online-text-muted);
  font-size: var(--online-room-phase-size);
  line-height: 1.35;
}
.online-count { margin-left: auto; color: var(--online-list-muted); font-size: var(--online-list-font); white-space: nowrap; }
.online-refresh { height: calc(var(--online-button-height) - 8px); padding: 0 10px; font-size: var(--online-mode-meta-size); }
.online-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.online-field-label { color: var(--online-text-subtitle); font-size: var(--online-room-phase-size); font-weight: 600; line-height: 1.25; }
.online-hint { margin: 0; color: var(--online-text-muted); font-size: var(--online-mode-meta-size); line-height: 1.35; }
.online-input {
  width: 100%;
  height: var(--online-input-height);
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--online-input-border);
  border-radius: 0;
  background: var(--online-input-bg);
  color: var(--online-input-text);
  font: inherit;
  font-size: var(--online-input-font);
}
.online-input::placeholder { color: var(--online-input-placeholder); opacity: 1; }
.online-input:focus-visible, .online-select:focus-visible {
  outline: 3px solid var(--online-title-color);
  outline-offset: 1px;
}
.online-mode-cards { display: flex; gap: var(--online-mode-gap); }
.online-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: var(--online-mode-width);
  height: var(--online-mode-height);
  padding: var(--online-mode-padding);
  border: 1.5px solid var(--online-mode-border);
  background: var(--online-mode-bg);
  color: var(--online-text-body);
  text-align: left;
  overflow: hidden;
}
.online-mode-card:hover:not(:disabled), .online-mode-card:focus-visible { border-color: var(--online-mode-active-border); }
.online-mode-card:disabled { cursor: not-allowed; opacity: 0.65; }
.online-mode-title { color: var(--online-mode-title-color); font-size: var(--online-mode-title-size); font-weight: 800; line-height: 1.1; }
.online-mode-desc {
  color: var(--online-mode-desc-color);
  font-size: var(--online-mode-desc-size);
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
}
.online-mode-meta { color: var(--online-mode-meta-color); font-size: var(--online-mode-meta-size); font-weight: 600; }
.online-mode-capability { color: var(--online-mode-meta-color); font-size: var(--online-mode-meta-size); font-weight: 700; }
.online-mode-capability[data-tone="blocked"] { color: var(--online-mode-blocked-color); }
.online-mode-reason {
  width: 100%;
  color: var(--online-mode-blocked-color);
  font-size: var(--online-mode-meta-size);
  line-height: 1.25;
  max-height: 2.5em;
  overflow: hidden;
}
.online-join-row { display: flex; align-items: flex-end; gap: var(--online-join-gap); }
.online-code-field { flex: 0 0 var(--online-code-width); width: var(--online-code-width); }
.online-join-row > .online-button { flex: 1; height: var(--online-input-height); }
.online-room-list {
  display: flex;
  flex-direction: column;
  gap: var(--online-list-gap);
  max-height: var(--online-list-max-height);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.online-room-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--online-list-row-height);
  padding: 0 7px 0 10px;
  border: 1px solid var(--online-list-border);
  background: var(--online-list-bg);
  font-size: var(--online-list-font);
}
.online-room-row-main { display: flex; flex: 1; align-items: center; gap: 7px; min-width: 0; }
.online-room-row-code { color: var(--online-list-text); font-size: var(--online-list-font); letter-spacing: 0.04em; }
.online-room-row-mode, .online-room-row-count { color: var(--online-list-muted); font-size: var(--online-list-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-room-join { height: calc(var(--online-list-row-height) - 8px); padding: 0 9px; font-size: var(--online-mode-meta-size); }
.online-rooms-empty { margin: 0; color: var(--online-list-muted); font-size: var(--online-list-font); line-height: 1.4; }
.online-right { display: flex; flex-direction: column; min-height: 0; }
.online-empty-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--online-list-border);
  background: var(--online-list-bg);
  overflow: hidden;
}
.online-empty-title { margin: 0; color: var(--online-title-color); font-size: var(--online-room-header-size); line-height: 1.2; }
.online-empty-hint, .online-private-note { margin: 0; color: var(--online-text-muted); font-size: var(--online-room-phase-size); line-height: 1.45; }
.online-private-note { color: var(--online-text-subtitle); }
.online-empty-modes { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.online-empty-mode { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-top: 4px; border-top: 1px solid var(--online-list-border); }
.online-empty-mode-name { color: var(--online-text-body); font-size: var(--online-room-phase-size); font-weight: 700; }
.online-empty-mode-cap { color: var(--online-text-muted); font-size: var(--online-mode-meta-size); text-align: right; }
.online-room-panel { display: flex; flex-direction: column; gap: var(--online-room-gap); height: 100%; min-height: 0; }
.online-room-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.online-room-code-block { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.online-room-code { color: var(--online-title-color); font-size: var(--online-room-header-size); letter-spacing: 0.08em; line-height: 1.15; }
.online-room-share { color: var(--online-text-muted); font-size: var(--online-room-phase-size); }
.online-room-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px; color: var(--online-text-subtitle); font-size: var(--online-room-mode-size); text-align: right; }
.online-room-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--online-room-side-width);
  gap: var(--online-room-grid-gap);
}
.online-seats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: var(--online-seat-gap);
  min-height: 0;
}
.online-seats[data-columns="1"] { grid-template-columns: minmax(0, 1fr); }
.online-seats[data-columns="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.online-seats[data-columns="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.online-seats[data-columns="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.online-seat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  height: var(--online-seat-height);
  min-width: 0;
  padding: var(--online-seat-padding);
  border: 1.5px solid var(--online-seat-border);
  background: var(--online-seat-bg);
  overflow: hidden;
}
.online-seat[data-ready="true"] { border-color: var(--online-seat-ready); }
.online-seat[data-you="true"] { border-color: var(--online-seat-you); }
.online-seat[data-empty="true"] { color: var(--online-seat-empty); border-style: dashed; }
.online-seat[data-disconnected="true"] .online-seat-meta { color: var(--online-seat-disconnected); }
.online-seat-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.online-seat-title { color: var(--online-text-muted); font-size: var(--online-seat-title-size); font-weight: 600; }
.online-seat-team { margin-left: auto; color: var(--online-text-subtitle); font-size: var(--online-seat-meta-size); white-space: nowrap; }
.online-seat-you { color: var(--online-seat-you); font-size: var(--online-seat-meta-size); font-weight: 700; white-space: nowrap; }
.online-seat-name { color: var(--online-text-body); font-size: var(--online-seat-name-size); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-seat-meta { color: var(--online-seat-not-ready); font-size: var(--online-seat-meta-size); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-seat-meta[data-ready="true"] { color: var(--online-seat-ready-text); }
.online-room-side { display: flex; flex-direction: column; gap: 7px; min-width: 0; min-height: 0; overflow: hidden; }
.online-team-buttons { display: flex; gap: 6px; }
.online-team-button { flex: 1; height: calc(var(--online-button-height) - 8px); font-size: var(--online-mode-meta-size); }
.online-team-button[aria-pressed="true"] { border-color: var(--online-button-primary-bg); color: var(--online-text-title); }
.online-ready { width: 100%; }
.online-leave-room { width: 100%; }
.online-pending { color: var(--online-start-blocked); }
.online-start { width: 100%; height: var(--online-start-height); margin-top: 2px; border: 1px solid var(--online-button-border); background: var(--online-button-bg); color: var(--online-button-disabled); font-size: var(--online-start-font); font-weight: 700; cursor: not-allowed; opacity: 0.7; }
.online-start-reason { margin: 0; color: var(--online-start-blocked); font-size: var(--online-room-phase-size); line-height: 1.35; }
.online-start-reason[data-tone="ok"] { color: var(--online-start-ok); }
.online-match-line { margin: 0; color: var(--online-start-ok); font-size: var(--online-room-phase-size); line-height: 1.35; }
.online-shell[data-in-room="true"] .online-left { display: none; }
.online-shell[data-in-room="true"] .online-body { grid-template-columns: minmax(0, 1fr); }
.online-select { padding-right: 6px; }
.online-select option { background: var(--online-input-bg); color: var(--online-input-text); }
.online-screen button:focus-visible, .online-screen input:focus-visible, .online-screen select:focus-visible {
  outline: 3px solid var(--online-title-color);
  outline-offset: 2px;
}

.team-hud { position:absolute; top:var(--team-top-y); left:0; right:0; }
.team-hud[hidden] { display:none; }
.team-group { position:absolute; width:var(--team-width); display:flex; gap:var(--team-gap-x); }
.team-1 { left:var(--team-left-x); }
.team-2 { left:var(--team-right-x); }
.team-seat { flex:1; min-width:0; height:var(--team-card-height); background:var(--team-bg-color); border:1px solid var(--team-border-color); }
.team-seat[data-you="true"] { border-color:var(--team-you-border-color); }
.team-seat[data-ko="true"] { border-color:var(--team-ko-border-color); }
.team-seat-heading { display:flex; justify-content:space-between; color:var(--team-name-color); font-size:var(--team-font-size-name); }
.team-seat-heading strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.team-seat-heading span { color:var(--team-char-color); font-size:var(--team-font-size-meta); flex-shrink:0; }
.team-seat-hp, .team-seat-meter { background:var(--team-bg-color); height:var(--team-bar-height); }
.team-seat-hp i, .team-seat-meter i { display:block; height:100%; }
.team-seat-hp i { background:var(--team-hp-fill-top); }
.team-seat-meter i { background:var(--team-meter-fill); }
