:root {
  --bonus-preview-size: 2rem;
  --cream: #f1f4fa;
  --paper: #f1f4fa;
  --gold: #34e0c6;
  --ink: #253750;
  --ink-deep: #0b1426;
  --orange: #ff5b5b;
  --pink: #f79ede;
  --blue: #00e5ff;
  --mint: #c7f6eb;
  --muted: #62758a;
  --rivals-coral: #ff5b5b;
  --rivals-teal: #34e0c6;
  --rivals-surface: #182740;
  --rivals-panel-background: #0b1426d9;
  --rivals-panel-surface: #182740d9;
  --rivals-bar-background: #0b1426b3;
  --rivals-bar-surface: #182740b3;
  --rivals-scene-top: 0rem;
  --rivals-scene-bottom: 0rem;
  --rivals-steel: #455a7a;
  --rivals-cyan: #00e5ff;
  --rivals-orange: #ffb454;
  --rivals-goal-accent: var(--rivals-cyan);
  --rivals-chamfer: .65rem;
  --rivals-glow-teal: #00e5ff44;
  --rivals-glow-coral: #ff5b5b33;
  --rivals-line: #455a7a;
  --radius: 1.25rem;
  --font-body: 'Space Grotesk', Arial, sans-serif;
  --font-display: 'Orbitron', 'Space Grotesk', Arial, sans-serif;
  --text-xs: .6875rem;
  --text-sm: .8125rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --text-2xl: 2.5rem;
  --text-hero: 4rem;
  --text-display: 6rem;
  --text-score: 4.75rem;
  --text-countdown: 8rem;
  --stage-ratio: 1.777777778;
  --rim-shadow: #17243b;
  --rim-light: #f1f4fa;
  --tray: #253750;
  --tray-edge: #0b1426;
  --timer-green: var(--rivals-cyan);
  --timer-warning: var(--rivals-orange);
  --timer-urgent: var(--rivals-coral);
  --brand-red: #0b1426;
  --brand-orange: #34e0c6;
  --brand-stripe: #ff5b5b;
  --clipboard-clip: #62758a;
  --elo-stakes-width: 34rem;
  --elo-digit-height: 6.5rem;
  --elo-gain-color: var(--rivals-teal);
  --elo-loss-color: var(--rivals-coral);
  --xp-recap-width: 34rem;
  --xp-recap-gauge-height: 2rem;
  --profile-xp-width: 10rem;
  --profile-xp-height: 1.125rem;
  --profile-xp-badge-size: 1.875rem;
  --timer-tick-width: 1.5rem;
  --turn-control-size: 3rem;
  --physics-panel-width: 24rem;
  --physics-panel-wide-width: 48rem;
  --physics-tooltip-width: 18rem;
  --game-profile-size: 4rem;
  --game-player-width: 6.5rem;
  --game-player-gap: 1rem;
  --lobby-profile-size: 4rem;
  --home-profile-size: 5rem;
  --profile-radius: .5rem;
  --home-menu-shade: #0b1426b3;
  --home-backdrop-zoom: 1.08;
  --home-backdrop-blur: .4rem;
  --home-backdrop-duration: .45s;
  --lobby-background-opacity: .3;
  --lobby-profile-offset: 1.5rem;
  --profile-picker-width: 30rem;
  --profile-picker-height: 32rem;
  --profile-grid-height: 24rem;
  --free-play-header-height: 6rem;
  --rivals-header-height: 6.25rem;
  --mobile-touch-size: 2.75rem;
  --mobile-hud-gutter: 2.75rem;
  --mobile-score-width: 9.5rem;
  --mobile-score-height: 3.25rem;
  --mobile-roster-rail: 4.5rem;
  --mobile-lobby-mascot-size: 12rem;
  --rules-scroll-distance: 0px;
  --rules-scroll-duration: 10s;
  --mobile-hud-top: calc(.5rem + env(safe-area-inset-top, 0rem));
  --mobile-hud-right: calc(.5rem + env(safe-area-inset-right, 0rem));
  --mobile-hud-bottom: calc(.5rem + env(safe-area-inset-bottom, 0rem));
  --mobile-hud-left: calc(.5rem + env(safe-area-inset-left, 0rem));
  --mobile-team-mascot-size: 12rem;
  --mobile-mode-image-height: 3rem;
  --button-primary-face: #28bdaa;
  --button-edge: var(--rivals-steel);
  --button-depth: .1875rem;
  --button-depth-hover: .3125rem;
  --button-depth-pressed: .0625rem;
  --button-lift: .125rem;
}

/* Resolve each extrusion against that button's accent and interaction depth. */
button, .download-cta, #game-length, .game-rules-panel input[type="checkbox"] {
  --button-shadow: calc(var(--button-depth) / -3) calc(var(--button-depth) / 3) 0 var(--button-edge), calc(var(--button-depth) * -2 / 3) calc(var(--button-depth) * 2 / 3) 0 var(--button-edge), calc(-1 * var(--button-depth)) var(--button-depth) 0 var(--button-edge);
}

.game-rules-panel input[type="checkbox"]:checked, .game-rule[aria-pressed="true"] { --button-edge: var(--rivals-teal); }

@media (max-width: 650px) { :root { --text-hero: 3rem; --text-display: 4.5rem; --text-xl: 1.5rem; --text-2xl: 2rem; } }
@media (max-width: 1050px) and (orientation: landscape) { :root { --text-score: 3.25rem; --text-countdown: 6rem; } }
@media (max-width: 700px) and (orientation: portrait) { :root { --text-score: 3rem; --text-countdown: 5rem; } }
@media (max-width: 700px) and (orientation: portrait) { :root { --free-play-header-height: 10rem; } }
@media (max-height: 550px) { :root { --free-play-header-height: 4rem; } }
@media (max-width: 1050px) { :root { --home-profile-size: 3rem; --lobby-profile-size: 3rem; } }
@media (max-width: 380px) and (orientation: portrait) { :root { --mobile-roster-rail: 3.75rem; } }
@media (min-width: 390px) and (orientation: portrait) { :root { --mobile-team-mascot-size: 14rem; --mobile-mode-image-height: 3rem; } }
.arena-rotated {
  --mobile-hud-top: calc(.5rem + env(safe-area-inset-right, 0rem));
  --mobile-hud-right: calc(.5rem + env(safe-area-inset-bottom, 0rem));
  --mobile-hud-bottom: calc(.5rem + env(safe-area-inset-left, 0rem));
  --mobile-hud-left: calc(.5rem + env(safe-area-inset-top, 0rem));
}

:root { --mvp-scale: 1; --mvp-previous-scale: 1; --spark-angle: 0deg; }

:root { --lobby-popup-scale: .94; }

@media (any-pointer: coarse) {
  :root { --button-lift: 0rem; }
}

@property --bonus-ring-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@media (min-height: 760px) and (orientation: portrait) { :root { --mobile-mode-image-height: 4rem; } }

@font-face { font-family: 'Orbitron'; font-style: normal; font-weight: 400 900; font-display: swap; src: url('/fonts/Orbitron-Variable.ttf') format('truetype'); }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('/fonts/SpaceGrotesk-Variable.ttf') format('truetype'); }
body { font-family: var(--font-body); font-size: var(--text-base); color: var(--ink); }
button, input, select { font: inherit; }
.text-base { font-size: var(--text-base); }
.text-sm, small { font-size: var(--text-sm); }
.eyebrow { font-size: var(--text-xs); font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; }
h1 { font-size: var(--text-hero); line-height: .95; letter-spacing: -.02em; }
h2 { font-size: var(--text-xl); line-height: 1.1; }
h3 { font-size: var(--text-lg); }
p { line-height: 1.6; }
.home-play>button, .home-private>button, .team-start { font-family: var(--font-display); font-weight: 700; }
.display-type { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; }

.text-lg { font-size: var(--text-lg); }
.text-hero { font-size: var(--text-hero); line-height: 1; }
.text-score { font-size: var(--text-score); line-height: 1; }

.text-2xl { font-size: var(--text-2xl); line-height: 1.1; }

.text-xl { font-size: var(--text-xl); line-height: 1.1; }

.text-display { font-size: var(--text-display); line-height: 1; }

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; min-height: 100vh; background: #d68053; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; color: inherit; transition: transform .15s, filter .15s, background .15s; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #3b849d; outline-offset: 4px; }
button[hidden], [hidden] { display: none !important; }
.game { overflow: hidden; overscroll-behavior-x: contain; min-height: 100vh; background: radial-gradient(ellipse at 48% 44%, #ffffff15, transparent 55%), linear-gradient(90deg, #e9a14f 0%, #e9a14f 49.9%, #eab19b 50%, #eab19b 100%); position: relative; padding: 0 2rem; }
.game::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .13; background-image: url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 80h160M80 0v160' fill='none' stroke='%23744939' stroke-width='.6'/%3E%3C/svg%3E"); }
.topbar { position: relative; height: 8rem; display: flex; align-items: center; justify-content: space-between; max-width: 1500px; margin: auto; z-index: 2; }
.wordmark { color: var(--cream); text-decoration: none; font-family: Georgia, serif; font-weight: 900; font-style: italic; font-size: var(--text-2xl); letter-spacing: -.065em; line-height: .8; transform: rotate(-7deg); text-shadow: 2px 3px var(--ink), -2px -1px var(--ink), 2px -1px var(--ink), -2px 2px var(--ink), 3px 5px #b3603a; display: flex; flex-direction: column; }
.wordmark>span:last-child { padding-left: 1.6rem; }
.logo-ball { font-size: var(--text-lg); vertical-align: super; text-shadow: none; margin-left: .15rem; }
.scoreboard { display: flex; position: absolute; top: -.4rem; left: 50%; transform: translateX(-50%); align-items: flex-start; filter: drop-shadow(0 6px 0 #8e555e66); }
.team-score { background: var(--ink); border: .45rem solid var(--gold); border-top: 0; height: 6.6rem; width: 11rem; display: flex; align-items: center; justify-content: space-evenly; padding: .75rem; gap: .75rem; }
.team-score.orange { border-radius: 0 0 0 2rem; border-right: 0; color: var(--orange); }
.team-score.pink { border-radius: 0 0 2rem 0; border-left: 0; color: var(--pink); }
.team-score strong { display: block; text-align: center; font-size: var(--text-2xl); font-weight: 900; line-height: 1; }
.team-score small { font-size: var(--text-xs); font-weight: 800; letter-spacing: .09em; display: block; margin-bottom: .45rem; }
.mascot-mini { font-size: var(--text-2xl); border: 3px solid currentColor; width: 3.1rem; height: 3.1rem; border-radius: 45% 45% 40% 40%; position: relative; text-align: center; line-height: 1; background: #8b593f; box-shadow: 0 0 0 2px var(--cream); }
.mascot-mini::before, .mascot-mini::after { content: ''; width: .8rem; height: .8rem; border-radius: 50%; position: absolute; background: inherit; border: 2px solid currentColor; top: -.45rem; }
.mascot-mini::before { left: -.3rem; }.mascot-mini::after {right:-.3rem;}
.rival-mini { background: #d2838f; color: var(--cream); border-radius: 45%; }
.turn-score { width: 8rem; border: .45rem solid var(--gold); border-top: 0; border-radius: 0 0 1.1rem 1.1rem; background: var(--cream); text-align: center; padding: .5rem .2rem; box-shadow: 0 0 0 3px #a46552; z-index: 1; }
.turn-score>span { display: block; padding: .8rem .4rem; border-radius: .3rem; background: var(--ink); color: var(--gold); font-size: var(--text-xl); font-weight: 900; }
.turn-score b { color: var(--cream); }.turn-score i{font-style:normal;opacity:.5;margin:0 .15rem;}
.turn-score small { display: block; margin-top: .35rem; font-weight: 900; letter-spacing: .1em; }
.top-actions { display: flex; gap: .6rem; }.icon-button { background: var(--cream); height: 2.6rem; width: 2.6rem; border-radius: .55rem; font-size: var(--text-xl); font-weight: 900; box-shadow: 0 3px #b47b62; }
.match-meta { position: relative; display: flex; justify-content: center; align-items: center; gap: .5rem; font-size: var(--text-xs); font-weight: 800; letter-spacing: .16em; margin-top: .5rem; height: 1.5rem; }
.live-dot { width: .4rem; height: .4rem; border-radius: 50%; background: var(--ink); }.room-code { font-size: var(--text-xs); background: #fff2c678; border-radius: .3rem; padding: .3rem .6rem; font-weight: bold; }
.arena { position: relative; max-width: 1500px; margin: -1.25rem auto -4.8rem; }
canvas { width: 100%; display: block; touch-action: none; cursor: crosshair; }
.phase-pill { position: absolute; bottom: 13%; left: 50%; transform: translateX(-50%); background: var(--cream); padding: .6rem 1.4rem; border-radius: 2rem; box-shadow: 0 3px 0 #4d49452b; font-size: var(--text-xs); font-weight: 900; letter-spacing: .1em; white-space: nowrap; pointer-events: none; }
.announcement { position: absolute; top: 42%; left: 50%; transform: translate(-50%,-50%) rotate(-3deg); color: var(--cream); text-shadow: 0 5px var(--ink), 3px 0 var(--ink), -3px 0 var(--ink), 0 -3px var(--ink); font-size: var(--text-hero); font-weight: 900; text-align: center; pointer-events: none; width: 90%; }
.announcement.countdown { font-size: 7rem; }
.control-dock { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr 2.2fr 1fr; max-width: 1300px; margin: 0 auto; align-items: center; gap: 1.5rem; }
.team-panel { display: flex; align-items: center; gap: .8rem; min-width: 0; }.team-panel strong { font-size: var(--text-sm); letter-spacing: .1em; }.team-right { text-align: right; justify-content: flex-end; }.player-list { font-size: var(--text-xs); margin-top: .45rem; line-height: 1.4; }.team-emblem { border-radius: 50%; height: 2.8rem; width: 2.8rem; display: grid; place-items: center; color: var(--cream); font-weight: 900; font-size: var(--text-lg); border: 3px solid var(--cream); flex-shrink: 0; box-shadow: 0 3px #92584250; }.orange-emblem{background:#986042;}.pink-emblem{background:#c57989;}
.turn-console { background: var(--ink); border: .45rem solid #b9755e; border-radius: var(--radius); padding: .65rem .8rem .8rem; box-shadow: 0 .35rem #925947; }
.timer-row { display: flex; align-items: center; gap: .6rem; color: var(--cream); margin-bottom: .65rem; }.timer-row>span { font-size: var(--text-xs); font-weight: 900; letter-spacing: .05em; white-space: nowrap; }.timer-row>b { min-width: 1.2rem; text-align: right; font-size: var(--text-sm); color: var(--gold); }.timer-bars { display: flex; gap: .2rem; flex: 1; }.timer-bars i { height: .55rem; flex: 1; background: #8fba91; border-radius: 2px; transition: background .3s; }.timer-bars i.off{background:#3e2d30;}.timer-bars i.urgent{background:var(--orange);}
.power-row { display: flex; align-items: stretch; gap: .5rem; }.power-book { background: var(--gold); width: 2.65rem; border-radius: .45rem; font-size: var(--text-xl); font-weight: 900; }.power-slots { display: flex; gap: .4rem; flex: 1; }.power-slot { width: 3rem; border-radius: .4rem; border: 2px dashed #aa8a79; background: #4e3739; color: #9e7e70; font-size: var(--text-lg); position: relative; }.power-slot.available { border: 2px solid var(--gold); background: var(--cream); color: var(--ink); }.power-slot.chosen { background: var(--mint); border-color: #83cabb; }.ready-button { background: var(--cream); border-radius: .4rem; padding: .8rem 1rem; font-size: var(--text-sm); font-weight: 900; white-space: nowrap; box-shadow: 0 3px #c5a574; }.ready-button span { margin-left: .5rem; }
footer { position: relative; max-width: 1450px; margin: 1.5rem auto; display: flex; justify-content: space-between; gap: 1rem; align-items: center; font-size: var(--text-xs); color: #744e45; }footer button{background:none;font-size:var(--text-xs);letter-spacing:.1em;font-weight:bold;} .footer-mark{letter-spacing:.15em;}.footer-mark span{padding-left:.6rem;}
.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 2rem; background: #3d29354f; backdrop-filter: blur(3px); overflow-y: auto; }.overlay:empty { display: none; }
.modal { position: relative; width: min(100%, 38rem); border: .5rem solid var(--gold); border-radius: 1.5rem; padding: 2rem; background: var(--paper); box-shadow: 0 .7rem 0 #74494470, 0 2rem 5rem #412d333b; animation: pop-in .3s ease-out; }
.modal.welcome { width: min(100%, 49rem); padding: 0; overflow: hidden; }.welcome-top { background: var(--cream); padding: 2rem 2.5rem 1.6rem; text-align: center; position: relative; border-bottom: 2px solid #dfc783; }.welcome-top .eyebrow { color: #a77b55; margin-bottom: .9rem; }.welcome-top h1 {color:var(--ink);}.welcome-top h1 span{color:#b76640;}.welcome-top p{margin-top:1rem;font-size:var(--text-sm);color:var(--muted);}.welcome-bottom{padding:1.75rem 2.5rem 2rem;}.welcome-ornament{position:absolute;left:2rem;top:3rem;font-size:var(--text-2xl);color:var(--gold);transform:rotate(-15deg);}.welcome-ornament.right{left:auto;right:2rem;transform:rotate(15deg);}
.name-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }.name-row label{font-size:var(--text-xs);font-weight:900;letter-spacing:.1em;white-space:nowrap;}input,select{border:2px solid #dfcca2;border-radius:.55rem;background:#fffdf1;padding:.8rem 1rem;color:var(--ink);min-width:0;}input{width:100%;} .mode-grid{display:grid;grid-template-columns:1fr 1fr;gap:.8rem;}.mode-card{border:2px solid #ddc58e;text-align:left;border-radius:.8rem;padding:1.1rem;background:#f8efce;display:flex;align-items:center;gap:1rem;}.mode-card.practice{background:var(--mint);border-color:#9fbfb1;}.mode-card .mode-icon{font-size:var(--text-xl);}.mode-card strong{display:block;font-size:var(--text-lg);margin-bottom:.25rem;}.mode-card small{font-size:var(--text-xs);color:#7c7060;}.join-row{display:flex;gap:.6rem;margin-top:1rem;}.join-row input{text-transform:uppercase;letter-spacing:.13em;}.join-row button{background:var(--ink);color:var(--cream);border-radius:.5rem;padding:.75rem 1.5rem;font-weight:bold;white-space:nowrap;}.small-note{text-align:center;font-size:var(--text-xs);color:var(--muted);margin-top:1.2rem;line-height:1.5;}.close-button{position:absolute;right:1rem;top:1rem;background:transparent;font-size:var(--text-xl);line-height:1;z-index:1;}.modal h2{padding-right:1.5rem;}.modal>.eyebrow{margin-bottom:.65rem;color:var(--muted);}.modal p{margin:1rem 0;color:#896c5e;font-size:var(--text-sm);}.primary{background:var(--ink);color:var(--cream);border-radius:.6rem;padding:1rem 1.4rem;font-weight:900;letter-spacing:.06em;box-shadow:0 4px #bba17b;}.full{width:100%;}.secondary{background:#eadab1;border-radius:.6rem;padding:.8rem 1rem;font-weight:bold;}.modal-actions{display:flex;gap:.7rem;margin-top:1.5rem;}.modal-actions>*{flex:1;}
.formation-list { display: grid; gap: .7rem; margin-top: 1.5rem; }.formation-choice{display:flex;align-items:center;gap:1.2rem;text-align:left;padding:.8rem;border:2px solid #d9c496;border-radius:.7rem;background:transparent;}.formation-choice:hover{background:var(--mint);}.formation-choice svg{width:7rem;flex-shrink:0;}.formation-choice strong{display:block;font-size:var(--text-lg);margin-bottom:.35rem;}.formation-choice small{line-height:1.4;display:block;}.lobby-teams{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin:1.5rem 0;}.lobby-team{padding:1.1rem;border:2px solid #d5b787;border-radius:.8rem;background:#f8e5bd;}.lobby-team:last-child{background:#f4d8d2;border-color:#dfb5ae;}.lobby-team h3{margin-bottom:.75rem;}.lobby-team ul{list-style:none;padding:0;min-height:3rem;margin:.6rem 0;font-size:var(--text-sm);}.lobby-team li{padding:.3rem 0;}.lobby-team button{padding:.5rem .8rem;background:var(--cream);border-radius:.35rem;font-size:var(--text-xs);font-weight:bold;}.room-invite{background:#eadbb7;padding:.75rem;border-radius:.5rem;display:flex;align-items:center;justify-content:space-between;margin-top:1rem;}.room-invite b{font-size:var(--text-xl);letter-spacing:.2em;}.room-invite button{background:transparent;font-weight:bold;}.lobby-options{display:flex;align-items:center;justify-content:space-between;gap:1rem;font-size:var(--text-sm);}.rule{display:flex;gap:1rem;margin:1.2rem 0;align-items:flex-start;}.rule>b{display:grid;place-items:center;flex-shrink:0;width:2rem;height:2rem;background:var(--gold);border-radius:50%;}.rule p{margin:.2rem 0;}.power-guide{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-top:1.4rem;}.power-guide article{padding:1rem;background:#f1e5c5;border-radius:.7rem;}.power-guide article>b{font-size:var(--text-xl);display:block;margin-bottom:.5rem;}.power-guide article p{font-size:var(--text-xs);margin:.5rem 0 0;}.result-score{font-size:var(--text-hero);text-align:center;font-weight:900;margin:1.5rem 0;color:#b66f4b;}.toast{position:fixed;z-index:20;bottom:2rem;left:50%;transform:translate(-50%,1rem);background:var(--ink);color:var(--cream);padding:.9rem 1.4rem;border-radius:.6rem;box-shadow:0 4px 15px #0002;opacity:0;pointer-events:none;transition:.2s;max-width:90vw;text-align:center;font-size:var(--text-sm);}.toast.visible{opacity:1;transform:translate(-50%,0);}
@keyframes pop-in{from{opacity:0;transform:translateY(12px) scale(.98);}to{opacity:1;transform:none;}}
@media(min-width:1600px){.arena{max-width:1400px;}.game{padding-top:1rem;}}
@media(max-width:1050px){.game{padding:0 1rem;}.team-emblem{display:none;}.control-dock{gap:.7rem;grid-template-columns:1fr 2.8fr 1fr;}.team-panel strong{font-size:var(--text-xs);}.arena{margin-bottom:-2.5rem;}.footer-mark{display:none;}.wordmark{font-size:var(--text-xl);}.scoreboard{transform:translateX(-50%) scale(.9);transform-origin:top center;}}
@media(max-width:700px){.game{padding:0 .5rem;}.topbar{height:7.5rem;align-items:flex-end;padding-bottom:.5rem;}.scoreboard{transform:translateX(-50%) scale(.72);}.wordmark{font-size:var(--text-lg);}.top-actions{gap:.4rem;}.icon-button{width:2rem;height:2rem;font-size:var(--text-lg);}.match-meta{font-size:var(--text-xs);letter-spacing:.04em;margin:0;}.arena{margin:0 -2rem -1.5rem;}.phase-pill{font-size:var(--text-xs);padding:.4rem .8rem;bottom:11%;}.control-dock{grid-template-columns:1fr 1fr;gap:1rem;padding:.5rem;}.turn-console{grid-column:1/-1;grid-row:1;}.team-panel{justify-content:flex-start;}.team-right{justify-content:flex-end;}.timer-bars{gap:.2rem;}.timer-row{gap:.5rem;}.overlay{padding:1rem;}.modal{padding:1.5rem;border-width:.35rem;max-height:92vh;overflow:auto;}.welcome-top{padding:1.8rem 1rem 1.2rem;}.welcome-ornament{display:none;}.welcome-bottom{padding:1.2rem;}.mode-card{padding:.8rem;gap:.5rem;}.mode-card strong{font-size:var(--text-base);}.name-row{display:block;}.name-row label{display:block;margin-bottom:.5rem;}.join-row button{padding:.7rem;}.power-guide{gap:.5rem;}footer{margin:1rem .5rem;}.announcement.countdown{font-size:var(--text-hero);}.lobby-teams{gap:.5rem;}.lobby-team{padding:.75rem;}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important;}}
.game { background: linear-gradient(90deg, var(--side-a, #e9a14f) 0%, var(--side-a, #e9a14f) 49.9%, var(--side-b, #eab19b) 50%, var(--side-b, #eab19b) 100%); }
.modal { max-height: 92svh; overflow-y: auto; }
.lab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.lab-grid button { text-align: left; }
.skin-choice { width: 100%; font-size: var(--text-sm); padding: .5rem; }
.placement-tools { position: absolute; top: 10%; left: 50%; transform: translateX(-50%); display: flex; gap: .4rem; align-items: center; padding: .5rem .7rem; background: var(--cream); box-shadow: 0 3px #b69c69; border-radius: .6rem; }
.placement-tools span { font-size: var(--text-sm); font-weight: bold; white-space: nowrap; padding-right: .5rem; }
.placement-tools button { border-radius: .25rem; background: var(--gold); padding: .2rem .5rem; font-size: var(--text-lg); }
@media(min-width:701px){.topbar{height:6.8rem;}.arena{width:min(100%,calc((100svh - 14rem) * 1.735));margin:-1rem auto -4rem;}.control-dock{max-width:1200px;}footer{margin:1rem auto;}.team-score small{max-width:7rem;font-size:var(--text-xs);}.team-score{width:11.5rem;}}


/* Tabletop framing, calibrated against the supplied gameplay reference. */
body { background: var(--ink-deep); display: grid; place-items: center; min-height: 100svh; }
.game { width: min(100vw, calc(100svh * var(--stage-ratio))); aspect-ratio: var(--stage-ratio); min-height: 0; padding: 0; isolation: isolate; }
.game::before { display: none; }
.topbar { position: absolute; inset: 0 0 auto; width: 100%; max-width: none; height: 15%; margin: 0; padding: 0; z-index: 4; }
.wordmark { position: absolute; right: 8%; top: 27%; font-style: normal; font-size: var(--text-2xl); line-height: .79; transform: rotate(-5deg); text-shadow: -2px -2px var(--ink), 2px -2px var(--ink), -2px 2px var(--ink), 2px 2px var(--ink), 0 4px #b25e43; }
.wordmark>span:last-child { padding-left: .8rem; }
.logo-ball { display: inline-block; font-size: var(--text-lg); transform: rotate(20deg); }
.scoreboard { top: -1%; width: 45%; height: 100%; transform: translateX(-50%); filter: drop-shadow(0 .5rem 0 #a95f51); }
.team-score { position: relative; height: 84%; width: 38%; padding: .3rem 1rem; border: .65rem solid var(--gold); border-top: 0; background: var(--ink); box-shadow: inset 0 0 0 .3rem var(--cream), 0 0 0 .8rem #ae6659; }
.team-score.orange { flex-direction: row-reverse; border-radius: 0 0 0 1.8rem; color: var(--side-a); }
.team-score.pink { flex-direction: row-reverse; border-radius: 0 0 1.8rem 0; color: var(--side-b); }
.team-score small { display: none; }
.team-score strong { font-family: var(--font-display); font-size: var(--text-score); font-weight: 700; line-height: .9; padding-top: .3rem; }
.mascot-mini { width: 4.1rem; height: 4.1rem; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.mascot-mini::before, .mascot-mini::after { display: none; }
.mascot-mini img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(1px 0 var(--cream)) drop-shadow(-1px 0 var(--cream)) drop-shadow(0 1px var(--cream)) drop-shadow(0 -1px var(--cream)); }
.turn-score { width: 26%; height: 100%; padding: .45rem .55rem .4rem; border: .65rem solid var(--gold); border-top: 0; border-radius: 0 0 1.2rem 1.2rem; box-shadow: 0 0 0 .55rem #ac675b; }
.turn-score>span { height: 71%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; padding: .5rem; }
.turn-score small { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; letter-spacing: 0; margin-top: .3rem; }
.top-actions { position: absolute; top: 18%; right: 1.4%; gap: .5rem; }
.icon-button { width: 2.8rem; height: 2.8rem; padding: .3rem; border-radius: .35rem; background: var(--cream); box-shadow: 0 3px #c09272; }
.icon-button svg { width: 100%; height: 100%; }
#help { position: absolute; right: 0; top: 3.4rem; width: 1.8rem; height: 1.8rem; font-size: var(--text-base); opacity: .75; }
.power-shortcut { position: absolute; top: 17%; left: 1.5%; width: 4.4rem; height: 4.4rem; background: #c6b46c77; border-radius: .8rem; color: var(--cream); padding: .5rem; }
.power-shortcut svg { width: 100%; height: 100%; filter: drop-shadow(2px 3px #8d7950); }
.match-meta { position: absolute; z-index: 5; bottom: .5rem; left: 1rem; height: auto; margin: 0; font-size: var(--text-xs); letter-spacing: .06em; opacity: .7; }
.match-meta .live-dot { display: none; }
.arena { position: absolute; inset: 0; width: 100%; max-width: none; margin: 0; }
#pitch { position: absolute; inset: 0; width: 100%; height: 100%; }
.phase-pill { bottom: 14%; background: transparent; box-shadow: none; padding: .25rem .75rem; font-family: var(--font-display); font-size: var(--text-sm); font-weight: 700; letter-spacing: .02em; color: #806d4c; }
.announcement { top: 47%; font-family: var(--font-display); font-weight: 700; font-size: var(--text-hero); text-shadow: 0 5px var(--ink), 3px 0 var(--ink), -3px 0 var(--ink), 0 -3px var(--ink); }
.announcement.countdown { font-size: var(--text-countdown); }
.control-dock { position: absolute; left: 6%; right: 6%; top: 88%; margin: 0; max-width: none; display: grid; grid-template-columns: 1fr 2.55fr 1fr; gap: 0; align-items: start; }
.turn-console { position: relative; border: .7rem solid var(--tray-edge); border-bottom: 0; border-radius: .9rem .9rem 0 0; box-shadow: none; padding: .7rem 1rem 1.5rem; background: var(--tray); outline: .5rem solid var(--gold); outline-offset: -.9rem; }
.timer-row { position: absolute; left: 3%; right: 3%; top: -3.35rem; height: 2.85rem; margin: 0; padding: .35rem 0; gap: .7rem; background: var(--tray); border-radius: .4rem .4rem 0 0; }
.timer-row>span { display: none; }
.timer-row>b { order: -1; display: grid; place-items: center; background: var(--cream); color: #9b695b; width: 2.7rem; height: 2.85rem; border-radius: .4rem; font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; }
.timer-bars { padding: .3rem; background: #503b37; border-radius: .4rem; gap: .2rem; }
.timer-bars i { height: .9rem; border-radius: .2rem; background: var(--timer-green); box-shadow: inset 0 2px #e2e578, 0 2px #3d2d2c; }
.timer-bars i.off { background: #342825; box-shadow: inset 0 2px #291e1c; }
.timer-bars i.urgent { background: var(--timer-urgent); box-shadow: inset 0 2px #ff9472, 0 2px #3d2d2c; }
.timer-bars i.warning { background: var(--timer-warning); box-shadow: inset 0 2px #ffc478, 0 2px #3d2d2c; }
.ready-button { width: 2.7rem; height: 2.85rem; padding: .2rem; font-size: var(--text-xl); font-weight: 900; color: #ad6d60; border-radius: .4rem; box-shadow: none; }
.ready-button span { margin: 0; }
.ready-button:disabled { opacity: .65; }
.power-row { gap: .8rem; min-height: 3.4rem; }
.power-book { width: 3.25rem; height: 3.25rem; border-radius: .6rem; background: var(--cream); color: #ae7460; padding: .5rem; }
.power-book svg { width: 100%; height: 100%; }
.power-slots { align-items: center; gap: .6rem; }
.power-slot { border: 0; background: #5f474680; color: #c8a47b; border-radius: 50%; width: 2.8rem; height: 2.8rem; font-family: var(--font-display); font-size: var(--text-xl); }
.power-slot.available { border: .18rem solid var(--gold); background: #f9eec8; color: var(--ink); box-shadow: 0 3px #443330; }
.power-slot.chosen { border-color: var(--cream); box-shadow: 0 0 0 3px var(--mint); }
.team-panel { padding: .9rem .75rem; background: #99634935; min-height: 6rem; border-radius: .5rem .5rem 0 0; gap: .65rem; }
.team-panel strong { display: none; }
.team-panel .team-emblem { display: grid; width: 2.6rem; height: 2.6rem; font-family: var(--font-display); color: var(--cream); border-color: var(--gold); }
.team-right { background: #b675763a; }
.player-list { color: var(--cream); margin: 0; font-family: var(--font-display); font-size: var(--text-sm); text-shadow: 0 1px #8a6255; }
footer { position: absolute; left: 1rem; right: 1rem; bottom: .4rem; margin: 0; max-width: none; justify-content: flex-end; pointer-events: none; }
footer #hint, .footer-mark { display: none; }
footer button { pointer-events: auto; font-size: var(--text-xs); opacity: .6; }
.overlay { background: #39303538; backdrop-filter: none; }
.overlay[data-dialog='formation'] { justify-content: flex-start; padding-left: max(2rem, calc((100vw - min(100vw, 100svh * var(--stage-ratio))) / 2 + 8%)); }
.overlay[data-dialog='formation']:where([data-formation-side='right']) { justify-content: flex-end; padding-left: 2rem; padding-right: max(2rem, calc((100vw - min(100vw, 100svh * var(--stage-ratio))) / 2 + 8%)); }
.clipboard { width: 31rem; border-width: .7rem; border-radius: 1.5rem; background: var(--cream); padding: 2.4rem 1.6rem 1rem; box-shadow: 0 .45rem #bb954f; overflow: visible; }
.clipboard::before { content: ''; position: absolute; top: -2.3rem; left: 20%; right: 20%; height: 3.4rem; background: var(--clipboard-clip); border-radius: .5rem .5rem 0 0; }
.clipboard::after { content: ''; position: absolute; top: -5.35rem; left: calc(50% - 2rem); width: 3rem; height: 3rem; border: .75rem solid var(--clipboard-clip); border-radius: 50%; }
.clipboard>.eyebrow { display: none; }
.clipboard h2 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; text-transform: uppercase; border-bottom: .2rem solid #988061; padding: 0 0 1rem; margin: 0 .7rem; }
.formation-list { gap: 0; margin: .7rem -1.6rem 0; }
.formation-choice { border: 0; border-radius: 0; padding: 1rem 1.6rem; gap: 1.5rem; }
.formation-choice:hover { background: var(--mint); transform: none; }
.formation-choice svg { width: 10.5rem; filter: drop-shadow(0 3px #918771); }
.formation-choice strong { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; }
.formation-choice small { color: #615248; font-size: var(--text-base); line-height: 1.25; }
.clipboard .small-note { margin: .5rem 0 0; font-size: var(--text-xs); }
@media (max-width: 1050px) and (orientation: landscape) {
  .wordmark { font-size: var(--text-xl); }
  .mascot-mini { width: 3rem; height: 3rem; }
  .turn-score>span { font-size: var(--text-xl); }
  .turn-score small { font-size: var(--text-sm); }
  .team-score { border-width: .45rem; padding: .3rem; }
  .turn-score { border-width: .45rem; padding: .3rem; }
  .control-dock { top: 87%; }
  .turn-console { padding: .5rem .8rem; }
  .timer-row { height: 2.2rem; top: -2.65rem; }
  .timer-row>b, .ready-button { height: 2.2rem; width: 2.1rem; }
  .timer-bars i { height: .65rem; }
  .power-book { width: 2.4rem; height: 2.4rem; }
  .power-slot { width: 2rem; height: 2rem; }
  .clipboard { transform: scale(.75); transform-origin: left center; }
}
@media (max-width: 700px) and (orientation: portrait) {
  body { display: block; background: var(--side-a, #f28625); }
  .game { width: 100%; min-height: 100svh; aspect-ratio: auto; overflow: hidden; }
  .topbar { height: 6rem; }
  .scoreboard { width: 80%; height: 6rem; }
  .team-score { padding: .25rem; border-width: .35rem; box-shadow: inset 0 0 0 .15rem var(--cream), 0 0 0 .5rem #ae6659; }
  .team-score strong { font-size: var(--text-score); }
  .mascot-mini { width: 2.3rem; height: 2.3rem; }
  .turn-score { border-width: .35rem; padding: .3rem; }
  .turn-score>span { font-size: var(--text-xl); }
  .turn-score small { font-size: var(--text-sm); }
  .wordmark { top: 7.3rem; right: 1rem; font-size: var(--text-xl); }
  .top-actions { top: 7.4rem; left: 1rem; right: auto; }
  #help { right: -2.6rem; top: .5rem; }
  .power-shortcut { display: none; }
  .arena { position: relative; inset: auto; margin: 10.5rem 0 0; width: 100%; aspect-ratio: var(--stage-ratio); }
  .phase-pill { bottom: 9%; font-size: var(--text-xs); white-space: normal; width: 80%; text-align: center; }
  .control-dock { position: relative; left: auto; right: auto; top: auto; margin: 1.8rem 1rem 0; grid-template-columns: 1fr 1fr; gap: .8rem; }
  .turn-console { grid-column: 1 / -1; grid-row: 1; padding: .7rem 1rem; border-bottom: .7rem solid var(--tray-edge); border-radius: .9rem; }
  .timer-row { top: -2.8rem; height: 2.3rem; }
  .timer-row>b, .ready-button { height: 2.3rem; width: 2.2rem; }
  .timer-bars i { height: .65rem; }
  .team-panel { min-height: 4rem; border-radius: .5rem; padding: .5rem; }
  .match-meta { bottom: 2rem; right: 1rem; left: 1rem; justify-content: center; font-size: var(--text-xs); }
  footer { bottom: .5rem; }
  .overlay[data-dialog='formation'] { justify-content: center; padding: 4.5rem 1rem 1rem; }
  .clipboard { width: 100%; padding: 2rem 1rem 1rem; }
  .clipboard::before { height: 3rem; }
  .clipboard::after { top: -4.5rem; width: 2rem; height: 2rem; left: calc(50% - 1.5rem); border-width: .6rem; }
  .clipboard h2 { font-size: var(--text-xl); }
  .formation-list { margin-left: -1rem; margin-right: -1rem; }
  .formation-choice { padding: .9rem 1rem; gap: 1rem; }
  .formation-choice svg { width: 8rem; }
  .formation-choice strong { font-size: var(--text-lg); }
  .formation-choice small { font-size: var(--text-sm); }
}
.power-slot svg { width: 100%; height: 100%; padding: .15rem; }
.power-guide b svg { display: block; width: 3rem; height: 3rem; margin: auto; }
.lab-grid button { display: flex; align-items: center; gap: .5rem; text-align: left; }
.lab-grid button svg { flex-shrink: 0; width: 2rem; height: 2rem; }

.ready-button svg { display: block; width: 100%; height: 100%; }
.ready-button.locked { color: var(--brand-red); opacity: 1; }
.back-home { background: var(--cream); color: var(--brand-red); padding: .65rem .75rem; border-radius: .5rem; box-shadow: .3rem 0 var(--brand-orange); font-family: var(--font-display); }
.top-actions { align-items: center; }
.wordmark { top: 66%; right: 15%; font-size: var(--text-xl); }
#help { right: 0; top: 3.5rem; }
.replay-banner { position: absolute; left: 27%; top: 0; width: 50%; height: 23%; z-index: 6; display: grid; place-items: center; background: var(--cream); color: var(--side-b); border-radius: 0 0 1rem 1rem; font-family: var(--font-display); font-size: var(--text-2xl); letter-spacing: .04em; white-space: nowrap; }
.replay-banner::before { content: ''; position: absolute; bottom: 0; left: 0; border-right: 5rem solid transparent; border-bottom: 4rem solid var(--brand-red); }
.replay-banner[hidden] { display: none; }
.team-panel { background: var(--side-a); filter: brightness(.83); }
.team-right { background: var(--side-b); }
.power-slot:disabled:not(.available) { display: none; }
@media (max-width: 700px) and (orientation: portrait) {
  .wordmark { top: 7.3rem; right: 1rem; }
  .back-home { display: block; position: absolute; left: 3.4rem; top: 0; white-space: nowrap; }
  #help { left: 0; right: auto; top: 3.1rem; }
  .replay-banner { left: 15%; width: 70%; height: 18%; font-size: var(--text-lg); }
  .replay-banner::before { border-right-width: 2rem; border-bottom-width: 1rem; }
}
.wordmark { width: 9%; right: 15%; top: 64%; transform: none; text-shadow: none; }
.wordmark img { display: block; width: 100%; }
.team-panel .team-emblem { display: none; }
.player-list { display: flex; align-items: center; gap: .55rem; }
.team-right .player-list { justify-content: flex-end; }
.player-avatar { display: inline-block; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: .12rem solid var(--brand-red); background: var(--cream); overflow: hidden; }
.player-avatar svg { width: 100%; height: 100%; }
.player-card { display: inline-flex; position: relative; }
.player-card.ready { filter: brightness(.7); }
.player-power { position: absolute; right: -.3rem; bottom: 0; width: 1.25rem; height: 1.25rem; background: var(--cream); border-radius: 50%; }
.player-power svg { width: 100%; height: 100%; }
.overlay[data-dialog='welcome'], .overlay[data-dialog='lobby'] { padding: 0; background: var(--ink-deep); }
.home-screen, .team-screen { position: relative; width: min(100vw, calc(100svh * var(--stage-ratio))); aspect-ratio: 16 / 9; overflow: hidden; font-family: var(--font-body); color: var(--brand-red); }
.home-screen { background: var(--cream); width: 100vw; height: 100svh; aspect-ratio: auto; }
.home-stripes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.home-logo { position: absolute; left: 38.8%; top: 13.4%; width: 40%; height: 36.4%; object-fit: contain; }
.home-play { position: absolute; left: 49%; top: 54%; width: 28%; display: grid; justify-items: center; }
.home-play>span, .home-play>label { background: var(--brand-red); color: var(--cream); padding: .7rem 1rem; border-radius: 1rem 1rem 0 0; font-size: var(--text-base); }
.home-play>button { width: 100%; padding: 1rem; border: .45rem solid var(--brand-red); outline: .18rem solid var(--cream); outline-offset: -.65rem; border-radius: 4rem; background: var(--brand-orange); font-size: var(--text-xl); color: var(--brand-red); }
.home-play>label { border-radius: 0 0 .8rem .8rem; padding: .45rem .8rem; font-size: var(--text-sm); }
.home-play>input { width: 68%; margin-top: .7rem; background: transparent; border: .15rem solid var(--brand-red); border-radius: .4rem; text-align: center; height: 2.5rem; }
.home-private { position: absolute; z-index: 2; left: 13%; bottom: 5%; width: 21%; }
.home-private>button { width: 100%; padding: .7rem .5rem; color: var(--brand-red); border: .45rem solid var(--brand-red); outline: .15rem solid var(--cream); outline-offset: -.6rem; border-radius: 4rem; background: var(--brand-orange); font-size: var(--text-lg); }
.home-private small { display: block; font-size: var(--text-sm); }
.home-join { display: flex; margin-top: .8rem; gap: .4rem; }
.home-join input { width: 70%; border-color: var(--brand-red); background: var(--cream); height: 2.2rem; padding: .5rem; font-size: var(--text-sm); }
.home-join button { background: var(--brand-red); color: var(--cream); padding: .5rem; border-radius: .4rem; }
.home-settings, .team-home { position: absolute; top: 1rem; right: 1rem; border-radius: .4rem; background: var(--brand-red); color: var(--cream); padding: .4rem .65rem; }
.home-settings { font-size: var(--text-xl); }
.home-credit { position: absolute; right: 1rem; bottom: .6rem; font-family: var(--font-body); font-size: var(--text-xs); }
.team-screen { background: var(--brand-red); color: var(--cream); }
.team-flow { position: absolute; inset: 0; width: 100%; height: 100%; }
.team-heading { position: absolute; top: 5%; left: 12%; width: 58%; text-align: center; }
.team-heading h1 { font-size: var(--text-hero); font-weight: 700; letter-spacing: .01em; text-shadow: 0 .5rem var(--ink); }
.team-heading p { margin-top: 1rem; font-size: var(--text-xl); }
.team-center-logo { position: absolute; left: 43%; top: 41%; width: 21%; height: 21%; }
.team-selection { position: absolute; top: 30%; width: 36%; height: 46%; color: var(--ink); text-align: center; }
.team-selection.side-0 { left: 8%; }
.team-selection.side-1 { right: 3%; top: 33%; width: 30%; }
.team-name { display: flex; align-items: center; justify-content: center; gap: .7rem; }
.team-name h2 { font-size: var(--text-2xl); letter-spacing: .03em; }
.team-name button { padding: .2rem; font-size: var(--text-xl); color: var(--ink); background: transparent; }
.team-name button:disabled { visibility: hidden; }
.team-large-mascot { width: 64%; height: 72%; object-fit: contain; filter: drop-shadow(0 .35rem var(--ink)); }
.team-join-slots { position: absolute; left: 10%; right: 10%; bottom: -17%; display: flex; justify-content: center; gap: .45rem; padding: 0; background: transparent; }
.side-1 .team-name { position: absolute; left: 0; right: 0; bottom: 7%; }
.side-1 .team-join-slots { top: -42%; bottom: auto; }
.side-1 .team-large-mascot { margin-top: 1.5rem; }
.empty-player, .team-join-slots .player-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 4.6rem; height: 4.6rem; border-radius: 50%; background: var(--ink); color: var(--cream); font-family: var(--font-body); font-size: var(--text-hero); line-height: 1; }
.side-0 .empty-player { background: #383769; }
.team-lobby-footer { position: absolute; left: 0; right: 0; bottom: 0; height: 15%; background: var(--ink); display: flex; align-items: center; justify-content: flex-end; gap: 2rem; padding: .65rem 2rem; }
.team-lobby-footer .room-invite { margin: 0 auto 0 0; background: transparent; color: var(--cream); flex-direction: column; align-items: flex-start; gap: .3rem; font-size: var(--text-sm); padding: 0; }
.team-lobby-footer .room-invite button { background: var(--cream); color: var(--brand-red); padding: .35rem .6rem; }
.team-length { display: grid; gap: .5rem; min-width: 13rem; }
.team-length select { height: 2.3rem; color: var(--brand-red); background: var(--cream); border-radius: .4rem; padding: .3rem .6rem; }
.team-length strong { font-size: var(--text-xl); font-weight: 700; line-height: 1.1; }
.team-length small { font-size: var(--text-sm); white-space: pre; }
.team-start { background: var(--brand-orange); color: var(--brand-red); border-radius: .5rem; padding: .7rem 1rem; font-size: var(--text-lg); }
.team-home { background: var(--cream); color: var(--brand-red); }
@media (max-width: 700px) and (orientation: portrait) {
  .wordmark { top: 7.3rem; right: 1rem; width: 28%; }
  .home-screen, .team-screen { width: 100%; min-height: 100svh; aspect-ratio: auto; }
  .home-logo { top: 12%; left: 29%; width: 68%; height: 24%; }
  .home-play { left: 20%; top: 42%; width: 68%; }
  .home-private { left: 15%; bottom: 8%; width: 70%; }
  .team-heading { left: 3%; width: 94%; top: 3%; }
  .team-heading h1 { font-size: var(--text-2xl); }
  .team-heading p { font-size: var(--text-sm); margin-top: .5rem; }

  .team-selection.side-0 { top: 22%; left: 3%; width: 94%; height: 24%; }
  .team-selection.side-1 { top: 51%; right: 3%; width: 94%; height: 24%; }
  .team-name h2 { font-size: var(--text-xl); }
  .team-large-mascot { height: 70%; width: 40%; }
  .team-join-slots { bottom: 0; left: 53%; right: 0; flex-wrap: wrap; }
  .side-1 .team-join-slots { top: auto; bottom: 0; }
  .side-1 .team-name { position: relative; bottom: auto; }
  .side-1 .team-large-mascot { margin-top: 0; }
  .team-large-mascot { margin-right: 40%; }
  .empty-player, .team-join-slots .player-avatar { width: 3rem; height: 3rem; font-size: var(--text-2xl); }
  .team-center-logo { left: 36%; top: 44%; width: 30%; height: 8%; }
  .team-lobby-footer { height: 20%; flex-wrap: wrap; gap: .5rem; padding: .5rem 1rem; }
  .team-lobby-footer .room-invite { font-size: var(--text-xs); }
  .team-length { min-width: 10rem; }
  .team-length strong { font-size: var(--text-lg); }
  .team-start { width: 100%; padding: .5rem; }
  .team-home { top: 6.5rem; }
}
.overlay[data-dialog='finished'] { background: transparent; padding: 0; }
.victory-screen { position: relative; width: min(100vw, calc(100svh * var(--stage-ratio))); aspect-ratio: 16 / 9; font-family: var(--font-body); }
.victory-scorecard { position: absolute; left: 42%; top: 25%; width: 25%; height: 23%; background: var(--cream); border-radius: .7rem .7rem 0 0; color: var(--ink); padding: .6rem 1rem .6rem 4rem; }
.victory-mascot { position: absolute; right: 78%; top: 0; width: 11rem; height: 11rem; border-radius: 50%; background: var(--side-a); }
.victory-mascot img { width: 100%; height: 100%; }
.victory-mascot>span { position: absolute; top: -3rem; left: -1.5rem; font-size: var(--text-score); color: var(--brand-orange); transform: rotate(-22deg); }
.victory-score { display: flex; align-items: center; justify-content: space-evenly; height: 70%; gap: .4rem; }
.victory-score strong { font-family: var(--font-display); font-size: var(--text-score); font-weight: 700; }
.victory-score>span { font-size: var(--text-xl); }
.victory-players { display: flex; gap: .4rem; }
.victory-letters { position: absolute; top: 56%; left: 8%; right: 8%; display: flex; justify-content: center; align-items: center; gap: .4rem; font-family: var(--font-display); }
.victory-letter { display: grid; place-items: center; width: 6.5rem; height: 8rem; border-radius: 50%; background: var(--cream); color: #e26d32; font-size: var(--text-countdown); font-weight: 700; text-shadow: -.3rem .4rem var(--brand-red); transform: rotate(-4deg); }
.victory-letter.color-1 { background: #e26d32; color: var(--cream); transform: translateY(1rem) rotate(4deg); }
.victory-letter.color-2 { background: var(--brand-red); color: var(--brand-orange); transform: translateY(-.7rem) rotate(-2deg); }
.victory-letter.color-3 { background: var(--brand-orange); color: var(--brand-red); text-shadow: .3rem .3rem var(--cream); transform: translateY(1rem) rotate(3deg); }
.victory-actions { position: absolute; bottom: 1rem; left: 1rem; right: 1rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .75rem; }
.victory-actions .small-note { color: var(--cream); margin: 0; margin-right: auto; }
@media (max-width: 700px) and (orientation: portrait) {
  .victory-screen { width: 100%; height: 100svh; aspect-ratio: auto; }
  .victory-scorecard { left: 30%; top: 29%; width: 65%; height: 15%; padding: .4rem .7rem .4rem 3rem; }
  .victory-score strong { font-family: var(--font-display); font-size: var(--text-2xl); }
  .victory-mascot { width: 6rem; height: 6rem; top: .4rem; }
  .victory-letters { top: 46%; gap: .15rem; left: 3%; right: 3%; }
  .victory-letter { width: 2.5rem; height: 3.5rem; font-size: var(--text-xl); }
  .victory-actions { bottom: 15%; }
}
.power-tooltip { position: absolute; left: calc(100% + 1rem); top: 0; width: 12rem; display: none; padding: .6rem .7rem; background: var(--cream); color: var(--ink); border-radius: .8rem; font-family: var(--font-display); line-height: 1.1; text-align: center; box-shadow: 0 .2rem #d8ae64; }
.power-tooltip::before { content: ''; position: absolute; right: 100%; top: 2rem; border-top: .65rem solid transparent; border-bottom: .65rem solid transparent; border-right: 1rem solid var(--cream); }
.power-tooltip strong { display: block; font-size: var(--text-lg); color: var(--brand-red); font-weight: 700; }
.power-tooltip small { display: block; font-size: var(--text-xs); color: #ed783a; margin: .3rem 0; }
.power-tooltip>span { display: block; font-family: var(--font-body); font-size: var(--text-xs); margin-top: .3rem; line-height: 1.15; }
.power-shortcut:hover .power-tooltip, .power-shortcut:focus-visible .power-tooltip { display: block; }
@media (min-width: 701px), (orientation: landscape) { .power-slots { display: none; } }
.victory-mascot>span svg { display: block; width: 5.5rem; height: 5.5rem; }
.victory-scorecard::after { content: ''; position: absolute; bottom: 0; right: 0; border-left: 2.5rem solid transparent; border-bottom: 2.5rem solid var(--brand-orange); }

.power-shortcut>img, .power-slot>img, .player-power>img { width: 100%; height: 100%; object-fit: contain; }
.power-guide b img { width: 3rem; height: 3rem; object-fit: contain; }
.lab-grid button img { width: 2rem; height: 2rem; object-fit: contain; }

/* Keep the sandbox's table and reusable controls inside the viewport. */
html, body { height: 100%; overflow: hidden; }
.game.free-play { width: 100%; height: 100dvh; min-height: 0; aspect-ratio: auto; overflow: hidden; display: grid; grid-template-rows: var(--free-play-header-height) auto minmax(0, 1fr) auto auto; }
.free-play .topbar { position: relative; height: 100%; }
.free-play .arena { position: relative; inset: auto; margin: 0; width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; container-type: size; }
.free-play #pitch { inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(100cqw, calc(100cqh * var(--stage-ratio))); height: auto; aspect-ratio: var(--stage-ratio); }
.free-play .phase-pill { bottom: calc(50% - min(50cqh, calc(50cqw / var(--stage-ratio)))); }
.free-play .control-dock { position: relative; left: auto; right: auto; top: auto; width: calc(100% - 2rem); max-width: 80rem; margin: 2.5rem auto 0; padding: 0; grid-template-columns: 1fr; }
.free-play .turn-console { grid-column: 1 / -1; border-bottom: .7rem solid var(--tray-edge); border-radius: .9rem; padding: .65rem .8rem; }
.free-play .team-panel, .free-play .power-book, .free-play .power-shortcut { display: none; }
.free-play .power-row { flex-wrap: wrap; align-items: center; min-height: 0; }
.free-play .power-slots { display: flex; flex-wrap: wrap; flex: 1; }
.free-play .power-slot { width: 2rem; height: 2rem; flex: 0 0 2rem; }
.free-play #open-free-game-settings, .free-play #reset-free-play, .free-play #open-free-physics { padding: .6rem .8rem; width: auto; }
.free-play .match-meta { position: relative; bottom: auto; left: auto; right: auto; margin: 0; padding: .25rem 1rem; justify-content: center; pointer-events: none; }
.free-play footer { position: relative; left: auto; right: auto; bottom: auto; margin: 0; padding: .5rem 1rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.free-play #hint { display: block; }
@media (max-width: 700px) and (orientation: portrait) {
  .free-play .power-slots { flex-basis: 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
  .free-play #open-free-game-settings, .free-play #reset-free-play, .free-play #open-free-physics { flex: 1; }
}

.physics-panel { position: fixed; z-index: 60; top: 1rem; right: 1rem; bottom: 1rem; width: min(var(--physics-panel-width), calc(100vw - 2rem)); display: flex; flex-direction: column; gap: .5rem; overflow: hidden; padding: 1rem; background: var(--cream); color: var(--ink-deep); border: .3rem solid var(--brand-red); border-radius: var(--radius); box-shadow: 0 .5rem 1.5rem var(--ink-deep); }
.physics-panel > :not(.physics-controls) { flex-shrink: 0; }
.physics-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.physics-heading .icon-button { flex-shrink: 0; }
.physics-category { display: flex; align-items: center; gap: .5rem; }
.physics-category select { flex: 1; padding: .5rem; }
.physics-save { margin: 0; color: var(--brand-red); }
.physics-controls { min-height: 0; flex: 1; display: grid; align-content: start; gap: .5rem; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; touch-action: pan-y; }
.physics-control { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .3rem .5rem; background: var(--paper); border: .1rem solid var(--gold); border-radius: .6rem; }
.physics-control-heading { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.physics-control-heading label { line-height: 1.15; }
.physics-control output { align-self: center; color: var(--brand-red); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.15; }
.physics-control input { width: 100%; height: 1.5rem; padding: 0; accent-color: var(--brand-red); cursor: pointer; }
.physics-info { flex-shrink: 0; display: grid; place-items: center; width: 1.25rem; height: 1.25rem; padding: 0; border: .1rem solid var(--brand-red); border-radius: 50%; background: transparent; color: var(--brand-red); font-family: var(--font-body); font-weight: bold; line-height: 1; }
.physics-tooltip { position: fixed; z-index: 70; width: min(var(--physics-tooltip-width), calc(100vw - 2rem)); padding: .75rem; border: .1rem solid var(--gold); border-radius: .6rem; background: var(--ink-deep); color: var(--cream); box-shadow: 0 .25rem .75rem var(--ink-deep); line-height: 1.4; pointer-events: none; }
.physics-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.physics-actions button { padding: .65rem; }
@media (max-height: 750px) {
  .physics-panel { padding: .5rem; gap: .25rem; }
  .physics-intro, .physics-heading .eyebrow { display: none; }
  .physics-controls { gap: .25rem; }
  .physics-control { padding: .25rem .5rem; gap: .4rem; }
  .physics-control input { height: 1.25rem; }
  .physics-info { width: 1rem; height: 1rem; }
  .physics-actions button { padding: .4rem .25rem; line-height: 1.2; }
}
@media (max-height: 750px) and (min-width: 600px) {
  .physics-panel { width: min(var(--physics-panel-wide-width), calc(100vw - 2rem)); display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .physics-category { justify-content: flex-end; }
  .physics-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .physics-save, .physics-controls, .physics-actions { grid-column: 1 / -1; }
}
@media (max-height: 600px) and (max-width: 599px) {
  .physics-control { padding-block: .125rem; }
}
@media (max-height: 550px) {
  .physics-panel { top: .5rem; bottom: .5rem; }
  .free-play .topbar .scoreboard { height: 4rem; }
  .free-play .team-score strong { font-size: var(--text-2xl); }
  .free-play .top-actions { top: .5rem; }
  .free-play .control-dock { margin-top: 1.8rem; }
  .free-play footer { padding: .25rem 1rem; }
}

/* Bobble Rivals: original neon stadium identity. */
.game { background: radial-gradient(ellipse at top, var(--rivals-surface), var(--ink-deep) 75%); }
.home-screen { background: linear-gradient(180deg, transparent, var(--ink-deep)), url('/artwork/rivals/brand-home.webp') center / cover; color: var(--cream); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 1rem; padding: 2rem 1rem; overflow-y: auto; }
.home-stripes { display: none; }
.home-logo { position: relative; inset: auto; width: min(32rem, 70vw); height: auto; flex-shrink: 0; filter: drop-shadow(0 .5rem 1.5rem var(--ink-deep)); }
.home-play { position: relative; inset: auto; width: min(22rem, 90vw); gap: .5rem; }
.home-play>span { background: transparent; color: var(--rivals-teal); font-size: var(--text-sm); letter-spacing: .16em; padding: 0; }
.home-play>button, .home-private>button { border: .125rem solid var(--rivals-teal); outline: 0; border-radius: .35rem; background: var(--rivals-teal); color: var(--ink-deep); box-shadow: .3rem .3rem 0 var(--ink-deep); padding: .75rem 1rem; }
.home-play>label { background: transparent; color: var(--cream); padding: .25rem; font-family: var(--font-body); font-size: var(--text-xs); letter-spacing: .12em; }
.home-play>input { width: 100%; height: auto; background: var(--rivals-panel-background); border-color: var(--rivals-line); color: var(--cream); margin: 0; padding: .65rem 1rem; }
.home-private { position: relative; inset: auto; width: min(22rem, 90vw); margin-top: .25rem; }
.home-private>button { background: var(--rivals-panel-background); color: var(--cream); border-color: var(--rivals-line); font-size: var(--text-base); }
.home-private small { color: var(--rivals-teal); font-family: var(--font-body); font-size: var(--text-xs); }
.home-join input { background: var(--rivals-panel-background); color: var(--cream); border-color: var(--rivals-line); height: auto; padding: .6rem; }
.home-join button { background: var(--rivals-coral); color: var(--ink-deep); padding: .5rem 1rem; }
.home-credit { position: relative; inset: auto; margin-top: auto; padding-top: 1rem; letter-spacing: .14em; color: var(--cream); }
.home-settings { background: var(--rivals-panel-background); color: var(--cream); border: .1rem solid var(--rivals-line); }
.team-screen { background: transparent; overflow: visible; }
.team-flow { position: fixed; opacity: var(--lobby-background-opacity); background: url('/artwork/rivals/orbital-space-v18.png') center / cover no-repeat; pointer-events: none; }
.team-flow canvas { display: block; width: 100%; height: 100%; }
.team-heading { left: 15%; width: 70%; }
.team-heading p { font-size: var(--text-sm); letter-spacing: .1em; }
.team-center-logo { left: 41%; top: 40%; width: 18%; height: 18%; }
.team-selection.side-0, .team-selection.side-1 { top: 30%; width: 35%; height: 44%; }
.team-selection.side-0 { left: 4%; }.team-selection.side-1 { right: 4%; }
.side-1 .team-name { position: relative; inset: auto; }
.side-1 .team-large-mascot { margin: 0; }
.team-name h2 { font-size: var(--text-xl); }
.team-name button { color: var(--cream); }
.team-large-mascot { width: 64%; height: 78%; filter: drop-shadow(0 .5rem .75rem var(--ink-deep)); }
.team-join-slots, .side-1 .team-join-slots { top: auto; bottom: -5%; }
.empty-player, .team-join-slots .player-avatar { width: var(--lobby-profile-size); height: var(--lobby-profile-size); font-size: var(--text-2xl); border: .1rem solid var(--rivals-line); }
.team-lobby-footer { left: calc((100% - 100vw) / 2); right: auto; width: 100vw; background: var(--rivals-bar-background); border-top: .1rem solid var(--rivals-line); }
.team-score { border-color: var(--rivals-line); border-width: .2rem; box-shadow: none; background: var(--ink-deep); }
.scoreboard { filter: none; }.turn-score { border-color: var(--rivals-line); border-width: .2rem; box-shadow: none; background: var(--rivals-surface); color: var(--cream); }
.mascot-mini img { filter: none; }
.turn-console { border-color: var(--ink-deep); border-width: .3rem; outline: .1rem solid var(--rivals-line); outline-offset: 0; background: var(--rivals-surface); }
.timer-row { background: var(--rivals-surface); }.timer-bars { background: var(--ink-deep); }.timer-bars i { box-shadow: none; }.timer-bars i.off { background: var(--rivals-line); box-shadow: none; }
.team-panel, .team-right { background: var(--ink-deep); filter: none; border-top: .15rem solid var(--side-a); }.team-right { border-color: var(--side-b); }
.player-list { text-shadow: none; }.phase-pill { color: var(--cream); }.match-meta { color: var(--cream); }.power-shortcut { background: var(--rivals-surface); border: .1rem solid var(--rivals-line); }
.wordmark { width: 13%; top: 70%; right: 12%; }.icon-button, .back-home { box-shadow: none; border: .1rem solid var(--rivals-line); }
.clipboard { border: .2rem solid var(--rivals-teal); border-radius: .5rem; box-shadow: 0 .5rem 2rem var(--ink-deep); padding-top: 1.2rem; }.clipboard::before, .clipboard::after { display: none; }
.victory-letter { border-radius: .3rem; text-shadow: none; }.victory-letter.color-1 { background: var(--rivals-coral); }.victory-letter.color-2 { background: var(--rivals-surface); }.victory-letter.color-3 { background: var(--rivals-teal); text-shadow: none; }
:focus-visible { outline: .2rem solid var(--rivals-coral); outline-offset: .2rem; }
@media (max-height: 700px) and (min-width: 701px) {
 .home-screen { align-items: flex-start; padding: 1.5rem 4rem; gap: .5rem; background-position: center; }
 .home-logo { width: min(26rem, 42vw); }.home-play, .home-private { width: min(22rem, 42vw); }.home-credit { padding-top: .5rem; }
}
@media (max-width: 700px) and (orientation: portrait) {
 .home-screen { padding: 3rem 1rem 1rem; background-position: center; }.home-logo { width: 90%; max-width: 30rem; margin-bottom: 1rem; }.home-play, .home-private { width: min(24rem, 90vw); }
 .team-heading { left: 3%; width: 94%; }.team-selection.side-0 { top: 20%; left: 3%; width: 94%; height: 24%; }.team-selection.side-1 { top: 49%; right: 3%; width: 94%; height: 24%; }
 .team-large-mascot { width: 40%; height: 70%; margin-right: 40%; }.side-1 .team-large-mascot { margin-right: 40%; }.team-join-slots, .side-1 .team-join-slots { bottom: 0; }.team-center-logo { top: 43%; left: 35%; width: 30%; height: 8%; }
 .wordmark { top: 7.3rem; right: 1rem; width: 28%; }
}

/* Match the arena's lit metal finish and illustrated character portraits. */
.game { background: radial-gradient(ellipse at 0 45%, var(--rivals-glow-teal), transparent 45%), radial-gradient(ellipse at 100% 45%, var(--rivals-glow-coral), transparent 45%), var(--ink-deep); }
.team-score.orange { border-color: var(--side-a); box-shadow: 0 0 1.25rem var(--rivals-glow-teal), inset 0 0 1rem var(--rivals-glow-teal); }
.team-score.pink { border-color: var(--side-b); box-shadow: 0 0 1.25rem var(--rivals-glow-coral), inset 0 0 1rem var(--rivals-glow-coral); }
.team-large-mascot { filter: drop-shadow(0 0 .8rem var(--rivals-glow-teal)); }.side-1 .team-large-mascot { filter: drop-shadow(0 0 .8rem var(--rivals-glow-coral)); }
.mascot-mini { width: 4.75rem; height: 4.75rem; }.mascot-mini img { filter: none; }
.turn-console { box-shadow: 0 0 1rem var(--rivals-glow-teal); }.ready-button, .power-book { color: var(--ink-deep); background: var(--rivals-teal); }
.game footer button { color: var(--cream); opacity: .8; }.timer-row>b { color: var(--ink-deep); }
@media (max-width: 700px) and (orientation: portrait) { .mascot-mini { width: 3.2rem; height: 3.2rem; } }

/* Chamfered metal frames follow the supplied identity; type scales stay centralized. */
.home-play>button, .home-private>button, .home-join button {
 border-radius: 0;
 clip-path: polygon(var(--rivals-chamfer) 0, 100% 0, 100% calc(100% - var(--rivals-chamfer)), calc(100% - var(--rivals-chamfer)) 100%, 0 100%, 0 var(--rivals-chamfer));
 box-shadow: inset 0 0 0 .125rem var(--rivals-teal);
 letter-spacing: .04em;
}
.home-private>button { box-shadow: inset 0 0 0 .125rem var(--rivals-steel); }
.home-join button { box-shadow: inset 0 0 0 .125rem var(--rivals-coral); }
.home-play>button:hover { background: var(--rivals-cyan); }
.home-private>button:hover { border-color: var(--rivals-teal); }
.home-credit { font-weight: 800; font-size: var(--text-xs); }
.team-score.orange, .team-score.pink, .turn-score { border-radius: 0; }
.team-score.orange { clip-path: polygon(0 0, 100% 0, 100% 100%, 1rem 100%, 0 calc(100% - 1rem)); }
.team-score.pink { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 1rem), calc(100% - 1rem) 100%, 0 100%); }
.team-score::after { content: ''; position: absolute; bottom: .35rem; width: 56%; height: .125rem; background: currentColor; opacity: .7; }
.turn-score { background: linear-gradient(145deg, var(--rivals-surface), var(--ink-deep)); border-color: var(--rivals-steel); }
.turn-score>small { background: var(--cream); color: var(--ink-deep); }
.team-panel, .turn-console { border-radius: .25rem; }
.power-slot { background: var(--ink-deep); border-color: var(--rivals-line); color: var(--rivals-line); }
.power-slot.available { border-color: var(--rivals-teal); background: var(--rivals-surface); color: var(--cream); }
.power-slot.chosen { background: var(--rivals-teal); color: var(--ink-deep); }


/* Prevent focus on match controls from scrolling the framed 3D canvas. */
.game:not(.free-play) { overflow: clip; }

/* Keep the field in its own row while the scenery extends behind the translucent HUD. */
body { display: block; background: var(--ink-deep); }
.game, .game.free-play { width: 100%; height: 100dvh; min-height: 0; aspect-ratio: auto; padding: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; background: var(--ink-deep); }
.game .topbar { position: relative; inset: auto; width: 100%; max-width: none; height: var(--rivals-header-height); padding: .5rem 1.5rem; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 1rem; background: url("/artwork/rivals/hud-chassis-v15.svg") center / 100% 100% no-repeat, linear-gradient(180deg, var(--rivals-bar-surface), var(--rivals-bar-background)); border-bottom: .0625rem solid var(--rivals-line); }
.game .wordmark { position: static; width: 9rem; height: auto; transform: none; text-shadow: none; filter: none; justify-self: start; }
.wordmark img { display: block; width: 100%; height: auto; }
.team-center-logo { object-fit: contain; }
.game .scoreboard { position: relative; inset: auto; transform: none; width: min(49rem, 46vw); height: 5.25rem; align-items: stretch; gap: .125rem; filter: none; }
.game .team-score { width: 36%; height: 100%; padding: .25rem .75rem; gap: .6rem; border: .125rem solid var(--rivals-steel); background: linear-gradient(145deg, var(--rivals-surface), var(--ink-deep)); align-items: center; justify-content: center; box-shadow: inset 0 -.1875rem currentColor; }
.game .team-score.orange { flex-direction: row; color: var(--side-a, var(--rivals-teal)); border-left: .3rem solid currentColor; }
.game .team-score.pink { flex-direction: row; color: var(--side-b, var(--rivals-coral)); border-right: .3rem solid currentColor; }
.game .team-score::after { display: none; }
.game .team-score strong { font-size: var(--text-hero); line-height: 1; padding: 0; text-shadow: 0 0 .35rem currentColor; }
.game .mascot-mini { width: 3.5rem; height: 3.5rem; flex-shrink: 0; }
.game .turn-score { width: 28%; height: 100%; padding: .25rem .25rem 0; border: .125rem solid var(--rivals-steel); border-top: .1875rem solid var(--rivals-cyan); border-radius: 0; clip-path: polygon(.5rem 0, calc(100% - .5rem) 0, 100% .5rem, 100% calc(100% - .6rem), calc(100% - .6rem) 100%, .6rem 100%, 0 calc(100% - .6rem), 0 .5rem); box-shadow: none; }
.game .turn-score>span { height: 70%; padding: 0; font-size: var(--text-2xl); line-height: 1; gap: .2rem; background: transparent; border-radius: 0; }
#turn { color: var(--rivals-cyan); } #turn-max, .turn-score i { color: var(--cream); }
.game .turn-score i { opacity: 1; }
.game .turn-score small { display: grid; align-items: center; height: 30%; font-size: var(--text-xs); padding: .125rem 0; margin: 0; }
.game .top-actions { position: static; inset: auto; display: flex; justify-self: end; gap: .5rem; }
.game .icon-button, .game .back-home { position: relative; inset: auto; height: 2.4rem; padding: .45rem; border-radius: 0; background: var(--ink-deep); color: var(--cream); border: .0625rem solid var(--rivals-steel); box-shadow: none; }
.game .icon-button { width: 2.4rem; display: grid; place-items: center; }
.game .icon-button svg { display: block; }
.game #help { position: relative; inset: auto; width: 2.4rem; height: 2.4rem; font-size: var(--text-base); opacity: 1; }
.game .back-home { display: flex; align-items: center; justify-content: center; padding: 0 .9rem; font-weight: 700; line-height: 1; white-space: nowrap; }
.game .power-shortcut { display: none; }
.game .match-meta { position: static; inset: auto; min-height: 0; margin: 0; padding: 0; justify-content: center; color: var(--rivals-steel); font-family: var(--font-body); font-size: var(--text-xs); letter-spacing: .12em; opacity: 1; pointer-events: auto; }
.game .match-meta .room-code { margin: .25rem 1rem; }
.game .arena, .game.free-play .arena { position: relative; inset: auto; width: 100%; height: 100%; min-height: 0; margin: 0; aspect-ratio: auto; container-type: normal; overflow: visible; z-index: 0; background: radial-gradient(ellipse, var(--rivals-surface), var(--ink-deep) 75%); }
.game #pitch, .game.free-play #pitch { position: absolute; inset: auto 0; top: calc(-1 * var(--rivals-scene-top)); width: 100%; height: calc(100% + var(--rivals-scene-top) + var(--rivals-scene-bottom)); max-height: none; transform: none; aspect-ratio: auto; display: block; }
.game .phase-pill { position: static; inset: auto; width: auto; max-width: 100%; padding: 0; border: 0; transform: none; background: transparent; color: var(--cream); font-family: var(--font-body); font-size: var(--text-xs); letter-spacing: .05em; text-align: center; pointer-events: none; }
.game .announcement { top: 45%; }
.game .replay-banner { left: 50%; top: .5rem; width: auto; height: auto; padding: .35rem 1rem; transform: translateX(-50%); border: .0625rem solid var(--rivals-cyan); border-radius: 0; background: var(--rivals-panel-background); color: var(--cream); font-size: var(--text-base); }
.game .replay-banner::before { display: none; }
.game .control-dock, .game.free-play .control-dock { position: relative; z-index: 2; inset: auto; width: 100%; max-width: none; margin: 0; padding: 1rem 1.5rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 28rem) minmax(0, 1fr); align-items: center; gap: 1rem; background: var(--rivals-bar-background); border-top: .0625rem solid var(--rivals-line); }
.game .turn-console, .game.free-play .turn-console { position: relative; grid-column: 2; grid-row: auto; padding: 0; border: 0; outline: 0; box-shadow: none; background: transparent; border-radius: 0; }
.game .timer-row, .game:not(.free-play) .timer-row { position: relative; inset: auto; width: 100%; height: var(--turn-control-size); margin: 0; padding: 0; gap: .75rem; justify-content: center; background: transparent; border-radius: 0; }
.game .timer-row>b { order: 0; width: var(--turn-control-size); height: var(--turn-control-size); flex-shrink: 0; background: transparent; color: var(--cream); font-family: var(--font-display); font-size: var(--text-xl); border-radius: 0; }
.game .timer-bars { flex: 0 1 auto; width: calc(var(--timer-tick-width) * var(--timer-ticks, 12) + .1875rem * (var(--timer-ticks, 12) - 1)); max-width: 100%; padding: 0; background: transparent; gap: .1875rem; border-radius: 0; }
.game .timer-bars i { height: .75rem; border-radius: 0; background: currentColor; color: var(--timer-green); box-shadow: 0 0 .35rem currentColor; transition: background .3s, color .3s, box-shadow .3s; }
.game .timer-bars i.warning { color: var(--timer-warning); background: currentColor; box-shadow: 0 0 .35rem currentColor; }
.game .timer-bars i.urgent { color: var(--timer-urgent); background: currentColor; box-shadow: 0 0 .35rem currentColor; }
.game .timer-bars i.off { background: var(--rivals-surface); box-shadow: none; }
.game .ready-button { width: var(--turn-control-size); height: var(--turn-control-size); padding: .4rem; flex-shrink: 0; border: .0625rem solid var(--rivals-cyan); background: var(--rivals-panel-background); color: var(--rivals-cyan); border-radius: 0; box-shadow: 0 0 .35rem var(--rivals-glow-teal); }
.game .ready-button svg { filter: drop-shadow(0 0 .125rem currentColor); }
.game .ready-button.locked { color: var(--rivals-cyan); }
.game .ready-button:disabled { background: var(--rivals-surface); color: var(--rivals-steel); border-color: var(--rivals-line); box-shadow: none; }
.game .ready-button:disabled svg { filter: none; }
.game .power-row, .game:not(.free-play) .turn-console .power-row { position: relative; inset: auto; min-height: 0; gap: .4rem; margin-top: .4rem; justify-content: center; }
.game .power-book { width: 1.8rem; height: 1.8rem; padding: .25rem; border: .0625rem solid var(--rivals-steel); border-radius: 0; background: var(--rivals-surface); color: var(--cream); }
.game .power-slots { display: flex; flex: 0; flex-wrap: wrap; gap: .4rem; }
.game .power-slot, .game.free-play .power-slot { width: 1.8rem; height: 1.8rem; flex: 0 0 1.8rem; border: .0625rem solid var(--rivals-steel); border-radius: .2rem; font-size: var(--text-base); }
.game .power-slot:not(.available) { opacity: .35; }
.game .team-panel, .game:not(.free-play) .team-panel { min-height: 0; padding: 0; gap: .5rem; border: 0; border-radius: 0; background: transparent; }
.game .team-panel strong, .game .team-emblem { display: none; }
.game .team-panel>div { min-width: 0; width: 100%; }
.game .player-card { flex: 0 1 var(--game-player-width); width: var(--game-player-width); min-width: 0; flex-direction: column; align-items: center; gap: .625rem; text-align: center; }
.game .player-portrait { position: relative; display: inline-flex; flex-shrink: 0; }
.game .player-name { width: 100%; color: var(--cream); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game .player-list { flex-wrap: wrap; gap: var(--game-player-gap); margin: 0; font-family: var(--font-body); font-size: var(--text-xs); text-shadow: none; }
.game .player-avatar { width: var(--game-profile-size); height: var(--game-profile-size); }
.game footer, .game.free-play footer { position: absolute; z-index: 3; inset: auto 1.5rem calc(100% + .75rem); max-width: none; margin: 0; padding: 0; display: flex; justify-content: flex-start; flex-wrap: wrap; gap: .75rem; background: transparent; pointer-events: none; }
.game footer #hint { display: block; color: var(--muted); font-size: var(--text-xs); }
.game footer button { color: var(--muted); font-size: var(--text-xs); opacity: 1; }
.game.free-play .control-dock { grid-template-columns: 1fr; }
.game.free-play .turn-console { grid-column: 1; width: min(100%, 50rem); justify-self: center; }
.game.free-play .timer-row { max-width: 28rem; margin: auto; justify-content: center; }
.game.free-play .timer-bars { display: none; }
.game.free-play .timer-row>span { display: block; color: var(--rivals-teal); font-size: var(--text-xs); }
.game.free-play .power-row { flex-wrap: wrap; }
.game.free-play .power-slots { flex: 1; justify-content: center; }
.game.free-play .free-tool { padding: .4rem .6rem; font-size: var(--text-xs); background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-steel); border-radius: 0; box-shadow: none; }
@media (max-width: 1050px) {
 .game .topbar { padding: .5rem .75rem; gap: .5rem; }
 .game .wordmark { width: 8rem; }
 .game .scoreboard { width: 26rem; }
 .game .team-score strong { font-size: var(--text-2xl); }
 .game .mascot-mini { width: 3.4rem; height: 3.4rem; }
 .game .turn-score>span { font-size: var(--text-xl); }
 .game .back-home { width: 2.4rem; overflow: hidden; font-size: 0; }
 .game .back-home::before { content: '⌂'; font-size: var(--text-lg); }
 .game .control-dock, .game.free-play .control-dock { padding: .5rem .75rem; gap: .5rem; }
}
@media (max-width: 700px) {
 .game .topbar { grid-template-columns: 1fr auto; grid-template-rows: auto auto; height: auto; padding: .5rem .75rem; }
 .game .wordmark { width: 7rem; }
 .game .top-actions { grid-row: 1; grid-column: 2; }
 .game .scoreboard { grid-row: 2; grid-column: 1 / -1; justify-self: center; width: min(100%, 26rem); height: 4rem; }
 .game .mascot-mini { width: 2.7rem; height: 2.7rem; }
 .game .control-dock { grid-template-columns: 1fr 1fr; }
 .game .turn-console { grid-column: 1 / -1; grid-row: 1; width: min(100%, 28rem); justify-self: center; }
 .game .team-panel { grid-row: 2; }
 .game.free-play .power-slots { flex: 0 0 100%; justify-content: center; }
 .game.free-play #open-free-game-settings, .game.free-play #open-free-physics, .game.free-play #reset-free-play, .game.free-play #end-free-play { flex: 1; }
 .game footer #hint { max-width: 75%; line-height: 1.3; }
 .game .match-meta { letter-spacing: .04em; }
}
@media (max-height: 550px) and (min-width: 701px) {
 .game .scoreboard { height: 3rem; width: 23rem; }
 .game .mascot-mini { width: 2.2rem; height: 2.2rem; }
 .game .team-score strong { font-size: var(--text-xl); }
 .game .turn-score>span { font-size: var(--text-lg); }
 .game .topbar { height: 4rem; padding-block: .25rem; }
 .game .control-dock { padding-block: .25rem; }
 .game .power-row { position: absolute; left: calc(100% + .5rem); top: 0; margin-top: 0; }
 .game .team-right { padding-right: 4rem; }
}
/* Carry the same chamfered navy/teal/coral identity through the existing dialogs. */
.is-loading .game, .is-loading .overlay, .is-loading .toast, .is-loading .physics-panel { visibility: hidden; }
.startup-loading { position: fixed; inset: 0; z-index: 100; display: flex; align-items: safe center; justify-content: center; padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left)); overflow-y: auto; overflow-x: hidden; color: var(--cream); background: transparent; }
.startup-content { position: relative; flex: 0 0 auto; width: min(34rem, 100%); min-width: 0; display: grid; justify-items: center; align-items: center; gap: 1.5rem; }
.startup-content .sign-in-parallax { width: min(28rem, 100%); margin: 0; }
.startup-content .sign-in-logo { max-height: calc(100dvh - 14rem); object-fit: contain; }
.startup-panel { width: min(22rem, 100%); min-height: 6rem; display: grid; align-content: center; padding: 0; border: 0; background: transparent; box-shadow: none; }
.startup-progress { height: .875rem; margin: 1.25rem 0 .75rem; padding: .125rem; border: .0625rem solid var(--rivals-steel); border-radius: var(--rivals-chamfer); background: var(--rivals-surface); }
.startup-progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--rivals-teal), var(--rivals-cyan)); box-shadow: 0 0 .75rem var(--rivals-cyan); transition: width .25s ease-out; }
.startup-detail { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; color: var(--mint); }
.startup-detail > :first-child { min-width: 0; }
.startup-detail > :last-child { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
#startup-retry { margin-top: 1rem; padding: .75rem 1.25rem; border-radius: .2rem; background: var(--rivals-teal); color: var(--ink-deep); font-weight: 800; }
@media (max-height: 550px) and (orientation: landscape) {
 .startup-content { width: min(52rem, 100%); grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2rem; }
 .startup-content .sign-in-logo { max-height: calc(100dvh - 6rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .startup-progress > span { transition: none; } }
.modal, .clipboard { background: var(--rivals-panel-background); color: var(--cream); border: .125rem solid var(--rivals-steel); border-radius: .35rem; box-shadow: 0 .5rem 2rem var(--ink-deep); }
.clipboard h2 { border-bottom-color: var(--rivals-steel); }
.clipboard .small-note, .formation-choice small { color: var(--muted); }
.formation-choice { color: var(--cream); }
.formation-choice:hover { background: var(--rivals-surface); }
.formation-choice[aria-pressed="true"] { background: var(--rivals-surface); box-shadow: inset .25rem 0 var(--rivals-cyan); }
.formation-countdown { margin: .75rem .7rem 0; color: var(--muted); }
.formation-countdown strong { color: var(--rivals-cyan); }
.home-screen { align-items: center; justify-content: center; padding: 3rem 7%; gap: 1rem; background: linear-gradient(90deg, var(--ink-deep), transparent 85%), url('/artwork/rivals/brand-home.webp') 65% center / cover; }
.home-logo { width: min(31rem, 45vw); margin-bottom: 1rem; }
.home-play, .home-private { width: min(23rem, 45vw); }
@media (max-width: 700px) {
 .home-screen { align-items: center; padding: 2rem 1rem; background: linear-gradient(180deg, transparent, var(--ink-deep) 60%), url('/artwork/rivals/brand-home.webp') center / cover; }
 .home-logo { width: min(31rem, 90vw); }
 .home-play, .home-private { width: min(23rem, 90vw); }
}

/* Bonus controls overlay the arena so selecting a power never resizes the camera viewport. */
.game .placement-tools { position: absolute; inset: auto; bottom: .75rem; left: 50%; z-index: 5; width: max-content; max-width: calc(100% - 1.5rem); transform: translateX(-50%); padding: .125rem .35rem; gap: .3rem; border: .0625rem solid var(--rivals-steel); border-radius: 0; background: var(--rivals-panel-surface); color: var(--cream); box-shadow: none; }
.game .placement-tools span { font-size: var(--text-xs); padding: 0; }
.game .placement-tools button { width: 1.5rem; height: 1.5rem; padding: .125rem; background: var(--ink-deep); color: var(--rivals-teal); font-size: var(--text-base); border-radius: 0; }

/* Rebrand the secondary screens and owner badges with the same existing color tokens. */
.player-avatar { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.formation-choice svg rect { fill: var(--rivals-surface); stroke: var(--rivals-steel); }
.formation-choice svg path { stroke: var(--cream); }
.formation-choice svg circle { fill: var(--rivals-teal); stroke: var(--cream); }
.formation-choice svg { filter: none; }
.modal .primary { background: var(--rivals-teal); color: var(--ink-deep); border: .0625rem solid var(--rivals-teal); border-radius: .2rem; box-shadow: none; }
.modal .secondary, .modal .close-button { background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-steel); border-radius: .2rem; box-shadow: none; }
.modal .small-note { color: var(--muted); }
.power-guide article { background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-steel); border-radius: .25rem; }
.power-guide article p { color: var(--cream); }
.team-lobby-footer .room-invite { background: transparent; color: var(--cream); border-radius: 0; }
.team-lobby-footer select { background: var(--rivals-surface); color: var(--cream); border-color: var(--rivals-steel); }
.team-lobby-footer .team-start { background: var(--rivals-teal); color: var(--ink-deep); border-radius: .2rem; }
.physics-panel { background: var(--rivals-panel-background); color: var(--cream); border-color: var(--rivals-steel); border-radius: .35rem; }
.physics-control { background: var(--rivals-surface); border-color: var(--rivals-steel); border-radius: .2rem; }
.physics-control output, .physics-save { color: var(--rivals-teal); }
.physics-control input { accent-color: var(--rivals-teal); }
.physics-info { border-color: var(--rivals-steel); color: var(--cream); }
.physics-category select { background: var(--rivals-surface); color: var(--cream); border-color: var(--rivals-steel); }
.physics-actions button { background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-steel); box-shadow: none; }
.victory-scorecard { background: var(--rivals-panel-background); color: var(--cream); border: .125rem solid var(--rivals-steel); border-radius: .25rem; }
.victory-letter { color: var(--cream); background: var(--rivals-surface); }

/* Machined scoreboard housing echoes the arena's stepped metal trim. */
.game .team-score {
 border-width: .25rem;
 background: linear-gradient(135deg, var(--rivals-surface), var(--ink-deep) 45%);
 box-shadow: inset 0 -.2rem currentColor, inset 0 0 0 .125rem var(--ink-deep), inset 0 0 0 .1875rem var(--rivals-steel);
}
.game .team-score.orange { clip-path: polygon(1rem 0, 100% 0, 100% 100%, 1.2rem 100%, 0 calc(100% - 1.2rem), 0 1rem); }
.game .team-score.pink { clip-path: polygon(0 0, calc(100% - 1rem) 0, 100% 1rem, 100% calc(100% - 1.2rem), calc(100% - 1.2rem) 100%, 0 100%); }
.game .turn-score { background: linear-gradient(145deg, var(--rivals-surface), var(--ink-deep)); border-width: .25rem; }
.game .turn-score small { background: var(--cream); color: var(--ink-deep); }

/* Painted armour frames stay individual UI surfaces, with live text and scores. */
.game .team-score, .game .turn-score {
 background-image: linear-gradient(180deg, transparent, var(--ink-deep)), url('/artwork/rivals/chassis-painted-v6.png');
 background-size: 100% 100%, 200% 200%;
 background-position: center, left top;
}
.game .team-score.pink { background-position: center, right bottom; }
.game .turn-score { background-position: center, right top; }
.game .team-score.orange { box-shadow: inset 0 -.2rem currentColor, inset 0 0 0 .125rem var(--ink-deep), inset 0 0 0 .1875rem var(--rivals-steel), inset 0 -.75rem 1.5rem var(--rivals-glow-teal); }
.game .team-score.pink { box-shadow: inset 0 -.2rem currentColor, inset 0 0 0 .125rem var(--ink-deep), inset 0 0 0 .1875rem var(--rivals-steel), inset 0 -.75rem 1.5rem var(--rivals-glow-coral); }

/* A held bonus floats below the top bar, over the arena space background. */
.game .arena .power-shortcut { position: absolute; top: 1rem; left: 1.5rem; z-index: 5; display: flex; align-items: center; gap: .5rem; width: auto; max-width: calc(100% - 3rem); height: auto; padding: .25rem .5rem .25rem .25rem; border: .125rem solid var(--rivals-teal); border-radius: .35rem; background: var(--rivals-panel-background); color: var(--cream); text-align: left; }
.game .arena .power-shortcut[hidden] { display: none; }
.game .arena .power-shortcut>img { width: 2.75rem; height: 2.75rem; flex-shrink: 0; }
.game .bonus-label { display: flex; flex-direction: column; gap: .125rem; line-height: 1.2; }
.game .arena .power-shortcut.chosen { background: var(--rivals-panel-surface); border-color: var(--cream); }
.game:not(.free-play) .power-slots { display: none; }
.game.free-play .power-slot { width: 2.75rem; height: 2.75rem; flex-basis: 2.75rem; padding: .125rem; }
.game .player-power { bottom: -.375rem; right: -.5rem; width: calc(var(--game-profile-size) * .6); height: calc(var(--game-profile-size) * .6); background: transparent; border-radius: 0; }
@media (max-width: 1050px) {
 .game .arena .power-shortcut { left: .75rem; max-width: calc(100% - 1.5rem); }
}

/* Landscape touch controls; keep the exit available after rotating the device. */
.game .fullscreen-button { display: none; }
.fullscreen-exit { display: none; }
.game-fullscreen .game .fullscreen-button { display: grid; }
.game-fullscreen .fullscreen-enter { display: none; }
.game-fullscreen .fullscreen-exit { display: block; }
.game-fullscreen, .game-fullscreen body { overflow: hidden; }
.game-fullscreen .game { padding: env(safe-area-inset-top, 0rem) env(safe-area-inset-right, 0rem) env(safe-area-inset-bottom, 0rem) env(safe-area-inset-left, 0rem); }
@media (orientation: landscape) and (max-width: 1050px), (orientation: landscape) and (any-pointer: coarse) {
 .game .fullscreen-button { display: grid; }
 .game .topbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; height: 4rem; padding: .25rem .75rem; }
 .game .wordmark { display: none; }
 .game .scoreboard { grid-row: 1; grid-column: 1; justify-self: center; width: min(23rem, 100%); height: 3rem; }
 .game .top-actions { grid-row: 1; grid-column: 2; }
 .game .mascot-mini { width: 2.2rem; height: 2.2rem; }
 .game .control-dock { grid-template-columns: minmax(0, 1fr); padding-block: .25rem; }
 .game .turn-console { grid-column: 1; grid-row: 1; width: min(100%, 28rem); justify-self: center; }
 .game .team-panel { display: none; }
 .game .power-row { position: static; margin-top: .25rem; }
 .game-fullscreen .game footer { display: none; }
}

/* Scoring feedback and match results share the arena's scoreboard treatment. */
.game .goal-announcement { top: 45%; width: min(22rem, calc(100% - 2rem)); display: grid; gap: .5rem; padding: 1rem 1.5rem; transform: translate(-50%, -50%); background: var(--rivals-panel-background); border: .125rem solid var(--rivals-goal-accent); border-radius: .35rem; box-shadow: 0 .5rem 2rem var(--ink-deep); text-shadow: none; }
.goal-announcement .eyebrow { color: var(--cream); }
.goal-announcement .goal-scorer { display: flex; align-items: center; justify-content: center; gap: .75rem; min-width: 0; overflow-wrap: anywhere; }
.goal-announcement .goal-scorer > span:last-child { min-width: 0; }
.game .goal-announcement .player-avatar { width: var(--lobby-profile-size); height: var(--lobby-profile-size); border-radius: var(--profile-radius); }
.goal-announcement strong { color: var(--rivals-goal-accent); text-shadow: 0 0 .35rem currentColor; }
.overlay[data-dialog='finished'] { padding: 5rem 1.5rem 1.5rem; background: #0b1426b3; align-items: center; }
.match-result { position: relative; width: min(100%, 46rem); margin: auto; display: grid; justify-items: center; gap: .5rem; padding: 4.5rem 1.25rem 1.25rem; background: var(--rivals-panel-background); border: .125rem solid var(--rivals-steel); border-top: .25rem solid var(--rivals-teal); border-radius: .5rem; color: var(--cream); text-align: center; box-shadow: 0 1rem 3rem var(--ink-deep); }
.match-result h1 { width: 100%; overflow-wrap: anywhere; letter-spacing: 0; }
.result-mascot { width: 3rem; height: 3rem; object-fit: contain; }
.result-scoreboard { position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%); width: min(24rem, calc(100% - 2rem)); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: .75rem; }
.result-heading { display: grid; align-content: center; justify-items: center; gap: .5rem; min-width: 0; }
.result-heading h2 { overflow-wrap: anywhere; }
.result-team { min-width: 0; overflow-wrap: anywhere; display: grid; gap: .5rem; padding: .75rem .5rem; border: .0625rem solid var(--rivals-steel); background: var(--rivals-surface); border-radius: .25rem; }
.result-team.is-winner { border-color: currentColor; box-shadow: 0 0 1.25rem -.25rem currentColor; }
.result-winners { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; width: 100%; }
.result-winners-team { display: grid; justify-items: center; gap: .75rem; min-width: 0; width: 100%; max-width: 100%; }
.result-players { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 1.5rem; width: 100%; }
.result-player { display: grid; justify-items: center; align-content: start; gap: .35rem; min-width: 0; max-width: 8rem; flex: 0 1 8rem; }
.result-player .player-avatar { width: 4.5rem; height: 4.5rem; }
.result-player p { color: var(--cream); overflow-wrap: anywhere; }
.result-players:empty { display: none; }
.result-actions { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .5rem; }
.result-actions button { flex: 1 1 8rem; box-shadow: none; border-radius: .25rem; }
.result-actions .primary { background: var(--rivals-teal); color: var(--ink-deep); }
.result-actions .secondary { background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-steel); }
@media (max-width: 650px), (max-height: 650px) {
  .overlay[data-dialog='finished'] { padding: 5rem 1rem 1rem; }
  .match-result { padding: 4.5rem 1rem 1rem; gap: .5rem; }
  .result-mascot { width: 2.5rem; height: 2.5rem; }
}

.sound-controls { display: grid; gap: 1rem; margin: 1.5rem 0; padding: 1rem; background: var(--rivals-panel-background); border: .0625rem solid var(--rivals-steel); border-radius: .2rem; }
.sound-controls > button { justify-self: start; }
.sound-controls p { color: var(--muted); }
.sound-volume { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center; color: var(--cream); }
.sound-volume output { font-variant-numeric: tabular-nums; }
.sound-volume input[type="range"] { grid-column: 1 / -1; width: 100%; min-height: 2rem; margin: 0; padding: 0; border: 0; background: transparent; accent-color: var(--rivals-teal); cursor: pointer; }

.recap-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; width: 100%; margin: 1.25rem 0; }
.recap-card { display: grid; align-content: start; justify-items: center; gap: .75rem; min-width: 0; padding: 1rem .75rem; border: .0625rem solid var(--rivals-line); border-radius: .5rem; }
.recap-winners { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; width: 100%; min-width: 0; }
.recap-player { display: grid; justify-items: center; align-content: start; gap: .35rem; flex: 1 1 4rem; min-width: 0; max-width: 100%; }
.recap-player .player-avatar { width: 3rem; height: 3rem; }
.recap-winner { color: var(--rivals-teal); overflow-wrap: anywhere; }
.recap-card > .text-sm { color: var(--cream); }
@media (max-width: 650px) and (orientation: portrait) {
  .recap-cards { grid-template-columns: 1fr; gap: .5rem; margin: 1rem 0; }
  .recap-card { gap: .5rem; padding: .75rem; text-align: left; justify-items: start; align-content: center; }
  .recap-winners { justify-content: flex-start; }
  .recap-player { flex: 0 1 auto; justify-items: start; }
  .recap-player .player-avatar { width: 2.5rem; height: 2.5rem; }
}
@media (max-height: 550px) and (orientation: landscape) {
  .overlay[data-dialog='finished'] { padding: 4rem .75rem .75rem; }
  .match-result { gap: .25rem; padding: 3.5rem .75rem .75rem; }
  .result-mascot { display: none; }
  .result-winners-team { gap: .25rem; }
  .result-player .player-avatar { width: 3rem; height: 3rem; }
  .result-team { gap: .25rem; padding: .5rem; }
  .recap-cards { margin: .75rem 0; gap: .5rem; }
  .recap-card { padding: .5rem; gap: .25rem; }
  .recap-player .player-avatar { width: 2rem; height: 2rem; }
}

/* Player names and inline editing in the multiplayer lobby. */
.team-join-slots { align-items: flex-start; }
.lobby-player-slot { display: flex; flex-direction: column; align-items: center; min-width: 0; flex: 1; gap: .35rem; }
.lobby-slot-avatar { background: transparent; padding: 0; border-radius: 50%; }
.lobby-name-row { display: flex; align-items: center; justify-content: center; gap: .25rem; width: 100%; }
.lobby-name-row, .lobby-name-editor { height: 2rem; flex: 0 0 2rem; }
.lobby-player-name { min-width: 0; color: var(--cream); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.show-player-names .team-join-slots { bottom: calc(-12% - var(--lobby-profile-offset)); }
.lobby-name-action { display: grid; place-items: center; flex: 0 0 auto; width: 1.5rem; height: 1.5rem; padding: .15rem; border-radius: .2rem; background: transparent; color: var(--rivals-cyan); }
button#edit-player-name { background: transparent; border: 0; box-shadow: none; color: var(--rivals-cyan); transform: none; filter: none; }
.lobby-name-action svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lobby-name-editor { display: flex; align-items: center; gap: .25rem; width: 100%; }
.lobby-name-editor input { height: 2rem; padding: .3rem; background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-cyan); border-radius: .2rem; }
@media (max-width: 700px) and (orientation: portrait) {
  .show-player-names .team-join-slots { bottom: calc(-.5rem - var(--lobby-profile-offset)); }
  .team-join-slots .lobby-player-slot { flex: 0 0 calc(50% - .45rem); }
}

.lobby-player-slot { position: relative; }
/* Empty seats and unrevealed ratings reserve the same badge row. */
.lobby-rating-placeholder { visibility: hidden; }
.lobby-ready-check { position: absolute; top: 1.75rem; left: calc(50% + .5rem); display: grid; place-items: center; flex: 0 0 auto; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--rivals-teal); color: var(--ink-deep); font-weight: 700; }
.lobby-readiness { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.lobby-readiness p { color: var(--cream); white-space: nowrap; }
.lobby-ready-button { padding: .65rem .8rem; border: .0625rem solid var(--rivals-teal); border-radius: .2rem; background: var(--rivals-surface); color: var(--cream); white-space: nowrap; }
.lobby-ready-button[aria-pressed="true"] { background: var(--rivals-teal); color: var(--ink-deep); }
.team-lobby-footer { gap: 1rem; }
@media (max-width: 700px) and (orientation: portrait) {
  .team-lobby-footer { height: auto; min-height: 20%; }
  .lobby-readiness { flex-direction: row; justify-content: space-between; width: 100%; }
}


/* Shared private-lobby rules; typography follows the responsive text classes. */
.team-lobby-footer:has(.lobby-game-rules) { height: auto; min-height: 15%; flex-wrap: wrap; gap: .75rem 1.5rem; }
.lobby-game-rules { flex: 1 0 100%; display: flex; align-items: center; gap: 1rem; }
.lobby-game-rules summary { cursor: pointer; color: var(--rivals-teal); }
#lobby-game-settings { flex-shrink: 0; padding: .65rem .8rem; color: var(--cream); background: var(--rivals-surface); }
/* A separate footer row keeps active labels from resizing the lobby controls. */
.game-rules-active { grid-column: 1 / -1; color: var(--cream); display: flex; flex-wrap: nowrap; justify-content: flex-end; justify-content: safe flex-end; contain: inline-size; width: 100%; min-width: 0; min-height: 1.5rem; gap: 1rem; overflow-x: auto; scrollbar-width: none; }
.game-rules-active::-webkit-scrollbar { display: none; }
.game-rules-track { display: inline-flex; flex: 0 0 auto; width: max-content; gap: 1rem; white-space: nowrap; }
.game-rules-track > span { flex: 0 0 auto; }
.game-rule-separator { opacity: .5; margin-inline: .25rem; }
.game-rules-panel { position: fixed; z-index: 10; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(28rem, calc(100% - 2rem)); max-height: calc(100svh - 2rem); overflow-y: auto; padding: 1.25rem; background: var(--ink-deep); border: .1rem solid var(--rivals-teal); border-radius: var(--radius); box-shadow: 0 .5rem 2rem var(--rivals-panel-background); }
.game-rules-panel > p { color: var(--cream); margin: .5rem 0; }
.game-rule { display: flex; align-items: center; gap: 1rem; width: 100%; padding: 1rem; background: var(--rivals-surface); color: var(--cream); text-align: left; font-family: var(--font-body); }
.game-rule-copy { flex: 1; min-width: 0; }
.game-rule-check { display: grid; place-items: center; flex: 0 0 auto; width: 1.5rem; height: 1.5rem; border: .0625rem solid var(--rivals-steel); color: transparent; }
.game-rule[aria-pressed="true"] .game-rule-check { border-color: var(--rivals-teal); background: var(--button-primary-face); color: var(--ink-deep); }
@media (hover: hover) { .game-rule:hover:not(:disabled) { background: var(--ink); } }
.game-rule small { display: block; color: var(--cream); margin-top: .25rem; line-height: 1.4; }
.game-rules-panel input[type="checkbox"] { appearance: none; display: grid; place-content: center; width: 1.5rem; height: 1.5rem; flex: 0 0 auto; margin: .25rem; padding: 0; border: .0625rem solid var(--rivals-steel); border-radius: 0; background: var(--rivals-surface); box-shadow: var(--button-shadow); cursor: pointer; }
.game-rules-panel input[type="checkbox"]::before { content: ''; width: .65rem; height: .35rem; border-left: .125rem solid var(--ink-deep); border-bottom: .125rem solid var(--ink-deep); transform: translateY(-.1rem) rotate(-45deg); visibility: hidden; }
.game-rules-panel input[type="checkbox"]:checked { background: var(--button-primary-face); border-color: var(--rivals-teal); }
.game-rules-panel input[type="checkbox"]:checked::before { visibility: visible; }
.game-rules-panel input[type="checkbox"]:focus-visible { outline: .125rem solid var(--rivals-cyan); outline-offset: .25rem; }
.game-rules-panel input[type="checkbox"]:disabled { opacity: .45; box-shadow: none; cursor: default; }
@media (hover: hover) { .game-rules-panel input[type="checkbox"]:hover:not(:disabled) { border-color: var(--rivals-cyan); } }
@media (forced-colors: active) { .game-rules-panel input[type="checkbox"] { appearance: auto; } .game-rules-panel input[type="checkbox"]::before { display: none; } }
.game-rules-panel > details { margin: 1rem 0; }
.game-rules-panel > #close-game-settings { display: block; margin-left: auto; }
#bonus-settings > summary { min-height: 2.75rem; align-content: center; }
#toggle-all-bonuses { display: block; margin: .5rem 0 0; padding: .65rem .8rem; background: var(--rivals-surface); color: var(--cream); text-transform: uppercase; }
.game-bonus-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; padding-top: 1rem; }
.game-bonus-options label { display: flex; align-items: center; gap: .5rem; }
.game-bonus-options label img { width: var(--bonus-preview-size); height: var(--bonus-preview-size); object-fit: contain; flex-shrink: 0; }
.game-bonus-options label span { min-width: 0; }
@media (max-width: 700px) and (orientation: portrait) {
  .lobby-game-rules { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .team-screen:has(.lobby-game-rules) { min-height: 64rem; }
}

/* Personal profiles: inline selection and the full icon picker. */
.profile-controls { display: flex; align-items: center; justify-content: center; gap: .125rem; }
[data-profile-picker] .player-avatar, .profile-option .player-avatar { transition: transform .18s ease-out, box-shadow .18s ease-out, border-color .18s ease-out; }
@media (hover: hover) and (pointer: fine) {
  [data-profile-picker]:hover:not(:disabled) .player-avatar, .profile-option:hover:not(:disabled) .player-avatar { transform: scale(1.08); border-color: var(--rivals-cyan); box-shadow: 0 0 .75rem var(--rivals-glow-teal); }
}
[data-profile-picker]:active:not(:disabled) .player-avatar, .profile-option:active:not(:disabled) .player-avatar { transform: scale(.98); }
@media (prefers-reduced-motion: reduce) {
  [data-profile-picker] .player-avatar, .profile-option .player-avatar { transition: none; }
  [data-profile-picker]:hover:not(:disabled) .player-avatar, [data-profile-picker]:active:not(:disabled) .player-avatar,
  .profile-option:hover:not(:disabled) .player-avatar, .profile-option:active:not(:disabled) .player-avatar { transform: none; }
}
.home-profile-field { display: flex; align-items: center; gap: .5rem; width: 100%; }
.home-profile-field input { min-width: 0; flex: 1; width: 0; }
.home-profile-controls { flex: 0 0 auto; }
.home-profile-controls .player-avatar { display: block; width: 2.6rem; height: 2.6rem; border: .1rem solid var(--rivals-line); border-radius: 50%; background: var(--ink-deep); }
.lobby-name-editor input { min-width: 0; width: 100%; flex: 1; }
.lobby-name-editor input:focus-visible { outline: .0625rem solid var(--rivals-cyan); outline-offset: .125rem; }
.profile-picker { width: min(var(--profile-picker-width), calc(100vw - 2rem)); max-height: min(var(--profile-picker-height), calc(100dvh - 2rem)); padding: 1.25rem; border: .125rem solid var(--rivals-line); border-radius: var(--radius); background: var(--ink-deep); color: var(--cream); overflow-y: auto; }
.profile-picker[open] { display: flex; flex-direction: column; }
.profile-picker-heading, .profile-picker > p { flex-shrink: 0; }
.profile-picker::backdrop { background: var(--rivals-panel-background); }
.profile-picker-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.profile-picker-close { flex: 0 0 auto; width: 2.75rem; height: 2.75rem; padding: .5rem; background: var(--rivals-surface); color: var(--cream); }
.profile-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; margin-top: 1rem; min-height: 0; max-height: var(--profile-grid-height); overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: .25rem .5rem .5rem .25rem; }
.profile-grid::-webkit-scrollbar { width: .5rem; }
.profile-grid::-webkit-scrollbar-track { background: var(--rivals-surface); border-radius: var(--radius); }
.profile-grid::-webkit-scrollbar-thumb { background: var(--rivals-cyan); border: .0625rem solid var(--rivals-teal); border-radius: var(--radius); box-shadow: 0 0 .5rem var(--rivals-cyan), inset 0 0 .25rem var(--cream); }
.profile-grid::-webkit-scrollbar-thumb:hover { background: var(--cream); }
@supports not selector(::-webkit-scrollbar) {
  .profile-grid { scrollbar-width: thin; scrollbar-color: var(--rivals-cyan) var(--rivals-surface); }
}
.profile-option { display: grid; place-items: center; padding: .75rem .25rem; background: transparent; color: var(--cream); border: 0; box-shadow: none; }
.profile-option .player-avatar { display: block; width: 4rem; height: 4rem; border: 0; border-radius: 50%; background: transparent; }
.profile-option[aria-pressed="true"] { background: var(--rivals-steel); border-radius: .75rem; box-shadow: inset 0 0 0 .0625rem var(--rivals-cyan); }
.profile-option[aria-pressed="true"] .player-avatar { outline: .125rem solid var(--rivals-cyan); outline-offset: .125rem; box-shadow: 0 0 1rem var(--rivals-glow-teal); }
:root body .profile-option:focus-visible { outline: 0; }
.profile-option:focus-visible .player-avatar { outline: .125rem solid var(--rivals-cyan); outline-offset: .25rem; }
.profile-option:disabled { opacity: .45; cursor: default; }
[data-profile-picker]:focus-visible, .profile-picker-close:focus-visible { outline: .125rem solid var(--rivals-cyan); outline-offset: .125rem; }
@media (max-width: 700px) {
  .profile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.home-profile-field input { background: var(--rivals-panel-background); border: .15rem solid var(--rivals-line); border-radius: .4rem; color: var(--cream); margin: 0; padding: .65rem .5rem; text-align: center; }

@media (min-width: 701px) and (max-width: 1150px) {
  .team-screen:has(.lobby-game-rules) { min-height: 50rem; }
}
.overlay:has(.lobby-game-rules) { align-items: safe center; }

@media (min-width: 701px) {
  .team-screen:has(.lobby-game-rules) .team-selection { height: 36%; }
}

/* Generated profile portraits share the existing profile sizing across all screens. */
.player-avatar { display: inline-block; flex-shrink: 0; overflow: hidden; border-radius: 50%; }
.player-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.profile-option > span:not(.player-avatar) { overflow-wrap: anywhere; }

/* Keep the invite inline and align the primary match controls on one row. */
.team-lobby-footer, .team-lobby-footer:has(.lobby-game-rules) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; height: auto; gap: 1.25rem 3rem; }
.lobby-game-rules { grid-column: 1 / -1; }
.team-lobby-footer .room-invite { flex-direction: row; align-items: center; justify-content: flex-start; flex-wrap: wrap; min-height: 3rem; margin: 0; gap: 1.25rem; }
.team-lobby-footer .room-invite > span { display: flex; flex-direction: column; align-items: flex-start; gap: .125rem; white-space: nowrap; }
.lobby-match-controls { display: grid; grid-template-columns: 13rem auto auto; align-items: start; gap: 2rem; min-width: 0; }
.lobby-match-controls .team-length { min-width: 0; gap: .5rem; }
.lobby-match-controls .lobby-readiness { flex-direction: column-reverse; gap: .5rem; width: auto; }
.lobby-match-controls #game-length, .lobby-match-controls .lobby-ready-button, .lobby-match-controls .team-start { height: 3rem; margin: 0; }
.lobby-match-controls #game-length { width: 100%; min-width: 0; }
.lobby-match-controls .team-start { white-space: nowrap; }
@media (max-width: 1150px) {
  .team-lobby-footer, .team-lobby-footer:has(.lobby-game-rules) { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .lobby-match-controls { grid-template-columns: minmax(10rem, 1fr) auto auto; }
}
@media (max-width: 700px) {
  .lobby-match-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem 1.5rem; }
  .lobby-match-controls .team-start { grid-column: 1 / -1; width: 100%; }
  .lobby-match-controls .lobby-ready-button { width: 100%; }
}
@media (min-width: 701px) and (max-width: 1150px) {
  .team-screen:has(.lobby-game-rules) .team-selection { height: 32%; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .team-screen:has(.lobby-game-rules) .team-selection { height: 19%; }
}

/* Team mascot cycling uses bare arrows with a light hover response. */
.team-name { gap: 1rem; }
.team-screen:has(.game-rules-panel:not([hidden])) .team-name button { visibility: hidden; }
.team-name button { background: transparent; border: 0; box-shadow: none; text-shadow: 0 .125rem .2rem var(--ink-deep); min-width: 2.25rem; min-height: 2.75rem; position: relative; pointer-events: none; transition: transform .18s ease-out, color .18s ease-out, filter .18s ease-out; }
@media (hover: hover) and (pointer: fine) {
  .team-name button:hover:not(:disabled) { color: var(--rivals-cyan); transform: scale(1.12); filter: drop-shadow(0 0 .35rem var(--rivals-glow-teal)); }
}
.team-name button:active:not(:disabled) { transform: scale(.96); }
.team-name button::after { content: ""; position: absolute; inset: 0; pointer-events: auto; transition: transform .18s ease-out; }
.team-name button:disabled::after { pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .team-name button:hover::after { transform: scale(calc(1 / 1.12)); }
}
.team-name button:active::after { transform: scale(calc(1 / .96)); }
@media (prefers-reduced-motion: reduce) {
  .team-name button, .team-name button::after { transition: none; }
  .team-name button:hover::after, .team-name button:active::after { transform: none; }
  .team-name button:hover:not(:disabled), .team-name button:active:not(:disabled) { transform: none; }
}

/* End-of-match MVP votes belong to the winning roster. */
.result-player { gap: .75rem; padding-top: 1.25rem; }
.result-vote { display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: none; cursor: pointer; color: var(--cream); }
.result-vote:hover, .result-vote:active { transform: none; box-shadow: none; background: transparent; }
.result-vote:focus-visible { outline: .125rem solid var(--rivals-cyan); outline-offset: .5rem; }
.result-portrait { position: relative; display: grid; place-items: center; isolation: isolate; transform: scale(var(--mvp-scale)); }
.result-portrait .player-avatar { position: relative; z-index: 1; }
.result-stars { position: absolute; z-index: 3; top: 0; right: -.5rem; padding: .15rem .35rem; border: .0625rem solid var(--rivals-teal); border-radius: 1rem; color: var(--rivals-teal); background: var(--ink-deep); line-height: 1.1; }
.result-mvp-label { position: absolute; z-index: 3; bottom: .15rem; left: 50%; transform: translateX(-50%); padding: .15rem .5rem; border-radius: 1rem; background: var(--rivals-teal); color: var(--ink-deep); line-height: 1.1; }
.result-player.is-mvp .result-portrait::before { content: ''; position: absolute; inset: -.3rem; z-index: 0; border-radius: 50%; background: conic-gradient(from 0deg, var(--rivals-teal), transparent 25%, var(--rivals-cyan) 50%, transparent 75%, var(--rivals-teal)); animation: mvp-orbit 3s linear infinite; box-shadow: 0 0 1.25rem var(--rivals-glow-teal); }
.result-player.is-mvp .player-avatar { box-shadow: 0 0 1.5rem var(--rivals-glow-teal); }
.result-portrait.is-pumping { animation: mvp-pump .28s ease-out; }
.result-sparks { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.result-sparks i { position: absolute; top: 50%; left: 50%; width: .2rem; height: .6rem; border-radius: 1rem; background: var(--rivals-teal); opacity: 0; animation: mvp-spark .8s ease-out forwards; }
@keyframes mvp-pump { 0% { transform: scale(var(--mvp-previous-scale)); } 60% { transform: scale(calc(var(--mvp-scale) + .06)); } 100% { transform: scale(var(--mvp-scale)); } }
@keyframes mvp-orbit { to { transform: rotate(360deg); } }
@keyframes mvp-spark { 0% { opacity: 1; transform: rotate(var(--spark-angle)) translateY(-2rem) scale(1); } 100% { opacity: 0; transform: rotate(var(--spark-angle)) translateY(-4.5rem) scale(.2); } }
@media (prefers-reduced-motion: reduce) {
  .result-portrait.is-pumping, .result-player.is-mvp .result-portrait::before, .result-sparks i { animation: none; }
}

/* Playground rules use one dialog, without the table settings underneath. */
.overlay[data-dialog="game-settings"] > .lobby-game-rules { flex: none; display: block; width: min(28rem, calc(100% - 2rem)); }
.overlay[data-dialog="game-settings"] #lobby-game-settings,
.overlay[data-dialog="game-settings"] .game-rules-active { display: none; }
.overlay[data-dialog="game-settings"] .game-rules-panel { position: relative; top: auto; left: auto; transform: none; width: 100%; }

/* Solo practice keeps a single team picker and local match controls. */
.solo-lobby .team-center-logo,
.solo-lobby .room-invite,
.solo-lobby .lobby-readiness { display: none; }
.solo-lobby .team-selection.side-0 { left: 25%; width: 50%; }
.solo-lobby .lobby-match-controls { grid-template-columns: 13rem auto; }
@media (max-width: 48rem) {
  .solo-lobby .team-selection.side-0 { left: 3%; width: 94%; }
  .solo-lobby .lobby-match-controls { grid-template-columns: minmax(0, 1fr); }
}

/* Main menu player dock and game selection. */
.home-screen .home-play { transform: translateY(-1.5rem); }
.home-screen .home-play { position: relative; inset: auto; width: min(23rem, 80vw); gap: 1rem; }
.home-screen .home-play .secondary { border: .1rem solid var(--rivals-line); border-radius: .5rem; outline: none; background: var(--rivals-panel-background); color: var(--cream); font-size: var(--text-lg); }
.home-player-panel { position: absolute; left: 3rem; bottom: 2rem; display: flex; align-items: center; gap: 1rem; max-width: calc(100% - 6rem); padding: 1rem 1.5rem 1rem 1rem; background: var(--rivals-panel-background); color: var(--cream); }
.home-player-panel .player-avatar { width: var(--home-profile-size); height: var(--home-profile-size); border-radius: var(--profile-radius); border-color: var(--rivals-cyan); }
.home-player-details { min-width: 0; }
.home-player-name { display: flex; align-items: center; gap: .75rem; }
.home-player-name strong { overflow-wrap: anywhere; }
.home-player-xp { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
progress { accent-color: var(--rivals-teal); height: .5rem; width: 8rem; }
.play-modes.modal, .leaderboard-panel.modal { width: min(68rem, calc(100vw - 2rem)); max-height: calc(100svh - 2rem); overflow: auto; }
.mode-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.mode-card { display: flex; flex-direction: column; align-items: stretch; gap: .75rem; padding: 0 0 1.25rem; text-align: left; overflow: hidden; border: .1rem solid var(--rivals-line); border-radius: .75rem; background: var(--rivals-surface); color: var(--cream); }
.mode-card img { width: 100%; height: 12rem; object-fit: cover; background: var(--ink-deep); }
.mode-card span { margin-inline: 1rem; }
.mode-card:hover, .mode-card:focus-visible { border-color: var(--rivals-cyan); }
.lobby-playlist-heading { display: flex; align-items: center; justify-content: center; gap: 1.5rem; }
.lobby-playlist-heading h1 { min-width: 0; }
.lobby-playlist-heading button { flex: 0 0 auto; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; line-height: 1; }
@media (max-width: 700px) { .lobby-playlist-heading { gap: .5rem; } }
.leaderboard-scroll { overflow-x: auto; margin-block: 1rem; }
.leaderboard-scroll table { width: 100%; border-collapse: collapse; text-align: left; }
.leaderboard-scroll th, .leaderboard-scroll td { padding: .75rem; border-bottom: .0625rem solid var(--rivals-line); }
.leaderboard-scroll tr > * + * { border-left: .0625rem solid var(--rivals-line); }
.leaderboard-scroll thead th { white-space: nowrap; }
.leaderboard-scroll tbody th { min-width: 10rem; }
.leaderboard-scroll .player-avatar { width: 2rem; height: 2rem; display: inline-block; vertical-align: middle; }
.leaderboard-scroll .is-you { background: var(--rivals-surface); color: var(--rivals-teal); }
.leaderboard-scroll .is-you > td:first-child { box-shadow: inset .25rem 0 var(--rivals-teal); }
#home-name-editor { display: flex; flex-wrap: wrap; gap: .75rem; }
#home-name-editor input { width: 100%; }
@media (max-width: 650px) {
 .home-player-panel { left: 1rem; bottom: 1rem; max-width: calc(100% - 2rem); padding: .75rem; }
 .mode-cards { grid-template-columns: 1fr; }
 .mode-card { display: grid; grid-template-columns: 5rem 1fr; align-items: center; gap: .5rem; padding: .75rem; }
 .mode-card img { grid-row: 1 / 4; height: 6rem; border-radius: .4rem; }
 .mode-card span { margin: 0; }
}
@media (max-height: 550px) and (min-width: 651px) {
 .home-player-panel { bottom: .75rem; padding: .5rem; }
 .home-screen .home-logo { max-height: 25svh; width: auto; max-width: 80vw; margin-bottom: 0; }
 .home-screen .home-play { gap: .5rem; }
 .mode-card img { height: 6rem; }
}

/* Home dialogs keep the menu artwork behind them instead of revealing the match. */
.overlay[data-home-menu="true"]:not(:empty) { background: linear-gradient(var(--home-menu-shade), var(--home-menu-shade)), url('/artwork/rivals/brand-home.webp') 65% center / cover, var(--ink-deep); }
body:has(.overlay[data-home-menu="true"]:not(:empty)) .game { visibility: hidden; }
@media (max-width: 700px) {
 .overlay[data-home-menu="true"]:not(:empty) { background-position: center; }
}

.leaderboard-xp { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }

/* A persistent artwork layer lets opening and closing menus reverse smoothly. */
.home-backdrop { position: fixed; inset: 0; z-index: 9; overflow: hidden; visibility: hidden; pointer-events: none; background: var(--ink-deep); }
.home-backdrop-image { position: absolute; inset: -1rem; background: linear-gradient(90deg, var(--ink-deep), transparent 85%), url('/artwork/rivals/brand-home.webp') 65% center / cover; transform: scale(var(--home-backdrop-zoom)); filter: blur(0); transition: transform var(--home-backdrop-duration) ease, filter var(--home-backdrop-duration) ease; }
.home-backdrop::after { content: ''; position: absolute; inset: 0; background: var(--home-menu-shade); opacity: 0; transition: opacity var(--home-backdrop-duration) ease; }
body:has(.overlay[data-dialog="welcome"]:not(:empty), .overlay[data-home-menu="true"]:not(:empty)) .home-backdrop { visibility: visible; }
body:has(.overlay[data-home-menu="true"]:not(:empty)) .home-backdrop-image,
body:has(.overlay[data-dialog="welcome"]:not(:empty)):has(#profile-picker[open]) .home-backdrop-image { transform: scale(1); filter: blur(var(--home-backdrop-blur)); }
body:has(.overlay[data-home-menu="true"]:not(:empty)) .home-backdrop::after,
body:has(.overlay[data-dialog="welcome"]:not(:empty)):has(#profile-picker[open]) .home-backdrop::after { opacity: 1; }
.overlay[data-dialog="welcome"], .overlay[data-home-menu="true"]:not(:empty), .overlay .home-screen { background: transparent; }
@media (max-width: 700px) {
 .home-backdrop-image { background: linear-gradient(180deg, transparent, var(--ink-deep) 60%), url('/artwork/rivals/brand-home.webp') center / cover; }
}
@media (prefers-reduced-motion: reduce) {
 .home-backdrop-image, .home-backdrop::after { transition: none; }
}

/* Lobby utilities share a row; match controls stay underneath. */
.lobby-utility-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.lobby-utility-row .lobby-game-rules { flex: 1 1 0; min-width: 0; }
.lobby-utility-row .room-invite { flex: 0 0 auto; }
.team-lobby-footer > .lobby-match-controls { grid-column: 1 / -1; justify-self: end; }
body:has(.overlay[data-dialog="lobby"]:not(:empty)) .game footer > .sound-reactions { display: none; }
@media (max-width: 700px) {
 .lobby-utility-row { flex-wrap: wrap; gap: 1rem; }
 .team-lobby-footer > .lobby-match-controls { justify-self: stretch; }
}

.team-lobby-footer .lobby-profile-panel { position: static; max-width: none; width: fit-content; min-width: 0; padding: .75rem; }
.team-lobby-footer:has(.lobby-profile-panel) > .lobby-match-controls { grid-column: auto; align-self: center; }
@media (max-width: 1050px) {
 .team-lobby-footer .lobby-profile-panel { width: 100%; }
 .team-lobby-footer:has(.lobby-profile-panel) > .lobby-match-controls { grid-column: 1 / -1; justify-self: stretch; }
}

/* Room invites anchor the left side; rules sit beside the match length. */
.lobby-player-area { display: grid; gap: .75rem; min-width: 0; }
.team-lobby-footer .lobby-player-area .room-invite { justify-content: flex-start; }
.team-lobby-footer .lobby-match-controls { grid-template-columns: auto 13rem auto auto; }
.team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: auto; flex-direction: column; align-items: flex-start; gap: .5rem; max-width: 12rem; }
.solo-lobby .team-lobby-footer .lobby-match-controls { grid-template-columns: auto 13rem auto; }
@media (max-width: 1400px) {
 .team-lobby-footer:has(.lobby-player-area) { grid-template-columns: minmax(0, 1fr); }
 .team-lobby-footer:has(.lobby-player-area) > .lobby-match-controls { grid-column: 1; grid-row: 1; justify-self: end; }
 .lobby-player-area { grid-column: 1; grid-row: 2; justify-self: start; }
}
@media (max-width: 700px) {
 .team-lobby-footer:has(.lobby-player-area) > .lobby-match-controls { justify-self: stretch; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
 .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1 / -1; }
 .lobby-player-area { justify-self: stretch; }
}

/* Ready players launch the match automatically after the lobby countdown. */
.team-lobby-footer .lobby-match-controls, .solo-lobby .team-lobby-footer .lobby-match-controls { grid-template-columns: auto 13rem auto; }
.solo-lobby .lobby-readiness { display: flex; }
@media (max-width: 700px) {
 .team-lobby-footer .lobby-match-controls, .solo-lobby .team-lobby-footer .lobby-match-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Room and profile details form a stack on the right. */
.team-lobby-footer .lobby-player-area { grid-column: 2; grid-row: 1; justify-self: end; }
.team-lobby-footer .lobby-player-area .room-invite { justify-content: flex-end; }
.team-lobby-footer:has(.lobby-player-area) > .lobby-match-controls { grid-column: 1; grid-row: 1; justify-self: start; }
@media (max-width: 1400px) {
 .team-lobby-footer .lobby-player-area { grid-column: 1; grid-row: 2; }
}
@media (max-width: 700px) {
 .team-lobby-footer:has(.lobby-player-area) > .lobby-match-controls { justify-self: stretch; }
 .team-lobby-footer .lobby-player-area { max-width: 100%; }
}

.team-join-slots .lobby-slot-avatar, .team-join-slots .player-avatar, .team-join-slots .empty-player { border-radius: var(--profile-radius); }

.lobby-match-controls .lobby-ready-button { height: 4rem; min-width: 12rem; padding: 1rem 1.5rem; }

/* Profile stays left; lobby actions and the invite share the right side. */
.team-lobby-footer:has(.lobby-controls-area) { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.team-lobby-footer .lobby-player-area { grid-column: 1; grid-row: 1; justify-self: start; }
.lobby-controls-area { grid-column: 2; grid-row: 1; display: grid; justify-items: end; gap: 1rem; min-width: 0; }
.team-lobby-footer .lobby-controls-area .room-invite { justify-content: flex-end; }
@media (max-width: 1050px) {
 .team-lobby-footer:has(.lobby-controls-area) { grid-template-columns: minmax(0, 1fr); }
 .lobby-controls-area { grid-column: 1; grid-row: 1; justify-self: end; }
 .team-lobby-footer .lobby-player-area { grid-column: 1; grid-row: 2; }
}
@media (max-width: 700px) {
 .lobby-controls-area { width: 100%; justify-items: stretch; }
 .team-lobby-footer .lobby-player-area { max-width: 100%; }
}

/* Match format lives in the settings panel, alongside the other rules. */
.game-rules-panel .team-length { min-width: 0; margin-bottom: 1rem; grid-template-columns: auto minmax(10rem, 1fr) auto; align-items: center; gap: 1rem; }
.game-rules-panel #game-length { width: 100%; height: 3rem; appearance: none; padding-right: 2.75rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23f4f3ff' stroke-width='1.5'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1rem; }
@media (max-width: 600px) {
  .game-rules-panel .team-length { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
}
.team-lobby-footer .lobby-match-controls, .solo-lobby .team-lobby-footer .lobby-match-controls { grid-template-columns: auto auto; }
@media (max-width: 700px) {
 .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: auto; }
}

/* Room sharing sits immediately before the settings control. */
.team-lobby-footer .lobby-match-controls { grid-template-columns: auto auto auto; }
.team-lobby-footer .lobby-match-controls .room-invite { gap: .75rem; flex-wrap: nowrap; }
.team-lobby-footer #copy-invite { display: grid; place-items: center; width: 3rem; height: 3rem; padding: .5rem; }
.team-lobby-footer #room-visibility-toggle { display: grid; place-items: center; width: 3rem; height: 3rem; padding: .5rem; }
#room-visibility-toggle svg { width: 1.25rem; height: 1.25rem; }
.solo-lobby .team-lobby-footer .lobby-match-controls { grid-template-columns: auto auto; }
@media (max-width: 700px) {
 .team-lobby-footer .lobby-match-controls { grid-template-columns: auto auto; }
 .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1 / -1; }
}

/* Give lobby controls more breathing room beneath than above. */
.team-lobby-footer { padding-top: .25rem; padding-bottom: 1.5rem; }

.lobby-match-controls:not(:has(.lobby-game-rules)) { grid-template-columns: auto auto; }

.elo-badge { display: inline-flex; align-items: center; width: fit-content; padding: .25rem .75rem; margin-bottom: .5rem; border: .0625rem solid var(--rivals-teal); border-radius: 999rem; background: var(--rivals-surface); color: var(--rivals-teal); white-space: nowrap; }
.mode-card .mode-elo { padding: .5rem .75rem; margin-bottom: 0; background: var(--ink-deep); box-shadow: 0 0 1rem var(--rivals-glow-teal); white-space: normal; }

.lobby-player-slot > .elo-badge { margin-bottom: 0; justify-self: center; align-self: center; }

.lobby-player-slot:has(> .elo-badge) { gap: .2rem; }
.lobby-player-slot > .elo-badge { margin-top: .5rem; }
.lobby-player-slot:has(> .elo-badge) > .lobby-name-row { height: auto; flex: 0 0 auto; }

/* Keep laptop lobbies inside the viewport and reserve space for names and footer. */
@media (min-width: 1051px) and (max-height: 850px) {
 .overlay[data-dialog="lobby"] { align-items: flex-start; }
 .team-screen, .team-screen:has(.lobby-game-rules) { width: 100vw; height: 100svh; min-height: 40rem; aspect-ratio: auto; }
 .team-screen .team-lobby-footer { left: 0; right: 0; width: 100%; padding-inline: 1.5rem; }
 .team-screen .team-selection.side-0, .team-screen .team-selection.side-1 { top: 20%; bottom: 11rem; height: auto; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center; gap: 1rem; }
 .team-screen .team-large-mascot { width: 100%; height: 100%; min-height: 0; max-height: 18rem; object-fit: contain; margin: 0; }
 .team-screen.show-player-names .team-join-slots { position: static; width: 100%; flex-wrap: nowrap; }
 .team-screen .team-center-logo { top: 34%; height: 16%; }
 .team-screen .lobby-match-controls { gap: 1.5rem; }
}

/* Team-name length never shifts the mascot navigation controls. */
.team-selection .team-name { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem; width: 100%; align-items: center; gap: .75rem; }
.team-selection .team-name h2 { min-width: 0; text-align: center; overflow-wrap: anywhere; }
.team-selection .team-name button { width: 2.75rem; }
@media (min-width: 1051px) {
 .team-selection .team-name { width: max-content; max-width: 100%; margin-inline: auto; justify-self: center; }
 .team-selection .team-name h2 { position: relative; }
 .team-selection .team-name h2::before { content: attr(data-longest-name); visibility: hidden; }
 .team-selection .team-name-label { position: absolute; inset: 0; display: grid; place-items: center; }
}


/* Keep practice difficulty available beside the settings button. */
.lobby-settings-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .75rem; }
.team-lobby-footer .lobby-match-controls .lobby-game-rules:has(.lobby-bot-difficulty) { max-width: none; }
.lobby-settings-controls .lobby-bot-difficulty { min-width: 10rem; }
.lobby-match-controls .lobby-readiness { margin-inline-start: .75rem; }
.lobby-bot-difficulty select { width: 100%; height: 3rem; }

/* Identify the current host directly on their lobby portrait. */
.team-join-slots .lobby-slot-avatar { position: relative; overflow: visible; }
.lobby-host-badge, .lobby-player-slot > .elo-badge { padding: .2rem .35rem; border: .0625rem solid var(--rivals-teal); border-radius: .2rem; background: var(--rivals-surface); color: var(--rivals-teal); font-size: var(--text-xs); line-height: 1; }
.lobby-host-badge { position: absolute; top: -.35rem; left: -.35rem; z-index: 1; pointer-events: none; }

.lobby-kick { position: absolute; top: -.35rem; right: 0; z-index: 2; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; padding: 0; line-height: 1; color: var(--rivals-coral); }
.team-home { padding: .75rem 1.25rem; }
.team-leaderboard { left: 1rem; right: auto; }

.sign-in-panel { padding: 2rem; color: var(--cream); width: min(100%, 46rem); display: grid; justify-items: center; gap: 2rem; text-align: center; border: 0; background: transparent; box-shadow: none; overflow: visible; }
.sign-in-parallax { width: 34rem; max-width: 100%; margin-bottom: 2rem; transform-style: preserve-3d; transition: transform .3s ease-out; }
.home-screen .home-logo.sign-in-parallax { position: relative; top: -4.5rem; width: min(31rem, 80vw); margin-bottom: 1rem; }
.sign-in-hologram { position: relative; width: 100%; isolation: isolate; animation: sign-in-hologram-float 7s ease-in-out infinite; }
.sign-in-logo { position: relative; z-index: 1; display: block; width: 100%; height: auto; filter: drop-shadow(0 .125rem 0 var(--rivals-cyan)) drop-shadow(0 .35rem 0 var(--ink-deep)) drop-shadow(0 .6rem .2rem var(--ink-deep)) drop-shadow(0 0 1.25rem var(--rivals-glow-teal)); }
.sign-in-hologram::before, .sign-in-hologram::after { content: ''; position: absolute; inset: 0; pointer-events: none; mask: url('/artwork/rivals/brand-logo-flat.webp') center / contain no-repeat; }
.sign-in-hologram::before { z-index: 0; background: linear-gradient(110deg, var(--rivals-cyan), var(--rivals-teal), var(--rivals-coral)); transform: translate(.15rem, .7rem); filter: blur(.15rem); opacity: .65; }
.sign-in-hologram::after { z-index: 2; background: repeating-linear-gradient(0deg, transparent 0 .2rem, var(--rivals-glow-teal) .2rem .25rem), linear-gradient(115deg, transparent 25%, var(--rivals-cyan) 45%, var(--rivals-teal) 50%, transparent 65%); background-size: 100% 100%, 250% 100%; background-repeat: no-repeat; mix-blend-mode: screen; opacity: .45; animation: sign-in-hologram-shimmer 5s linear infinite; }
@keyframes sign-in-hologram-float { 0%, 100% { transform: perspective(50rem) rotateY(-5deg) rotateX(3deg) translateY(0); } 50% { transform: perspective(50rem) rotateY(5deg) rotateX(-2deg) translateY(-.5rem); } }
@keyframes sign-in-hologram-shimmer { from { background-position: 0 0, 150% 0; } to { background-position: 0 0, -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sign-in-parallax { transform: none !important; transition: none; } .sign-in-hologram, .sign-in-hologram::after { animation: none; } }

.privacy-page { max-width: 46rem; margin: 2rem auto; padding: 1.5rem; color: var(--cream); background: var(--rivals-panel-background); border: .0625rem solid var(--rivals-steel); }
.privacy-page h1, .privacy-page h2 { margin: 1.5rem 0 .75rem; }
.privacy-page p { margin: .75rem 0; line-height: 1.6; }
.privacy-page a { color: var(--rivals-cyan); }

.sign-in-privacy { position: absolute; bottom: calc(1.5rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); white-space: nowrap; color: var(--muted); text-decoration: none; text-underline-offset: .2rem; transition: color .15s; }
.sign-in-privacy:hover, .sign-in-privacy:focus-visible { color: var(--rivals-cyan); text-decoration: underline; }
.sign-in-panel #sign-in-status:empty { display: none; }

body.is-loading .home-backdrop { visibility: visible; }
body.is-loading .home-backdrop-image { transform: scale(1); filter: blur(var(--home-backdrop-blur)); transition: none; }
body.is-loading .home-backdrop::after { opacity: 1; transition: none; }
.sign-in-panel #google-sign-in { min-height: 6rem; display: grid; place-items: center; }

.profile-setup { text-align: center; }
.profile-setup form { display: grid; justify-items: center; gap: 1rem; margin-top: 1.5rem; }
.profile-setup input { width: min(22rem, 100%); }
.setup-profile-picture { padding: 0; border-radius: var(--profile-radius); overflow: hidden; }
.setup-profile-picture .player-avatar { display: block; width: var(--home-profile-size); height: var(--home-profile-size); border-radius: var(--profile-radius); }
.profile-setup #profile-setup-status:empty { display: none; }
.profile-editor form { margin-top: 2rem; gap: 1.5rem; }
.profile-editor .modal-actions { margin-top: .5rem; gap: 1rem; }
.profile-editor #profile-editor-status:empty { display: none; }
.profile-editor input[name="name"] { min-height: 3rem; padding: .875rem 1rem; border: .0625rem solid var(--rivals-steel); border-radius: .2rem; background: var(--rivals-surface); color: var(--cream); cursor: text; }
.profile-editor input[name="name"]:focus-visible { border-color: var(--rivals-cyan); outline: .125rem solid var(--rivals-cyan); outline-offset: .125rem; }

/* Keep lobby and match controls aligned with the main menu panels. */
.game .top-actions { align-items: center; flex-wrap: nowrap; }
.game .top-actions > button { flex-shrink: 0; }
.team-selection .team-large-mascot { transform: scaleX(-1); }
.game-rules-panel { width: min(46rem, calc(100% - 2rem)); padding: 2rem; border-color: var(--rivals-steel); border-radius: .2rem; background: var(--rivals-panel-background); }
.overlay[data-dialog="game-settings"] > .lobby-game-rules { width: min(46rem, calc(100% - 2rem)); }
.game-rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; padding-block: .5rem; }
.team-lobby-footer .lobby-match-controls .lobby-game-rules { max-width: 22rem; }
.mode-card .mode-elo { padding: .35rem .65rem; border-radius: .3rem; box-shadow: none; }
@media (max-width: 700px) { .game-rule-grid { grid-template-columns: minmax(0, 1fr); } .game-rules-panel { padding: 1.5rem; } }

.room-browser.modal { width: min(46rem, calc(100vw - 2rem)); }
.server-browser-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; margin-block: 1.5rem; }
.server-room-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: .75rem; max-height: 24rem; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: .5rem; margin-bottom: 1.5rem; }
.server-room-list::-webkit-scrollbar { width: .625rem; }
.server-room-list::-webkit-scrollbar-track { background: var(--rivals-surface); border: .0625rem solid var(--rivals-steel); border-radius: .125rem; }
.server-room-list::-webkit-scrollbar-thumb { min-height: 2.5rem; background: var(--rivals-teal); border: .0625rem solid var(--rivals-cyan); border-radius: .125rem; box-shadow: 0 0 .5rem var(--rivals-cyan), inset 0 0 .25rem var(--cream); }
.server-room-list::-webkit-scrollbar-thumb:hover { background: var(--rivals-cyan); }
.server-room-list::-webkit-scrollbar-thumb:active { background: var(--cream); }
.server-room-list::-webkit-scrollbar-button { display: none; }
@supports not selector(::-webkit-scrollbar) {
  .server-room-list { scrollbar-width: thin; scrollbar-color: var(--rivals-teal) var(--rivals-surface); }
}
.server-room { position: relative; display: flex; align-items: flex-start; min-width: 0; padding: .75rem; background: var(--rivals-surface); border: .0625rem solid var(--rivals-line); }
.server-host { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; min-width: 0; }
.server-host > span { min-width: 0; }
.server-host .player-avatar { width: 2.5rem; height: 2.5rem; flex-shrink: 0; }
.server-host strong { overflow-wrap: anywhere; }
.server-host > span > span, .room-visibility small { display: block; margin-top: .25rem; color: var(--muted); }
.server-room-lock { position: absolute; top: .75rem; right: .75rem; display: grid; place-items: center; color: var(--cream); }
.server-room-lock svg { display: block; width: 1.5rem; height: 1.5rem; }
.room-visibility { display: grid; gap: 1rem; margin-block: 1.5rem; padding: 1rem; border: .0625rem solid var(--rivals-line); }
.room-visibility label { display: flex; align-items: center; gap: .75rem; padding: .5rem; cursor: pointer; }
.room-visibility input { width: 1.25rem; height: 1.25rem; accent-color: var(--rivals-teal); }

#room-listing-status:empty { display: none; }
#room-listing-status { color: var(--rivals-orange); }
.room-browser-heading { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 1rem; margin: 3rem 0 2rem; }
.room-browser-heading h2 { margin: 0; text-align: center; }
.room-browser-heading > button, .server-browser-actions .room-refresh { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: .5rem; }
.room-refresh svg { display: block; width: 1.25rem; height: 1.25rem; }
@media (max-width: 550px) { .room-browser-heading { gap: .5rem; } }
.room-browser #join-room-form { gap: 1rem; align-items: center; flex-wrap: wrap; }
.room-browser #join-code { width: 12rem; max-width: 100%; flex: 0 1 12rem; }
.room-browser #room-list-status { color: var(--cream); text-align: center; margin-block: .5rem; }
.server-browser-actions { justify-content: flex-end; margin-bottom: .5rem; }
.server-browser-bottom { display: flex; justify-content: flex-start; margin-top: 2rem; }
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .overlay[data-dialog="room-options"] > .room-browser { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; gap: .5rem; width: 100%; height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow: hidden; }
 .room-browser .room-browser-heading { grid-row: 1; margin: .25rem 2rem .5rem; }
 .room-browser .room-browser-heading h2 { padding-right: 0; }
 .room-browser #room-list-status { grid-row: 2; margin: 0; }
 .room-browser .server-room-list { grid-row: 3; grid-template-columns: minmax(0, 1fr); align-content: start; min-height: 0; max-height: none; margin: 0; overscroll-behavior-y: contain; }
 .room-browser .server-browser-bottom { grid-row: 4; display: flex; margin-top: .5rem; padding: .25rem .5rem; }
 .room-browser #create-room-options { width: 100%; min-height: var(--mobile-touch-size); padding: .75rem 1rem; }
 .room-browser .server-room { align-items: center; gap: .75rem; padding: .5rem .75rem; min-height: var(--mobile-touch-size); }
 .room-browser .server-host { flex: 1; flex-direction: row; align-items: center; gap: .75rem; }
 .room-browser .server-room-lock { position: static; flex-shrink: 0; }
}
@media (max-width: 1050px) and (orientation: landscape), (max-height: 550px) and (orientation: landscape) {
 .room-browser .server-room-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 700px) and (max-height: 550px) and (orientation: landscape) {
 .room-browser .server-room-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
 .room-browser .room-browser-heading { margin: 2rem 0 .5rem; }
}
@media (max-width: 1050px) and (orientation: landscape) {
 .room-browser-heading { margin: .25rem 3rem .75rem; }
}
.arena-rotated .overlay[data-dialog="room-options"] > .room-browser { height: calc(100dvw - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right)); }
button.server-room { width: 100%; text-align: left; font-family: var(--font-body); cursor: pointer; }
button.server-room:disabled { cursor: default; }
button.server-room:focus-visible { border-color: var(--rivals-cyan); }
@media (hover: hover) {
 button.server-room:hover:not(:disabled) { background: var(--ink); border-color: var(--rivals-cyan); }
 button.server-room:hover:not(:disabled) .server-room-lock { color: var(--rivals-teal); }
}

/* Preserve the live lobby beneath its leaderboard popup. */
.overlay[data-lobby-backdrop="true"]::before { content: ''; position: fixed; inset: 0; z-index: 1; background: var(--home-menu-shade); pointer-events: none; }
.overlay[data-lobby-backdrop="true"] > .leaderboard-panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; animation-name: lobby-leaderboard-open; }
@keyframes lobby-leaderboard-open {
 from { opacity: 0; transform: translate(-50%, -50%) scale(.98); }
 to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}


/* Mobile play: equal score gutters and a slim dock leave room for the field. */
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .game, .game.free-play, .game-fullscreen .game { padding: env(safe-area-inset-top, 0rem) env(safe-area-inset-right, 0rem) env(safe-area-inset-bottom, 0rem) env(safe-area-inset-left, 0rem); grid-template-rows: auto auto minmax(0, 1fr) auto auto; }
 .game .topbar { grid-row: 1; }
 .game .match-meta { grid-row: 2; }
 .game .arena { grid-row: 3; }
 .game .control-dock { grid-row: 4; }
 .game footer { grid-row: 5; }
 .game .topbar { grid-template-columns: var(--mobile-hud-gutter) minmax(0, 1fr) var(--mobile-hud-gutter); grid-template-rows: auto; height: auto; min-height: 3.25rem; padding: .25rem; gap: .25rem; }
 .game .wordmark, .game .back-home, .game #help { display: none; }
 .game .scoreboard, .game.free-play .scoreboard { grid-column: 2; grid-row: 1; justify-self: center; width: min(100%, 23rem); min-width: 0; height: 2.75rem; }
 .game .top-actions { display: contents; }
 .game .fullscreen-button { display: grid; grid-column: 1; grid-row: 1; justify-self: start; }
 .game #settings { grid-column: 3; grid-row: 1; justify-self: end; }
 .game .icon-button, .game .ready-button { width: var(--mobile-touch-size); height: var(--mobile-touch-size); }
 .game .team-score { min-width: 0; padding: .125rem .25rem; gap: .25rem; border-width: .125rem; }
 .game .team-score > div { min-width: 0; }
 .game .team-score strong { font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
 .game .team-score small { display: none; }
 .game .mascot-mini { width: 1.75rem; height: 1.75rem; }
 .game .turn-score { display: grid; grid-template-rows: minmax(0, 1fr) auto; border-width: .125rem; padding: 0; }
 .game .turn-score > span { height: auto; min-height: 0; align-self: center; font-size: var(--text-lg); font-variant-numeric: tabular-nums; white-space: nowrap; gap: .25rem; }
 .game .turn-score i { margin: 0; font-size: var(--text-sm); }
 .game #turn-max { font-size: var(--text-base); }
 .game .turn-score small { height: auto; padding: .125rem 0; line-height: 1; letter-spacing: .04em; }
 .game .match-meta { height: auto; min-height: 1rem; padding: 0 .5rem .125rem; letter-spacing: 0; }
 .game .control-dock, .game.free-play .control-dock { grid-template-columns: minmax(0, 1fr); padding: .125rem .5rem; gap: 0; }
 .game .team-panel { display: none; }
 .game .turn-console, .game.free-play .turn-console { grid-column: 1; grid-row: 1; width: min(100%, 28rem); justify-self: center; }
 .game .timer-row, .game:not(.free-play) .timer-row { height: var(--mobile-touch-size); gap: .5rem; }
 .game .timer-row > b { height: var(--mobile-touch-size); }
 .game .power-row { position: static; margin-top: 0; }
 .game:not(.free-play) .power-row { display: none; }
 .game footer, .game.free-play footer { padding: .125rem .5rem; gap: .5rem; align-items: center; }
 .game footer > .gfx-controls { display: none; }
 .game footer > button, .game footer .gfx-controls button { min-height: 2rem; }
 .game .arena .power-shortcut { top: .5rem; left: 50%; transform: translateX(-50%); max-width: calc(100% - 1rem); padding: .125rem; gap: .25rem; }
 .game .arena .power-shortcut > img { width: 2rem; height: 2rem; }
 .game .bonus-label { display: none; }
 .game .placement-tools { bottom: .5rem; padding: .25rem; }
 .game .placement-tools button { width: var(--mobile-touch-size); height: var(--mobile-touch-size); }
 .game.free-play .power-slots { flex: 0 0 100%; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding: .25rem; }
 .game.free-play .power-row { gap: .25rem; }
 .game.free-play #open-free-game-settings, .game.free-play #open-free-physics, .game.free-play #reset-free-play { display: none; }
 .game.free-play #end-free-play { flex: 0 1 auto; margin: .25rem auto; min-height: var(--mobile-touch-size); }
}

/* Menus flow with their content, including short landscape screens. */
@media (max-width: 1050px) {
 .overlay { padding: max(.75rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) max(.75rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)); align-items: safe center; overscroll-behavior: contain; }
 .overlay > .modal, .overlay > .clipboard { max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 1.25rem; min-width: 0; }
 .modal-actions { flex-wrap: wrap; }
 .modal-actions > * { flex: 1 1 10rem; }
 .clipboard .formation-list { margin-inline: 0; }
 .clipboard .formation-choice { width: 100%; padding: .75rem 0; gap: .75rem; }
 .clipboard .formation-choice svg { width: 6rem; flex-shrink: 0; }
 .clipboard .formation-choice > span { min-width: 0; overflow-wrap: anywhere; }
 .overlay[data-dialog="welcome"], .overlay[data-dialog="lobby"] { padding: 0; align-items: flex-start; }
 .home-screen { min-height: 100dvh; height: auto; padding: max(1.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); gap: 1.5rem; }
 .home-screen .home-logo.sign-in-parallax { top: auto; width: min(24rem, 80%); max-height: none; margin: 0; }
 .home-screen .home-play { width: min(23rem, 100%); gap: 1.5rem; }
 .home-screen .home-player-panel { position: static; width: min(23rem, 100%); max-width: 100%; margin-top: .5rem; padding: .75rem; }
 .home-player-name { flex-wrap: wrap; gap: .5rem; }
 .home-player-xp { gap: .25rem .5rem; }
 .overlay[data-dialog="lobby"] > .team-screen, .team-screen:has(.lobby-game-rules) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1.5rem 1rem; width: 100%; height: auto; min-height: 100dvh; aspect-ratio: auto; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
 .team-screen .team-heading { position: static; grid-column: 1 / -1; width: 100%; padding: 0; }
 .team-screen .team-heading h1 { font-size: var(--text-2xl); text-shadow: none; }
 .team-screen .team-heading p { margin-top: .5rem; }
 .team-screen .team-center-logo { display: none; }
 .team-screen .team-selection.side-0, .team-screen .team-selection.side-1 { position: static; width: 100%; height: auto; display: grid; grid-template-rows: auto 8rem auto; justify-items: center; align-content: start; gap: .75rem; min-width: 0; }
 .team-screen.solo-lobby .team-selection { grid-column: 1 / -1; width: min(24rem, 100%); justify-self: center; }
 .team-screen .team-name { grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem; gap: .25rem; }
 .team-screen .team-name h2 { font-size: var(--text-lg); }
 .team-screen .team-large-mascot { width: 100%; height: 100%; max-height: none; min-height: 0; margin: 0; object-fit: contain; }
 .team-screen.show-player-names .team-join-slots { position: static; width: 100%; flex-wrap: wrap; justify-content: center; gap: .75rem .5rem; }
 .team-screen .team-join-slots .lobby-player-slot { flex: 0 1 calc(50% - .5rem); }
 .team-screen .team-lobby-footer { position: static; grid-column: 1 / -1; width: 100%; padding: 1rem 0 0; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
 .team-screen .lobby-controls-area { grid-column: 1; grid-row: 1; width: 100%; justify-items: stretch; }
 .team-screen .team-lobby-footer .lobby-match-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 1rem; }
 .team-screen .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1 / -1; margin: 0; width: 100%; }
 .team-screen .lobby-ready-button { width: 100%; min-width: 0; }
 .team-screen .lobby-player-area { grid-column: 1; grid-row: 2; width: 100%; justify-self: stretch; }
 .team-screen .lobby-profile-panel { width: 100%; }
 .team-screen .team-home { position: static; grid-column: 1 / -1; justify-self: start; min-height: var(--mobile-touch-size); padding: .75rem 1rem; }
 .team-screen .team-home.team-leaderboard { grid-column: 1 / -1; }
 .team-screen .lobby-settings-controls { flex-wrap: wrap; }
 .team-screen .lobby-settings-controls .lobby-bot-difficulty { min-width: 0; width: 100%; }
 .sign-in-panel { padding: 1rem; gap: 1rem; }
 .sign-in-panel .sign-in-parallax { width: min(24rem, 70vw); margin-bottom: 0; }
 .sign-in-privacy { position: static; transform: none; white-space: normal; text-align: center; }
 .overlay[data-dialog="sign-in"] { flex-direction: column; gap: 1rem; }
}
@media (max-width: 380px) {
 .game .mascot-mini { display: none; }
 .team-screen .team-selection.side-0, .team-screen .team-selection.side-1 { grid-column: 1 / -1; }
}
@media (max-height: 550px) and (orientation: landscape) {
 .home-screen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: center; justify-items: center; gap: 1rem 2rem; }
 .home-screen .home-logo.sign-in-parallax { grid-column: 1; grid-row: 1; width: min(20rem, 100%); }
 .home-screen .home-play { grid-column: 2; grid-row: 1 / 3; }
 .home-screen .home-player-panel { grid-column: 1; grid-row: 2; margin: 0; }
 .sign-in-panel .sign-in-parallax { width: min(18rem, 45vw); }
 .game .match-meta:empty { display: none; }
}
@media (max-width: 1050px) {
 .home-player-panel .elo-badge { max-width: 100%; white-space: normal; }
 .home-player-panel .home-player-name strong { font-size: var(--text-lg); }
 .home-player-panel .home-player-xp { margin-top: .5rem; }
 .team-screen .lobby-profile-panel .player-avatar { width: var(--lobby-profile-size); height: var(--lobby-profile-size); }
}
@media (max-height: 550px) and (orientation: landscape) {
 .team-screen.solo-lobby .team-selection.side-0 { grid-column: 1; grid-row: 2; grid-template-rows: auto 5rem auto; gap: .5rem; width: 100%; }
 .team-screen.solo-lobby .team-lobby-footer { grid-column: 2; grid-row: 2; padding-top: .5rem; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: auto; align-self: end; }
 .team-screen.solo-lobby .lobby-ready-button { padding: .5rem; }
 .team-screen.solo-lobby .lobby-readiness p { white-space: normal; }
}
/* Practice bonuses scroll sideways instead of taking rows away from the field. */
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .game.free-play .power-row { flex-wrap: nowrap; }
 .game.free-play .power-slots { flex: 1 1 0; min-width: 0; }
 .game.free-play #end-free-play { flex: 0 0 auto; }
}
@media (max-height: 550px) and (orientation: landscape) {
 .game.free-play .turn-console { width: 100%; display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: .75rem; align-items: center; }
 .game.free-play .power-row { margin-top: 0; min-width: 0; }
 .game.free-play .timer-row { min-width: 0; }
}

/* Keep a clear exit above the lobby content and the profile at its foot. */
.team-screen { isolation: isolate; }
.team-screen > .team-flow { z-index: -1; }
@media (max-width: 1050px) {
 .team-screen { position: relative; }
 .overlay[data-dialog="lobby"] > .team-screen { padding-top: calc(4rem + env(safe-area-inset-top)); }
 .team-screen .team-home:not(.team-leaderboard) { position: absolute; top: calc(.75rem + env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right)); min-height: var(--mobile-touch-size); padding: .5rem .75rem; font-size: var(--text-sm); }
 .team-screen .team-lobby-footer { align-self: stretch; grid-template-rows: auto minmax(1rem, 1fr) auto; }
 .team-screen .lobby-player-area { grid-row: 3; align-self: end; }
}
@media (max-width: 1050px) and (orientation: portrait) {
 .home-screen { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(1rem, 1fr) auto auto minmax(1.5rem, 1fr) auto; align-content: stretch; justify-items: center; gap: 1rem; }
 .home-screen .home-logo.sign-in-parallax { grid-column: 1; grid-row: 2; width: min(24rem, 90%); }
 .home-screen .home-play { grid-column: 1; grid-row: 3; margin: 1.5rem 0 0; transform: none; }
 .home-screen .home-player-panel { grid-column: 1; grid-row: 5; align-self: end; margin: 0; }
 .play-modes.modal { padding: 1rem; }
 .play-modes .mode-cards { grid-template-columns: minmax(0, 1fr); gap: .5rem; margin-top: .75rem; }
 .play-modes .mode-card { display: flex; flex-direction: column; align-items: stretch; gap: .25rem; padding: 0 0 .5rem; }
 .play-modes .mode-card img { width: 100%; height: var(--mobile-mode-image-height); object-fit: cover; border-radius: 0; }
 .play-modes .mode-card span { margin: 0 .65rem; }
 .play-modes .mode-card img + span { margin-top: 0; }
 .play-modes .mode-card .mode-elo { align-self: flex-start; padding: .125rem .4rem; margin: 0 .65rem; }
 .overlay[data-dialog="lobby"] > .team-screen { grid-template-rows: auto auto minmax(min-content, 1fr); gap: 1.5rem; padding-top: calc(6rem + env(safe-area-inset-top)); }
 .team-screen .team-selection.side-0, .team-screen .team-selection.side-1 { grid-template-rows: auto var(--mobile-team-mascot-size) auto; gap: 1rem; }
 .team-screen.show-player-names .team-join-slots { margin-top: .75rem; margin-bottom: 1.5rem; }
 .team-screen .team-large-mascot { max-width: 100%; }
 .team-screen .team-lobby-footer { grid-template-rows: auto auto auto minmax(2rem, 1fr) auto auto; gap: .75rem; padding-top: 1.5rem; }
 .team-screen .lobby-controls-area, .team-screen .lobby-match-controls { display: contents; }
 .team-screen .team-lobby-footer .room-invite { grid-column: 1; grid-row: 1; }
 .team-screen .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1; grid-row: 2; width: 100%; max-width: none; }
 .team-screen .game-rules-active { grid-column: 1; grid-row: 3; justify-content: flex-start; }
 .team-screen .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1; grid-row: 5; }
 .team-screen .team-lobby-footer .lobby-player-area { grid-column: 1; grid-row: 6; align-self: end; }
 .team-screen .lobby-profile-panel { margin: 0; }
}
@media (min-width: 390px) and (max-width: 1050px) and (orientation: portrait) {
 .team-screen.solo-lobby .lobby-settings-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; width: 100%; align-items: end; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1 / -1; max-width: none; width: 100%; }
 .team-screen.solo-lobby .lobby-settings-controls .lobby-bot-difficulty { width: 100%; }
 .team-screen.solo-lobby #lobby-game-settings { height: 3rem; }
}


/* Mobile surfaces keep swipe scrolling without drawing browser scrollbars. */
@media (max-width: 1050px) {
 html, body { height: 100%; overflow: hidden; }
 html, body, body * { scrollbar-width: none; }
 html::-webkit-scrollbar, body::-webkit-scrollbar, body *::-webkit-scrollbar { display: none; width: 0; height: 0; }
 .profile-grid, .server-room-list { scrollbar-gutter: auto; scrollbar-width: none; }
}

/* The lobby fits the visible phone height; artwork takes the remaining space. */
@media (max-width: 1050px) and (orientation: portrait) {
 .overlay[data-dialog="lobby"]:has(> .solo-lobby) { overflow: hidden; }
 .overlay[data-dialog="lobby"] > .team-screen.solo-lobby { height: 100dvh; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; gap: 1rem; padding-top: calc(5.5rem + env(safe-area-inset-top)); }
 .team-screen.solo-lobby .team-selection.side-0 { height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; gap: .5rem; }
 .team-screen.solo-lobby .team-large-mascot { min-height: 0; max-height: var(--mobile-team-mascot-size); align-self: center; }
 .team-screen.solo-lobby.show-player-names .team-join-slots { margin: 0; }
 .team-screen.solo-lobby .team-lobby-footer { min-height: 0; grid-template-rows: auto auto auto 0 auto auto; gap: .5rem; padding-top: .75rem; }
 .team-screen.solo-lobby .lobby-profile-panel { padding: .5rem; }
 .team-screen.solo-lobby .lobby-readiness { gap: .25rem; }
}
@media (max-width: 1050px) and (max-height: 740px) and (orientation: portrait) {
 .team-screen.solo-lobby .team-heading h1 { font-size: var(--text-xl); }
 .team-screen.solo-lobby .team-heading > p { display: none; }
 .team-screen.solo-lobby .team-join-slots .elo-badge, .team-screen.solo-lobby .lobby-profile-panel .elo-badge { display: none; }
 .team-screen.solo-lobby .lobby-settings-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: .75rem; align-items: end; }
 .team-screen.solo-lobby #lobby-game-settings { height: 3rem; padding: .5rem; font-size: var(--text-xs); }
 .team-screen.solo-lobby .lobby-ready-button { height: 3rem; padding: .5rem; }
 .team-screen.solo-lobby .lobby-profile-panel .home-player-xp { margin-top: .25rem; }
}
@media (max-width: 1050px) and (max-height: 740px) and (orientation: portrait) {
 .team-screen.solo-lobby .team-lobby-footer { grid-template-rows: auto auto auto auto; gap: .375rem; padding-top: .5rem; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-row: 3; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-player-area { grid-row: 4; }
 .team-screen.solo-lobby .game-rules-active:empty { display: none; }
 .team-screen.solo-lobby .team-join-slots .lobby-player-slot { flex-direction: row; flex-basis: auto; gap: .75rem; }
 .team-screen.solo-lobby .team-join-slots .lobby-name-row { flex: 0 1 auto; width: auto; height: auto; }
 .home-screen { height: 100dvh; min-height: 0; grid-template-rows: minmax(0, 1fr) minmax(0, 8rem) auto minmax(0, 1fr) auto; gap: .75rem; }
 .home-screen .home-logo.sign-in-parallax { height: 100%; min-height: 0; }
 .home-screen .home-logo .sign-in-hologram { height: 100%; }
 .home-screen .home-logo .sign-in-logo { height: 100%; object-fit: contain; }
 .home-screen .home-play { margin-top: .5rem; }
}

.game-settings-mobile-note { display: none; }
@media (max-width: 1050px) {
 .game-rules-panel { padding: 1rem; max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); background: var(--ink-deep); }
 .game-rules-panel .game-settings-detail { display: none; }
 .game-rules-panel .game-settings-mobile-note { display: block; margin: .375rem 0 .75rem; color: var(--muted); }
 .game-rules-panel .team-length { grid-template-columns: auto minmax(0, 1fr); gap: .5rem .75rem; margin-bottom: .75rem; }
 .game-rules-panel #game-length { height: var(--mobile-touch-size); }
 .game-rules-panel #mode-summary { grid-column: 1 / -1; }
 .game-rules-panel .game-rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; padding: 0; }
 .game-rules-panel .game-rule { min-height: var(--mobile-touch-size); padding: .375rem .625rem; gap: .5rem; box-shadow: none; }
 .game-rules-panel .game-rule-check { width: 1.125rem; height: 1.125rem; }
 .game-rules-panel .game-rule-copy strong { font-size: var(--text-sm); }
 .game-rules-panel .game-rule-copy small { position: absolute; width: .0625rem; height: .0625rem; padding: 0; margin: -.0625rem; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
 .game-rules-panel > details { margin: .75rem 0; }
 .game-rules-panel > details > summary { min-height: var(--mobile-touch-size); align-content: center; }
 .game-rules-panel .game-bonus-options { gap: .5rem; padding-top: .5rem; }
 .game-rules-panel #close-game-settings { position: sticky; bottom: 0; z-index: 1; width: 100%; min-height: var(--mobile-touch-size); padding: .5rem 1rem; background: var(--rivals-teal); }
}

/* Rotate the complete play surface on upright phones, including dialogs/input. */
#play-surface { position: relative; width: 100%; height: 100dvh; }
.arena-rotated #play-surface { position: fixed; inset: 0 auto auto 0; width: 100dvh; height: 100dvw; transform-origin: top left; transform: translateX(100dvw) rotate(90deg); }
.arena-rotated .game, .arena-rotated .game.free-play { width: 100%; height: 100%; padding: env(safe-area-inset-right, 0rem) env(safe-area-inset-bottom, 0rem) env(safe-area-inset-left, 0rem) env(safe-area-inset-top, 0rem); }
.arena-rotated .game .match-meta:empty { display: none; }
.arena-rotated .game.free-play .turn-console { width: 100%; display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: .75rem; align-items: center; }
.arena-rotated .game.free-play .power-row { min-width: 0; margin-top: 0; }
.arena-rotated .game.free-play .timer-row { min-width: 0; }
.arena-rotated .overlay { padding: .75rem; }
.arena-rotated .overlay > .modal, .arena-rotated .overlay > .clipboard, .arena-rotated .game-rules-panel { max-height: calc(100dvw - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right)); }
.arena-rotated .game-rules-panel .game-rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.arena-rotated .physics-panel { max-height: calc(100dvw - 1rem); }

/* Keep mobile results in one panel instead of hanging the score above it. */
.result-help-compact { display: none; }
@media (max-width: 1050px) {
 .overlay[data-dialog="finished"] { padding: .75rem; align-items: safe center; }
 .overlay[data-dialog="finished"] .match-result { width: min(100%, 46rem); max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; padding: 1rem; gap: .75rem; background: var(--ink-deep); }
 .match-result .result-scoreboard { position: static; transform: none; width: 100%; gap: .5rem; }
 .match-result .result-team { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .75rem .5rem; }
 .match-result .result-team > span { font-size: var(--text-xs); text-align: left; }
 .match-result .result-team > strong { font-size: var(--text-2xl); }
 .match-result .result-heading h1 { font-size: var(--text-xl); }
 .match-result .result-heading h2 { display: none; }
 .match-result .result-help-full, .match-result > p:last-child { display: none; }
 .match-result .result-help-compact { display: inline; }
 .match-result .result-players { gap: 1rem; }
 .match-result .result-player { flex: 0 1 5rem; gap: .5rem; padding-top: .25rem; }
 .match-result .result-player .player-avatar { width: 3rem; height: 3rem; }
 .match-result .recap-cards { grid-template-columns: minmax(0, 1fr); gap: .5rem; margin: 0; }
 .match-result .recap-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center; align-items: center; justify-items: start; gap: .25rem .75rem; padding: .625rem .75rem; text-align: left; }
 .match-result .recap-card > h2 { grid-column: 1; grid-row: 1; font-size: var(--text-base); }
 .match-result .recap-card > .text-sm { grid-column: 1; grid-row: 2; }
 .match-result .recap-winners { grid-column: 2; grid-row: 1 / 3; width: auto; max-width: 8rem; gap: .5rem; }
 .match-result .recap-player { flex: 0 1 auto; display: flex; align-items: center; gap: .375rem; }
 .match-result .recap-player .player-avatar { width: 2rem; height: 2rem; }
 .match-result .recap-winner { max-width: 5rem; font-size: var(--text-xs); }
 .match-result .result-actions { position: sticky; bottom: 0; margin: 0; padding-top: .25rem; background: var(--ink-deep); }
 .match-result .result-actions button { min-height: var(--mobile-touch-size); padding: .625rem .75rem; font-size: var(--text-sm); }
}
@media (max-width: 1050px) and (max-height: 740px) {
 .overlay[data-dialog="finished"] .match-result { gap: .5rem; }
}
@media (max-width: 1050px) and (max-height: 550px) and (orientation: landscape) {
 .overlay[data-dialog="finished"] .match-result { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .75rem; gap: .375rem; }
 .match-result .result-scoreboard { grid-column: 1; grid-row: 1; }
 .match-result .result-heading { grid-column: 2; grid-row: 1; }
 .match-result > p:not(:last-child) { grid-column: 1; grid-row: 2; }
 .match-result .result-winners { grid-column: 1; grid-row: 3; align-self: center; }
 .match-result .recap-cards { grid-column: 2; grid-row: 2 / 4; }
 .match-result .result-actions { grid-column: 1 / -1; grid-row: 4; }
}

/* Mobile HUD floats at the edges so the arena owns the full screen. */
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .game, .game.free-play, .arena-rotated .game, .arena-rotated .game.free-play { display: block; padding: 0; }
 .game .topbar, .game .scoreboard, .game.free-play .scoreboard { display: contents; }
 .game .match-meta, .game footer, .game.free-play footer, .game .top-actions .fullscreen-button { display: none; }
 .game .arena, .game.free-play .arena { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
 .game .team-score { position: absolute; z-index: 5; top: var(--mobile-hud-top); width: var(--mobile-score-width); height: var(--mobile-score-height); padding: .125rem .75rem; gap: .5rem; border: .1875rem solid var(--rivals-steel); border-radius: 0; background-image: linear-gradient(180deg, transparent, var(--ink-deep)), url('/artwork/rivals/chassis-painted-v6.png'); background-size: 100% 100%, 200% 200%; background-position: center, left top; box-shadow: inset 0 -.1875rem currentColor, inset 0 0 0 .125rem var(--ink-deep), inset 0 0 0 .1875rem var(--rivals-steel); pointer-events: none; }
 .game .team-score.orange { left: var(--mobile-hud-left); border-left: .1875rem solid currentColor; clip-path: polygon(.5rem 0, 100% 0, 100% 100%, .5rem 100%, 0 calc(100% - .5rem), 0 .5rem); }
 .game .team-score.pink { right: var(--mobile-hud-right); border-right: .1875rem solid currentColor; background-position: center, right bottom; clip-path: polygon(0 0, calc(100% - .5rem) 0, 100% .5rem, 100% calc(100% - .5rem), calc(100% - .5rem) 100%, 0 100%); }
 .game .team-score .mascot-mini { display: inline-flex; width: 2.25rem; height: 2.25rem; }
 .game .team-score strong { font-size: var(--text-2xl); text-shadow: 0 0 .35rem currentColor; }
 .game .turn-score { position: absolute; z-index: 5; left: var(--mobile-hud-left); bottom: var(--mobile-hud-bottom); display: flex; align-items: center; justify-content: center; gap: .5rem; width: auto; height: var(--mobile-touch-size); padding: .375rem .625rem; border: .0625rem solid var(--rivals-steel); border-radius: .375rem; clip-path: none; background: var(--rivals-panel-background); box-shadow: none; pointer-events: none; }
 .game .turn-score > span { height: auto; font-size: var(--text-base); }
 .game .turn-score small { order: -1; height: auto; padding: 0; background: transparent; color: var(--cream); letter-spacing: 0; }
 .game #settings { position: absolute; z-index: 6; inset: auto var(--mobile-hud-right) var(--mobile-hud-bottom) auto; border-radius: .375rem; background: var(--rivals-panel-background); }
 .game .control-dock, .game.free-play .control-dock { position: absolute; z-index: 5; inset: auto auto var(--mobile-hud-bottom) 50%; transform: translateX(-50%); width: min(28rem, calc(100% - 15rem)); margin: 0; padding: 0; border: 0; background: transparent; pointer-events: none; }
 .game .control-dock .turn-console, .game.free-play .control-dock .turn-console { display: block; width: 100%; }
 .game .timer-row, .game:not(.free-play) .timer-row { height: var(--mobile-touch-size); margin: 0; }
 .game .ready-button, .game .power-row { pointer-events: auto; }
 .game.free-play .power-row { position: absolute; top: auto; right: auto; bottom: calc(var(--mobile-touch-size) + .375rem); left: 0; width: 100%; margin: 0; padding: .125rem; background: var(--rivals-panel-background); border-radius: .375rem; }
 .game.free-play #end-free-play { margin: 0; }
 .game .arena .power-shortcut { top: var(--mobile-hud-top); left: 50%; transform: translateX(-50%); }
 .game .placement-tools { bottom: calc(var(--mobile-hud-bottom) + var(--mobile-touch-size) + .5rem); }
}

/* Landscape mobile formation choices fit beside one another. */
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .overlay[data-dialog="formation"] { justify-content: center; align-items: safe center; padding: .75rem; }
 .overlay[data-dialog="formation"] > .clipboard { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem; width: min(100%, 44rem); max-height: calc(100% - 1.5rem); padding: 1rem; transform: none; overflow-y: auto; background: var(--ink-deep); }
 .overlay[data-dialog="formation"] .clipboard h2 { grid-column: 1; grid-row: 1; margin: 0; padding: 0; border: 0; font-size: var(--text-lg); }
 .overlay[data-dialog="formation"] .formation-countdown { grid-column: 2; grid-row: 1; margin: 0; white-space: nowrap; }
 .overlay[data-dialog="formation"] .formation-list { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin: 0; }
 .overlay[data-dialog="formation"] .formation-choice { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .5rem; min-width: 0; min-height: var(--mobile-touch-size); padding: .75rem .5rem; text-align: center; background: var(--rivals-surface); border: .0625rem solid var(--rivals-steel); }
 .overlay[data-dialog="formation"] .formation-choice[aria-pressed="true"] { border-color: var(--rivals-cyan); box-shadow: inset 0 -.1875rem var(--rivals-cyan); }
 .overlay[data-dialog="formation"] .formation-choice svg { width: min(100%, 7rem); height: auto; }
 .overlay[data-dialog="formation"] .formation-choice strong { margin-bottom: .375rem; font-size: var(--text-base); }
 .overlay[data-dialog="formation"] .formation-choice small { font-size: var(--text-xs); line-height: 1.4; color: var(--cream); }
 .overlay[data-dialog="formation"] .clipboard > .small-note { grid-column: 1 / -1; grid-row: 3; margin: 0; line-height: 1.4; }
}

.game .mobile-reset-camera { display: none; }
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .game #mobile-reset-camera { position: absolute; z-index: 6; inset: auto calc(var(--mobile-hud-right) + var(--mobile-touch-size) + .5rem) var(--mobile-hud-bottom) auto; display: grid; place-items: center; width: var(--mobile-touch-size); height: var(--mobile-touch-size); border-radius: .375rem; background: var(--rivals-panel-background); }
}

/* Settings lead to focused audio and graphics panels on every screen. */
.match-settings-menu { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; margin-top: 1.25rem; }
.match-settings-menu > button { min-height: 3.25rem; padding: .75rem; }
.match-settings-menu #leave { color: var(--rivals-coral); border-color: var(--rivals-coral); }
.overlay > .match-settings { width: min(100%, 28rem); background: var(--ink-deep); }
.settings-exit { position: fixed; bottom: max(1.5rem, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(28rem, calc(100% - 3rem)); }
.settings-exit > button { width: 100%; min-height: var(--mobile-touch-size); }
@media (max-height: 550px) and (orientation: landscape) {
 .match-settings-menu > button { min-height: var(--mobile-touch-size); padding: .5rem .75rem; }
}
.overlay > .settings-submenu { width: min(100%, 34rem); background: var(--ink-deep); }
.settings-submenu h2, .match-settings h2 { font-size: var(--text-xl); }
.settings-submenu .sound-controls { gap: .5rem; margin: 1rem 0 0; padding: 0; border: 0; background: transparent; }
.settings-submenu .sound-controls > button { min-height: var(--mobile-touch-size); padding: .5rem .75rem; margin-bottom: .25rem; }
.settings-submenu .sound-volume { grid-template-columns: 6.5rem minmax(0, 1fr) 3rem; gap: .5rem; min-height: var(--mobile-touch-size); }
.settings-submenu .sound-volume label { grid-column: 1; grid-row: 1; }
.settings-submenu .sound-volume output { grid-column: 3; grid-row: 1; text-align: right; }
.settings-submenu .sound-volume input[type="range"] { grid-column: 2; grid-row: 1; min-height: var(--mobile-touch-size); }
.settings-submenu .settings-graphics { margin: 1.25rem 0 0; padding: 0; border: 0; background: transparent; }
.settings-submenu .settings-graphics h3 { display: none; }
.settings-submenu .gfx-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; padding: 0; gap: .75rem; }
.settings-submenu .gfx-controls button { min-height: var(--mobile-touch-size); }

/* Phone landscape lobbies use their height for the mascot and match controls. */
@media (max-width: 1050px) and (orientation: landscape) {
 .overlay[data-dialog="lobby"]:has(> .solo-lobby) { overflow: hidden; }
 .overlay[data-dialog="lobby"] > .team-screen.solo-lobby { height: 100dvh; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(0, 1fr); gap: 1rem 1.5rem; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
 .team-screen.solo-lobby .team-heading { min-height: var(--mobile-touch-size); padding-right: 11rem; text-align: left; }
 .team-screen.solo-lobby .lobby-playlist-heading { justify-content: flex-start; }
 .team-screen.solo-lobby .team-heading h1 { font-size: var(--text-xl); }
 .team-screen.solo-lobby .team-heading p { margin-top: .25rem; letter-spacing: .04em; }
 .team-screen.solo-lobby .team-selection.side-0 { grid-column: 1; grid-row: 2; height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; gap: .5rem; }
 .team-screen.solo-lobby .team-large-mascot { width: 100%; height: 100%; min-height: 0; max-height: none; }
 .team-screen.solo-lobby.show-player-names .team-join-slots { margin: 0; }
 .team-screen.solo-lobby .team-join-slots .lobby-player-slot { flex-direction: row; flex-basis: auto; align-items: center; gap: .75rem; }
 .team-screen.solo-lobby .team-join-slots .lobby-name-row { flex: 0 1 auto; width: auto; height: auto; }
 .team-screen.solo-lobby .team-join-slots .elo-badge, .team-screen.solo-lobby .lobby-profile-panel .elo-badge { display: none; }
 .team-screen.solo-lobby .team-lobby-footer { grid-column: 2; grid-row: 2; min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; gap: .5rem; border: 0; background: transparent; }
 .team-screen.solo-lobby .lobby-controls-area { grid-column: 1; grid-row: 1; min-width: 0; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-game-rules { width: 100%; max-width: none; }
 .team-screen.solo-lobby .lobby-settings-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; width: 100%; gap: .75rem; }
 .team-screen.solo-lobby .lobby-settings-controls .lobby-bot-difficulty { width: 100%; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1; width: 100%; margin: 0; gap: .25rem; }
 .team-screen.solo-lobby .lobby-ready-button { height: 3rem; padding: .5rem .75rem; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-player-area { grid-column: 1; grid-row: 3; align-self: end; }
 .team-screen.solo-lobby .lobby-profile-panel { margin: 0; padding: .5rem; }
}
@media (max-width: 1050px) and (max-height: 340px) and (orientation: landscape) {
 .overlay[data-dialog="lobby"] > .team-screen.solo-lobby { padding-block: .5rem; gap: .5rem 1rem; }
 .team-screen.solo-lobby .team-heading > p { display: none; }
 .team-screen.solo-lobby .team-heading h1 { font-size: var(--text-lg); }
 .team-screen.solo-lobby #lobby-game-settings { padding-inline: .5rem; font-size: var(--text-xs); }
 .team-screen.solo-lobby .home-player-xp .profile-xp-bar { max-width: var(--profile-xp-width); }
}

@media (max-width: 1050px) and (orientation: landscape) {
 .home-screen { height: 100dvh; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr) auto; align-content: stretch; gap: 1rem 2rem; padding-top: max(1rem, env(safe-area-inset-top)); padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
 .home-screen .home-play { grid-column: 2; grid-row: 1 / -1; align-self: center; margin: 0; transform: none; }
 .home-screen .home-player-panel { grid-column: 1; grid-row: 2; justify-self: start; align-self: end; margin: 0; }
 .home-screen .home-logo.sign-in-parallax { grid-column: 1; grid-row: 1; align-self: center; width: min(20rem, 100%); height: 100%; min-height: 0; max-height: 100%; margin: 0; }
 .home-screen .home-logo .sign-in-hologram { height: 100%; }
 .home-screen .home-logo .sign-in-logo { height: 100%; object-fit: contain; }
}

@media (max-width: 1050px) {
 .game-rules-panel { container: game-settings / inline-size; }
}
@container game-settings (min-width: 36rem) {
 .game-rules-panel .game-rule-grid, .arena-rotated .game-rules-panel .game-rule-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Two-team phone lobbies keep all eight seats and the match actions visible. */
.lobby-rating-compact { display: none; }
@media (max-width: 1050px) {
 .overlay[data-dialog="lobby"]:has(> .team-screen:not(.solo-lobby)) { overflow: hidden; }
 .overlay[data-dialog="lobby"] > .team-screen:not(.solo-lobby) { height: 100dvh; min-height: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto minmax(0, 1fr) auto; gap: .75rem; padding-top: calc(5rem + env(safe-area-inset-top)); }
 .team-screen:not(.solo-lobby) .team-heading h1 { font-size: var(--text-xl); }
 .team-screen:not(.solo-lobby) .team-selection.side-0, .team-screen:not(.solo-lobby) .team-selection.side-1 { grid-row: 2; height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; gap: .5rem; }
 .team-screen:not(.solo-lobby) .team-selection.side-0 { grid-column: 1; }
 .team-screen:not(.solo-lobby) .team-selection.side-1 { grid-column: 2; }
 .team-screen:not(.solo-lobby) .team-name { position: relative; display: block; min-height: 2.5rem; }
 .team-screen:not(.solo-lobby) .team-name h2 { font-size: var(--text-base); line-height: 1.2; overflow-wrap: normal; word-break: normal; }
 .team-screen:not(.solo-lobby) .team-name button { position: absolute; top: calc(100% + .25rem); z-index: 2; }
 .team-screen:not(.solo-lobby) .team-name button:first-child { left: 0; }
 .team-screen:not(.solo-lobby) .team-name button:last-child { right: 0; }
 .team-screen:not(.solo-lobby) .team-large-mascot { width: 100%; height: 100%; min-height: 0; }
 .team-screen:not(.solo-lobby).show-player-names .team-join-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .5rem; width: 100%; margin: 0; }
 .team-screen:not(.solo-lobby) .lobby-player-slot { width: 100%; gap: .125rem; }
 .team-screen:not(.solo-lobby) .team-join-slots .player-avatar, .team-screen:not(.solo-lobby) .empty-player { width: var(--mobile-touch-size); height: var(--mobile-touch-size); font-size: var(--text-xl); }
 .team-screen:not(.solo-lobby) .lobby-name-row { width: 100%; height: auto; flex: 0 0 auto; }
 .team-screen:not(.solo-lobby) .lobby-player-name { font-size: var(--text-xs); line-height: 1.2; }
 .team-screen:not(.solo-lobby) .lobby-player-slot > .elo-badge { max-width: 100%; margin: 0; padding: .125rem .25rem; font-size: var(--text-xs); white-space: normal; }
 .team-screen:not(.solo-lobby) .lobby-rating-full { display: none; }
 .team-screen:not(.solo-lobby) .lobby-rating-compact { display: inline; }
 .team-screen:not(.solo-lobby) .team-lobby-footer { grid-column: 1 / -1; grid-row: 3; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto auto auto; gap: .5rem; padding: .75rem 0 0; min-height: 0; }
 .team-screen:not(.solo-lobby) .lobby-controls-area, .team-screen:not(.solo-lobby) .lobby-match-controls { display: contents; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .room-invite { grid-column: 1 / -1; grid-row: 1; min-height: var(--mobile-touch-size); justify-content: center; flex-wrap: nowrap; gap: .5rem; }
 .team-screen:not(.solo-lobby) .room-invite > span { gap: .125rem; font-size: var(--text-xs); }
 .team-screen:not(.solo-lobby) .room-invite b { font-size: var(--text-base); letter-spacing: .08em; }
 .team-screen:not(.solo-lobby) .team-lobby-footer #copy-invite { width: var(--mobile-touch-size); height: var(--mobile-touch-size); }
 .team-screen:not(.solo-lobby) #room-visibility-toggle { width: var(--mobile-touch-size); height: var(--mobile-touch-size); padding: .5rem; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1; grid-row: 2; width: 100%; max-width: none; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 2; grid-row: 2; width: 100%; margin: 0; gap: .25rem; }
 .team-screen:not(.solo-lobby) .team-lobby-footer:not(:has(.lobby-game-rules)) .lobby-readiness { grid-column: 1 / -1; }
 .team-screen:not(.solo-lobby) .lobby-ready-button { height: 3rem; padding: .5rem; }
 .team-screen:not(.solo-lobby) .lobby-readiness p { white-space: normal; text-align: center; }
 .team-screen:not(.solo-lobby) .game-rules-active { grid-column: 1 / -1; grid-row: 3; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-player-area { grid-column: 1 / -1; grid-row: 4; align-self: end; }
 .team-screen:not(.solo-lobby) .lobby-profile-panel { margin: 0; padding: .5rem; }
 .team-screen:not(.solo-lobby) .lobby-profile-panel .elo-badge { display: none; }
 .team-screen:not(.solo-lobby) .team-home.team-leaderboard { position: absolute; top: calc(.75rem + env(safe-area-inset-top)); left: 1rem; right: auto; min-height: var(--mobile-touch-size); padding: .5rem; font-size: var(--text-xs); }
}
@media (max-width: 1050px) and (orientation: landscape) {
 .overlay[data-dialog="lobby"] > .team-screen:not(.solo-lobby) { grid-template-rows: minmax(0, 1fr) auto; padding-top: calc(5rem + env(safe-area-inset-top)); }
 .team-screen:not(.solo-lobby) .team-heading { position: absolute; top: calc(.75rem + env(safe-area-inset-top)); left: 1rem; width: calc(100% - 21rem); text-align: left; }
 .team-screen:not(.solo-lobby) .lobby-playlist-heading { justify-content: flex-start; }
 .team-screen:not(.solo-lobby) .team-heading > p:not(#room-listing-status) { display: none; }
 .team-screen:not(.solo-lobby) .team-home.team-leaderboard { left: auto; right: calc(11rem + env(safe-area-inset-right)); }
 .team-screen:not(.solo-lobby) .team-home:not(.team-leaderboard), .team-screen:not(.solo-lobby) .team-home.team-leaderboard { font-size: var(--text-sm); padding: .5rem .75rem; }
 .team-screen:not(.solo-lobby) .team-selection.side-0, .team-screen:not(.solo-lobby) .team-selection.side-1 { grid-row: 1; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(0, 1fr); }
 .team-screen:not(.solo-lobby) .team-name { grid-column: 1 / -1; display: grid; grid-template-columns: 2rem minmax(0, 1fr) 2rem; align-items: center; justify-self: center; width: max-content; max-width: 100%; min-height: 2.75rem; gap: .5rem; }
 .team-screen:not(.solo-lobby) .team-name h2 { position: relative; min-width: 0; }
 .team-screen:not(.solo-lobby) .team-name h2::before { content: attr(data-longest-name); visibility: hidden; }
 .team-screen:not(.solo-lobby) .team-name-label { position: absolute; inset: 0; display: grid; place-items: center; }
 .team-screen:not(.solo-lobby) .team-name button { position: relative; inset: auto; width: 2rem; min-width: 2rem; }
 .team-screen:not(.solo-lobby) .team-name button:disabled { visibility: hidden; }
 .team-screen:not(.solo-lobby) .team-large-mascot { grid-column: 1; grid-row: 2; }
 .team-screen:not(.solo-lobby).show-player-names .team-join-slots { grid-column: 2; grid-row: 2; align-self: center; gap: .5rem; }
 .team-screen:not(.solo-lobby) .team-selection.side-0 { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
 .team-screen:not(.solo-lobby) .side-0 .team-large-mascot { grid-column: 2; }
 .team-screen:not(.solo-lobby).show-player-names .side-0 .team-join-slots { grid-column: 1; }
 .team-screen:not(.solo-lobby) .lobby-player-slot { display: grid; grid-template-columns: var(--mobile-touch-size) minmax(0, 1fr); grid-template-rows: auto auto; gap: .125rem .25rem; align-items: center; }
 .team-screen:not(.solo-lobby) .lobby-slot-avatar { grid-column: 1; grid-row: 1 / 3; }
 .team-screen:not(.solo-lobby) .lobby-name-row { grid-column: 2; grid-row: 1; text-align: left; }
 .team-screen:not(.solo-lobby) .lobby-player-slot > .elo-badge { grid-column: 2; grid-row: 2; font-size: var(--text-xs); }
 .team-screen:not(.solo-lobby) .team-lobby-footer { grid-row: 2; grid-template-columns: minmax(0, 1fr) minmax(10rem, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .room-invite { grid-column: 1; grid-row: 1; align-self: end; flex-wrap: nowrap; justify-content: flex-start; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 2; grid-row: 1; align-self: end; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-match-controls .lobby-readiness, .team-screen:not(.solo-lobby) .team-lobby-footer:not(:has(.lobby-game-rules)) .lobby-readiness { grid-column: 3; grid-row: 1; align-self: end; flex-direction: column; align-items: stretch; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-player-area { display: none; }
 .team-screen:not(.solo-lobby) .game-rules-active { grid-column: 1 / -1; grid-row: 2; }
 .team-screen:not(.solo-lobby) .lobby-profile-panel .home-player-xp { display: none; }
}
@media (max-width: 700px) and (orientation: landscape), (max-width: 1050px) and (max-height: 740px) and (orientation: portrait) {
 .team-screen:not(.solo-lobby) .team-heading h1 { font-size: var(--text-lg); }
 .team-screen:not(.solo-lobby) .lobby-profile-panel .home-player-xp { display: none; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-player-slot:has(.empty-player) .lobby-name-row { display: none; }
 .team-screen:not(.solo-lobby) .team-heading > p:not(#room-listing-status) { display: none; }
}
@media (max-width: 1050px) {
 .team-screen:not(.solo-lobby) .team-heading { display: flex; flex-direction: column; }
 .team-screen:not(.solo-lobby) #room-listing-status { order: 2; width: 100%; margin: .25rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); line-height: 1.2; }
 .team-screen:not(.solo-lobby) .lobby-kick { left: auto; right: 0; width: 1.25rem; height: 1.25rem; padding: 0; }
 .team-screen:not(.solo-lobby) .game-rules-active:empty { display: none; }
}
@media (max-width: 1050px) and (orientation: landscape) {
 .team-screen:not(.solo-lobby) .lobby-player-slot { display: flex; flex-direction: column; gap: .125rem; }
 .team-screen:not(.solo-lobby) .lobby-player-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
 .team-screen:not(.solo-lobby) .lobby-player-slot > .elo-badge { font-size: var(--text-xs); white-space: nowrap; }
 .team-screen:not(.solo-lobby) .team-lobby-footer { grid-template-columns: minmax(0, 1fr) auto minmax(9rem, 11rem); grid-template-rows: auto auto; gap: .75rem; padding-top: .75rem; }
 .team-screen:not(.solo-lobby) .lobby-profile-panel { gap: .5rem; }
 .team-screen:not(.solo-lobby) .lobby-profile-panel .home-player-name strong { font-size: var(--text-sm); }
}
@media (max-width: 1050px) and (max-height: 740px) and (orientation: portrait), (max-width: 1050px) and (max-height: 340px) and (orientation: landscape) {
 .overlay[data-dialog="lobby"] > .team-screen:not(.solo-lobby) { gap: .5rem; padding-bottom: max(.5rem, env(safe-area-inset-bottom)); }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-player-slot { position: relative; display: block; min-height: 3rem; padding: 0; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-slot-avatar { display: flex; align-items: flex-start; justify-content: center; width: 100%; height: 3rem; padding: 0 0 1rem; }
 .team-screen:not(.solo-lobby) .team-join-slots .player-avatar, .team-screen:not(.solo-lobby) .empty-player { width: 2rem; height: 2rem; font-size: var(--text-lg); }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-name-row, .team-screen:not(.solo-lobby) .team-join-slots .lobby-player-slot:has(.empty-player) .lobby-name-row { position: absolute; inset: auto 0 0; display: block; width: 100%; height: 1rem; pointer-events: none; }
 .team-screen:not(.solo-lobby) .lobby-player-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
 .team-screen:not(.solo-lobby) .lobby-player-slot > .elo-badge { display: none; }
 .team-screen:not(.solo-lobby) .lobby-host-badge { padding: .125rem; }
}
@media (max-width: 700px) and (orientation: landscape) {
 .team-screen:not(.solo-lobby) .room-invite b { font-size: var(--text-sm); }
 .team-screen:not(.solo-lobby) #room-visibility-toggle { padding: .375rem; font-size: var(--text-xs); }
}
@media (max-width: 380px) and (orientation: portrait) {
 .team-screen:not(.solo-lobby) .team-home { padding-inline: .375rem; font-size: var(--text-xs); }
}

/* Portrait lobbies mirror two team columns, with the roster below each mascot. */
@media (max-width: 1050px) and (orientation: portrait) {
 .overlay[data-dialog="lobby"]:has(> .team-screen:not(.solo-lobby)) { overflow-y: auto; overflow-x: hidden; }
 .overlay[data-dialog="lobby"] > .team-screen:not(.solo-lobby) { height: auto; min-height: 100dvh; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto minmax(min-content, 1fr) auto; column-gap: 1rem; padding-top: calc(4.75rem + env(safe-area-inset-top)); }
 .team-screen:not(.solo-lobby) .team-heading h1 { font-size: var(--text-2xl); }
 .team-screen:not(.solo-lobby) .team-heading { margin-bottom: .75rem; }
 .team-screen:not(.solo-lobby) .team-selection.side-0, .team-screen:not(.solo-lobby) .team-selection.side-1 { display: grid; grid-row: 2; grid-template-columns: 2rem minmax(0, 1fr) 2rem; grid-template-rows: auto calc(var(--mobile-lobby-mascot-size) * .8) minmax(0, 1fr); align-content: start; align-items: center; gap: .75rem .25rem; }
 .team-screen:not(.solo-lobby) .team-selection.side-0 { grid-column: 1; }
 .team-screen:not(.solo-lobby) .team-selection.side-1 { grid-column: 2; }
 .team-screen:not(.solo-lobby) .team-name { display: contents; }
 .team-screen:not(.solo-lobby) .team-name h2 { grid-column: 1 / -1; grid-row: 1; align-self: start; width: 100%; min-height: 2.5rem; text-align: center; }
 .team-screen:not(.solo-lobby) .side-1 .team-name h2 { text-align: center; }
 .team-screen:not(.solo-lobby) .team-name button { position: relative; inset: auto; grid-row: 2; width: 2rem; min-width: 2rem; }
 .team-screen:not(.solo-lobby) .team-name button:disabled { visibility: hidden; }
 .team-screen:not(.solo-lobby) .team-name button:first-child { grid-column: 1; left: auto; }
 .team-screen:not(.solo-lobby) .team-name button:last-child { grid-column: 3; right: auto; }
 .team-screen:not(.solo-lobby) .team-large-mascot { grid-column: 1 / -1; grid-row: 2; justify-self: center; width: 120%; max-width: none; height: 100%; padding: 0; object-fit: contain; object-position: center; }
 .team-screen:not(.solo-lobby).show-player-names .team-join-slots { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(4, 3rem); align-self: start; align-content: start; align-items: start; height: auto; gap: .75rem; padding: 0; margin: 0; background: transparent; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-player-slot { position: relative; display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 3rem; padding: 0; gap: .25rem; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-slot-avatar { display: flex; align-items: center; justify-content: flex-start; width: 100%; height: 3rem; padding: .375rem; border: .0625rem solid var(--rivals-steel); border-radius: .2rem; background: var(--rivals-surface); }
 .team-screen:not(.solo-lobby) .team-join-slots .player-avatar, .team-screen:not(.solo-lobby) .empty-player { width: 2rem; height: 2rem; font-size: var(--text-lg); flex: 0 0 auto; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-name-row, .team-screen:not(.solo-lobby) .team-join-slots .lobby-player-slot:has(.empty-player) .lobby-name-row { position: absolute; inset: 0 .375rem auto 2.75rem; display: flex; align-items: center; justify-content: flex-start; width: auto; height: 3rem; pointer-events: none; }
 .team-screen:not(.solo-lobby) .lobby-player-name { text-align: left; }
 .team-screen:not(.solo-lobby) .side-1 .team-join-slots .lobby-player-slot { align-items: flex-end; }
 .team-screen:not(.solo-lobby) .side-1 .lobby-slot-avatar { justify-content: flex-end; }
 .team-screen:not(.solo-lobby) .side-1 .team-join-slots .lobby-name-row { left: .375rem; right: 2.75rem; justify-content: flex-end; }
 .team-screen:not(.solo-lobby) .side-1 .lobby-player-name { text-align: right; }
 .team-screen:not(.solo-lobby) .side-1 .lobby-host-badge { left: -.35rem; right: auto; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-player-slot > .elo-badge { position: absolute; top: -.35rem; right: .25rem; z-index: 1; display: inline-flex; max-width: calc(100% - 3.5rem); margin: 0; white-space: nowrap; pointer-events: none; }
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-kick { left: 0; right: auto; }
 .team-screen:not(.solo-lobby) .team-lobby-footer { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-player-area { display: none; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .room-invite { grid-column: 1; grid-row: 1; justify-content: flex-start; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .room-invite { width: 100%; }
 .team-screen:not(.solo-lobby) #room-visibility-toggle { margin-left: auto; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1; grid-row: 2; justify-self: center; width: min(100%, 26rem); }
 .team-screen:not(.solo-lobby) .lobby-settings-controls { justify-content: center; width: 100%; }
 .team-screen:not(.solo-lobby) #lobby-game-settings { width: 100%; }
 .team-screen:not(.solo-lobby) .game-rules-active { grid-column: 1; grid-row: 3; justify-content: center; }
 .team-screen:not(.solo-lobby) .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1; grid-row: 4; flex-direction: column; justify-self: center; width: min(100%, 26rem); }
 .team-screen:not(.solo-lobby) .team-home, .team-screen:not(.solo-lobby) .team-home.team-leaderboard { font-size: var(--text-sm); padding: .5rem .625rem; }
}
@media (max-width: 380px) and (orientation: portrait) {
 .team-screen:not(.solo-lobby) .team-home, .team-screen:not(.solo-lobby) .team-home.team-leaderboard { font-size: var(--text-xs); padding-inline: .375rem; }
}

/* Overflowing active rules drift across the row, then return to the start. */
@media (max-width: 1050px) and (prefers-reduced-motion: no-preference) {
 .team-screen .game-rules-active.is-overflowing { justify-content: flex-start; overflow-x: hidden; }
 .game-rules-active.is-overflowing .game-rules-track { animation: active-rules-drift var(--rules-scroll-duration) linear infinite alternate; }
 .game-rules-active:hover .game-rules-track, .game-rules-active:focus-within .game-rules-track { animation-play-state: paused; }
}
@keyframes active-rules-drift {
 0%, 10% { transform: translateX(0); }
 90%, 100% { transform: translateX(calc(-1 * var(--rules-scroll-distance))); }
}

.arena-rotated .settings-exit { position: absolute; }

/* Mobile rankings prioritize player identity and rating; other stats expand inline. */
.leaderboard-cards { display: none; }
.leaderboard-panel > p { color: var(--mint); }
.leaderboard-empty { padding: 2rem 1rem; margin-top: 1.5rem; text-align: center; background: var(--rivals-surface); border: .0625rem solid var(--rivals-steel); }
.leaderboard-empty p { color: var(--cream); margin: .75rem 0 0; }
@media (max-width: 1050px) {
 .overlay > .leaderboard-panel { width: 100%; }
 .leaderboard-panel .leaderboard-scroll { display: none; }
 .leaderboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); align-items: start; gap: .75rem; margin-top: 1.25rem; }
 .leaderboard-card { min-width: 0; background: var(--rivals-surface); border: .0625rem solid var(--rivals-steel); }
 .leaderboard-card.is-you { border-color: var(--rivals-teal); }
 .leaderboard-card summary { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .75rem; cursor: pointer; list-style: none; }
 .leaderboard-card summary::-webkit-details-marker { display: none; }
 .leaderboard-card summary:focus-visible { outline: .125rem solid var(--rivals-cyan); outline-offset: .125rem; }
 .leaderboard-rank { grid-column: 1; grid-row: 1; color: var(--rivals-teal); }
 .leaderboard-identity { grid-column: 2 / -1; display: flex; align-items: center; gap: .75rem; min-width: 0; }
 .leaderboard-identity > span { min-width: 0; }
 .leaderboard-identity strong { display: block; overflow-wrap: anywhere; }
 .leaderboard-identity small { display: block; color: var(--mint); margin-top: .125rem; }
 .leaderboard-identity .player-avatar { width: 2.5rem; height: 2.5rem; flex: 0 0 auto; border-radius: var(--profile-radius); }
 .leaderboard-rating { grid-column: 2 / -1; color: var(--rivals-teal); }
 .leaderboard-record { grid-column: 2; }
 .leaderboard-expand { grid-column: 3; color: var(--mint); }
 .leaderboard-expand > span { display: inline-block; }
 .leaderboard-card[open] .leaderboard-expand > span { transform: rotate(180deg); }
 .leaderboard-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 0; padding: .75rem; border-top: .0625rem solid var(--rivals-steel); }
 .leaderboard-stats dt { color: var(--mint); }
 .leaderboard-stats dd { margin: .125rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
}

@media (max-width: 1050px) and (orientation: portrait) {
 .team-screen .team-home:not(.team-leaderboard) { left: 0; right: 0; width: max-content; margin-inline: auto; }
 .team-screen:not(.solo-lobby) .team-home.team-leaderboard { top: calc(3.75rem + env(safe-area-inset-top)); left: 0; right: 0; width: max-content; margin-inline: auto; }
 .overlay[data-dialog="lobby"] > .team-screen:not(.solo-lobby):has(.team-leaderboard) { padding-top: calc(6.75rem + env(safe-area-inset-top)); }
}

/* Solo uses the same compact player card and action ordering as multiplayer. */
@media (max-width: 1050px) {
 .team-screen.solo-lobby .team-heading > p:not(#room-listing-status) { display: none; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-player-area { display: none; }
 .team-screen.solo-lobby .lobby-controls-area, .team-screen.solo-lobby .lobby-match-controls { display: contents; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1; grid-row: 1; width: 100%; max-width: none; }
 .team-screen.solo-lobby .lobby-settings-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; width: 100%; gap: .75rem; }
 .team-screen.solo-lobby .lobby-settings-controls .lobby-bot-difficulty { width: 100%; min-width: 0; }
 .team-screen.solo-lobby .game-rules-active { grid-column: 1; grid-row: 2; align-self: start; justify-content: flex-start; }
 .team-screen.solo-lobby .game-rules-active:empty { display: none; }
 .team-screen.solo-lobby .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1; grid-row: 3; align-self: end; flex-direction: column; align-items: stretch; width: 100%; margin: 0; }
 .team-screen.solo-lobby .lobby-ready-button { height: 3rem; padding: .5rem .75rem; }
 .team-screen.solo-lobby .lobby-readiness p { text-align: center; }
 .team-screen.solo-lobby .team-join-slots .lobby-player-slot { position: relative; display: block; width: 100%; min-height: 3rem; padding: 0; }
 .team-screen.solo-lobby .team-join-slots .lobby-slot-avatar { display: flex; align-items: center; justify-content: flex-start; width: 100%; height: 3rem; padding: .375rem; border: .0625rem solid var(--rivals-steel); border-radius: .2rem; background: var(--rivals-surface); }
 .team-screen.solo-lobby .team-join-slots .player-avatar { width: 2rem; height: 2rem; }
 .team-screen.solo-lobby .team-join-slots .lobby-name-row { position: absolute; inset: 0 .375rem 0 2.75rem; display: flex; align-items: center; justify-content: flex-start; width: auto; height: 3rem; pointer-events: none; }
 .team-screen.solo-lobby .lobby-player-name { text-align: left; }
}
@media (max-width: 1050px) and (orientation: portrait) {
 .overlay[data-dialog="lobby"]:has(> .solo-lobby) { overflow-y: auto; overflow-x: hidden; }
 .overlay[data-dialog="lobby"] > .team-screen.solo-lobby { height: auto; min-height: 100dvh; grid-template-rows: auto minmax(min-content, 1fr) auto; padding-top: calc(4.75rem + env(safe-area-inset-top)); }
 .team-screen.solo-lobby .team-heading { margin-bottom: .75rem; }
 .team-screen.solo-lobby .team-heading h1 { font-size: var(--text-2xl); }
 .team-screen.solo-lobby .team-selection.side-0 { display: grid; align-self: start; height: auto; grid-template-columns: 2rem minmax(0, 1fr) 2rem; grid-template-rows: auto calc(var(--mobile-lobby-mascot-size) * .8) 3rem; gap: .75rem; }
 .team-screen.solo-lobby .team-name { display: contents; }
 .team-screen.solo-lobby .team-name h2 { grid-column: 1 / -1; grid-row: 1; width: 100%; text-align: center; }
 .team-screen.solo-lobby .team-name button { position: relative; inset: auto; grid-row: 2; width: 2rem; min-width: 2rem; z-index: 2; }
 .team-screen.solo-lobby .team-name button:first-child { grid-column: 1; }
 .team-screen.solo-lobby .team-name button:last-child { grid-column: 3; }
 .team-screen.solo-lobby .team-large-mascot { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 100%; max-height: none; }
 .team-screen.solo-lobby.show-player-names .team-join-slots { grid-column: 1 / -1; grid-row: 3; margin: 0; }
 .team-screen.solo-lobby .team-join-slots .lobby-player-slot { flex-basis: 100%; }
 .team-screen.solo-lobby .team-lobby-footer { grid-column: 1 / -1; grid-row: 3; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; gap: .75rem; padding-top: .75rem; }
}
@media (max-width: 1050px) and (orientation: landscape) {
 .team-screen.solo-lobby .team-name { display: grid; grid-template-columns: 2rem minmax(0, 1fr) 2rem; align-items: center; justify-self: center; width: max-content; max-width: 100%; min-height: 2.75rem; gap: .5rem; }
 .team-screen.solo-lobby .team-name h2 { position: relative; min-width: 0; }
 .team-screen.solo-lobby .team-name h2::before { content: attr(data-longest-name); visibility: hidden; }
 .team-screen.solo-lobby .team-name-label { position: absolute; inset: 0; display: grid; place-items: center; }
 .team-screen.solo-lobby .team-name button { position: relative; inset: auto; width: 2rem; min-width: 2rem; }
}

/* Cooperative practice shares one four-seat roster against the computer. */
.team-screen.practice-lobby .team-center-logo { display: none; }
.team-screen.practice-lobby .team-selection.side-0 { left: 25%; width: 50%; }
@media (max-width: 1050px) {
 .team-screen.practice-lobby .team-selection.side-0 { left: auto; grid-column: 1 / -1; width: 100%; }
 .team-screen.practice-lobby .lobby-settings-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; width: 100%; gap: .75rem; }
 .team-screen.practice-lobby .lobby-settings-controls .lobby-bot-difficulty { width: 100%; min-width: 0; }
 .team-screen.practice-lobby #lobby-game-settings { width: 100%; height: 3rem; }
 .team-screen.practice-lobby .lobby-bot-difficulty select { padding-inline: .5rem 1.5rem; background-position: right .5rem center; }
}
@media (max-width: 1050px) and (orientation: portrait) {
 .team-screen.practice-lobby.show-player-names .team-join-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, 3rem); }
 .team-screen.practice-lobby .team-join-slots .lobby-player-name { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
 .team-screen.practice-lobby .team-large-mascot { width: 100%; max-width: 100%; }
}

@media (max-width: 1050px) and (orientation: landscape) {
 .team-screen.practice-lobby .team-lobby-footer { grid-template-columns: auto minmax(0, 1fr) minmax(9rem, 11rem); }
 .team-screen.practice-lobby .team-lobby-footer .lobby-match-controls .lobby-game-rules { width: 100%; min-width: 0; }
 .team-screen.practice-lobby #lobby-game-settings { min-width: 0; padding-inline: .5rem; white-space: normal; }
}
@media (max-width: 1050px) and (max-height: 360px) and (orientation: landscape) {
 .overlay[data-dialog="lobby"] > .team-screen.practice-lobby { padding-top: calc(4rem + env(safe-area-inset-top)); }
 .team-screen.practice-lobby .team-selection.side-0 { gap: .25rem; }
 .team-screen.practice-lobby .team-lobby-footer { gap: .5rem; padding-top: .5rem; }
}
@media (max-width: 700px) and (orientation: landscape) {
 .team-screen.practice-lobby .team-lobby-footer { grid-template-columns: auto minmax(0, 1fr) 8.5rem; }
 .team-screen.practice-lobby .lobby-settings-controls { grid-template-columns: minmax(0, 1fr) minmax(10rem, 1fr); }
}

/* Desktop lobby actions sit in a compact bar at the viewport edge. */
@media (min-width: 1051px) {
 /* Keep the fixed footer anchored to the lobby before, during and after its zoom. */
 .overlay[data-dialog="lobby"] > .team-screen { transform: scale(1); }
 .overlay[data-dialog="lobby"] > .team-screen .team-lobby-footer { position: fixed; inset: auto auto 0 50%; transform: translateX(-50%); width: 100vw; height: auto; min-height: 0; grid-template-rows: none; align-items: end; gap: .5rem 1.5rem; padding: .75rem 1.5rem max(.75rem, env(safe-area-inset-bottom)); }
 .overlay[data-dialog="lobby"] > .team-screen .game-rules-active:empty { display: none; }
 .overlay[data-dialog="lobby"] .lobby-match-controls { align-items: end; padding-bottom: 2rem; }
 .overlay[data-dialog="lobby"] .lobby-match-controls .room-invite { align-items: flex-end; }
 .overlay[data-dialog="lobby"] .lobby-match-controls .lobby-readiness { position: relative; }
 .overlay[data-dialog="lobby"] .lobby-match-controls .lobby-ready-button { height: 3rem; padding: .65rem 1rem; }
 .overlay[data-dialog="lobby"] .lobby-readiness p { position: absolute; top: calc(100% + .5rem); left: 0; width: 100%; margin: 0; text-align: center; }
}

/* Lift lobby settings above the same recessed, shaded backdrop as other menus. */
.overlay[data-dialog="lobby"] { isolation: isolate; }
.overlay[data-dialog="lobby"] > .team-flow { z-index: -1; transform: scale(var(--home-backdrop-zoom)); transition: transform var(--home-backdrop-duration) ease, filter var(--home-backdrop-duration) ease; }
.overlay[data-lobby-settings="true"] > .team-flow, .overlay[data-lobby-backdrop="true"] > .team-flow { transform: scale(1); filter: blur(var(--home-backdrop-blur)); }
.overlay[data-dialog="lobby"] > .team-screen { transition: transform var(--home-backdrop-duration) ease, filter var(--home-backdrop-duration) ease; }
.overlay[data-lobby-settings="true"] > .team-screen, .overlay[data-lobby-backdrop="true"] > .team-screen { z-index: 0; transform: scale(var(--lobby-popup-scale)); filter: blur(var(--home-backdrop-blur)); pointer-events: none; }
.lobby-settings-shade { position: fixed; inset: 0; z-index: 1; background: var(--home-menu-shade); }
.overlay[data-lobby-settings="true"] > .game-rules-panel { z-index: 2; background: var(--ink-deep); color: var(--cream); }
.overlay[data-lobby-settings="true"] > .game-rules-panel #game-length { background-color: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--button-edge); border-radius: 0; box-shadow: var(--button-shadow); }
.overlay[data-lobby-settings="true"] > .game-rules-panel summary { color: var(--rivals-teal); cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
 .overlay[data-dialog="lobby"] > .team-screen, .overlay[data-dialog="lobby"] > .team-flow { transition: none; }
}

@media (prefers-reduced-motion: no-preference) {
 .game-rules-panel.is-opening { transform-origin: center; animation: game-settings-open var(--home-backdrop-duration) ease both; }
 .overlay[data-dialog="game-settings"] .game-rules-panel.is-opening { animation-name: game-settings-open-inline; }
}
@keyframes game-settings-open {
 from { opacity: 0; transform: translate(-50%, -50%) scale(var(--lobby-popup-scale)); }
 to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes game-settings-open-inline {
 from { opacity: 0; transform: scale(var(--lobby-popup-scale)); }
 to { opacity: 1; transform: scale(1); }
}

/* Collected bonuses streak from the field into the held bonus card. */
.toast.bonus-toast { display: flex; align-items: center; gap: .75rem; max-width: calc(100% - 2rem); text-align: left; }
.game .toast.bonus-toast { position: absolute; top: auto; bottom: calc(100% + .75rem); width: max-content; }
.bonus-toast .player-avatar { width: var(--game-profile-size); height: var(--game-profile-size); border-radius: var(--profile-radius); }
.bonus-toast-copy { display: flex; flex-direction: column; gap: .25rem; min-width: 0; overflow-wrap: anywhere; }
.bonus-collection-star { position: absolute; inset: 0 auto auto 0; z-index: 8; width: 1.25rem; height: 1.25rem; margin: -.625rem; border-radius: 50%; background: var(--cream); box-shadow: 0 0 .625rem var(--cream), 0 0 1.5rem var(--rivals-cyan), 0 0 2.5rem var(--rivals-glow-teal); pointer-events: none; }
.bonus-collection-star::before { content: ''; position: absolute; top: 50%; right: 50%; width: 12rem; height: 1.5rem; transform: translateY(-50%); background: linear-gradient(90deg, transparent, var(--cream)) center / 100% .1875rem no-repeat, linear-gradient(90deg, transparent, var(--rivals-cyan)) center / 100% .625rem no-repeat, linear-gradient(90deg, transparent, var(--rivals-glow-teal), var(--rivals-cyan)); clip-path: polygon(0 50%, 70% 20%, 100% 0, 100% 100%, 70% 80%); filter: drop-shadow(0 0 .375rem var(--rivals-cyan)); }
.bonus-collection-star::after { content: ''; position: absolute; inset: -.75rem; background: var(--cream); clip-path: polygon(50% 0, 59% 33%, 77% 23%, 67% 41%, 100% 50%, 67% 59%, 77% 77%, 59% 67%, 50% 100%, 41% 67%, 23% 77%, 33% 59%, 0 50%, 33% 41%, 23% 23%, 41% 33%); }

.bonus-collection-sparkle { position: absolute; inset: 0 auto auto 0; z-index: 7; width: .5rem; height: .5rem; margin: -.25rem; background: var(--cream); box-shadow: 0 0 .5rem var(--rivals-cyan); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); pointer-events: none; }
.bonus-collection-sparkle:nth-of-type(even) { width: .375rem; height: .375rem; background: var(--rivals-cyan); }
.bonus-collection-star::after { animation: bonus-star-shimmer .6s ease-in-out infinite alternate; }
@keyframes bonus-star-shimmer {
  from { opacity: .75; transform: scale(.85); }
  to { opacity: 1; transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .bonus-collection-star::after { animation: none; }
}

.connection-loading { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; gap: 1rem; background: var(--home-menu-shade); backdrop-filter: blur(.5rem); }
.connection-spinner { width: 2rem; height: 2rem; border: .2rem solid var(--rivals-line); border-top-color: var(--rivals-teal); border-radius: 50%; animation: connection-spin .8s linear infinite; }
@keyframes connection-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .connection-spinner { animation: none; } }

.home-download { position: absolute; right: max(1.5rem, env(safe-area-inset-right)); bottom: calc(1.5rem + env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: .6rem; padding: .75rem 1rem; color: var(--cream); background: var(--rivals-surface); border: .0625rem solid var(--rivals-line); text-decoration: none; }
@media (max-width: 700px) { .home-download { position: relative; right: auto; bottom: auto; justify-self: center; margin: 1rem; } }

.desktop-app .home-download { display: none; }

.download-icon { display: block; margin: 1.5rem 0; border-radius: 1.5rem; }
.download-cta { display: inline-flex; align-items: center; gap: .75rem; align-self: flex-start; padding: 1rem 1.5rem; color: var(--cream); text-decoration: none; }
.download-page ol { padding-left: 1.5rem; line-height: 1.8; }

// Test tools should wrap below the bonus row, rather than compressing it.
.game.free-play .power-row { flex-wrap: wrap; }
.game.free-play .power-slots { flex: 0 0 100%; min-width: 0; justify-content: center; }

/* Competitive opening: all three choices share the center of the arena. */
.overlay[data-dialog="formation"][data-formation-layout="center"] { justify-content: center; align-items: safe center; padding: 1rem; }
.overlay[data-dialog="formation"][data-formation-layout="center"] > .clipboard { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; width: min(100%, 56rem); max-height: calc(100% - 2rem); padding: 1.5rem; transform: none; overflow-y: auto; }
.overlay[data-formation-layout="center"] .clipboard h2 { margin: 0; padding: 0; border: 0; }
.overlay[data-formation-layout="center"] .formation-countdown { margin: 0; white-space: nowrap; }
.overlay[data-formation-layout="center"] .formation-list { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.overlay[data-formation-layout="center"] .formation-choice { flex-direction: column; align-items: center; justify-content: flex-start; gap: .75rem; min-width: 0; padding: 1rem; text-align: center; background: var(--rivals-surface); }
.overlay[data-formation-layout="center"] .formation-choice svg { width: min(100%, 11rem); height: auto; }
.overlay[data-formation-layout="center"] .formation-choice > span { min-width: 0; }
.overlay[data-formation-layout="center"] .clipboard > .small-note { grid-column: 1 / -1; margin: 0; }
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .overlay[data-dialog="formation"][data-formation-layout="center"] { padding: .75rem; }
 .overlay[data-dialog="formation"][data-formation-layout="center"] > .clipboard { width: min(100%, 44rem); max-height: calc(100% - 1.5rem); gap: .5rem; padding: 1rem; }
 .overlay[data-formation-layout="center"] .formation-list { gap: .75rem; }
 .overlay[data-formation-layout="center"] .formation-choice { padding: .75rem .5rem; gap: .5rem; }
 .overlay[data-formation-layout="center"] .formation-choice svg { width: min(100%, 7rem); }
}

/* Anchor moderation to the portrait rather than the wider name/rating slot. */
.team-join-slots .lobby-avatar-controls { position: relative; display: flex; width: fit-content; max-width: 100%; }
.team-screen .team-join-slots .lobby-avatar-controls .lobby-kick { top: -.35rem; right: -.35rem; left: auto; }
@media (max-width: 1050px) and (orientation: portrait) {
 .team-screen:not(.solo-lobby) .team-join-slots .lobby-avatar-controls { width: 100%; }
 .team-screen:not(.solo-lobby) .side-0 .lobby-avatar-controls .lobby-kick { top: 0; right: auto; left: 1.75rem; }
 .team-screen:not(.solo-lobby) .side-1 .lobby-avatar-controls .lobby-kick { top: 0; right: 0; left: auto; }
}

@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (max-width: 1050px) and (any-pointer: coarse) {
 .toast.bonus-toast { top: calc(.5rem + env(safe-area-inset-top)); bottom: auto; left: 50%; width: max-content; max-width: min(18rem, calc(100% - 1rem)); padding: .4rem .65rem; gap: .5rem; }
 .bonus-toast .player-avatar { width: 1.75rem; height: 1.75rem; }
 .bonus-toast-copy { gap: .125rem; }
}

@media (max-width: 1050px) and (orientation: portrait) {
 .team-screen.standard-lobby .team-lobby-footer { grid-template-columns: minmax(0, 1fr) 3rem; grid-template-rows: auto auto auto; }
 .team-screen.standard-lobby .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1; grid-row: 1; width: 100%; max-width: none; align-self: stretch; }
 .team-screen.standard-lobby .team-lobby-footer .room-invite { grid-column: 2; grid-row: 1; width: 3rem; min-height: 0; align-self: stretch; }
 .team-screen.standard-lobby #room-visibility-toggle { width: 3rem; height: 3rem; margin: 0; aspect-ratio: 1; }
 .team-screen.standard-lobby #lobby-game-settings { height: 3rem; }
 .team-screen.standard-lobby .game-rules-active { grid-column: 1 / -1; grid-row: 2; }
 .team-screen.standard-lobby .team-lobby-footer .lobby-match-controls .lobby-readiness { grid-column: 1 / -1; grid-row: 3; }
 .team-screen.standard-lobby:not(:has(#room-visibility-toggle)) .team-lobby-footer .lobby-match-controls .lobby-game-rules { grid-column: 1 / -1; }
}

.lobby-chevron { display: none; }
@media (max-width: 1050px) {
 .team-name .lobby-arrow { display: none; }
 .team-name .lobby-chevron { display: block; width: 1.25rem; height: 1.25rem; margin: auto; }
}

@media (max-width: 1050px) and (orientation: portrait) {
 .team-screen:not(.solo-lobby):has(.team-leaderboard) .team-home:not(.team-leaderboard) { left: 1rem; right: calc(50% + .25rem); width: auto; margin: 0; }
 .team-screen:not(.solo-lobby) .team-home.team-leaderboard { top: calc(.75rem + env(safe-area-inset-top)); left: calc(50% + .25rem); right: 1rem; width: auto; margin: 0; }
 .overlay[data-dialog="lobby"] > .team-screen:not(.solo-lobby):has(.team-leaderboard) { padding-top: calc(4.75rem + env(safe-area-inset-top)); }
}

@media (max-width: 1050px) and (orientation: portrait) {
 .overlay[data-dialog="play-modes"] { padding: 0; overflow: hidden; }
 .overlay[data-dialog="play-modes"] > .play-modes.modal { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: .25rem; width: 100%; height: 100dvh; max-height: 100dvh; padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom)); border-radius: 0; overflow: hidden; }
 .play-modes .mode-cards { min-height: 0; grid-template-rows: repeat(3, minmax(0, 1fr)); gap: .875rem; margin-top: .75rem; }
 .play-modes .mode-card { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto auto; align-content: stretch; gap: .25rem; }
 .play-modes .mode-card img { min-height: 0; height: 100%; grid-column: 1; grid-row: 1; object-fit: cover; }
}

/* A compact energy gauge keeps earned XP directly inside its fill. */
.profile-xp-meter { display: inline-flex; align-items: center; max-width: 100%; isolation: isolate; }
.profile-xp-level { position: relative; z-index: 2; flex-shrink: 0; display: grid; place-items: center; min-width: var(--profile-xp-badge-size); height: var(--profile-xp-badge-size); padding-inline: .3rem; border: .0625rem solid var(--rivals-teal); border-radius: .3rem; background: var(--rivals-surface); color: var(--cream); box-shadow: 0 0 .65rem var(--rivals-glow-teal), inset 0 0 .4rem var(--rivals-glow-teal); font-variant-numeric: tabular-nums; }
.profile-xp-bar { margin-left: -.45rem; padding-left: .45rem; position: relative; display: inline-grid; place-items: center; width: var(--profile-xp-width); max-width: 100%; height: var(--profile-xp-height); overflow: hidden; isolation: isolate; border: .0625rem solid var(--rivals-steel); border-radius: .2rem; background: var(--rivals-surface); box-shadow: inset 0 .0625rem 0 var(--rivals-line); }
.home-player-xp .profile-xp-bar progress { position: absolute; inset: 0; width: 100%; height: 100%; appearance: none; border: 0; background: transparent; }
.profile-xp-bar progress::-webkit-progress-bar { background: var(--rivals-surface); }
.profile-xp-bar progress::-webkit-progress-value { background: linear-gradient(90deg, var(--rivals-surface), color-mix(in srgb, var(--rivals-teal) 45%, var(--ink-deep))); border-right: .125rem solid var(--rivals-teal); box-shadow: inset 0 .125rem 0 var(--rivals-teal); }
.profile-xp-bar progress::-moz-progress-bar { background: linear-gradient(90deg, var(--rivals-surface), color-mix(in srgb, var(--rivals-teal) 45%, var(--ink-deep))); border-right: .125rem solid var(--rivals-teal); box-shadow: inset 0 .125rem 0 var(--rivals-teal); }
.profile-xp-value { position: relative; z-index: 1; padding-inline: .5rem; white-space: nowrap; color: var(--cream); font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 .0625rem .125rem var(--ink-deep); pointer-events: none; }
.profile-xp-value > span { opacity: .8; }

/* Match XP returns as a brief holographic transmission over the lobby. */
.xp-preview-actions { display: flex; gap: .75rem; justify-content: center; }
.xp-preview-actions button { flex: 1; }
.xp-recap-layer { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 1rem; background: color-mix(in srgb, var(--ink-deep) 90%, transparent); backdrop-filter: blur(.5rem); opacity: 1; transition: opacity .4s ease; }
.xp-recap-layer.is-leaving { opacity: 0; pointer-events: none; }
.xp-recap-card { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: .75rem; width: min(var(--xp-recap-width), 100%); padding: 2.5rem 2rem 1.5rem; border: .0625rem solid var(--rivals-teal); border-radius: .75rem; color: var(--cream); text-align: center; background: radial-gradient(ellipse at 50% 35%, var(--rivals-glow-teal), transparent 65%), var(--rivals-panel-background); box-shadow: 0 0 3rem var(--rivals-glow-teal), inset 0 0 2rem var(--rivals-glow-teal); }
.xp-recap-card .eyebrow { color: var(--rivals-teal); }
.xp-recap-card h2, .xp-recap-card p { margin: 0; }
.xp-recap-orbit { position: absolute; z-index: -1; top: 3rem; left: calc(50% - 6rem); width: 12rem; height: 12rem; border: .0625rem solid var(--rivals-teal); border-radius: 50%; opacity: .3; box-shadow: 0 0 1.5rem var(--rivals-glow-teal), inset 0 0 1.5rem var(--rivals-glow-teal); }
.xp-recap-level { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 10rem; text-shadow: 0 0 1.5rem var(--rivals-cyan); }
.xp-recap-level strong { line-height: 1; font-variant-numeric: tabular-nums; }
.xp-recap-gain { color: var(--rivals-teal); font-variant-numeric: tabular-nums; }
.xp-recap-gauge { position: relative; display: grid; place-items: center; width: 100%; height: var(--xp-recap-gauge-height); border: .0625rem solid var(--rivals-steel); border-radius: .25rem; overflow: hidden; background: var(--rivals-surface); }
.xp-recap-gauge progress { position: absolute; inset: 0; appearance: none; width: 100%; height: 100%; border: 0; background: transparent; }
.xp-recap-gauge progress::-webkit-progress-bar { background: var(--rivals-surface); }
.xp-recap-gauge progress::-webkit-progress-value { background: linear-gradient(90deg, var(--rivals-panel-background), color-mix(in srgb, var(--rivals-teal) 50%, var(--ink-deep))); border-right: .125rem solid var(--rivals-teal); box-shadow: inset 0 .125rem 0 var(--rivals-teal); }
.xp-recap-gauge progress::-moz-progress-bar { background: color-mix(in srgb, var(--rivals-teal) 50%, var(--ink-deep)); border-right: .125rem solid var(--rivals-teal); }
.xp-recap-gauge > span { position: relative; font-variant-numeric: tabular-nums; text-shadow: 0 .0625rem .125rem var(--ink-deep); }
.xp-recap-burst { position: absolute; inset: 0; pointer-events: none; }
.xp-recap-burst i { position: absolute; left: 50%; top: 40%; width: .1875rem; height: 1rem; background: var(--rivals-cyan); box-shadow: 0 0 .75rem var(--rivals-cyan); opacity: 0; }
.level-up .xp-recap-burst i { animation: xp-orbit-burst 1.2s ease-out forwards; }
.level-up .xp-recap-level strong { animation: xp-level-pop 1s cubic-bezier(.16, 1, .3, 1); }
.level-up .xp-recap-orbit { animation: xp-ring-pulse 1s ease-out; }
.level-up .xp-recap-card { animation: xp-card-impact 1s ease-out; }
@keyframes xp-orbit-burst { from { opacity: 1; transform: rotate(var(--xp-spark-angle)) translateY(-3rem); } to { opacity: 0; transform: rotate(var(--xp-spark-angle)) translateY(-13rem); } }
@keyframes xp-level-pop { 0% { transform: scale(1.65); filter: brightness(2); text-shadow: 0 0 2rem var(--cream), 0 0 4rem var(--rivals-cyan); } 18% { transform: scale(1.85); } 48% { transform: scale(.92); filter: brightness(1.3); } 72% { transform: scale(1.08); } 100% { transform: scale(1); filter: brightness(1); } }
@keyframes xp-card-impact { 0% { border-color: var(--cream); box-shadow: 0 0 5rem var(--rivals-cyan), inset 0 0 4rem var(--rivals-glow-teal); } 20% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes xp-ring-pulse { 0% { transform: scale(.7); opacity: 1; border-color: var(--cream); box-shadow: 0 0 2rem var(--rivals-cyan), inset 0 0 2rem var(--rivals-cyan); } 100% { transform: scale(2.5); opacity: 0; } }
.xp-recap-layer.reduced-motion .xp-recap-burst { display: none; }
.xp-recap-layer.reduced-motion .xp-recap-level, .xp-recap-layer.reduced-motion .xp-recap-orbit { animation: none; }
@media (max-width: 700px), (max-height: 550px) { .xp-recap-card { padding: 1.25rem; gap: .5rem; } .xp-recap-level { min-height: 7rem; } .xp-recap-orbit { top: 1.5rem; } }
@media (max-height: 450px) { .xp-recap-card { display: grid; grid-template-columns: 1fr 1fr; } .xp-recap-level { grid-column: 1; grid-row: 2 / 5; } .xp-recap-card .eyebrow, .xp-recap-gauge { grid-column: 1 / -1; } }

.xp-recap-card button { padding: .65rem 1.25rem; border: .0625rem solid var(--rivals-steel); border-radius: .2rem; background: var(--rivals-surface); color: var(--cream); box-shadow: none; }

.is-charging .xp-recap-level strong { animation: xp-level-charge .55s ease-in forwards; }
.is-charging .xp-recap-orbit { opacity: .85; box-shadow: 0 0 3rem var(--rivals-cyan), inset 0 0 2rem var(--rivals-glow-teal); transition: opacity .3s, box-shadow .3s; }
.xp-recap-burst i:nth-child(3n) { background: var(--cream); width: .25rem; height: 1.5rem; }
.level-up .xp-recap-gain { animation: xp-reward-glow 1s ease-out; }
@keyframes xp-level-charge { 0% { transform: scale(1); } 65% { transform: scale(1.25) rotate(-2deg); filter: brightness(1.4); } 80% { transform: scale(1.35) rotate(2deg); } 90% { transform: scale(1.4) rotate(-1deg); } 100% { transform: scale(1.45); filter: brightness(1.8); text-shadow: 0 0 2rem var(--rivals-cyan); } }
@keyframes xp-reward-glow { 0% { color: var(--cream); text-shadow: 0 0 1.5rem var(--rivals-cyan); } 100% { color: var(--rivals-teal); } }
.xp-recap-layer.reduced-motion .xp-recap-card, .xp-recap-layer.reduced-motion .xp-recap-level strong, .xp-recap-layer.reduced-motion .xp-recap-gain { animation: none; }

.xp-preview-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.elo-gain { --elo-accent: var(--elo-gain-color); }
.elo-loss { --elo-accent: var(--elo-loss-color); }
.elo-recap-card { gap: 1.5rem; padding-block: 3rem 1.5rem; border-color: var(--elo-accent); background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--elo-accent) 18%, transparent), transparent 70%), var(--rivals-panel-background); }
.elo-recap-rating { display: flex; justify-content: center; gap: .125rem; margin-top: .75rem; font-variant-numeric: tabular-nums; color: var(--cream); transition: color .3s, text-shadow .3s; }
.elo-digit { display: block; width: .75em; height: var(--elo-digit-height); overflow: hidden; mask-image: linear-gradient(transparent, black 15%, black 85%, transparent); }
.elo-digit-track { display: flex; flex-direction: column; will-change: transform; }
.elo-digit-track > span { flex: 0 0 var(--elo-digit-height); height: var(--elo-digit-height); display: grid; place-items: center; line-height: 1; }
.elo-recap-layer.is-spinning .elo-recap-rating { color: var(--elo-accent); text-shadow: 0 0 1.5rem color-mix(in srgb, var(--elo-accent) 65%, transparent); }
.elo-recap-delta { color: var(--elo-accent); }
@media (max-width: 650px) { .elo-digit { --elo-digit-height: 5rem; } .elo-recap-card { gap: 1rem; padding: 1.5rem 1rem; } }

.elo-recap-layer.is-settled .elo-digit.elo-leading-zero { width: 0; opacity: 0; }

.profile-xp-value.text-xs { font-size: var(--text-xs); }

.elo-stakes { position: absolute; z-index: 7; top: 50%; left: 50%; transform: translate(-50%, -50%); display: grid; grid-template-columns: 1fr 1.25fr 1fr; align-items: center; width: min(var(--elo-stakes-width), calc(100% - 2rem)); padding: .5rem; gap: .35rem; border: .0625rem solid var(--rivals-steel); border-radius: .35rem; background: var(--rivals-panel-background); color: var(--cream); box-shadow: 0 0 2rem var(--rivals-glow-teal); pointer-events: none; }
.elo-stakes[hidden] { display: none; }
.elo-stakes-heading { grid-column: 1 / -1; text-align: center; color: var(--muted); }
.elo-stakes .text-xs { font-size: var(--text-xs); }
.elo-stakes-loss, .elo-stakes-win { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; }
.elo-stakes-loss strong { color: var(--elo-loss-color); }
.elo-stakes-win strong { color: var(--elo-gain-color); }
.elo-stakes-current { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .5rem; border-inline: .125rem solid var(--rivals-teal); background: var(--rivals-surface); font-variant-numeric: tabular-nums; }
.elo-stakes-current small { color: var(--muted); font-family: var(--font-body); }
@media (max-width: 700px) { .elo-stakes { width: calc(100% - 1rem); gap: .25rem; } .elo-stakes-loss, .elo-stakes-win { flex-direction: column; gap: .25rem; } }

.leaderboard-header { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; padding-right: 2.5rem; margin-bottom: 1.5rem; }
.leaderboard-header h2 { margin: 0; padding: 0; }
.leaderboard-modes { display: flex; gap: 1.25rem; margin-left: auto; }
.leaderboard-modes button { flex: 0 1 auto; min-width: 0; }
.leaderboard-modes button[aria-pressed="true"] { --button-edge: var(--rivals-teal); background: var(--rivals-teal); color: var(--ink-deep); border-color: var(--rivals-teal); }

@media (max-width: 650px) {
 .leaderboard-header { padding-right: 0; }
 .leaderboard-header h2 { padding-right: 2.5rem; }
 .leaderboard-modes { width: 100%; margin-left: 0; }
 .leaderboard-modes button { flex: 1; }
}

/* Shared solid extrusion: the intermediate shadows join the diagonal corners. */
.download-page .download-cta, body button:not([hidden]):not(.lobby-slot-avatar):not(.name-profile-selector):not(.setup-profile-picture):not(.profile-option):not([data-cycle]):not(.result-vote):not(.free-tool), .formation-choice[aria-pressed="true"],
.home-play > button, .home-private > button, .home-join button,
.team-lobby-footer .room-invite button, .team-lobby-footer .team-start,
.modal .primary, .modal .secondary, .modal .close-button,
.game .icon-button, .game .back-home, .game .ready-button,
.game .power-book, .game .power-slot, .game.free-play .power-slot,
.game .arena .power-shortcut, .game .placement-tools button,
.physics-actions button, .result-actions button, #startup-retry, #close-game-settings {
  border: .0625rem solid var(--button-edge);
  border-radius: 0;
  clip-path: none;
  box-shadow: var(--button-shadow);
  transition: transform .15s ease-out, box-shadow .15s ease-out, background .15s ease-out, border-color .15s ease-out;
}

/* Opaque faces keep the extrusion behind the button, including icon controls. */
body button { background: var(--rivals-surface); color: var(--cream); }
/* Commit taps without waiting for a possible double tap; scrolling and pinch zoom remain available. */
button, a, input, select, textarea, summary, label { touch-action: manipulation; }
.download-page .download-cta, .home-play > button, .modal .primary, .team-lobby-footer .team-start, .result-actions .primary,
#startup-retry, #close-game-settings {
  --button-edge: var(--rivals-teal);
  background: var(--button-primary-face);
  color: var(--ink-deep);
}
.home-join button { --button-edge: var(--rivals-coral); background: var(--rivals-coral); color: var(--ink-deep); }
.home-private > button, .home-settings, .team-home,
.team-lobby-footer .room-invite button,
.lobby-name-action, .room-code,
.game footer button, .game .placement-tools button, .physics-info {
  background: var(--rivals-surface);
  color: var(--cream);
}
.game .ready-button, .game .power-slot.available, .game .arena .power-shortcut,
.lobby-ready-button, .formation-choice[aria-pressed="true"] { --button-edge: var(--rivals-teal); }
.game .ready-button.locked, .game .power-slot.chosen,
.lobby-ready-button[aria-pressed="true"] {
  background: var(--button-primary-face);
  color: var(--ink-deep);
}
.game footer button, .room-code { padding: .25rem .5rem; }
.modal .close-button { width: 2rem; height: 2rem; padding: 0; display: grid; place-items: center; }

/* The transparent target counteracts the face movement, including during transitions.
   Existing positioned controls retain their layout; header controls establish their own target bounds. */
:where(body button:not(.lobby-slot-avatar):not(.name-profile-selector):not(.setup-profile-picture):not(.profile-option):not([data-cycle]):not(.result-vote)) {
  position: relative;
  overflow: visible;
  pointer-events: none;
}
body button:not(.lobby-slot-avatar):not(.name-profile-selector):not(.setup-profile-picture):not(.profile-option):not([data-cycle]):not(.result-vote)::after {
  content: '';
  position: absolute;
  inset: -.0625rem;
  pointer-events: auto;
  transform: none;
  transition: transform .15s ease-out;
}
.game .icon-button, .game .back-home { position: relative; overflow: visible; }
body button:disabled::after { pointer-events: none; }
@media (hover: hover) {
  body button:hover::after { transform: translate(calc(-1 * var(--button-lift)), var(--button-lift)); }
}
body button:active::after { transform: translate(var(--button-lift), calc(-1 * var(--button-lift))); }

/* Touch targets stay under the finger instead of sliding during press/release. */
@media (any-pointer: coarse) {
 body button, body button::after { transition: none; }
}

/* Move the face while keeping its activation area in place. */
@media (hover: hover) {
  :root body button:hover:not(:disabled):not(.lobby-slot-avatar):not(.name-profile-selector):not(.setup-profile-picture):not(.profile-option):not([data-cycle]):not(.result-vote) {
    --button-edge: var(--rivals-cyan);
    --button-depth: var(--button-depth-hover);
    transform: translate(var(--button-lift), calc(-1 * var(--button-lift)));
    box-shadow: var(--button-shadow);
    filter: none;
  }
}
:root body button:active:not(:disabled):not(.lobby-slot-avatar):not(.name-profile-selector):not(.setup-profile-picture):not(.profile-option):not([data-cycle]):not(.result-vote) {
  --button-depth: var(--button-depth-pressed);
  transform: translate(calc(-1 * var(--button-lift)), var(--button-lift));
  box-shadow: var(--button-shadow);
  filter: none;
}
:root body button:focus-visible { outline: .125rem solid var(--rivals-cyan); outline-offset: .25rem; }
:root body button:disabled {
  --button-edge: var(--rivals-line);
  box-shadow: none;
  transform: none;
  filter: none;
  opacity: .45;
}
@media (prefers-reduced-motion: reduce) {
  :root body button, :root body button::after { transition: none; }
  :root body button:hover::after, :root body button:active::after { transform: none; }
  :root body button:hover:not(:disabled), :root body button:active:not(:disabled) { transform: none; }
}

/* Shared sound reactions use the existing responsive typography scale. */
.sound-reactions, .reaction-buttons { display: flex; align-items: center; gap: .5rem; }
.game .reaction-buttons button { min-width: 2.75rem; min-height: 2.75rem; padding: .25rem .5rem; line-height: 1; opacity: 1; }
.team-lobby-footer > .sound-reactions { grid-column: 1 / -1; justify-self: start; }

.game .reaction-buttons .text-lg { font-size: var(--text-lg); }

.sound-reactions { position: relative; pointer-events: auto; }
.game footer > .sound-reactions { margin-left: 0; }
.game footer > #reset-camera { margin-left: auto; }
.soundboard-menu { position: absolute; bottom: calc(100% + .75rem); left: 0; z-index: 10; padding: .75rem; background: var(--rivals-surface); border: .0625rem solid var(--rivals-steel); border-radius: .2rem; box-shadow: 0 .5rem 1.5rem var(--ink-deep); }
.soundboard-menu .reaction-buttons { flex-wrap: wrap; width: 6rem; gap: .5rem; }
.soundboard-toggle[aria-expanded="true"] { border-color: var(--rivals-cyan); }

/* Lobby dropdowns share the Game Settings button treatment. */
.team-lobby-footer #game-length, .team-lobby-footer #bot-difficulty { background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--button-edge); border-radius: 0; padding: .65rem .8rem; box-shadow: var(--button-shadow); }
.team-lobby-footer #lobby-game-settings { height: 3rem; }

.team-lobby-footer #bot-difficulty { text-transform: uppercase; }

.gfx-controls { display: inline-flex; align-items: center; gap: .25rem; padding-left: .5rem; }
.gfx-controls > span { color: var(--muted); margin-right: .25rem; }

.settings-graphics { margin: 1.5rem 0; padding: 1rem; background: var(--rivals-panel-background); border: .0625rem solid var(--rivals-steel); border-radius: .2rem; }
.settings-graphics p { color: var(--muted); margin: .5rem 0 1rem; }
.settings-graphics .gfx-controls { padding-left: 0; flex-wrap: wrap; gap: .5rem; }
.settings-graphics button[aria-pressed="true"] { color: var(--cream); border-color: var(--rivals-cyan); background: var(--rivals-surface); }

.modal #sign-out, .settings-exit #sign-out { --button-edge: var(--rivals-coral); background: var(--rivals-coral); color: var(--ink-deep); border-color: var(--rivals-coral); }
.settings-graphics { padding-bottom: 1.5rem; margin-bottom: 2rem; }
.settings-graphics h3 { margin-bottom: 1rem; }
.graphics-settings .settings-graphics { margin: 1.25rem 0 0; padding: 0; border: 0; background: transparent; }
.graphics-settings .graphics-presets { padding-bottom: 1rem; }
.graphics-settings .graphics-presets > .gfx-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: .75rem; }
.graphics-settings .graphics-presets p { margin: .75rem 0 0; }
.graphics-settings .graphics-category { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 1.25rem 0; border-top: .0625rem solid var(--rivals-steel); }
.graphics-settings .graphics-category h3 { display: block; margin: 0; }
.graphics-settings .graphics-category p { margin: .5rem 0 0; color: var(--cream); opacity: .7; }
.graphics-settings .gfx-controls button { min-height: 2.75rem; padding: .5rem .75rem; }
.graphics-settings .gfx-controls button[aria-pressed="true"] { color: var(--ink-deep); border-color: var(--rivals-teal); background: var(--rivals-teal); }
@media (max-width: 700px) {
 .graphics-settings .graphics-category { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
 .graphics-settings .graphics-category > .gfx-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.lobby-playlist-heading [data-switch-playlist] { background: var(--rivals-surface); color: var(--cream); }
.lobby-playlist-heading [data-switch-playlist]:hover:not(:disabled), .lobby-playlist-heading [data-switch-playlist]:focus-visible { color: var(--rivals-teal); border-color: var(--rivals-teal); }
@media (hover: hover) {
  .home-play > button:not(.secondary):hover:not(:disabled), .modal .primary:hover:not(:disabled), .team-lobby-footer .team-start:hover:not(:disabled), .result-actions .primary:hover:not(:disabled), #startup-retry:hover:not(:disabled), #close-game-settings:hover:not(:disabled) { background: var(--rivals-teal); }
}
.room-browser #join-room-form button { --button-edge: var(--rivals-steel); background: var(--rivals-surface); color: var(--cream); }

#room-visibility-toggle[aria-pressed="true"] { --button-edge: var(--rivals-teal); background: var(--button-primary-face); color: var(--ink-deep); }

.settings-exit #leave { --button-edge: var(--rivals-coral); color: var(--rivals-coral); }

/* A traveling highlight keeps the held bonus visible without covering its content. */
.game .arena .power-shortcut::before {
  content: '';
  position: absolute;
  inset: -.1875rem;
  padding: .125rem;
  border-radius: .25rem;
  background: conic-gradient(from var(--bonus-ring-angle), transparent 0deg 200deg, var(--rivals-teal) 260deg, var(--rivals-cyan) 310deg, var(--cream) 340deg, transparent 360deg);
  -webkit-mask: linear-gradient(var(--cream) 0 0) content-box, linear-gradient(var(--cream) 0 0);
  mask: linear-gradient(var(--cream) 0 0) content-box, linear-gradient(var(--cream) 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  filter: drop-shadow(0 0 .375rem var(--rivals-cyan));
  pointer-events: none;
  animation: bonus-ring-orbit 3s linear infinite;
}
@keyframes bonus-ring-orbit {
  to { --bonus-ring-angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
  .game .arena .power-shortcut::before { animation: none; }
}

/* Held bonuses keep their full color; usable cards respond to hover. */
:root body #power-shortcut { opacity: 1; transform-origin: left center; transition: transform .15s ease-out, box-shadow .15s ease-out, background .15s ease-out, border-color .15s ease-out, scale .25s ease; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :root body #power-shortcut:hover:not(:disabled) { scale: 1.04; }
}

.lobby-ready-button[aria-pressed="false"] { --button-edge: var(--rivals-line); background: var(--rivals-surface); color: var(--cream); }
.lobby-ready-button[aria-pressed="true"] { --button-edge: var(--rivals-teal); background: var(--button-primary-face); color: var(--ink-deep); }

/* Free Play tools share one compact style, with explicit toggle states. */
.game.free-play .power-row > .free-tool {
 padding: .5rem .75rem; min-height: 2.25rem; font-size: var(--text-xs); pointer-events: auto;
 background: var(--rivals-surface); color: var(--cream); border: .0625rem solid var(--rivals-steel);
 border-radius: .25rem; box-shadow: none; transform: none; clip-path: none;
 transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.game.free-play .power-row > .free-tool::before, .game.free-play .power-row > .free-tool::after { display: none; }
.game.free-play .power-row > .free-tool:hover, .game.free-play .power-row > .free-tool:focus-visible { border-color: var(--rivals-teal); background: var(--ink-deep); }
.game.free-play .power-row > .free-tool[aria-pressed="true"] { background: var(--rivals-teal); color: var(--ink-deep); border-color: var(--rivals-teal); box-shadow: 0 0 .5rem var(--rivals-glow-teal); }
.game.free-play .power-row > #end-free-play { color: var(--rivals-coral); }
