:root {
  color-scheme: dark;
  --bg: #171A33; --panel: #21254A; --line: #4B4585; --thread: #9B90C8; --stitch: #E7A3C4;
  --ink: #F4EFE6; --muted: #AEB2D6; --card-ink: #1B1E3A;
  --ember: #FF7A59; --tide: #3CCBDA; --gold: #FFE066;
  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--display); font-weight: 500; line-height: 1.45; padding: 20px 16px 48px; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ---------- pages ---------- */
.wrap { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.wrap header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
/* Soft pillow white, so the title belongs to neither team. */
.logo { font-size: clamp(2.4rem, 11vw, 3.6rem); line-height: 1; color: var(--ink); text-shadow: 0 3px 0 rgba(18,20,43,.6), 0 0 26px rgba(244,239,230,.28); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.btn { font: inherit; background: var(--ink); color: var(--card-ink); border: 0; border-radius: 6px; padding: 10px 16px; font-weight: 800; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.joinrow { display: flex; gap: 8px; width: 100%; }
input[type=text] { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; flex: 1; min-width: 0; }
input.code-input { text-transform: uppercase; font-family: var(--mono); letter-spacing: .15em; }
input::placeholder { text-transform: none; letter-spacing: normal; font-family: var(--display); }
.err { color: #FF9A8A; min-height: 1.2em; }
.err:empty { display: none; }

/* ---------- lobby ---------- */
/* Home page banner: a live view of the bed. Taller on phones so the fighters stay big. */
.hero { width: 100%; aspect-ratio: 2 / 1; display: block; border-radius: 12px; border: 1px solid var(--line); background: #171A3A; }
@media (max-width: 480px) { .hero { aspect-ratio: 4 / 3; } }
/* Meet the fighters */
.meet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
@media (max-width: 460px) { .meet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.meet { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; min-width: 0; }
.meet > * { max-width: 100%; overflow-wrap: break-word; }
.meet canvas { width: 64px; height: 64px; flex: none; }
.meet .fn { font-weight: 800; }
.meet .fb { line-height: 1.25; font-size: .74rem; color: var(--muted); }
.meet .fs { font-size: .7rem; color: var(--gold); line-height: 1.2; margin-top: auto; padding-top: 2px; }
/* Home page rows. On phones and narrow windows they stack like everything else. */
.play-row, .info-row { display: flex; flex-direction: column; gap: 16px; }
/* Tablets and computers (700 pixels and wider): a wider page, a wide banner, the three
   ways to play side by side, and the two explanations side by side. From 900 pixels all
   six fighters fit in one row; below that they stay three to a row. */
@media (min-width: 700px) {
  #home.wrap { max-width: 1080px; }
  #home .hero { aspect-ratio: 7 / 2; }
  .play-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .info-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .play-row .joinrow { flex-wrap: wrap; }
}
@media (min-width: 900px) {
  #home .meet-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.wrap.lobby { max-width: 760px; }
.wrap .lobby-top { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.room-id { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.room-code { font-size: 2.2rem; font-weight: 600; letter-spacing: .18em; color: var(--gold); }
.lobby-body { display: flex; flex-direction: column; gap: 16px; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #3A2F12; border: 1px solid var(--gold); border-radius: 8px; padding: 10px 14px; font-weight: 800; }
.banner.fatal { background: #3A1C24; border-color: #FF7A8A; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.name-input { width: 100%; max-width: 320px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
/* Fighter cards: picture on top, text below, so the text always fits inside the card. */
.fighter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
@media (max-width: 460px) { .fighter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fighter-pick { font: inherit; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 10px; padding: 8px 8px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; min-width: 0; overflow: hidden; }
.fighter-pick > * { max-width: 100%; overflow-wrap: break-word; hyphens: auto; }
.fighter-pick canvas { width: 56px; height: 56px; flex: none; }
.fighter-pick .fn { font-weight: 800; }
.fighter-pick .fb { line-height: 1.25; font-size: .74rem; }
.fighter-pick .fs { font-size: .7rem; color: var(--gold); line-height: 1.2; margin-top: auto; padding-top: 2px; }
.fighter-pick.on { border-color: var(--gold); background: #2A2C55; }
.team-row { display: flex; gap: 8px; }
.team-btn { font: inherit; font-weight: 800; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 8px; padding: 10px 18px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.team-btn .tc { font-family: var(--mono); font-size: .75rem; color: var(--muted); font-weight: 500; }
.team-btn.a.on { border-color: var(--ember); background: rgba(255,122,89,.18); }
.team-btn.b.on { border-color: var(--tide); background: rgba(60,203,218,.18); }
.team-btn:disabled { opacity: .4; cursor: not-allowed; }
.rosters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.roster { background: var(--panel); border: 1px solid var(--line); border-top: 5px solid var(--c); border-radius: 10px; padding: 12px 14px; }
.roster.a { --c: var(--ember); } .roster.b { --c: var(--tide); }
.roster h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--c); display: flex; justify-content: space-between; }
.roster ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.roster li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.roster li canvas { width: 40px; height: 40px; flex: none; }
.roster li > div { min-width: 0; }
.roster .pn { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .away { color: var(--gold); }
@media (max-width: 460px) { .rosters { grid-template-columns: 1fr; } }

/* ---------- game screen ---------- */
body.playing { padding: 0; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
.game { position: fixed; inset: 0; background: #12142B; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.chip { font: inherit; font-size: .8rem; color: var(--ink); background: rgba(18,20,43,.75); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; text-decoration: none; cursor: pointer; white-space: nowrap; }
select.chip { appearance: none; padding-right: 12px; }
.hud-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hud-cards { display: flex; gap: 8px; pointer-events: none; }
.card { display: flex; align-items: center; gap: 8px; background: rgba(18,20,43,.75); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 8px; padding: 4px 10px 4px 8px; }
.card.a { --c: var(--ember); } .card.b { --c: var(--tide); }
.card .nm { font-size: .72rem; color: var(--muted); line-height: 1.1; }
.card .heat { font-size: 1.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.card .heat small { font-size: .6em; color: var(--muted); font-weight: 500; margin-left: 2px; }
.card .kos { font-family: var(--mono); font-size: .7rem; color: var(--muted); }

/* practice vs online */
body:not(.mode-online) .online-only { display: none !important; }
body:not(.mode-practice) .practice-only { display: none !important; }

/* Home page footer: who made the game. */
.site-foot { text-align: center; padding: 6px 0 18px; }
.site-foot a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.site-foot a:hover { color: var(--gold); }

/* online match HUD */
.clock.untimed { font-size: .8rem; font-family: inherit; font-weight: 800; padding-top: 6px; padding-bottom: 6px; }
.match-hud { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); pointer-events: none; }
.team-hud { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.team-hud.a { align-items: flex-start; }
.team-hud.b { align-items: flex-end; }

/* A thin line under each control so the rows are easy to tell apart. */
.team-hud .lives { font-weight: 800; font-size: .9rem; background: rgba(18,20,43,.75); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; }
.team-hud.a .lives span { color: var(--ember); } .team-hud.b .lives span { color: var(--tide); }
.team-hud .lives b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.team-hud .lives small { color: var(--muted); font-weight: 500; }
.heat-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.team-hud.b .heat-chips { justify-content: flex-end; }
/* Each player's heat: a small card with the name on top and a big number, like practice. */
.heat-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: rgba(18,20,43,.8); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 6px; padding: 3px 10px 4px 8px; font-size: .72rem; max-width: 150px; line-height: 1.1; }
.team-hud.a .heat-chip { --c: var(--ember); } .team-hud.b .heat-chip { --c: var(--tide); }
.heat-chip .hn { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.heat-chip b { font-size: 1.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.heat-chip b small { font-size: .5em; color: var(--muted); font-weight: 500; margin-left: 3px; }
.heat-chip.me { border-top-color: #fff; border-right-color: #fff; border-bottom-color: #fff; }
.heat-chip.ko, .heat-chip.out { opacity: .45; }

/* Player chart along the bottom of an online match (computers). Phones keep the small
   heat cards at the top instead, because the touch buttons are at the bottom. */
.player-bar { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding: 0 10px 8px; pointer-events: none; }
.pb-team { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-team.a { justify-content: flex-end; }
.pb-team.b { justify-content: flex-start; }
/* A big gold "VS" between the two teams. */
.pb-vs { font-size: 2.6rem; font-weight: 800; font-style: italic; line-height: 1; letter-spacing: -1px; color: var(--gold); -webkit-text-stroke: 2px #12142B; paint-order: stroke fill; text-shadow: 0 3px 0 #12142B, 0 0 18px rgba(255,214,102,.45); padding: 0 4px; }
/* Each side: the team's lives on top, its player cards under that. */
.pb-side { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pb-side.a { align-items: flex-end; } .pb-side.b { align-items: flex-start; }
.pb-lives { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; background: rgba(18,20,43,.82); border: 1px solid var(--line); border-radius: 999px; padding: 3px 14px; font-size: .82rem; line-height: 1.2; }
.pb-side.a .pb-lives { justify-content: flex-end; }
.pb-lives b { font-weight: 800; }
.pb-lives.a b, .pb-lives.a .pb-hearts { color: var(--ember); } .pb-lives.b b, .pb-lives.b .pb-hearts { color: var(--tide); }
/* One heart per life the team started with. Lost lives stay as faint hearts. */
.pb-hearts { display: flex; flex-wrap: wrap; gap: 0 2px; font-size: .95rem; line-height: 1; }
.pb-hearts .lost { color: var(--ink) !important; opacity: .22; }
.pb-left { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pb-left.last { color: var(--gold); animation: pb-last 1s ease-in-out infinite alternate; }
@keyframes pb-last { from { opacity: 1; } to { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .pb-left.last { animation: none; } }
.pb-lives[hidden] { display: none; }
.pb-card { display: flex; align-items: center; gap: 7px; background: rgba(18,20,43,.82); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 12px; padding: 4px 10px 4px 6px; line-height: 1.1; }
.pb-team.a .pb-card { --c: var(--ember); } .pb-team.b .pb-card { --c: var(--tide); }
.pb-card.me { border-top-color: #fff; border-right-color: #fff; border-bottom-color: #fff; }
.pb-card.gone { opacity: .45; }
.pb-card.powered { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,224,102,.7); }
.pb-pic { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: .6rem; color: var(--muted); }
.pb-pic canvas { width: 38px; height: 38px; display: block; }
.pb-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pb-name { font-size: .74rem; font-weight: 800; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-body b { font-size: 1.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.pb-body b small { font-size: .5em; color: var(--muted); font-weight: 500; margin-left: 3px; }
.pb-kd { font-size: .66rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
body:not(.touch-on) .hud-cards { visibility: hidden; }
/* Phones: the touch buttons are at the bottom, so in a match the chart goes across the top,
   each team in its own corner with the clock between them, and the cards are smaller.
   Practice and bot matches on phones keep their own cards at the top instead. */
body.touch-on.mode-practice .player-bar { display: none; }
body.touch-on .player-bar { top: 0; bottom: auto; align-items: start; gap: 8px; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); }
body.touch-on .pb-side.a { align-items: flex-start; } body.touch-on .pb-side.b { align-items: flex-end; }
body.touch-on .pb-team.a { justify-content: flex-start; } body.touch-on .pb-team.b { justify-content: flex-end; }
body.touch-on .pb-side { gap: 3px; } body.touch-on .pb-team { gap: 3px; }
body.touch-on .pb-vs { font-size: 1.5rem; min-width: 104px; text-align: center; margin-top: 74px; -webkit-text-stroke-width: 1.5px; }
body.touch-on .pb-lives { font-size: .68rem; padding: 1px 9px; gap: 1px 5px; }
body.touch-on .pb-hearts { font-size: .72rem; gap: 0 1px; }
body.touch-on .pb-card { gap: 4px; padding: 2px 7px 2px 3px; border-left-width: 4px; }
body.touch-on .pb-pic canvas { width: 26px; height: 26px; }
body.touch-on .pb-pic span { display: none; }
body.touch-on .pb-name { font-size: .62rem; max-width: 58px; }
body.touch-on .pb-body b { font-size: 1rem; }
body.touch-on .pb-kd { font-size: .56rem; }
body:not(.touch-on) .watching { bottom: 96px; }
.clock { font-size: 1.5rem; font-weight: 600; background: rgba(18,20,43,.8); border: 1px solid var(--line); border-radius: 8px; padding: 2px 12px; }
.clock-col { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; }
.small-chip { font-size: .7rem; padding: 2px 10px; }
.clock.low { color: #FF7A8A; border-color: #FF7A8A; }
.watching { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-weight: 800; color: var(--gold); pointer-events: none; }
.net-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #3A2F12; border: 1px solid var(--gold); border-radius: 8px; padding: 10px 16px; font-weight: 800; }
.results { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(12,14,36,.72); padding: 16px; overflow: auto; }
.results-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; width: min(560px, 100%); display: flex; flex-direction: column; gap: 12px; }
.results-card h2 { font-size: 1.8rem; }
/* Team wins in this room: "Ember 2  1 Tide". */
.record { display: inline-flex; align-items: baseline; gap: 8px; font-weight: 800; background: rgba(18,20,43,.6); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; white-space: nowrap; }
.record .rl { font-size: .68rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.record .ra { color: var(--ember); } .record .rb { color: var(--tide); }
.record .rn { font-family: var(--mono); font-size: 1.15em; color: var(--ink); }
.record .rd { font-size: .75rem; font-weight: 500; color: var(--muted); }
.record.record-big { font-size: 1.05rem; }
.result-scores { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; }
.score-box { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.score-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.round-tag { font-size: .72rem; font-weight: 800; background: rgba(18,20,43,.8); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
/* Rounds per game picker in the lobby. */
.rounds-pick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { font: inherit; font-size: .85rem; color: var(--ink); background: rgba(18,20,43,.6); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.seg button.on { background: var(--gold); color: #1B1E3A; border-color: var(--gold); font-weight: 800; }
.seg button:disabled { cursor: default; opacity: .6; }
.seg button.on:disabled { opacity: 1; }

/* Champions: the winning team's fighters, bouncing, with confetti behind the card. */
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.results-card { position: relative; }
.champions { border-radius: 10px; padding: 10px 8px 12px; background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--champ, var(--gold)) 28%, transparent), transparent 70%); }
.champ-label { text-align: center; font-weight: 800; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }
.champ-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.champ { margin: 0; width: 84px; display: flex; flex-direction: column; align-items: center; position: relative; }
.champ canvas { width: 84px; height: 84px; display: block; animation: champ-hop 1.1s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -0.18s); }
.champ figcaption { font-size: .8rem; font-weight: 800; text-align: center; overflow-wrap: anywhere; line-height: 1.2; }
.champ .champ-kind { display: block; font-weight: 500; font-size: .7rem; color: var(--muted); }
.champ .star-badge { position: absolute; top: -2px; right: 0; font-size: .62rem; font-weight: 800; color: #1B1E3A; background: var(--gold); border-radius: 999px; padding: 1px 6px; white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.champ.me figcaption { text-decoration: underline; text-underline-offset: 3px; }
@keyframes champ-hop { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-9px) rotate(-4deg); } 50% { transform: translateY(0) rotate(0); } 75% { transform: translateY(-5px) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .champ canvas { animation: none; } }
.feedback-line { margin: 0; }
.feedback-line a, .panel p a { color: var(--ink); }
.result-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-table { border-collapse: collapse; font-size: .85rem; width: 100%; }
.result-table caption { text-align: left; font-weight: 800; padding-bottom: 4px; }
.result-table.a caption { color: var(--ember); } .result-table.b caption { color: var(--tide); }
.result-table th { color: var(--muted); font-weight: 500; text-align: left; font-size: .72rem; }
.result-table th + th, .result-table td + td { text-align: right; width: 3.2em; font-variant-numeric: tabular-nums; }
.result-table td { padding: 3px 0; border-top: 1px solid var(--line); }
.result-table td.me { font-weight: 800; }
@media (max-width: 520px) { .result-teams { grid-template-columns: 1fr; } }
/* Short screens (phones on their side): name and number on one line to save room. */
@media (max-height: 430px) { .heat-chip { flex-direction: row; align-items: baseline; gap: 5px; padding: 2px 8px 2px 6px; } .heat-chip .hn { max-width: 60px; } .heat-chip b { font-size: 1.1rem; } .clock { font-size: 1.2rem; } }

.keys { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: .78rem; color: var(--muted); pointer-events: none; padding: 0 12px; }
.keys b { color: var(--ink); font-family: var(--mono); font-weight: 600; }

/* touch controls: only shown on touch screens */
.touch { display: none; }
body.touch-on .touch { display: block; }
body.touch-on .keys { display: none; }
.stick-zone { position: absolute; left: 0; top: 64px; bottom: 0; width: 45%; touch-action: none; }
.stick-base { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(244,239,230,.08); border: 2px solid rgba(244,239,230,.3); pointer-events: none; }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(244,239,230,.55); transform: translate(-50%, -50%); }
.pad { position: absolute; right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom); width: 290px; height: 200px; }
.tb { position: absolute; border-radius: 50%; border: 2px solid rgba(244,239,230,.35); background: rgba(33,37,74,.7); color: var(--ink); font: inherit; font-size: .72rem; font-weight: 800; touch-action: none; -webkit-user-select: none; user-select: none; padding: 0; }
.tb.on { background: rgba(244,239,230,.35); border-color: #fff; }
.tb.jump { right: 16px; bottom: 16px; width: 82px; height: 82px; font-size: .85rem; }
.tb.strike { right: 110px; bottom: 22px; width: 66px; height: 66px; border-color: var(--ember); }
.tb.wallop { right: 92px; bottom: 102px; width: 66px; height: 66px; border-color: var(--gold); }
.tb.special { right: 18px; bottom: 112px; width: 58px; height: 58px; border-color: var(--tide); }
.tb.guard { right: 190px; bottom: 18px; width: 54px; height: 54px; }

.rotate { display: none; position: absolute; inset: 0; background: var(--bg); place-items: center; text-align: center; padding: 24px; font-size: 1.2rem; font-weight: 800; }
@media (orientation: portrait) and (pointer: coarse) { .rotate { display: grid; } }
@media (max-height: 430px) {
  .card .heat { font-size: 1.2rem; }
  .chip { padding: 4px 10px; }
}

/* ---------- soft, pillowy shapes (Pillow Brawl look) ----------
   Rounder corners, lavender outlines like the quilt's stitching, and a short pink
   cross-stitch line under panel headings. Team colors are unchanged. */
.panel { border-radius: 20px; padding: 20px; box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 6px 18px rgba(8,9,26,.35); }
.panel > h2::after { content: ""; display: block; width: 46px; margin-top: 7px; border-top: 2px dashed var(--stitch); opacity: .9; }
.btn { border-radius: 14px; box-shadow: 0 3px 0 rgba(8,9,26,.35); }
.btn.ghost { box-shadow: none; border-color: var(--thread); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(8,9,26,.35); }
input[type=text] { border-radius: 14px; }
.hero { border-radius: 20px; }
.meet, .fighter-pick { border-radius: 16px; }
.team-btn { border-radius: 14px; }
.roster { border-radius: 18px; }
.results-card { border-radius: 22px; }
.champions { border-radius: 16px; }
.heat-chip, .clock, .card { border-radius: 12px; }
.banner, .net-banner { border-radius: 14px; }

/* ---------- home: the main menu ----------
   The home page is a game menu, not a list of boxes: a big outlined title (straight, not tilted: Ryan, 2026-12-03), the live bedroom
   as a banner, three bright "way to play" cards with chunky buttons, a fighter line-up, and
   numbered how-to-play steps. Everything here is scoped to #home. */
/* The night sky behind the menu and the room lobby (the game screen covers it). */
body:not(.playing) {
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,.75) 50%, transparent 51%),
    radial-gradient(1px 1px at 31% 62%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 9%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 74% 41%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 89% 77%, rgba(255,255,255,.65) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 88%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(900px 520px at 50% -80px, #3A2A8C 0%, rgba(58,42,140,0) 70%),
    linear-gradient(#141633, #1B1746 55%, #151833);
  background-size: 520px 520px, 430px 430px, 610px 610px, 380px 380px, 560px 560px, 470px 470px, auto, auto;
  background-attachment: scroll;
}
#home.wrap { gap: 20px; }
#home .title { align-items: center; text-align: center; gap: 8px; margin: 2px 0 0; }
#home .logo {
  font-size: clamp(3rem, 13vw, 5.6rem); line-height: .95; letter-spacing: -.03em; color: #FFF8EC;
  -webkit-text-stroke: 10px #2A2160; paint-order: stroke fill;
  text-shadow: 0 7px 0 #2A2160, 0 10px 0 rgba(8,9,26,.45), 0 0 40px rgba(255,224,102,.35);
}
#home .tag { font-size: 1.05rem; color: #D9D4F5; text-wrap: balance; }
#home .hero { border: 4px solid #FFF8EC; border-radius: 28px; box-shadow: 0 8px 0 rgba(8,9,26,.45), 0 18px 40px rgba(8,9,26,.5); }

/* The three ways to play. */
#home .mode {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  border-radius: 26px; padding: 20px 20px 22px; color: #1B1E3A;
  background: linear-gradient(165deg, var(--m1), var(--m2));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.45), inset 0 -6px 0 rgba(0,0,0,.14), 0 8px 0 rgba(8,9,26,.45), 0 16px 30px rgba(8,9,26,.4);
  transition: transform .15s ease;
}
#home .mode:hover { transform: translateY(-3px); }
#home .mode.friends { --m1: #FFB15C; --m2: #FF6F61; }
#home .mode.solo { --m1: #B79CFF; --m2: #7C5CFF; }
#home .mode.practice { --m1: #8BE9D9; --m2: #3CCBDA; }
#home .mode h2 { font-size: 1.5rem; line-height: 1.05; max-width: calc(100% - 84px); text-shadow: 0 1px 0 rgba(255,255,255,.35); }
#home .mode p { font-size: .95rem; font-weight: 600; color: rgba(27,30,58,.82); max-width: calc(100% - 70px); }
#home .mode p.err { max-width: none; color: #5A0F1E; background: rgba(255,255,255,.6); border-radius: 10px; padding: 4px 10px; }
#home .mode-pic { position: absolute; right: -6px; top: 6px; width: 104px; height: 104px; transform: rotate(8deg); filter: drop-shadow(0 4px 0 rgba(27,30,58,.25)); pointer-events: none; }
#home .mode .btn { background: #FFF8EC; color: #1B1E3A; border-radius: 16px; box-shadow: 0 5px 0 #1B1E3A; border: 2px solid #1B1E3A; padding: 9px 16px; }
#home .mode .btn.big { font-size: 1.12rem; padding: 12px 22px; margin-top: auto; }
#home .mode .btn:hover:not(:disabled) { background: #fff; }
#home .mode .btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #1B1E3A; }
#home .mode .joinrow { margin-top: 2px; align-items: stretch; }
#home .mode input[type=text] { background: rgba(27,30,58,.88); color: #FFF8EC; border: 2px solid #1B1E3A; border-radius: 16px; min-width: 9ch; }
#home .mode input::placeholder { color: #B9B4DC; }
#home .mode :focus-visible { outline-color: #1B1E3A; }

/* Sections under the cards: a centered title with a stitched line each side, no box. */
#home .band { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
#home .band-title { display: flex; align-items: center; gap: 14px; justify-content: center; font-size: 1.5rem; }
#home .band-title::before, #home .band-title::after { content: ""; flex: 1; max-width: 160px; border-top: 3px dashed var(--thread); opacity: .6; }

/* Fighter line-up: bigger pictures, each card lit in its fighter's color. */
#home .meet { background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 26%, #1B1E3A), #1B1E3A 70%); border: 2px solid color-mix(in srgb, var(--fc) 55%, #1B1E3A); border-radius: 22px; padding: 12px 10px 14px; box-shadow: 0 6px 0 rgba(8,9,26,.4); transition: transform .15s ease; }
#home .meet:hover { transform: translateY(-4px) rotate(-1deg); }
#home .meet canvas { width: 84px; height: 84px; }
#home .meet .fn { font-size: 1.15rem; }
#home .meet .fb { font-size: .8rem; color: #D2CEF0; }
#home .meet .fs { font-size: .74rem; font-weight: 800; }

/* How to play: four numbered steps. */
#home .steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 12px; counter-reset: step; }
#home .steps li { counter-increment: step; position: relative; background: rgba(33,37,74,.85); border: 2px solid var(--line); border-radius: 22px; padding: 16px 16px 16px 66px; font-size: .92rem; color: #D2CEF0; min-height: 68px; }
#home .steps li b { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 2px; }
#home .steps li::before { content: counter(step); position: absolute; left: 14px; top: 14px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; color: #1B1E3A; background: var(--gold); box-shadow: 0 4px 0 rgba(8,9,26,.45); }
#home .fine { text-align: center; max-width: 76ch; margin: 0 auto; }
#home .feedback-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; text-align: center; border-top: 2px dashed rgba(155,144,200,.4); padding-top: 20px; margin-top: 10px; }
#home .feedback-strip p { flex-basis: 100%; }

@media (min-width: 700px) {
  #home .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #home .mode { min-height: 250px; }
}
@media (min-width: 1000px) {
  #home .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #home .steps li { padding: 62px 16px 16px; }
}
@media (prefers-reduced-motion: reduce) { #home .mode, #home .meet { transition: none; } #home .mode:hover, #home .meet:hover { transform: none; } }

/* ---------- room lobby: matches the main menu ----------
   Same night sky, cream outlines, chunky buttons, and fighter cards lit in each fighter's
   color. Team buttons and rosters are filled with their team color. Scoped to #room. */
#room.wrap { gap: 18px; }
#room .lobby-top { background: rgba(33,37,74,.85); border: 3px solid #FFF8EC; border-radius: 24px; padding: 10px 16px; box-shadow: 0 6px 0 rgba(8,9,26,.45); }
#room .room-code { font-size: 2.6rem; font-weight: 600; color: var(--gold); text-shadow: 0 3px 0 #2A2160, 0 0 22px rgba(255,224,102,.35); }
#room .chip { border: 2px solid var(--thread); font-weight: 800; }
#room .panel { background: rgba(33,37,74,.88); border: 2px solid var(--line); border-radius: 26px; padding: 22px; box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 8px 0 rgba(8,9,26,.4); gap: 14px; }
#room .panel > h2 { font-size: 1.5rem; }
#room .panel > h2::after { display: none; }
#room .field > .small, #room .rounds-pick > .small:first-child { font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--thread); }
#room .btn { background: #FFF8EC; color: #1B1E3A; border: 2px solid #1B1E3A; border-radius: 16px; box-shadow: 0 5px 0 #0E1026; padding: 10px 18px; font-weight: 800; }
#room .btn:hover:not(:disabled) { background: #fff; }
#room .btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #0E1026; }
#room .btn.ghost { background: transparent; color: var(--ink); border-color: var(--thread); box-shadow: none; }
#room .btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); }
#room #joinBtn, #room #startBtn { font-size: 1.12rem; padding: 12px 26px; }
#room #startBtn { background: var(--gold); }
#room #startBtn:hover:not(:disabled) { background: #FFEA8F; }
#room input[type=text] { background: #14163A; border: 2px solid var(--line); border-radius: 16px; padding: 11px 14px; }
#room input[type=text]:focus { border-color: var(--gold); }

/* Fighter picker: lit in each fighter's color; the chosen one gets a gold ring and lifts. */
#room .fighter-pick { background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 24%, #1B1E3A), #1B1E3A 72%); border: 2px solid color-mix(in srgb, var(--fc) 50%, #1B1E3A); border-radius: 20px; padding: 10px 8px 12px; box-shadow: 0 5px 0 rgba(8,9,26,.4); transition: transform .12s ease; }
#room .fighter-pick:hover { transform: translateY(-2px); }
#room .fighter-pick canvas { width: 68px; height: 68px; }
#room .fighter-pick .fn { font-size: 1.05rem; }
#room .fighter-pick.on { border-color: var(--gold); background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 42%, #1B1E3A), #262A58 72%); box-shadow: 0 0 0 3px var(--gold), 0 6px 0 rgba(8,9,26,.4); transform: translateY(-3px); }

/* Team buttons: filled with the team color once picked. */
#room .team-btn { border-radius: 16px; padding: 11px 22px; font-size: 1.05rem; background: #14163A; border: 2px solid var(--c); box-shadow: 0 5px 0 rgba(8,9,26,.45); }
#room .team-btn.a { --c: var(--ember); } #room .team-btn.b { --c: var(--tide); }
#room .team-btn.on { color: #1B1E3A; }
#room .team-btn.a.on { background: linear-gradient(165deg, #FFB15C, #FF6F61); border-color: #1B1E3A; }
#room .team-btn.b.on { background: linear-gradient(165deg, #8BE9D9, #3CCBDA); border-color: #1B1E3A; }
#room .team-btn.on .tc { color: rgba(27,30,58,.75); font-weight: 600; }
#room .team-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(8,9,26,.45); }

/* Rosters: a colored header strip for each team. */
#room .roster { background: rgba(33,37,74,.88); border: 2px solid var(--c); border-radius: 24px; padding: 0 0 12px; overflow: hidden; box-shadow: 0 8px 0 rgba(8,9,26,.4); }
#room .roster h3 { margin: 0 0 10px; padding: 9px 16px; font-size: 1.15rem; color: #1B1E3A; }
#room .roster.a h3 { background: linear-gradient(165deg, #FFB15C, #FF6F61); }
#room .roster.b h3 { background: linear-gradient(165deg, #8BE9D9, #3CCBDA); }
#room .roster h3 .mono { color: #1B1E3A; }
#room .roster ul { padding: 0 14px; }

/* Round, lives, and time choices. */
#room .seg button { border: 2px solid var(--line); background: #14163A; padding: 7px 16px; font-weight: 600; }
#room .seg button.on { background: var(--gold); border-color: #1B1E3A; color: #1B1E3A; font-weight: 800; box-shadow: 0 3px 0 rgba(8,9,26,.45); }
#room .banner { border-width: 2px; border-radius: 18px; }
@media (prefers-reduced-motion: reduce) { #room .fighter-pick { transition: none; } #room .fighter-pick:hover, #room .fighter-pick.on { transform: none; } }

/* ---------- results screens: match the main menu ----------
   The end of an online match (#results) and of a match against the bot (#soloEnd):
   a cream-framed card, a big outlined headline in the winner's color, team-colored score
   tables, and the same chunky buttons, with a gold one for the main action. */
.results { background: rgba(14,12,44,.78); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.results .results-card { background: linear-gradient(180deg, #2B2666, #21254A 55%); border: 4px solid #FFF8EC; border-radius: 30px; padding: 24px 24px 22px; gap: 16px; width: min(600px, 100%); box-shadow: 0 10px 0 rgba(8,9,26,.5), 0 24px 50px rgba(8,9,26,.6); text-align: center; align-items: center; }
.results .results-card > * { width: 100%; }
.results .results-card h2 { font-size: clamp(2rem, 7vw, 3rem); line-height: 1; letter-spacing: -.02em; color: #FFF8EC; -webkit-text-stroke: 8px #1B1746; paint-order: stroke fill; text-shadow: 0 5px 0 #1B1746, 0 0 30px rgba(255,224,102,.3); padding: 6px 0 2px; }
.results #resultReason, .results #soloText { font-size: 1rem; color: #D9D4F5; }
.results .champions { border-radius: 22px; padding: 12px 10px 14px; background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--champ, var(--gold)) 38%, transparent), transparent 72%), rgba(18,20,43,.45); border: 2px solid color-mix(in srgb, var(--champ, var(--gold)) 55%, #1B1E3A); }
.results .champ-label { font-size: .9rem; }
.results .record { background: #14163A; border: 2px solid var(--line); padding: 6px 18px; }
.results .record.record-big { font-size: 1.2rem; }
.results .score-label { font-weight: 800; color: var(--thread); }
/* Score tables: a team-colored name tab on top of a rounded table. */
.results .result-teams { text-align: left; gap: 14px; }
.results .result-table { border-collapse: separate; border-spacing: 0; background: #14163A; border: 2px solid var(--c); border-radius: 0 16px 16px 16px; overflow: hidden; }
.results .result-table.a { --c: var(--ember); } .results .result-table.b { --c: var(--tide); }
.results .result-table caption { text-align: left; padding: 0; }
.results .result-table caption span { display: inline-block; color: #1B1E3A; font-weight: 800; padding: 5px 16px 4px; border-radius: 12px 12px 0 0; }
.results .result-table.a caption span { background: linear-gradient(165deg, #FFB15C, #FF6F61); }
.results .result-table.b caption span { background: linear-gradient(165deg, #8BE9D9, #3CCBDA); }
.results .result-table th, .results .result-table td { padding: 6px 10px; }
.results .result-table th { color: var(--thread); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .68rem; }
.results .result-table td { border-top: 1px solid rgba(75,69,133,.7); }
.results .result-table td.me { color: var(--gold); }
/* Buttons. */
.results .row { justify-content: center; gap: 12px; }
.results .btn { background: #FFF8EC; color: #1B1E3A; border: 2px solid #1B1E3A; border-radius: 16px; box-shadow: 0 5px 0 #0E1026; padding: 11px 20px; font-weight: 800; font-size: 1.02rem; }
.results .btn:hover:not(:disabled) { background: #fff; }
.results .btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #0E1026; }
.results .btn.ghost { background: transparent; color: var(--ink); border-color: var(--thread); box-shadow: none; font-weight: 600; }
.results #rematchBtn, .results #soloAgain { background: var(--gold); font-size: 1.12rem; padding: 12px 26px; }
.results #rematchBtn:hover:not(:disabled), .results #soloAgain:hover { background: #FFEA8F; }
.results .feedback-line a { color: var(--ink); }

/* lobby: bot difficulty sits under the bots on/off buttons */
#botLevelRow { margin-top: 6px; }
#botLevelRow[hidden] { display: none; }
.hud-cards .card.powered { box-shadow: 0 0 12px rgba(255,224,102,.7); }

/* home: the two power-ups, each with its picture and what it does */
#home .pu-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
#home .pu { --pc: var(--gold); display: flex; align-items: center; gap: 14px; background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 20%, #1B1E3A), #1B1E3A 75%); border: 2px solid color-mix(in srgb, var(--pc) 50%, #1B1E3A); border-radius: 22px; padding: 14px 18px 14px 12px; }
#home .pu.cocoa { --pc: #FF9A6B; }
#home .pu canvas { width: 92px; height: 92px; flex: none; }
#home .pu h3 { margin: 0 0 3px; font-size: 1.15rem; color: var(--pc); }
#home .pu p { margin: 0; font-size: .9rem; line-height: 1.35; color: #D2CEF0; }
@media (min-width: 700px) { #home .pu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* home: "OR" between Create a room and joining with a code */
#home .or-line { display: flex; align-items: center; gap: 10px; width: 100%; font-weight: 800; font-size: .95rem; letter-spacing: .12em; color: #1B1E3A; margin: 2px 0 -2px; }
#home .or-line::before, #home .or-line::after { content: ""; flex: 1; border-top: 2px solid rgba(27,30,58,.45); }
