/* Ububall arena and layout */
.ball-page { margin: 0 auto; }
:root {
  --safe-top: var(--discord-safe-area-inset-top, env(safe-area-inset-top));
  --safe-right: var(--discord-safe-area-inset-right, env(safe-area-inset-right));
  --safe-bottom: var(--discord-safe-area-inset-bottom, env(safe-area-inset-bottom));
  --safe-left: var(--discord-safe-area-inset-left, env(safe-area-inset-left));
}

/* Game labels and scores use the display face (see site.css). */
.setting, .setting-slider, .column-heading, .card-titles strong, .super-name-badge, .mint-entry-badge, .mint-entry-cta,
.bug-team, .bug-status, .bug-tab {
  font-family: var(--font-display); font-weight: 700; font-synthesis: none; letter-spacing: .01em;
}
.team .team-card, .mint-entry, .pause-menu, .team-sheet, #online-dialog, #match-summary, .replays-dialog, .export-dialog, .stats-dialog { box-shadow: var(--panel-shadow); }

/* Play home: the lineup, the way into a match and the way to Ubu Mint. */
.play-home { display: grid; gap: .875rem; width: min(55rem, 100%); margin: .25rem auto 1.5rem; }
.home-team { padding: 1.125rem; background: var(--card); border: .0625rem solid var(--border); border-radius: 1.375rem; box-shadow: var(--panel-shadow); }
.home-team-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .875rem; }
.home-team-head h1 { color: var(--team-home); }
.home-lineup { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.home-ubu {
  display: grid; justify-items: center; align-content: start; gap: .375rem; padding: 1rem .5rem .875rem; text-align: center; border-radius: 1rem;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--team-home) 16%, var(--elevated)), var(--elevated) 70%);
}
.home-ubu-art { width: min(7rem, 100%); height: auto; aspect-ratio: 1; filter: drop-shadow(0 .5rem .625rem #0007); }
.home-ubu strong { font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1.15; overflow-wrap: anywhere; }
.home-ubu-archetype { color: var(--muted); font-size: .75rem; line-height: 1.15; }
.home-ubu small { display: flex; align-items: center; gap: .25rem; color: var(--secondary); font-size: .75rem; }
.home-ubu small img { width: 1.125rem; }
.home-actions { display: grid; gap: .75rem; }
.home-actions button { min-height: 4.25rem; border-radius: 1.125rem; font-size: 1.375rem; }
.match-action-pair { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .5rem; }
#replays-open { min-height: 3rem; font-size: 1.125rem; }
#home-play {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .125rem;
  box-shadow: var(--bevel), 0 .625rem 1.75rem color-mix(in srgb, var(--primary) 30%, transparent);
}
#quick-play-setup, #quick-play-signin, #online-open-note { font-size: .8125rem; font-weight: 700; }
#online-open { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.availability-actions:not([hidden]) { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-block: .75rem; }
#signed-out-panel { width: min(100%, 36rem); text-align: center; }
#signed-out-title { margin: 0; font: 700 clamp(2rem, 7vw, 4rem)/1.1 var(--font-display); }
#signed-out-message { margin: .75rem 0; font-size: 1rem; }
#signed-out-panel .button { min-height: 2.75rem; }
.mint-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .875rem 1rem; border-radius: 1.125rem;
  background: color-mix(in srgb, var(--card) 90%, var(--primary) 10%);
  border: .0625rem solid color-mix(in srgb, var(--border) 60%, var(--primary) 40%);
}
.mint-entry-content { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.mint-entry-badge {
  flex: none; padding: .25rem .5625rem; border-radius: .5rem; font-size: .8125rem; text-transform: uppercase; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent); border: .0625rem solid color-mix(in srgb, var(--primary) 32%, transparent);
}
.mint-entry-text { margin: 0; font-size: .8125rem; line-height: 1.35; }
.mint-entry-links { display: flex; align-items: center; gap: .875rem; flex: none; }
.mint-entry-cta {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: .5rem 1rem; border-radius: .75rem; font-size: .90625rem;
  color: #2B1608; background: linear-gradient(color-mix(in srgb, var(--primary), white 14%), var(--primary)); box-shadow: var(--bevel);
}
.mint-entry-link {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: .5rem 1rem .6875rem; border-radius: 62.4375rem;
  background: var(--elevated); color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: .90625rem;
}
.mint-entry-link:hover { background: var(--hover); }
/* The team waits for the session, so a signed-in player never sees a guest team first. */
.home-team:not(.settled) > * { visibility: hidden; }
.starter-pack .candy-pack { width: min(26rem, 100%); filter: drop-shadow(0 .5rem 1rem #0006); transition: scale .2s; }
.starter-pack .candy-pack:not(:disabled):is(:hover, :focus-visible) { scale: 1.04; }
.starter-pack .candy-pack:disabled { opacity: 1; }
/* A pack is waiting: the dot sits over the tab or button that leads to it. */
.has-notice { position: relative; }
.has-notice::after {
  content: ''; position: absolute; top: .25rem; right: .25rem; width: .625rem; height: .625rem; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 .125rem var(--card), 0 0 .5rem var(--primary);
}
@media (orientation: portrait) and (max-width: 640px) {
  .home-team { padding: .875rem .625rem; }
  .home-lineup { gap: .375rem; }
  .home-ubu { padding: .75rem .25rem .625rem; }
  .home-ubu strong { font-size: .8125rem; }
  .home-ubu small { font-size: .6875rem; }
  .mint-entry, .mint-entry-content { flex-direction: column; align-items: stretch; text-align: center; gap: .625rem; }
  .mint-entry-badge { align-self: center; }
  .mint-entry-links { justify-content: center; }
}

/* Match and replay shots: the stadium fills the screen; the home screen and site chrome step aside. */
body:is([data-shot="match"], [data-shot="replay"]) :is(.play-home, .site-nav, .site-header) { display: none; }
:where(body[data-shot="match"], body[data-shot="replay"]) { height: 100dvh; }
body:is([data-shot="match"], [data-shot="replay"]) { padding-bottom: 0; overflow: hidden; }
body:is([data-shot="match"], [data-shot="replay"]) .ball-page {
  width: 100%; max-width: none; height: 100%; margin: 0;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
body:is([data-shot="match"], [data-shot="replay"]) .arena-layout {
  --roster-width: clamp(12rem, 15vw, 16.5rem);
  height: 100%; padding: .5rem; gap: 0 clamp(.25rem, 1vw, .875rem);
  grid-template-columns: var(--roster-width) minmax(0, 1fr) var(--roster-width);
  grid-template-rows: auto minmax(0, 1fr) auto;
}
body:is([data-shot="match"], [data-shot="replay"]) .team-column { grid-row: 2; align-self: center; max-height: 100%; overflow-y: auto; }
body:is([data-shot="match"], [data-shot="replay"]) .home-column { grid-column: 1; }
body:is([data-shot="match"], [data-shot="replay"]) .away-column { grid-column: 3; }
body:is([data-shot="match"], [data-shot="replay"]) .stadium {
  grid-column: 2; grid-row: 1 / -1; align-self: stretch; min-width: 0; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: subgrid;
}
body:is([data-shot="match"], [data-shot="replay"]) .stadium-stage-area { grid-row: 2; min-width: 0; min-height: 0; container-type: size; touch-action: none; }
body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) > .stadium-stage-area { --visible-rink-height: 516; }
body:is([data-shot="match"], [data-shot="replay"]) .scoreboard { grid-row: 1; }
body:is([data-shot="match"], [data-shot="replay"]) .stadium-actions { grid-row: 3; }
body:is([data-shot="match"], [data-shot="replay"]) .stadium > :is(.scoreboard, .stadium-stage-area, .stadium-actions) { grid-column: 1; }
body:is([data-shot="match"], [data-shot="replay"]).sidebars-hidden .arena-layout { grid-template-columns: minmax(0, 1fr); }
body:is([data-shot="match"], [data-shot="replay"]).sidebars-hidden .stadium { grid-column: 1; }
body.match-fullscreen .stadium { border: 0; border-radius: 0; box-shadow: none; }
@media (min-width: 68rem) and (min-height: 32.5625rem) and (orientation: landscape) and (not ((pointer: coarse) and (max-height: 600px))) {
  body:is([data-shot="match"], [data-shot="replay"]):not(.sidebars-hidden) .arena-layout > .stadium {
    grid-column: 1 / -1; grid-template-columns: subgrid;
  }
  body:is([data-shot="match"], [data-shot="replay"]):not(.sidebars-hidden) .arena-layout > .stadium > .stadium-stage-area { grid-column: 2; }
  body:is([data-shot="match"], [data-shot="replay"]):not(.sidebars-hidden) .arena-layout > .stadium > :is(.scoreboard, .stadium-actions) { grid-column: 1 / -1; }
  body:is([data-shot="match"], [data-shot="replay"]) .arena-layout > .team-column { position: relative; z-index: 1; }
}
@media (orientation: portrait) {
  body:is([data-shot="match"], [data-shot="replay"]) .team-column { display: none; }
  body:is([data-shot="match"], [data-shot="replay"]) .arena-layout { grid-template-columns: 1fr; padding: 0; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium { grid-column: 1; border: 0; border-radius: 0; box-shadow: none; }
}
@media (orientation: landscape) and ((width < 68rem) or (max-height: 32.5rem)) {
  body:is([data-shot="match"], [data-shot="replay"]) .team-column, #btn-sidebars { display: none; }
  body:is([data-shot="match"], [data-shot="replay"]) .arena-layout { grid-template-columns: minmax(0, 1fr); }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium { grid-column: 1; }
}
/* Shared persistent stage shell: Play, Ubu Mint and Collection share .arena-layout inside .ball-page. */
main[data-screen="play"]:not([hidden]) { display: contents; }
body:not([data-shot="mint"]) :is(#mint-world, #mint-reveal) { display: none !important; }
body:not([data-shot="collection"]) #collection-world { display: none !important; }

/* Ubu Mint shot: matches Play's full 114rem content width; header and Mint title stay outside the dark spotlit rink. */
body[data-shot="mint"] .ball-page {
  display: grid; grid-template-rows: auto auto auto; justify-items: center; gap: .25rem;
  width: min(114rem, calc(100% - 3rem)); max-width: none; margin: 0 auto .75rem;
}
body[data-shot="mint"] main[data-screen="mint"]:not([hidden]),
body[data-shot="mint"] .pack-shop { display: contents; }
body[data-shot="mint"] .mint-head { grid-row: 1; width: 100%; }
body[data-shot="mint"] .arena-layout { grid-row: 2; display: block; width: 100%; margin: 0; }
body[data-shot="mint"] .mint-foot { grid-row: 3; width: 100%; }
body[data-shot="mint"] :is(.team-column, .scoreboard, .match-tools, .stadium-toolbar, #game-status, .stadium-actions, #field-spin, #skip-goal-replay, #roster-slots),
body[data-shot="mint"] .rink-stage > :is(.demo-badge, .demo-play, .demo-finger, .field-banner, #skip-goal-replay) { display: none; }
body[data-shot="mint"] .stadium-stage-area { touch-action: pan-y; }
@media (min-width: 48rem) and (min-height: 37.5625rem) {
  body[data-shot="mint"] .stadium-stage-area {
    width: 100%;
    height: clamp(18.5rem, calc(100dvh - 13rem - var(--safe-top, 0px) - var(--safe-bottom, 0px)), calc(min(114rem, 100vw - 3rem) * 0.54));
    border-radius: 1.5rem;
    border: .0625rem solid transparent;
    container-type: size;
    transition: border-color .35s ease, box-shadow .35s ease;
  }
  body[data-shot="mint"] .stadium-stage-area:has(.rink-stage.mint-zoomed) {
    border-color: color-mix(in srgb, var(--border) 65%, transparent);
    box-shadow: var(--panel-shadow);
  }
  body[data-shot="mint"] .rink-stage { width: min(100%, calc(100cqh * 5 / 3)); margin: 0 auto; }
}
body[data-shot="mint"] .rink-stage > :is(.rink-wrap, .mint-world) {
  transform-origin: 50% 50%;
  transform: translate(var(--mint-pan-x, 0%), var(--mint-pan-y, 0%)) scale(var(--mint-zoom, 1));
  transition: transform .48s cubic-bezier(.3, .8, .2, 1);
}
body[data-shot="mint"] .rink-stage.mint-camera-cut > :is(.rink-wrap, .mint-world) { transition: none; }
body[data-shot="mint"] #mint-world > #signed-out-panel {
  position: absolute; left: 50%; top: 50%; z-index: 6; translate: -50% -50%;
  width: min(82%, 30rem); padding: 1.25rem; border-radius: 1.25rem;
  background: color-mix(in srgb, var(--card) 82%, transparent); border: .0625rem solid var(--border);
  box-shadow: var(--panel-shadow); backdrop-filter: blur(.375rem);
}
@media (max-height: 37.5rem) {
  body[data-shot="mint"] .site-header { margin: .25rem auto; }
  body[data-shot="mint"] .ball-page { width: calc(100% - 1.25rem); gap: .125rem; margin-bottom: .25rem; }
  body[data-shot="mint"] .mint-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .1875rem .625rem; min-height: 1.625rem; }
  body[data-shot="mint"] #pack-title { font-size: clamp(1.1875rem, 3.2vw, 1.5rem); }
  body[data-shot="mint"] .pack-subtitle { min-height: 0; font-size: .8125rem; }
  body[data-shot="mint"] .stadium-stage-area {
    width: 100%;
    height: clamp(10rem, calc(100dvh - 8.5rem - var(--safe-top, 0px) - var(--safe-bottom, 0px)), 20rem);
    border-radius: 1rem;
    border: .0625rem solid transparent;
    container-type: size;
  }
  body[data-shot="mint"] .stadium-stage-area:has(.rink-stage.mint-zoomed) {
    border-color: color-mix(in srgb, var(--border) 65%, transparent);
    box-shadow: var(--panel-shadow);
  }
  body[data-shot="mint"] .rink-stage { width: min(100%, calc(100cqh * 5 / 3)); margin: 0 auto; }
  body[data-shot="mint"] .mint-foot { min-height: 1.25rem; gap: .125rem; }
  body[data-shot="mint"] .mint-foot #mint { min-height: 2rem; padding: .25rem .875rem .375rem; font-size: .875rem; }
  body[data-shot="mint"] .mint-foot .daily-next { font-size: .75rem; }
  body[data-shot="mint"] .pack-prompt { font-size: .9375rem; }
}
@media (max-width: 47.99rem) and (min-height: 37.5625rem) {
  body[data-shot="mint"] .ball-page { width: calc(100% - 1rem); margin-bottom: .5rem; }
  body[data-shot="mint"] .mint-head { min-height: 2.875rem; }
  body[data-shot="mint"] .stadium-stage-area {
    display: grid;
    grid-template-columns: 2.625rem minmax(0, 1fr) 2.625rem auto;
    grid-template-rows: minmax(15.25rem, auto) auto;
    align-items: center;
    gap: .5rem .375rem;
    width: 100%;
    overflow: visible;
  }
  body[data-shot="mint"] .rink-stage {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    border-radius: 1.25rem;
    border: .0625rem solid transparent;
  }
  body[data-shot="mint"] .rink-stage.mint-zoomed {
    height: clamp(16.25rem, 39dvh, 18.75rem);
    aspect-ratio: auto;
    border-color: color-mix(in srgb, var(--border) 65%, transparent);
    box-shadow: var(--panel-shadow);
  }
  body[data-shot="mint"] .rink-stage.mint-zoomed > :is(.rink-wrap, .mint-world) {
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 3;
    inset: auto;
    flex: none;
  }
}

/* Collection shot: stretched portrait rink matching Ubu Mint's width (minimum 3:5 height), sticky dock above, ubu grid and hybrid viewer on the ice. */
body[data-shot="collection"] .ball-page {
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  width: min(114rem, calc(100% - 3rem));
  max-width: none;
  margin: 0 auto 2.5rem;
}
body[data-shot="collection"] main[data-screen="collection"]:not([hidden]) { display: contents; }
body[data-shot="collection"] .collection-dock {
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 25;
  width: 100%;
  padding: .625rem .875rem .5rem;
  margin-bottom: .125rem;
  border-radius: 0 0 1.125rem 1.125rem;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(.625rem);
  border: .0625rem solid color-mix(in srgb, var(--border) 55%, transparent);
  border-top: 0;
  box-shadow: 0 .625rem 1.5rem rgb(0 0 0 / .32);
}
body[data-shot="collection"] .collection-dock:not(:has(> :not([hidden]))) { display: none; }
body[data-shot="collection"] .collection-dock .ubu-toolbar { margin: .5rem 0 .125rem; }
body[data-shot="collection"] .arena-layout { grid-row: 2; display: block; width: 100%; margin: 0; }
html:has(body[data-shot="collection"]) { overflow-x: clip; }
body[data-shot="collection"] { overflow-x: clip; }
body[data-shot="collection"] :is(.team-column, .scoreboard, .match-tools, .stadium-toolbar, #game-status, .stadium-actions, #field-spin, #skip-goal-replay, #skaters, .field-badges, #roster-slots),
body[data-shot="collection"] .rink-stage > :is(.demo-badge, .demo-play, .demo-finger, .field-banner, #skip-goal-replay) { display: none; }
body[data-shot="collection"] :is(.stadium, .stadium-stage-area) {
  display: block;
  width: 100%;
  overflow: visible;
  border: 0 none transparent;
  background: none;
  box-shadow: none;
}
body[data-shot="collection"] .rink-stage {
  display: block;
  width: 100%;
  aspect-ratio: auto;
  container-type: inline-size;
  min-height: var(--collection-hold-h, 0px);
  overflow: visible;
}
body[data-shot="collection"] .rink-stage.collection-rotating {
  aspect-ratio: 3 / 5;
  min-height: 0;
  overflow: hidden;
}
body[data-shot="collection"] .rink-stage.collection-rotating #collection-world {
  opacity: 0;
  pointer-events: none;
}
body[data-shot="collection"] .rink-wrap {
  position: sticky;
  top: 0;
  z-index: 0;
  aspect-ratio: auto;
  pointer-events: none;
}
body[data-shot="collection"] #rink { touch-action: pan-y; }
.rink-stage.collection-shrinking {
  position: fixed !important;
  left: var(--shrink-left, 0px) !important;
  top: var(--shrink-top, 0px) !important;
  z-index: 18;
  display: block !important;
  margin: 0 !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  overflow: hidden !important;
  pointer-events: none !important;
}
.rink-stage.collection-shrinking > :not(.rink-wrap) {
  display: none !important;
}
.rink-stage.collection-shrinking > .rink-wrap {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  margin: 0 !important;
  aspect-ratio: auto !important;
  transform: none !important;
  transition: none !important;
}
@media (max-height: 37.5rem) {
  body[data-shot="collection"] .site-header { margin: .25rem auto; }
  body[data-shot="collection"] .ball-page { width: calc(100% - 1.25rem); margin-bottom: 1.25rem; }
  body[data-shot="collection"] .collection-dock {
    padding: .375rem .625rem .25rem;
    border-radius: 0 0 .875rem .875rem;
    transition: opacity .18s ease;
  }
  body[data-shot="collection"] .collection-dock .collection-header { margin-bottom: .3125rem; gap: .5rem; }
  body[data-shot="collection"] .collection-dock .ubu-toolbar { margin: .25rem 0 .125rem; gap: .3125rem; }
  body[data-shot="collection"] .collection-dock :is(.game-select, .ubu-search, .ubu-direction, .ubu-filters-toggle, #play-with-ubus, .collection-actions .file-btn) {
    min-height: 1.9375rem;
    padding-block: .25rem;
  }
  body[data-shot="collection"]:has(.collection-world.viewer-open) .collection-dock {
    opacity: 0;
    pointer-events: none;
  }
}
@media (max-width: 47.99rem) {
  body[data-shot="collection"] .site-header {
    width: calc(100% - 1rem);
  }
  body[data-shot="collection"] .ball-page {
    width: 100%;
    margin-bottom: 1.5rem;
  }
  body[data-shot="collection"] .collection-dock {
    padding: .5rem .625rem .375rem;
    border-inline: 0;
    border-radius: 0 0 .875rem .875rem;
    transition: opacity .18s ease;
  }
  body[data-shot="collection"] .arena-layout {
    width: calc(100% - .25rem);
    margin: 0 auto;
  }
  body[data-shot="collection"] .rink-stage {
    width: calc(100% * 600 / 484);
    margin-inline: calc(100% * -58 / 484);
  }
}
@media (max-width: 47.99rem) and (min-height: 37.5625rem) {
  body[data-shot="collection"]:has(.collection-world.viewer-open) .collection-dock {
    opacity: 0;
    pointer-events: none;
  }
}

/* Home, Activity lobby and setup shots: in landscape, the rink sits beside the home/lobby panel (or fills the stage in setup); in portrait and phone sideways, above it. */
body:is([data-shot="home"], [data-shot="lobby"], [data-shot="team"], [data-shot="rules"]) .ball-page { display: grid; grid-template-columns: minmax(0, 1fr) 28.5rem; gap: 0 1.25rem; align-items: stretch; width: min(114rem, calc(100% - 3rem)); max-width: none; margin: 0 auto; }
@media (min-width: 56rem) and (orientation: landscape) and (not ((pointer: coarse) and (max-height: 600px))) {
  body:is([data-shot="home"], [data-shot="team"], [data-shot="rules"]) .ball-page { align-items: center; margin-block: clamp(.75rem, 2dvh, 2rem); }
  body[data-shot="home"] .stadium:not(.portrait-mode) .stadium-stage-area { aspect-ratio: 1000 / 540; }
}
body:is([data-shot="home"], [data-shot="lobby"], [data-shot="team"], [data-shot="rules"]) .arena-layout { grid-area: 1 / 1; display: block; width: 100%; margin: 0; pointer-events: none; }
body:is([data-shot="home"], [data-shot="lobby"], [data-shot="team"], [data-shot="rules"]) :is(.team-column, .match-tools, .stadium-toolbar, #game-status, .stadium-actions, #field-spin, #skip-goal-replay) { display: none; }
body:is([data-shot="home"], [data-shot="lobby"]) .play-home { grid-area: 1 / 2; width: 100%; margin: 0; }
body[data-shot="home"] .play-home :is(.mint-entry, .mint-entry-content) { flex-direction: column; align-items: stretch; text-align: center; gap: .625rem; }
body[data-shot="home"] .play-home .mint-entry-badge { align-self: center; }
body[data-shot="home"] .play-home .mint-entry-links { justify-content: center; }
@media (orientation: portrait), (orientation: landscape) and (width < 42rem) {
  body[data-shot="home"] .ball-page { display: flex; flex-direction: column; width: min(95rem, calc(100% - 1.5rem)); }
  body[data-shot="home"] .arena-layout { order: -1; width: min(55rem, 100%); margin: .25rem auto 0; }
  body[data-shot="home"] .play-home { width: min(55rem, 100%); margin: .75rem auto 1.5rem; }
}
@media (orientation: landscape) and (min-width: 42rem) and ((max-height: 600px) or (width < 56rem)) {
  body[data-shot="home"] .site-header { margin: .25rem auto .375rem; }
  body[data-shot="home"] .ball-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(17rem, min(22.5rem, 42%));
    gap: .625rem .875rem;
    align-items: start;
    width: min(114rem, calc(100% - 1.5rem));
    margin: .25rem auto .75rem;
  }
  body[data-shot="home"] .arena-layout { order: 0; width: 100%; margin: 0; }
  body[data-shot="home"] .rink-stage { width: min(100%, calc((100dvh - 5.25rem) * 5 / 3)); margin: 0 auto; }
  body[data-shot="home"] .play-home { width: 100%; margin: 0; gap: .4375rem; }
  body[data-shot="home"] .home-actions { gap: .4375rem; }
  body[data-shot="home"] .home-actions button { min-height: 2.625rem; padding: .375rem .75rem .5rem; border-radius: .875rem; font-size: 1rem; }
  body[data-shot="home"] :is(#quick-play-setup, #quick-play-signin, #online-open-note) { font-size: .75rem; }
  body[data-shot="home"] .home-team { padding: .625rem; border-radius: 1rem; }
  body[data-shot="home"] .home-team-head { margin-bottom: .5rem; }
  body[data-shot="home"] .home-team-head h1 { font-size: 1.125rem; }
  body[data-shot="home"] .home-team-head button { min-height: 2rem; padding: .25rem .625rem; font-size: .8125rem; }
  body[data-shot="home"] .home-lineup { gap: .375rem; }
  body[data-shot="home"] .home-ubu { padding: .5rem .25rem .4375rem; gap: .1875rem; }
  body[data-shot="home"] .home-ubu-art { width: min(3.75rem, 100%); }
  body[data-shot="home"] .home-ubu strong { font-size: .8125rem; }
  body[data-shot="home"] .home-ubu small { font-size: .6875rem; }
  body[data-shot="home"] #replays-open { min-height: 2.25rem; padding: .375rem .75rem .5rem; font-size: .9375rem; }
}
@media (orientation: portrait), (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  body[data-shot="lobby"] .ball-page { display: flex; flex-direction: column; width: min(95rem, calc(100% - 1.5rem)); }
  body[data-shot="lobby"] .arena-layout { order: -1; width: min(55rem, 100%); margin: .25rem auto 0; }
  body[data-shot="lobby"] .play-home { width: min(55rem, 100%); margin: .75rem auto 1.5rem; }
}
@media (orientation: landscape) and (max-height: 600px) and (width < 42rem) {
  body[data-shot="home"] .site-header { margin: .25rem auto; }
  body[data-shot="home"] .rink-stage { width: min(100%, calc(48dvh * 5 / 3)); margin: 0 auto; }
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  body[data-shot="lobby"] .site-header { margin: .25rem auto; }
  body[data-shot="lobby"] .rink-stage { width: min(100%, calc(48dvh * 5 / 3)); margin: 0 auto; }
}
/* The Discord Activity opens on the lobby shot with the friends queue beside the rink (below on phones). */
.discord-activity :is(.nav-more, .site-header-actions),
.discord-activity .play-home > :not(.activity-play, .home-team, .mint-entry),
.discord-activity #signed-out-panel a[href="/"],
body[data-shot="lobby"] .rink-stage > :is(.demo-badge, .demo-play, .demo-finger, .field-banner, #skip-goal-replay) { display: none; }
html:is(.discord-activity, .capacitor-native) body .site-header {
  margin-top: max(.375rem, calc(var(--safe-top, 0px) + .25rem));
  width: min(114rem, calc(100% - 1.5rem - var(--safe-left, 0px) - var(--safe-right, 0px)));
}
html:is(.discord-activity, .capacitor-native) body[data-shot="collection"] .collection-dock { top: var(--safe-top, 0px); }
html:is(.discord-activity, .capacitor-native) dialog:not(.stat-drawer):not(.team-sheet):not(.on-ice) {
  inset: var(--safe-top, 0px) var(--safe-right, 0px) var(--safe-bottom, 0px) var(--safe-left, 0px);
  max-width: calc(100vw - 1.5rem - var(--safe-left, 0px) - var(--safe-right, 0px));
  max-height: calc(100dvh - 1.5rem - var(--safe-top, 0px) - var(--safe-bottom, 0px));
}
body[data-shot="lobby"] .ball-page {
  gap: 1rem; height: auto;
  padding-bottom: max(.75rem, var(--safe-bottom, 0px));
  padding-inline: var(--safe-left, 0px) var(--safe-right, 0px);
}
body[data-shot="lobby"] .play-home { align-self: center; gap: .6875rem; }
.activity-play { display: grid; gap: .75rem; }
.activity-friends {
  position: relative;
  display: grid; gap: .875rem; padding: 1.125rem;
  border: .0625rem solid var(--border); border-radius: 1.375rem;
  background: var(--card); box-shadow: var(--panel-shadow); text-align: center;
}
#online-friends {
  min-height: 3.5rem; padding: .625rem .75rem .875rem; border-radius: .875rem;
  font: 700 1.375rem/1.1 var(--font-display); color: #2b1608;
}
.activity-lobby-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-bottom: .75rem; border-bottom: .0625rem solid var(--border); }
.activity-lobby-heading h1 { margin: 0; font: 700 1.5rem/1.1 var(--font-display); }
.activity-lobby-title { display: flex; align-items: center; gap: .625rem; min-width: 0; }
.activity-loading-slot { display: grid; place-items: center; flex: none; width: 1.25rem; height: 1.25rem; }
#activity-online-count { color: var(--muted); font-size: .8125rem; }
.activity-users { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row dense; gap: .5rem; max-height: 21rem; overflow-y: auto; padding: .125rem; }
.activity-user {
  display: flex; flex-direction: column; align-items: center; gap: .375rem; min-width: 0;
  padding: .75rem .25rem .875rem; border: .125rem solid var(--border); border-radius: .75rem;
  background: var(--elevated); color: var(--text); font-size: .9375rem; box-shadow: var(--bevel);
}
.activity-user[aria-disabled="true"] { cursor: default; }
.activity-user[aria-disabled="true"]:hover { background: var(--elevated); }
.activity-user:not([aria-disabled="true"]):hover { border-color: var(--primary); }
.activity-user:not([aria-disabled="true"]):active { transform: translateY(.125rem); box-shadow: var(--bevel-pressed); }
.activity-user-avatar { position: relative; display: grid; place-items: center; width: 3rem; max-width: 100%; aspect-ratio: 1; flex: none; border-radius: 50%; background: var(--card); font: 700 1rem var(--font-display); }
.activity-user-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; grid-area: 1 / 1; }
.activity-user[data-self="true"] .activity-user-avatar::after { content: 'You'; position: absolute; bottom: -.125rem; right: -.125rem; border-radius: .25rem; padding: .0625rem .1875rem; background: var(--primary); color: #2b1608; font: 600 .5625rem Inter, sans-serif; }
.activity-user-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.activity-user-status { font: .6875rem/1.2 var(--font-body); color: var(--muted); overflow-wrap: anywhere; }
.activity-user[data-status="ready"] { border-color: #42c66b; }
.activity-user[data-status="ready"] .activity-user-status { color: #89d8b5; }
.activity-challenge { padding: .75rem; border: .125rem solid var(--primary); border-radius: .75rem; background: var(--elevated); box-shadow: var(--bevel); }
.activity-challenge p { margin: 0 0 .625rem; }
#activity-status { position: absolute; top: 3.5rem; inset-inline: .875rem; z-index: 2; margin: 0; padding: .625rem; border: .0625rem solid var(--primary); border-radius: .625rem; background: var(--card); color: var(--text); font-size: .875rem; box-shadow: var(--panel-shadow); }
.activity-match { position: relative; grid-column: span 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; min-width: 0; border: .125rem solid var(--border); border-radius: .75rem; background: var(--elevated); box-shadow: var(--bevel); }
.activity-match:has(.activity-user:not([aria-disabled="true"]):hover) { border-color: var(--primary); }
.activity-match .activity-user { border-color: transparent; background: transparent; box-shadow: none; padding: .625rem .125rem .75rem; }
.activity-match .activity-user:not([aria-disabled="true"]):hover { border-color: transparent; }
.activity-match .activity-user:hover { background: transparent; }
.activity-match .activity-user:active { box-shadow: none; }
.activity-versus { position: absolute; left: 50%; top: 2.25rem; transform: translate(-50%, -50%); padding: .1875rem .3125rem; border: .0625rem solid var(--border); border-radius: .375rem; background: var(--background); color: var(--text); font: 700 .75rem var(--font-display); pointer-events: none; }
.online-spinner { display: inline-block; justify-self: center; width: 1.25rem; height: 1.25rem; border: .1875rem solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary); border-radius: 50%; animation: online-spin .8s linear infinite; }
.stadium-actions { position: relative; }
.online-loading-slot { position: absolute; right: .5rem; top: .375rem; width: 1.25rem; height: 1.25rem; pointer-events: none; }
@keyframes online-spin { to { rotate: 360deg; } }
.discord-activity :is(#lobby-note, #online-account-status) { display: none; }

#online-change-rules { grid-column: 1 / -1; min-height: 2.75rem; font: 700 1.125rem var(--font-display); }
.activity-friend-actions, .activity-other { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.activity-friend-actions > button { flex: 1 1 auto; }
.activity-other > button { flex: 1 1 auto; min-height: 2.75rem; }
@media (orientation: landscape) and (min-width: 600px) and (not ((pointer: coarse) and (max-height: 600px))) {
  body[data-shot="lobby"] .ball-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18.5rem, min(28.5rem, 34%));
    align-items: center;
    width: min(114rem, calc(100% - 2rem));
    min-height: calc(100dvh - 4.25rem - var(--safe-top, 0px));
  }
  body[data-shot="lobby"] .arena-layout { order: 0; height: auto; max-width: none; margin: 0; }
  body[data-shot="lobby"] .stadium { height: auto; }
  body[data-shot="lobby"] .stadium-stage-area { flex: none; height: auto; container-type: normal; }
  body[data-shot="lobby"] .stadium:not(.portrait-mode) .rink-stage {
    width: min(100%, max(12rem, calc((100dvh - 8.5rem - var(--safe-top, 0px) - var(--safe-bottom, 0px)) * 5 / 3)));
    height: auto;
    margin: 0 auto;
  }
  body[data-shot="lobby"] .play-home { width: 100%; margin: 0; gap: .5625rem; }
  body[data-shot="lobby"] .activity-play { gap: .5rem; }
  body[data-shot="lobby"] .activity-friends { gap: .625rem; padding: .875rem; }
  body[data-shot="lobby"] .activity-lobby-heading { padding-bottom: .5rem; }
  body[data-shot="lobby"] .activity-user { padding: .5rem .25rem .625rem; gap: .25rem; }
  body[data-shot="lobby"] .activity-user-avatar { width: 2.5rem; }
  body[data-shot="lobby"] .activity-versus { top: 1.9375rem; }
  body[data-shot="lobby"] #online-friends { min-height: 3rem; padding: .5rem .75rem .6875rem; font-size: 1.25rem; }
  body[data-shot="lobby"] :is(.activity-friend-actions > button, .activity-other > button) { min-height: 2.375rem; padding-block: .375rem; }
  body[data-shot="lobby"] .home-team { padding: .75rem .875rem; }
  body[data-shot="lobby"] .home-team-head { margin-bottom: .5rem; }
  body[data-shot="lobby"] .home-team-head h1 { font-size: 1.25rem; margin: 0; }
  body[data-shot="lobby"] .home-team-head button { min-height: 2.25rem; padding: .375rem .75rem; }
  body[data-shot="lobby"] .home-ubu { padding: .5rem .375rem; gap: .1875rem; }
  body[data-shot="lobby"] .home-ubu-art { width: min(3.75rem, 100%); }
  body[data-shot="lobby"] .mint-entry { padding: .5rem .75rem; gap: .5rem; }
  body[data-shot="lobby"] .mint-entry-text { display: none; }
  body[data-shot="lobby"] .mint-entry-links { gap: .5rem; }
  body[data-shot="lobby"] :is(.mint-entry-cta, .mint-entry-link) { min-height: 2.25rem; padding: .375rem .75rem; font-size: .84375rem; }
}
@media (max-width: 599px) {
  body[data-shot="lobby"] .ball-page { display: flex; flex-direction: column; width: min(95rem, calc(100% - 2rem)); }
  body[data-shot="lobby"] .arena-layout { order: -1; width: min(55rem, 100%); margin: .25rem auto 0; }
  body[data-shot="lobby"] .play-home { width: min(55rem, 100%); margin: .875rem auto 1.5rem; }
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  body:is([data-shot="match"], [data-shot="replay"]) .arena-layout { grid-template-columns: 1fr; padding: 0; }
  body:is([data-shot="match"], [data-shot="replay"]) .team-column { display: none; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium { grid-column: 1; border: 0; border-radius: 0; box-shadow: none; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) {
    --controls-width: clamp(9.5rem, 24vw, 14rem);
    --controls-inset: 1.75rem;
    --controls-shift: var(--controls-inset);
    grid-template: "score field" auto ". field" minmax(0, 1fr) "actions field" auto / var(--controls-width) minmax(0, 1fr);
  }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode)[data-controls-side="right"] {
    --controls-shift: calc(-1 * var(--controls-inset));
    grid-template: "field score" auto "field ." minmax(0, 1fr) "field actions" auto / minmax(0, 1fr) var(--controls-width);
  }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) > .stadium-stage-area {
    --visible-rink-height: 536;
    grid-area: field; width: auto; height: 100%; margin-inline-start: -1rem; justify-content: flex-start;
  }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode)[data-controls-side="right"] > .stadium-stage-area {
    margin-inline: 0 -1rem; justify-content: flex-end;
  }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) > :is(.scoreboard, .stadium-actions) { translate: var(--controls-shift) 0; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) > .scoreboard { grid-area: score; border-bottom: 0; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) > .stadium-actions {
    grid-area: actions; grid-template-columns: minmax(0, 1fr); padding: .375rem 1rem .5rem;
    z-index: 1;
  }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .knob svg { width: 2.625rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .knob-row { grid-column: 1; width: min(100%, 8rem); justify-self: center; }
}
.pause-menu {
  width: min(23.75rem, calc(100% - 1.5rem)); padding: 1.375rem; border: .0625rem solid var(--border); border-radius: 1.375rem;
  background: var(--card); color: var(--text); text-align: center;
}
.pause-menu::backdrop { background: rgb(0 0 0 / .65); backdrop-filter: blur(.1875rem); }
.pause-menu-main { display: contents; }
.pause-heading { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem; align-items: center; gap: .25rem; margin-bottom: 1rem; }
.pause-menu h2 { font-size: 1.75rem; margin: 0; }
#pause-help { justify-self: start; }
.pause-actions { display: grid; gap: .625rem; }
.pause-actions button { min-height: 3.25rem; font-size: 1.125rem; border-radius: .875rem; }
.pause-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.875rem, 1fr)); gap: .5rem; margin: 1rem 0 .75rem; padding-top: 1rem; border-top: .0625rem solid var(--border); }
#setting-sidebar { display: none; }
@media (not (any-pointer: coarse)) { #setting-touch-aim { display: none; } }
@media (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  .pause-menu[open] {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    align-items: start; gap: .625rem 1rem;
    width: min(34rem, calc(100% - 2rem)); max-height: calc(100dvh - 1.5rem); overflow: auto;
    padding: .875rem;
  }
  .pause-menu :is(.pause-heading, .pause-links) { grid-column: 1 / -1; margin: 0; }
  .pause-settings { grid-template-columns: minmax(0, 1fr); margin: 0; padding: 0; border: 0; }
  body:has(.stadium:not(.portrait-mode)) #setting-sidebar { display: flex; }
}
/* A setting: its name, then its current value; pressing it switches the value. */
.pause-menu.has-activity-lobby[open] { display: grid; grid-template-columns: minmax(18rem, 23.75rem) minmax(20rem, 27rem); align-items: start; gap: 1.25rem; width: min(54rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); overflow-y: auto; }
.has-activity-lobby .pause-menu-main { display: block; min-width: 0; }
#pause-lobby { min-width: 0; }
#pause-lobby .activity-friends { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
#activity-match-offer-error { position: absolute; inset-inline: 1rem; bottom: 3.75rem; z-index: 1; padding: .625rem; border: .0625rem solid var(--primary); border-radius: .625rem; background: var(--card); color: var(--text); box-shadow: var(--panel-shadow); }
.has-activity-lobby .pause-settings { display: grid; gap: .5rem; margin: 1rem 0 .75rem; padding-top: 1rem; border-top: .0625rem solid var(--border); }
@media (max-width: 46rem) {
  .pause-menu.has-activity-lobby[open] { grid-template-columns: minmax(0, 1fr); width: min(28rem, calc(100vw - 1.5rem)); }
}
.setting { display: flex; align-items: center; justify-content: space-between; gap: .625rem; min-height: 2.75rem; padding: .5rem .625rem .5rem .875rem; border-radius: .75rem; font-size: .875rem; text-align: left; }
.setting > span:first-child { white-space: nowrap; }
.setting-value { flex: none; min-width: 6.25rem; padding: .1875rem .625rem; text-align: center; border-radius: 62.4375rem; background: var(--background); color: var(--muted); font-size: .75rem; }
.setting-pill {
  display: inline-flex; align-items: center; gap: .125rem; flex: none;
  padding: .1875rem; border-radius: 62.4375rem; background: var(--background);
}
.setting-seg {
  padding: .1875rem .5625rem; border-radius: 62.4375rem;
  color: var(--muted); font-size: .75rem; line-height: 1.25; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.setting-seg.active { background: var(--primary); color: #2B1608; }
.setting-seg.active[data-value="off"] { background: color-mix(in srgb, var(--text) 16%, var(--elevated)); color: var(--text); }
.setting[aria-pressed="true"] { border-color: color-mix(in srgb, var(--primary) 60%, var(--border)); }
.setting[aria-pressed="true"] .setting-value { background: var(--primary); color: #2B1608; }
.setting-slider {
  display: flex; align-items: center; gap: .625rem;
  min-height: 2.75rem; padding: .5rem .625rem .5rem .875rem;
  border-radius: .75rem; border: .0625rem solid var(--border);
  background: var(--elevated); box-shadow: var(--bevel); font-size: .875rem;
  text-align: left;
}
.setting-slider:focus-within { border-color: color-mix(in srgb, var(--primary) 60%, var(--border)); }
.setting-slider label { flex: none; min-width: 3.25rem; cursor: pointer; user-select: none; }
.setting-slider .game-slider { flex: 1 1 auto; min-width: 0; }
.setting-slider .setting-value { min-width: 3.25rem; font-variant-numeric: tabular-nums; }
.game-slider {
  appearance: none; display: block; width: 100%; height: 1.25rem; margin: 0; padding: 0;
  background: transparent; cursor: pointer; touch-action: pan-y;
}
.game-slider::-webkit-slider-runnable-track {
  height: .375rem; border-radius: .25rem;
  background: linear-gradient(to right, var(--primary) var(--fill-pct, 80%), var(--muted) var(--fill-pct, 80%));
}
.game-slider::-webkit-slider-thumb {
  appearance: none; width: 1.125rem; height: 1.125rem; margin-top: -.375rem;
  border-radius: 50%; border: .125rem solid var(--elevated); background: var(--primary);
  box-shadow: 0 .0625rem .25rem rgba(0, 0, 0, .4);
}
.game-slider::-moz-range-track {
  height: .375rem; border-radius: .25rem;
  background: linear-gradient(to right, var(--primary) var(--fill-pct, 80%), var(--muted) var(--fill-pct, 80%));
}
.game-slider::-moz-range-thumb {
  width: 1.125rem; height: 1.125rem; border-radius: 50%;
  border: .125rem solid var(--elevated); background: var(--primary);
  box-shadow: 0 .0625rem .25rem rgba(0, 0, 0, .4);
}
.game-slider:focus-visible { outline: none; }
.game-slider:focus-visible::-webkit-slider-thumb { outline: .125rem solid var(--primary); outline-offset: .125rem; }
.game-slider:focus-visible::-moz-range-thumb { outline: .125rem solid var(--primary); outline-offset: .125rem; }
.pause-links { display: flex; justify-content: center; gap: 1.25rem; font-family: var(--font-display); font-weight: 700; }
.pause-links a { color: var(--muted); }
.pause-links a:hover { color: var(--text); }

/* Arena layout: persistent stage wrapper configured per shot. */
.arena-layout { display: grid; }
.column-heading {
  font-size: .9375rem;
  margin-bottom: .5rem;
  padding-left: .125rem;
}
.team-column { display: flex; flex-direction: column; min-width: 0; }
.team { display: flex; flex-direction: column; gap: .625rem; }
.team .team-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: .625rem;
  background: var(--card);
  border: .125rem solid var(--border);
  border-radius: .75rem;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}
.team button { cursor: pointer; }
.team button:hover { background: var(--hover); }
.team .team-card.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--card), var(--primary) 9%);
}
.cpu-team .team-card {
  background: var(--card);
  border: .0625rem solid var(--border);
}
.card-header { display: flex; align-items: center; gap: .625rem; }
.card-header svg, .card-header .ball-thumb { display: block; width: 2.75rem; height: 2.75rem; flex: none; }
/* A card's portrait opens that ubu's stat drawer. */
.card-portrait { flex: none; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; transition: scale .12s ease; }
.team .card-portrait:hover { background: none; scale: 1.08; }
.card-portrait:focus-visible { outline: .125rem solid var(--primary); outline-offset: .125rem; }
.team .card-header .card-select { flex: 1; min-width: 0; }
/* The stat drawer slides in over the screen edge on its team's side. */
.stat-drawer {
  position: fixed; inset: 0 auto 0 0; width: min(18.75rem, 86vw); height: 100dvh; max-height: none; margin: 0;
  padding: calc(.875rem + var(--safe-top, 0px)) .875rem calc(1.25rem + var(--safe-bottom, 0px)) calc(.875rem + var(--safe-left, 0px));
  overflow-y: auto; border: 0; border-right: .0625rem solid var(--border); border-radius: 0 1.125rem 1.125rem 0;
  background: var(--card); color: var(--text); box-shadow: var(--panel-shadow); animation: drawer-in-left .2s ease-out;
}
.stat-drawer[data-side="away"] {
  inset: 0 0 0 auto; border-right: 0; border-left: .0625rem solid var(--border); border-radius: 1.125rem 0 0 1.125rem;
  padding: calc(.875rem + var(--safe-top, 0px)) calc(.875rem + var(--safe-right, 0px)) calc(1.25rem + var(--safe-bottom, 0px)) .875rem;
  animation-name: drawer-in-right;
}
.stat-drawer::backdrop { background: rgb(0 0 0 / .35); }
@keyframes drawer-in-left { from { translate: -100% 0; } }
@keyframes drawer-in-right { from { translate: 100% 0; } }
.stat-drawer-head { display: flex; align-items: center; gap: .625rem; margin-bottom: .25rem; }
.stat-drawer-art { flex: none; width: 4rem; height: 4rem; }
.stat-drawer-super {
  display: grid; gap: .375rem; margin: .5rem 0 .25rem; padding: .5625rem .625rem;
  border: .0625rem solid var(--border); border-radius: .75rem; background: var(--elevated);
}
.stat-drawer-super.ready { border-color: color-mix(in srgb, #ff7197 55%, var(--border)); }
.stat-drawer-super.armed { border-color: #ff7197; box-shadow: 0 0 .5rem rgb(255 113 151 / .28); }
.stat-drawer-super-head { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.stat-drawer-super-icon {
  flex: none; width: 2rem; height: 2rem; padding: .125rem; border-radius: .5rem;
  background: rgb(255 255 255 / .06); object-fit: contain;
}
.stat-drawer-super-main { flex: 1; min-width: 0; display: grid; gap: .25rem; }
.stat-drawer-super-title { display: flex; align-items: baseline; justify-content: space-between; gap: .375rem; min-width: 0; }
.stat-drawer-super-title strong {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #ff7197; font-size: .875rem; font-weight: 700;
}
.stat-drawer-super .super-pct { flex: none; white-space: nowrap; font-size: .6875rem; }
.stat-drawer-super.ready .super-pct { color: #ffffff; }
.stat-drawer-super.armed .super-pct { padding: 0 .375rem; border-radius: 62.4375rem; background: #ff7197; color: #0b0d10; font-weight: 800; }
.stat-drawer-super-desc { margin: 0; color: var(--muted); font-size: .75rem; line-height: 1.35; }
.stat-drawer-super-mastery { display: block; color: var(--secondary); font-size: .6875rem; font-weight: 600; line-height: 1.3; }
.stat-drawer .card-titles strong { font-size: 1.125rem; white-space: normal; }
.stat-drawer .stat-row, .stat-drawer .stat-lbl, .stat-drawer .stat-val { font-size: .75rem; }
.stat-drawer .stat-lbl { width: 5.25rem; }
.stat-drawer .stat-val { width: 1.625rem; }
.stat-drawer .stat-row { gap: .5rem; padding: .125rem 0; }
.stat-drawer .stat-group-title { margin-top: .625rem; font-size: .6875rem; }
/* Hiding the sidebars gives the rink the whole width; the toggle shows only where sidebars do. */
body:is([data-shot="match"], [data-shot="replay"]).sidebars-hidden .team-column { display: none; }
@media (orientation: portrait), (orientation: landscape) and (pointer: coarse) and (max-height: 600px) { #btn-sidebars { display: none; } }
.card-titles { min-width: 0; flex: 1; }
.card-titles:has(> .card-guard) { display: flex; align-items: center; gap: .25rem; }
.card-titles > .card-select { display: block; }
.card-guard { flex: none; margin-left: auto; }
button.card-guard { background: transparent; border: 0; box-shadow: none; padding: .25rem; }
.card-header .card-guard svg, .shot-buttons svg { width: 1rem; height: 1rem; }
.guard-toggle svg { color: #b8bcc3; }
.guard-toggle[aria-pressed="true"] svg, .cpu-card .card-guard svg { color: #4798ff; fill: currentColor; }
.card-titles strong {
  display: block;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.card-titles small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); margin-top: .1875rem; font-size: .6875rem; }

/* Stats box below ubu name */
.ubu-stats-wrap { width: 100%; }
.ubu-stats {
  display: flex;
  flex-direction: column;
  gap: .1875rem;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: .0625rem solid #ffffff12;
  width: 100%;
}
.stat-group-title {
  font-size: .5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: .375rem;
  margin-bottom: .125rem;
}
.stat-group-title:first-child { margin-top: 0; }
.stat-row { display: flex; align-items: center; gap: .375rem; font-size: .625rem; }
.stat-lbl {
  width: 4.125rem;
  flex: none;
  color: var(--muted);
  font-size: .625rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-track {
  flex: 1;
  height: .375rem;
  background: var(--background);
  border-radius: .1875rem;
  overflow: hidden;
  border: .0625rem solid #ffffff0a;
}
.stat-track i { display: block; height: 100%; border-radius: .1875rem; transition: width 0.2s ease; }
.stat-val {
  width: 1.25rem;
  flex: none;
  text-align: right;
  color: var(--muted);
  font-size: .625rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Super Ability Panel */
.super-panel {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: .0625rem solid #ffffff12;
  width: 100%;
}
.super-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .6875rem;
}
.super-name-badge {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-weight: 700;
  color: #ff7197;
  font-size: .6875rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.super-icon {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: .25rem;
  flex: none;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
  padding: .0625rem;
}
.super-panel:hover .super-icon {
  transform: scale(1.08);
  transition: transform 0.15s ease;
}
.super-pct {
  font-size: .625rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.super-meter-track {
  height: .375rem;
  background: var(--background);
  border-radius: .1875rem;
  overflow: hidden;
  border: .0625rem solid #ffffff0a;
  width: 100%;
}
.super-meter-fill {
  display: block;
  height: 100%;
  border-radius: .1875rem;
  background: linear-gradient(90deg, #ff7197, #ff9954);
  transition: width 0.2s ease;
}
/* A sidebar super panel only shows the charge (arming is in the dock): lit when ready, tagged when armed. */
.super-panel.ready .super-pct { color: #ffffff; }
.super-panel.armed .super-pct { padding: 0 .375rem; border-radius: 62.4375rem; background: #ff7197; color: #0b0d10; font-weight: 800; }
/* Launch knobs (see makeKnob): the dock holds the selected ubu's three. */
.knob-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .125rem; }
.knob { display: flex; flex-direction: column; align-items: center; gap: .0625rem; min-width: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.knob svg { width: min(100%, 3.125rem); aspect-ratio: 1; cursor: grab; overflow: visible; }
.knob svg:active { cursor: grabbing; }
.knob svg:focus { outline: none; }
.knob svg:focus-visible { outline: .125rem solid var(--primary); outline-offset: .125rem; border-radius: 50%; }
.knob-track { fill: none; stroke: var(--background); stroke-width: 8; }
.knob-value { fill: none; stroke: var(--primary); stroke-width: 8; stroke-linecap: round; }
.knob-arc-arrow { fill: none; stroke: var(--primary); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.knob-face { fill: var(--elevated); stroke: var(--border); stroke-width: 1.5; }
.knob-needle { stroke: var(--text); stroke-width: 6; stroke-linecap: round; }
.knob-arrow { fill: none; stroke: var(--text); stroke-width: 5.5; stroke-linecap: round; stroke-linejoin: round; }
.knob small { font-family: var(--font-display); font-weight: 700; font-synthesis: none; font-size: .625rem; color: var(--muted); }
.knob.disabled { opacity: .45; }
.knob.disabled svg { cursor: default; }
.knob-popover {
  padding: .25rem; border-radius: 999px; overflow: visible;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.knob-popover:popover-open { display: inline-flex; align-items: center; gap: .125rem; }
.knob-popover .knob-step {
  display: grid; place-items: center; width: 2rem; height: 2rem; min-height: 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text); box-shadow: none;
  touch-action: none;
}
.knob-popover .knob-step:hover { background: var(--hover); }
.knob-popover .knob-step:active { background: color-mix(in srgb, var(--primary) 24%, transparent); color: var(--primary); }
.knob-popover .knob-step .icon { width: 1rem; height: 1rem; }
.knob-popover .knob-readout {
  min-width: 3.125rem; height: 2rem; min-height: 0; padding: 0 .375rem;
  border: 0; border-radius: 999px; background: transparent; color: var(--text); box-shadow: none;
  font-size: .875rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.knob-popover .knob-readout:not(:disabled):hover { background: var(--hover); }
.knob-popover .knob-readout:not(:disabled):active { background: color-mix(in srgb, var(--primary) 22%, transparent); }
.knob-popover .knob-readout:disabled { opacity: 1; cursor: default; }
.knob-drag-pill {
  position: fixed; z-index: 60; pointer-events: none;
  padding: .25rem .625rem; border-radius: 999px;
  border: .0625rem solid var(--border); background: var(--elevated); color: var(--text);
  box-shadow: var(--panel-shadow);
  font-size: .875rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.knob-drag-pill.fine { border-color: var(--primary); color: var(--primary); }


/* Stadium */
.stadium {
  position: relative;
  overflow: hidden;
}

.stadium-toolbar {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: .375rem;
}
.stadium-tool-btn {
  width: 2.125rem;
  height: 2.125rem;
  padding: .4375rem;
  border-radius: .5rem;
  background: var(--elevated);
  color: var(--muted);
  border: .0625rem solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  touch-action: manipulation;
}
#btn-fullscreen[hidden],
#btn-fullscreen[aria-pressed="true"] #icon-fs-enter,
#btn-fullscreen[aria-pressed="false"] #icon-fs-exit { display: none; }
.stadium-tool-btn:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border);
}
.stadium-tool-btn[aria-pressed="true"] {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 18%, var(--card));
  border-color: var(--primary);
}
.stadium-tool-btn svg {
  width: 1.125rem;
  height: 1.125rem;
  display: block;
}
.rotate-option { position: relative; display: grid; place-items: center; }
.stadium-tool-btn .rotate-option svg { width: 1.5rem; height: 1.5rem; }
.rotate-option b { position: absolute; font: 700 .625rem/1 var(--font-display); }
#btn-rotate[aria-pressed="true"] .rotate-portrait,
#btn-rotate:not([aria-pressed="true"]) .rotate-landscape { display: none; }

.stadium-stage-area {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 0 none transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.rink-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.rink-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 5 / 3;
}
#rink { display: block; width: 100%; height: 100%; touch-action: none; }
#skaters { position: absolute; inset: 0; pointer-events: none; }
.first-turn-guide { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.first-turn-guide > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#first-turn-arrow { fill: none; stroke: var(--team-home); stroke-width: 3; stroke-dasharray: 6 5; stroke-linecap: round; }
.first-turn-prompt {
  position: absolute; top: var(--tip-y, 1rem); left: var(--tip-x, 50%); transform: translateX(-50%);
  width: max-content; max-width: min(23rem, var(--tip-width, 100%), calc(100% - 1rem)); padding: .5rem .75rem;
  background: color-mix(in srgb, var(--background) 90%, transparent);
  color: var(--text); border-radius: .75rem; text-align: center;
}
.first-turn-prompt p { margin: 0; font: 700 clamp(.875rem, 2vw, 1.125rem)/1.35 var(--font-display); }
.first-turn-prompt button { pointer-events: auto; min-height: 1.875rem; margin-top: .25rem; padding: .125rem .5rem; font-size: .75rem; }
.stadium-stage-area:has(> .first-turn-guide:not([hidden])) .field-banner[data-tone="plan"] { visibility: hidden; }
.match-help[open] { display: block; }
.match-help ol { display: grid; gap: .625rem; padding-left: 1.5rem; margin-bottom: 1rem; text-align: left; }
.match-help-keyboard { margin-top: 1rem; margin-bottom: 1rem; border-top: .0625rem solid var(--border); padding-top: .875rem; text-align: left; }
.match-help-keyboard h3 { margin: 0 0 .625rem; font: 600 .75rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.match-help-keys { display: grid; grid-template-columns: 1fr; gap: .375rem; list-style: none; padding: 0; margin: 0; font-size: .8125rem; }
.match-help-keys li { display: flex; align-items: center; gap: .625rem; }
.match-help-keys li > span { display: inline-flex; gap: .25rem; min-width: 5.75rem; }
.match-help-keys kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.5rem; padding: 0 .375rem; border-radius: .25rem; border: 1px solid var(--border); background: var(--background, #101112); font-family: monospace; font-size: .75rem; font-weight: 600; color: var(--text); }
.skater { position: absolute; width: 5%; aspect-ratio: 1; transform: translate(-50%, -50%); }
.skater svg, .skater img { width: 100%; height: 100%; display: block; }

/* Launch and HUD actions in stadium */
.stadium-actions {
  display: grid;
  grid-template-columns: minmax(0, 9rem) repeat(2, minmax(0, 10rem));
  justify-content: center;
  align-items: center;
  gap: clamp(.25rem, 1vw, .75rem);
  padding: .375rem .5rem .625rem;
}
.stadium-actions :is(.stadium-super-btn, #launch) {
  width: 100%;
  min-width: 0;
  height: 2.75rem;
  min-height: 0;
  padding: 0 .25rem;
  border-radius: 999px;
  white-space: nowrap;
  font-size: .75rem;
}
.stadium-super-controls { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .375rem; }
#super-info { width: 2.25rem; height: 2.25rem; min-width: 2.25rem; min-height: 2.25rem; padding: 0; border-radius: 50%; }
#super-info .icon { width: 1.125rem; height: 1.125rem; }
#super-ready-hint:not([hidden]) {
  position: absolute; left: 50%; bottom: calc(100% + .375rem); transform: translateX(-50%); z-index: 25;
  padding: .1875rem .625rem; border-radius: 999px; border: .0625rem solid #ff7197;
  background: var(--card); color: var(--text); font-size: .75rem; font-weight: 600; white-space: nowrap;
  box-shadow: var(--panel-shadow); pointer-events: none;
}
.classic-match .stadium-super-controls { visibility: hidden; }
.super-info-panel { max-width: min(18rem, calc(100vw - 2rem)); padding: .75rem; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: .75rem; }
.stadium-actions > #launch, #stadium-super-text { overflow: hidden; text-overflow: ellipsis; }
.stadium-actions > #launch:not([hidden]) {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.shot-controls { min-width: 0; }
.shot-buttons { display: flex; justify-content: center; gap: .25rem; margin-top: .25rem; }
.shot-buttons button {
  display: flex; align-items: center; gap: .125rem; min-height: 1.75rem;
  padding: 0 .25rem; font-size: .625rem;
}
#launch-plan:not([hidden]) { display: block; font-size: .625rem; }
#stadium-super-text { min-width: 0; }
.online-match-actions {
  grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; gap: .5rem;
  min-width: 0; white-space: nowrap;
}
.online-match-actions:not(:has(> :not([hidden]))) { display: none; }
.online-match-actions button { flex: none; }
.stadium-super-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .125rem;
  font-weight: 700;
  border-radius: 1.3125rem;
  border: .0625rem solid var(--border);
  background: var(--elevated);
  color: var(--muted);
  cursor: default;
  transition: all 0.15s ease;
  user-select: none;
  touch-action: manipulation;
}
.stadium-super-btn .super-icon {
  flex: none;
  width: 1rem;
  height: 1rem;
}
.stadium-super-btn:not(:disabled) {
  background: color-mix(in srgb, #ff7197 22%, var(--card));
  border-color: #ff7197;
  color: #ffffff;
  box-shadow: var(--bevel), 0 0 .75rem rgba(255, 113, 151, 0.45);
  cursor: pointer;
}
.stadium-super-btn.armed {
  background: #ff7197;
  color: #0b0d10;
  border-color: #ffffff;
  box-shadow: var(--bevel), 0 0 1.125rem rgba(255, 113, 151, 0.9);
}
.stadium.goal-phase #stadium-super-btn {
  visibility: hidden;
}
#launch {
  font-weight: 700;
  box-shadow: var(--bevel), 0 .25rem 1rem rgba(255, 153, 84, 0.35);
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
#launch:hover:not(:disabled, :active) {
  transform: translateY(-.0625rem);
  box-shadow: var(--bevel), 0 .375rem 1.25rem rgba(255, 153, 84, 0.5);
}

/* Goal phase: the kickoff button stays below the rink so the goal and its replay stay visible */
.stadium.goal-phase #launch {
  box-shadow: 0 .5rem 2rem #000e, 0 0 0 .1875rem var(--primary), 0 0 1.75rem rgba(255, 153, 84, 0.7);
  animation: pulse-kickoff 1.4s ease-in-out infinite alternate;
}
@keyframes pulse-kickoff {
  0% { box-shadow: 0 .5rem 2rem #000e, 0 0 0 .125rem var(--primary), 0 0 1rem rgba(255, 153, 84, 0.4); }
  100% { box-shadow: 0 .875rem 2.5rem #000f, 0 0 0 .25rem var(--primary), 0 0 2.25rem rgba(255, 153, 84, 0.9); }
}

/* Portrait orientation for stadium */
.stadium.portrait-mode .rink-stage {
  aspect-ratio: 3 / 5;
  max-width: 100%;
  margin: 0 auto;
}
.stadium.portrait-mode .rink-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center center;
}
@media (orientation: portrait) and (max-width: 650px) {
  .stadium-toolbar { right: .5rem; gap: .25rem; }
  .stadium-tool-btn { width: 1.875rem; height: 1.875rem; padding: .3125rem; border-radius: .375rem; }
  .stadium-tool-btn svg { width: 1rem; height: 1rem; }
  .stadium-actions { gap: .5rem; padding: .375rem .75rem .75rem; }
}

/* Separate selection, character actions, and the team-wide turn action. */
.team .card-select { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.team .card-select:disabled { opacity: 1; }

/* Prominent ability art and touch-friendly spin control outside the aiming area. */
.super-icon { width: 2.25rem; height: 2.25rem; padding: .125rem; }
.super-name-badge { gap: .5rem; }
.super-panel .super-name-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Bare spin slider follows the selected ubu in screen space. */
#field-spin { position: absolute; z-index: 30; display: flex; align-items: center; gap: .375rem; width: min(9.125rem, calc(100% - .75rem)); height: 2.75rem; margin: 0; padding: 0; }
#field-spin[hidden] { display: none; }
#field-spin svg { flex: none; width: 1.25rem; height: 1.25rem; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
#shot-spin { appearance: none; display: block; min-width: 0; width: 100%; height: 2.75rem; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
#shot-spin::-webkit-slider-runnable-track { height: .25rem; border-radius: .125rem; background: linear-gradient(to right, var(--muted) var(--spin-start, 50%), var(--primary) var(--spin-start, 50%), var(--primary) var(--spin-end, 50%), var(--muted) var(--spin-end, 50%)); }
#shot-spin::-webkit-slider-thumb { appearance: none; width: .875rem; height: .875rem; margin-top: -.3125rem; border-radius: 50%; border: 0; background: var(--primary); }
#shot-spin::-moz-range-track { height: .25rem; border-radius: .125rem; background: linear-gradient(to right, var(--muted) var(--spin-start, 50%), var(--primary) var(--spin-start, 50%), var(--primary) var(--spin-end, 50%), var(--muted) var(--spin-end, 50%)); }
#shot-spin::-moz-range-thumb { width: .875rem; height: .875rem; border-radius: 50%; border: 0; background: var(--primary); }
#shot-spin:disabled { opacity: .45; cursor: default; }

.stadium.portrait-mode.goal-phase #launch { animation: none; padding: .5rem 1rem; }
#field-spin button { display: grid; place-items: center; flex: none; width: 2rem; min-height: 2.75rem; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
#field-spin { gap: .125rem; }

.field-badges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

.skater { left: 0; top: 0; will-change: transform; }
.skater canvas { display: block; width: 100%; height: 100%; }

/* Field sizing must not feed its previous fitted dimensions back into the grid. */
.stadium.portrait-mode .stadium-stage-area { contain: size layout; min-width: 0; }
.stadium.portrait-mode .rink-stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* Keep status available to assistive technology without resizing the rink. */
#game-status { position: absolute !important; width: .0625rem; height: .0625rem; min-height: 0 !important; padding: 0 !important; margin: -.0625rem !important; overflow: hidden; clip-path: inset(50%); }
.stadium.portrait-mode .stadium-stage-area { width: 100%; height: 100%; overflow: hidden; }

/* Isolate spin overlay overflow and visibility from the fullscreen sizing tree. */
.spin-layer { position: absolute; inset: 0; contain: strict; overflow: clip; pointer-events: none; z-index: 30; }
#field-spin { left: 0; top: 0; width: 9.125rem; max-width: calc(100% - .75rem); height: 2.75rem; box-sizing: border-box; visibility: hidden; pointer-events: auto; }
#shot-spin { font-size: 1rem; }

/* Touch aiming magnifying glass on phone screens (Drag arrow scheme). */
.aim-loupe {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  width: clamp(6rem, 28vmin, 7.75rem);
  height: clamp(6rem, 28vmin, 7.75rem);
  pointer-events: none;
  user-select: none;
  will-change: transform;
}
.aim-loupe-lens {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-sizing: border-box;
  border: .15625rem solid var(--team-home);
  background: var(--background);
  box-shadow:
    0 0 0 .125rem rgb(16 18 23 / .92),
    0 .625rem 1.75rem rgb(0 0 0 / .62),
    inset 0 0 0 .0625rem rgb(255 255 255 / .22);
  overflow: hidden;
}
.aim-loupe-lens::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 24%, rgb(255 255 255 / .22), rgb(255 255 255 / .04) 36%, transparent 62%),
    radial-gradient(circle at 50% 50%, transparent 66%, rgb(0 0 0 / .28) 100%);
}
.aim-loupe canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.aim-loupe-pointer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.aim-loupe-pointer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: .75rem;
  height: .5rem;
  transform: translate(-50%, calc(var(--loupe-radius, 3.5rem) - .0625rem));
  background: var(--team-home);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 .125rem .1875rem rgb(0 0 0 / .65));
}

.classic-match .super-panel { display: none; }
.classic-match #stadium-super-btn { visibility: hidden; }
#blitz-clock { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; margin-left: .375rem; }
/* Online setup follows the site's slate modal and control palette. */
#online-dialog { width: min(35rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); overflow: auto; padding: 1.5rem; border: .0625rem solid var(--border); border-radius: 1.375rem; background: var(--card); color: var(--text); }
#online-dialog label { display: block; margin: .75rem 0; }
#online-dialog::backdrop { background: #000b; }
body:has(#online-dialog[open]) { overflow: hidden; }
.online-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.online-heading p { margin: .375rem 0 0; color: var(--muted); }
.online-mode-line { display: flex; align-items: center; gap: .625rem; margin: 0 0 1.25rem; font-family: var(--font-display); font-weight: 700; }
.online-mode-line strong { font-weight: 700; color: var(--primary); }
.online-hint { color: var(--muted); font-size: .75rem; line-height: 1.6; margin: .75rem 0 1.25rem; }
#online-create { width: 100%; }
#online-status { display: block; min-height: 1.25rem; margin: .625rem 0 0; font-size: .875rem; }
#online-status[hidden], #online-status:empty { display: block; visibility: hidden; }
.online-account { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-top: .625rem; padding-top: 1rem; border-top: .0625rem solid var(--border); color: var(--muted); font-size: .75rem; }
@media (orientation: portrait) and (max-width: 400px) { #online-dialog { padding: 1rem; } }

/* Super meter: a glint at the growing end on each gain, and a shimmer when full. */
.super-meter-fill { position: relative; }
.super-meter-fill.gain::after { content: ''; position: absolute; top: -.125rem; bottom: -.125rem; right: -.125rem; width: .625rem; border-radius: .3125rem; background: radial-gradient(closest-side, #fff, #fff0); animation: meter-gain .5s ease-out forwards; }
@keyframes meter-gain { from { opacity: 1; transform: scaleX(1.8); } to { opacity: 0; transform: scaleX(.6); } }
.super-meter-fill.full { background: linear-gradient(90deg, #ff7197, #ffd166, #ff9954, #ff7197); background-size: 300% 100%; animation: meter-full 1.6s linear infinite; }
.super-meter-track:has(.full) { box-shadow: 0 0 .5rem #ff995466; border-color: #ffd16655; }
@keyframes meter-full { to { background-position: -300% 0; } }
@media (prefers-reduced-motion: reduce) { .super-meter-fill.gain::after, .super-meter-fill.full { animation: none; } }

/* Match setup panel: docks over the away half on wide screens and stacks below the rink on phones. */
.team-sheet {
  position: fixed; inset: var(--setup-top, 4.5rem) max(1rem, var(--safe-right, 0px)) max(1rem, var(--safe-bottom, 0px)) 50%; z-index: 40;
  display: none; flex-direction: column; overflow: hidden; padding: 0; margin: 0;
  border: .0625rem solid var(--border); border-radius: 1.375rem;
  background: var(--card); color: var(--text);
  translate: calc(100% + 2rem) 0;
  transition: translate .45s cubic-bezier(.3, .8, .2, 1), display .45s allow-discrete;
}
.team-sheet.open { display: flex; translate: 0 0; }
@starting-style { .team-sheet.open { translate: calc(100% + 2rem) 0; } }
@media (prefers-reduced-motion: reduce) { .team-sheet { transition: none; } }
@media (orientation: landscape) and (not ((pointer: coarse) and (max-height: 600px))) {
  #online-dialog { width: min(42rem, calc(100% - 1.5rem)); }
  .replays-dialog { width: min(46rem, calc(100% - 1.5rem)); }
  .share-dialog { width: min(34rem, calc(100% - 1.5rem)); }
}
.team-sheet-close { position: absolute; top: .75rem; right: .75rem; z-index: 3; }
.sheet-step { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 1rem; }
.team-sheet[data-step="mode"] .team-step, .team-sheet[data-step="team"] .mode-step,
.team-sheet[data-step="mode"] #start-match, .team-sheet[data-step="team"] #sheet-next,
.team-sheet:not([data-for="cpu"]) .cpu-levels { display: none; }
.team-sheet[data-for="rules"] #sheet-next { display: block; }
.team-sheet-foot { flex: none; padding: .75rem 1rem calc(.75rem + var(--safe-bottom)); border-top: .0625rem solid var(--border); background: var(--card); }
.team-sheet-foot button { width: 100%; min-height: 3.5rem; border-radius: 1rem; font-size: 1.25rem; }
.team-sheet[data-step="mode"][data-for="cpu"] .team-sheet-foot {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: .625rem;
}
#sheet-start { display: grid; justify-items: center; align-content: center; gap: .25rem; line-height: 1.15; }
#sheet-team-name { max-width: 100%; overflow-wrap: anywhere; font-size: .875em; }
#sheet-team-preview { display: flex; justify-content: center; gap: .375rem; }
#sheet-team-preview svg, #sheet-team-preview img { display: block; width: 1.75rem; height: 1.75rem; }

/* Mode screen: the logo across the sheet, then the three rules (any combination) in their colours. */
.mode-step { justify-content: center; gap: .875rem; overflow-y: auto; overscroll-behavior: contain; padding-block: .75rem; }
.mode-logo { margin: 0; padding: 0 2.75rem; }
.mode-logo img { display: block; width: 100%; max-height: clamp(4rem, calc(100dvh * 0.22), 13.75rem); object-fit: contain; }
.mode-intro { margin: 0; color: var(--muted); font-family: var(--font-display); font-weight: 700; font-size: clamp(.875rem, calc(100vw * 0.024), 1.125rem); text-align: center; }
.mode-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .625rem; margin: 0; padding: 0; border: 0; }
.mode-option[data-rule="classic"] { --mode: #E8CA48; --mode-ink: #1d1600; }
.mode-option[data-rule="pulse"] { --mode: #DA4DB5; --mode-ink: #fff; }
.mode-option[data-rule="blitz"] { --mode: #0066FF; --mode-ink: #fff; }
.mode-option {
  position: relative; container-type: inline-size; display: grid; justify-items: center; align-content: center; gap: .375rem; min-width: 0;
  padding: 1rem .375rem .875rem; border: .125rem solid var(--border); border-radius: 1.125rem; background: var(--elevated); text-align: center; cursor: pointer;
}
.mode-option input, .cpu-levels input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option strong { color: var(--mode); font-family: var(--font-display); font-size: clamp(1.375rem, 30cqi, 3.75rem); font-weight: 700; line-height: 1; }
.mode-option small { color: var(--muted); font-family: var(--font-display); font-weight: 700; font-size: clamp(.8125rem, 8cqi, 1.25rem); line-height: 1.2; }
/* The whole card is the toggle; a rule that is on glows in its colour and wears a check badge on
   its corner. */
.mode-check {
  position: absolute; top: -.5625rem; right: -.5625rem; z-index: 1; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: var(--mode); color: var(--mode-ink); box-shadow: 0 .125rem 0 rgb(0 0 0 / .3); scale: 0; transition: scale .18s cubic-bezier(.2, .9, .3, 1.4);
}
.mode-check .icon { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.mode-option:has(input:checked) { border-color: var(--mode); background: color-mix(in srgb, var(--elevated), var(--mode) 16%); box-shadow: var(--bevel), 0 0 1.125rem color-mix(in srgb, var(--mode), transparent 65%); }
.mode-option:has(input:checked) small { color: var(--text); }
.mode-option:has(input:checked) .mode-check { scale: 1; }
@media (orientation: portrait) and (max-width: 520px) { .mode-check { top: -.4375rem; right: -.4375rem; width: 1.375rem; height: 1.375rem; } .mode-check .icon { width: .875rem; height: .875rem; } }
.mode-summary { margin: 0; color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: clamp(1rem, calc(100vw * 0.028), 1.375rem); text-align: center; }
.mode-option:has(input:focus-visible), .cpu-levels label:has(input:focus-visible) { outline: .125rem solid var(--mode, var(--primary)); outline-offset: .125rem; }
.cpu-levels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; margin: 0; padding: 0; border: 0; }
.cpu-levels legend { margin-bottom: .5rem; padding: 0; font-size: 1.125rem; }
.cpu-levels label { position: relative; grid-column: span 2; min-width: 0; cursor: pointer; }
.cpu-levels:has([data-tier="ballistic"][hidden]) label:nth-of-type(n + 4) { grid-column: span 3; }
.cpu-levels span {
  display: grid; place-items: center; min-height: 2.875rem; padding: 0 .375rem; border: .125rem solid var(--border); border-radius: .875rem;
  background: var(--elevated); font-family: var(--font-display); font-weight: 700; font-size: clamp(.9375rem, calc(100vw * 0.028), 1.3125rem); text-align: center; white-space: nowrap;
}
.cpu-levels input:checked + span { border-color: var(--primary); background: var(--primary); color: #1f1206; }
.cpu-levels label[data-tier="insane"] input:checked + span {
  border-color: #ff5c39; background: #ff5c39; color: #1d0804; box-shadow: var(--bevel), 0 0 .875rem rgb(255 92 57 / .4);
}
.cpu-levels label[data-tier="god"] input:checked + span {
  border-color: #ffd84d; background: linear-gradient(135deg, #c266ff, #ff8f3d 55%, #ffd84d); color: #170a24;
  box-shadow: var(--bevel), 0 0 1.125rem rgb(218 115 255 / .5);
}
.cpu-levels label[data-tier="ballistic"] input:checked + span {
  border-color: #72edff; background: #72edff; color: #06242c; box-shadow: var(--bevel), 0 0 .875rem rgb(114 237 255 / .45);
}

/* Team screen. */
.team-step { padding-top: .75rem; }
.team-step-head { display: flex; align-items: center; gap: .625rem; min-height: 2.75rem; padding-right: 3.25rem; margin-bottom: .625rem; }
.team-step-head .quiet { flex: none; padding: .5rem .75rem; white-space: nowrap; }
.team-heading { display: grid; min-width: 0; }
.team-step-head h2 { margin: 0; font-size: 1.375rem; line-height: 1.1; white-space: nowrap; }
.team-mode { overflow: hidden; color: var(--muted); font-family: var(--font-display); font-weight: 700; font-size: .8125rem; text-overflow: ellipsis; white-space: nowrap; }
/* On-ice kickoff position cards (--x, --y, --r from physics kickoff spots). */
.roster-slots { position: absolute; inset: 0; z-index: 6; display: block; pointer-events: none; }
.roster-slots:empty { display: none; }
.formation-slot {
  --art: calc(var(--r, 5) * 1cqw); --head: 1.375rem;
  position: absolute; left: var(--x); top: var(--y); translate: -50% calc(-.375rem - var(--head) - var(--art) / 2);
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; justify-items: center;
  gap: .25rem; width: 12.5cqw; min-width: 0; padding: .375rem .375rem .5rem;
  border: .125rem solid var(--border); border-radius: 1.25rem;
  background: color-mix(in srgb, var(--elevated) 55%, transparent); pointer-events: auto;
  transition: border-color .15s, background .15s;
}
.formation-slot.is-selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 16%, transparent); }
.formation-slot.is-empty { border-style: dashed; }
.formation-slot.drop-target { border-color: var(--team-home); background: color-mix(in srgb, var(--elevated), var(--team-home) 18%); }
.formation-slot.just-changed { animation: slot-changed .6s ease-out; }
@keyframes slot-changed { from { box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--team-home) 70%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
.formation-pick {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: 0; align-items: center;
  width: 100%; min-width: 0; min-height: 0; padding: 0; border: 0; background: none; color: var(--text); text-align: center; box-shadow: none;
}
.formation-pick:hover { background: none; }
.formation-pos { grid-column: 1 / -1; height: var(--head); color: var(--muted); font: 600 .75rem/var(--head) var(--font-body); letter-spacing: .12em; text-transform: uppercase; }
.formation-slot.is-selected .formation-pos { color: var(--primary); }
.formation-art { width: var(--art); height: var(--art); }
.formation-empty-art { display: block; border: .125rem dashed var(--border); border-radius: 50%; }
.formation-name { display: grid; justify-items: center; max-width: 100%; min-width: 0; margin-top: .25rem; }
.formation-name strong { max-width: 100%; overflow: hidden; font-size: clamp(.6875rem, 1.3cqw, .9375rem); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.formation-name small { max-width: 100%; overflow: hidden; color: var(--muted); font: .6875rem var(--font-body); text-overflow: ellipsis; white-space: nowrap; }
@container (width < 75rem) { .formation-slot:not(.is-empty) .formation-name small { display: none; } }
.formation-super {
  grid-column: 1; justify-self: center; display: inline-flex; align-items: center; gap: .25rem; min-height: 0; max-width: 100%; padding: .1875rem .5rem .1875rem .25rem;
  border: .0625rem solid var(--border); border-radius: 62.4375rem; background: var(--card); color: var(--secondary); font: clamp(.625rem, 1.1cqw, .75rem) var(--font-body);
}
.formation-super img { flex: none; width: 1.25rem; height: 1.25rem; }
.formation-super span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.formation-super svg { flex: none; width: .875rem; height: .875rem; color: var(--muted); }
.formation-super svg, .formation-tool svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.formation-super[aria-expanded="true"] { border-color: var(--secondary); }
.formation-tools { position: absolute; top: .375rem; right: .375rem; bottom: auto; display: grid; gap: .25rem; }
/* Position tools are bare icons: no button chrome, only a color change on hover. */
.formation-tool { width: 1.5rem; height: 1.5rem; min-height: 0; padding: 0; border: 0; background: none; color: var(--muted); box-shadow: none; }
.formation-tool svg { width: 1.25rem; height: 1.25rem; }
.formation-tool:hover, .formation-tool:focus-visible { background: none; color: var(--text); }
[data-locked] .roster-scroll { opacity: .55; pointer-events: none; }
/* A position's super choices: icon, name with mastery, and what it does. */
.super-popover { padding: .625rem; border-color: var(--secondary); }
.roster-super-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.roster-super-head h3 { margin: 0; font-size: .9375rem; }

/* Up to four choices a row; phones take two. */
.super-choice-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 13.125rem)); gap: .375rem; }
@media (orientation: portrait) and (max-width: 600px) { .super-choice-grid { grid-template-columns: repeat(var(--cols-narrow, 2), minmax(0, 1fr)); } }
.super-choice {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: .5rem; justify-items: start;
  min-height: 0; padding: .375rem .5rem; border: .125rem solid transparent; border-radius: .75rem; background: var(--card); text-align: left;
}
.super-choice img { grid-row: span 2; width: 2.25rem; height: 2.25rem; }
.super-choice strong { font-size: .875rem; font-weight: 700; }
.super-choice small { color: var(--muted); font: .6875rem/1.3 var(--font-body); }
.super-choice[aria-pressed="true"] { border-color: var(--secondary); }
.roster-hint { margin: .375rem 0 .25rem; color: var(--text); font-size: .8125rem; }
.roster-hint:empty { display: none; }
/* Saved teams: step through them, pick from the list, save or manage. */
.team-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; margin-bottom: .5rem; }
.team-bar > button { min-height: 2.25rem; padding: .375rem .75rem; font-size: .875rem; }
.team-step-btn { width: 2.25rem; padding: 0 !important; }
.team-step-btn .icon { width: 1.25rem; height: 1.25rem; }
.team-bar .game-select { flex: 1 1 8.75rem; min-height: 2.25rem; padding: .375rem .625rem; border: .0625rem solid var(--border); border-radius: .625rem; background: var(--card); font: .875rem var(--font-body); }
.team-menu:popover-open { display: grid; gap: .125rem; min-width: 11.25rem; }
.team-menu button { justify-content: flex-start; min-height: 2.25rem; border-radius: .5rem; background: none; font-size: .875rem; box-shadow: none; }
.team-menu button:hover { background: var(--hover); }
/* The online lobby's invite and status sit above the same team screen. */
.lobby-panel { position: relative; display: grid; gap: .375rem; margin-bottom: .5rem; padding: .625rem; border-radius: .875rem; background: var(--elevated); }
.lobby-invite { display: flex; gap: .375rem; }
.lobby-invite input { flex: 1; min-width: 0; padding: .5rem .625rem; border: .0625rem solid var(--border); border-radius: .625rem; background: var(--background); color: var(--text); font: .8125rem var(--font-body); }
.lobby-invite button, .lobby-actions .button, .lobby-actions button { min-height: 2.25rem; padding: .375rem .75rem; font-size: .875rem; }
.lobby-status:not([hidden]) {
  position: absolute; top: 3.125rem; inset-inline: .625rem; z-index: 2; margin: 0; padding: .5rem .625rem;
  border: .0625rem solid var(--primary); border-radius: .625rem; background: var(--card); color: var(--text);
  font-size: .875rem; box-shadow: var(--panel-shadow);
}
.lobby-note { margin: 0; color: var(--muted); font-size: .75rem; }
.lobby-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .375rem; }
[data-for="lobby"] #team-back[hidden] { display: none; }

.roster-status { margin: .25rem 0; color: var(--muted); font-size: .75rem; }
.roster-status:empty { display: none; }
.roster-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -1rem; padding: 0 1rem .75rem; overscroll-behavior: contain; }
.roster-signin { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem; border-radius: .875rem; background: var(--elevated); }
.roster-signin p { margin: 0; font-size: .8125rem; }
/* Picker tiles are smaller than Collection's; the toolbar stays put while the list scrolls. */
.roster-toolbar { position: sticky; top: 0; z-index: 2; margin: 0 -1rem; padding: 0 1rem; background: var(--card); }
.roster-toolbar .ubu-toolbar { margin: 0 0 .5rem; padding-top: .125rem; }
.roster-grid { grid-template-columns: repeat(auto-fill, minmax(max(7rem, calc((100% - 1.625rem) / 4)), 1fr)); gap: .5rem; margin: 0; }
.roster-grid .ubu-tile-main { gap: .25rem; padding: .75rem .25rem .5rem; border-radius: .875rem; background-color: var(--elevated); }
.roster-grid .ubu-tile-art { width: 3.5rem; height: 3.5rem; }
/* Camera moves (camera() in ububall.js): the rink stage is played from its old box to its new one,
   so nothing above it may clip it on the way. */
html:has(.stadium.camera-moving), body:has(.stadium.camera-moving) { overflow-x: clip; }
html:has(body:not([data-shot="collection"]) .stadium.camera-moving),
body:not([data-shot="collection"]):has(.stadium.camera-moving) { overflow-y: clip; }
.stadium.camera-moving, .stadium.camera-moving .stadium-stage-area { overflow: visible; }
.stadium.camera-moving .stadium-stage-area { z-index: 30; }
.stadium.camera-moving .rink-stage { will-change: transform; }
/* The cast is away: the ice is drawn empty and its sprites and badges wait out of sight. */
.rink-wrap.cast-away :is(#skaters, .field-badges) { visibility: hidden; }

/* The rules and team setup shots (see docs/rink-stage.md): on a wide screen the rink grows to
   game size, the team sheet docks over the away half, and the lineup stands on the ice. */
body:is([data-shot="team"], [data-shot="rules"]) { overflow: hidden; }
body:is([data-shot="team"], [data-shot="rules"]) .arena-layout { grid-column: 1 / -1; }
body:is([data-shot="team"], [data-shot="rules"]) :is(.play-home, .scoreboard),
body:is([data-shot="team"], [data-shot="rules"]) .rink-stage > :is(.demo-badge, .demo-play, .demo-finger, .field-banner, #skip-goal-replay) { display: none; }
body:is([data-shot="team"], [data-shot="rules"]) .stadium-stage-area { min-height: calc(100dvh - var(--setup-top, 4.5rem) - max(1rem, var(--safe-bottom, 0px))); }
body:is([data-shot="team"], [data-shot="rules"]) .rink-stage { width: min(100%, calc((100dvh - var(--setup-top, 4.5rem) - max(1rem, var(--safe-bottom, 0px))) * 5 / 3)); }
/* Phones and narrow screens stack the rink above the docked team sheet and keep the three kickoff
   slots clear across the ice. */
@media (orientation: portrait), (width < 56rem), ((pointer: coarse) and (max-height: 600px)) {
  body:is([data-shot="team"], [data-shot="rules"]) { height: 100dvh; overflow: hidden; padding-bottom: 0; }
  body:is([data-shot="team"], [data-shot="rules"]) :is(.site-header, .site-nav) { display: none; }
  body:is([data-shot="team"], [data-shot="rules"]) .ball-page {
    display: flex; flex-direction: column; align-items: center; gap: .3125rem;
    width: min(55rem, calc(100% - .5rem)); height: 100dvh; margin: 0 auto;
    padding-top: max(.25rem, var(--safe-top, 0px));
    padding-bottom: max(.375rem, var(--safe-bottom, 0px));
  }
  body:is([data-shot="team"], [data-shot="rules"]) .arena-layout { order: -1; flex: none; width: 100%; }
  body:is([data-shot="team"], [data-shot="rules"]) .stadium-stage-area { min-height: 0; }
  body:is([data-shot="team"], [data-shot="rules"]) .rink-stage {
    width: min(100%, max(17.5rem, calc(36dvh * 5 / 3)));
    margin: -2.5% auto;
  }
  .team-sheet {
    position: relative; inset: auto; z-index: 20;
    flex: 1; min-height: 0; height: auto;
    width: 100%; max-width: none; padding-top: 0;
    border: .0625rem solid var(--border); border-radius: 1.125rem;
    translate: 0 0; transition: opacity .18s ease-out, translate .18s ease-out;
  }
  .team-sheet .team-sheet-foot { padding: .5rem .75rem; }
  .team-sheet .team-sheet-foot button { min-height: 2.75rem; font-size: 1.0625rem; }
  .team-sheet .mode-step { justify-content: flex-start; gap: .5rem; padding-block: .5rem; }
  .team-sheet .mode-logo img { max-height: clamp(2.25rem, 8dvh, 4.5rem); }
  .team-sheet .mode-option { padding: .625rem .25rem .5rem; }
  .team-sheet .cpu-levels span { min-height: 2.3125rem; }
  @starting-style { .team-sheet.open { opacity: 0; translate: 0 .625rem; } }
  .team-sheet .team-sheet-close { top: .375rem; right: .5rem; width: 1.875rem; height: 1.875rem; min-height: 0; padding: .25rem; }
  .team-sheet .sheet-step { padding: 0 .75rem; }
  .team-sheet .team-step { padding-top: .375rem; }
  .team-sheet .team-step-head { min-height: 2rem; gap: .5rem; padding-right: 2.375rem; margin-bottom: .25rem; }
  .team-sheet .team-step-head .quiet { min-height: 1.875rem; padding: .25rem .5625rem; font-size: .8125rem; }
  .team-sheet .team-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .125rem .4375rem; }
  .team-sheet .team-step-head h2 { font-size: 1.0625rem; }
  .team-sheet .team-mode { font-size: .75rem; }
  .team-sheet .team-bar { flex-wrap: nowrap; gap: .25rem; margin-bottom: .1875rem; }
  .team-sheet .team-bar > button { min-height: 1.875rem; padding: .1875rem .5rem; font-size: .75rem; white-space: nowrap; }
  .team-sheet .team-bar .team-step-btn { width: 1.875rem; flex: none; }
  .team-sheet .team-bar .game-select { flex: 1 1 0; min-width: 0; min-height: 1.875rem; padding: .1875rem .5rem; font-size: .75rem; }
  .team-sheet .roster-hint { margin: 0 0 .25rem; font-size: .6875rem; line-height: 1.2; }
  .team-sheet .roster-scroll { margin: 0 -.75rem; padding: 0 .75rem .5rem; }
  .team-sheet .roster-toolbar { position: static; margin: 0; padding: 0; background: none; }
  .team-sheet .roster-toolbar .ubu-toolbar { gap: .25rem; margin: .125rem 0 .375rem; padding-top: 0; }
  .team-sheet .roster-toolbar .ubu-search { min-height: 1.9375rem; padding: .25rem 2rem .25rem .5625rem; font-size: .75rem; }
  .team-sheet .roster-toolbar .ubu-filters-toggle { width: 1.9375rem; height: 1.9375rem; min-height: 0; padding: .3125rem; }
  .team-sheet .roster-toolbar .ubu-help-toggle { width: 1.5rem; height: 1.5rem; right: .25rem; }
  .team-sheet .roster-toolbar .ubu-help-toggle .icon { width: 1.125rem; height: 1.125rem; }
  .roster-slots .formation-slot {
    border-radius: .875rem;
    background: color-mix(in srgb, var(--elevated) 78%, transparent);
    backdrop-filter: blur(.25rem);
  }
  .roster-slots .formation-slot.is-selected {
    background: color-mix(in srgb, var(--elevated) 65%, var(--primary) 28%);
  }
  .roster-slots .formation-slot[data-position="back"] {
    --art: clamp(1.875rem, 9cqw, 2.75rem);
    --head: 1.0625rem;
    left: 6.5%; top: 50%; translate: 0 -50%;
    width: 31%; max-width: 9.5rem;
    gap: .125rem; padding: .25rem .25rem .3125rem;
  }
  .roster-slots .formation-slot[data-position="back"] .formation-pick { width: 100%; overflow: hidden; }
  .roster-slots .formation-slot[data-position="back"] .formation-pos { justify-self: start; padding-left: .125rem; font-size: .5625rem; }
  .roster-slots .formation-slot[data-position="back"] .formation-name { width: 100%; min-width: 0; margin-top: .125rem; overflow: hidden; }
  .roster-slots .formation-slot[data-position="back"] .formation-name strong {
    display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
    font-size: clamp(.6875rem, 2.15cqw, .8125rem); line-height: 1.12; white-space: nowrap;
  }
  .roster-slots .formation-slot[data-position="back"] .formation-name small { display: none; }
  .roster-slots .formation-slot[data-position="back"] .formation-super {
    max-width: 100%; padding: .125rem .3125rem .125rem .1875rem; font-size: .625rem; gap: .1875rem;
  }
  .roster-slots .formation-slot[data-position="back"] .formation-super img { width: .9375rem; height: .9375rem; }
  .roster-slots .formation-slot[data-position="back"] .formation-super svg { width: .6875rem; height: .6875rem; }
  .roster-slots .formation-slot[data-position="back"] .formation-tools { top: .1875rem; right: .1875rem; display: flex; gap: .125rem; }
  .roster-slots .formation-slot[data-position="back"] .formation-tool { width: 1.1875rem; height: 1.1875rem; }
  .roster-slots .formation-slot[data-position="back"] .formation-tool svg { width: .9375rem; height: .9375rem; }
  .roster-slots .formation-slot:not([data-position="back"]) {
    --slot-art: clamp(1.875rem, 8.5cqw, 2.375rem);
    left: 39%; width: 54.5%; max-width: 19.5rem; translate: 0 -50%;
    display: grid; grid-template-columns: minmax(0, 1fr);
    align-items: center; justify-items: stretch; row-gap: .125rem;
    padding: .25rem .375rem;
  }
  .roster-slots .formation-slot[data-position="top"] { top: 29.5%; }
  .roster-slots .formation-slot[data-position="bottom"] { top: 70.5%; }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-pick {
    grid-column: 1; grid-row: 1;
    display: grid; grid-template-columns: var(--slot-art) minmax(0, 1fr); grid-template-rows: auto auto;
    column-gap: .375rem; row-gap: .0625rem; align-items: center; justify-items: stretch;
    width: 100%; overflow: visible; text-align: left;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-art {
    grid-column: 1; grid-row: 1 / span 2;
    width: var(--slot-art); height: var(--slot-art);
  }
  .roster-slots .formation-slot:not([data-position="back"]):has(> .formation-super) .formation-art {
    translate: 0 .5rem;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-pos {
    grid-column: 2; grid-row: 1; height: auto; line-height: 1.1; font-size: .5625rem;
    padding-right: 2.625rem;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-name {
    grid-column: 2; grid-row: 2; margin-top: 0; width: 100%; min-width: 0; justify-items: stretch; overflow: hidden;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-name strong {
    display: block; overflow: hidden; text-overflow: ellipsis;
    font-size: clamp(.6875rem, 2.2cqw, .875rem); line-height: 1.15; white-space: nowrap;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-name small { display: none; }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-tools {
    position: absolute; top: .1875rem; right: .25rem; z-index: 2; display: flex; gap: .125rem;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-tool { width: 1.1875rem; height: 1.1875rem; }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-tool svg { width: .9375rem; height: .9375rem; }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-super {
    grid-column: 1; grid-row: 2; justify-self: start;
    margin-left: calc(var(--slot-art) + .375rem);
    max-width: calc(100% - var(--slot-art) - .375rem);
    padding: .125rem .375rem .125rem .1875rem; font-size: .625rem; gap: .1875rem;
  }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-super img { width: 1rem; height: 1rem; }
  .roster-slots .formation-slot:not([data-position="back"]) .formation-super svg { width: .75rem; height: .75rem; }
}
@media (max-width: 34rem) {
  .team-sheet .roster-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .375rem;
  }
  .team-sheet .roster-grid .ubu-tile-main {
    gap: .1875rem;
    padding: .5rem .25rem .375rem;
    border-radius: .75rem;
  }
  .team-sheet .roster-grid .ubu-tile-art {
    width: clamp(2.75rem, 13vw, 3.375rem);
    height: clamp(2.75rem, 13vw, 3.375rem);
  }
  .team-sheet .roster-grid .ubu-tile-name { font-size: .75rem; line-height: 1.1; }
  .team-sheet .roster-grid .ubu-tile-archetype { font-size: .625rem; line-height: 1.1; }
  .team-sheet .roster-grid .ubu-tile-meta { font-size: .625rem; gap: .125rem .25rem; }
  .team-sheet .roster-grid .ubu-tile-grade { font-size: .75rem; }
  .team-sheet .roster-grid .ubu-tile-supers { gap: .125rem; min-height: 1.125rem; }
  .team-sheet .roster-grid .ubu-tile-supers img { width: 1.125rem; height: 1.125rem; }
  .team-sheet .roster-grid :is(.ubu-tile-heart, .ubu-tile-inspect) {
    top: .1875rem; width: 1.5rem; height: 1.5rem; padding: .1875rem;
  }
  .team-sheet .roster-grid .ubu-tile-heart { right: .1875rem; }
  .team-sheet .roster-grid .ubu-tile-inspect { left: .1875rem; }
  .team-sheet .roster-grid :is(.ubu-tile-heart svg, .ubu-tile-inspect svg) { width: .9375rem; height: .9375rem; }
}
@media (orientation: portrait) and (max-height: 44rem), (width < 56rem) and (max-height: 44rem), (pointer: coarse) and (max-height: 600px) {
  .team-sheet .team-sheet-foot { padding: .375rem .75rem; }
  .team-sheet .team-sheet-foot button { min-height: 2.4375rem; font-size: 1rem; }
}
@media (orientation: portrait) and (max-height: 36rem), (width < 56rem) and (max-height: 36rem), (pointer: coarse) and (max-height: 36rem) {
  .team-sheet .mode-logo img { max-height: 2.5rem; }
  .team-sheet .mode-option { padding: .5rem .25rem; }
  .team-sheet .cpu-levels span { min-height: 2.125rem; }
}
/* Extreme short viewports (e.g., open software keyboard or heavy zoom): let the page scroll explicitly
   rather than clipping controls or squeezing content into a one-line inner scroller. */
@media (orientation: portrait) and (max-height: 21.99rem), (width < 56rem) and (max-height: 21.99rem), (pointer: coarse) and (max-height: 21.99rem) {
  body:is([data-shot="team"], [data-shot="rules"]) { height: auto; overflow-x: clip; overflow-y: auto; }
  body:is([data-shot="team"], [data-shot="rules"]) .ball-page {
    height: auto; min-height: 100dvh;
    padding-bottom: max(.75rem, var(--safe-bottom, 0px));
  }
  body:is([data-shot="team"], [data-shot="rules"]) .rink-stage {
    width: min(100%, 17.5rem); margin: 0 auto;
  }
  .team-sheet { flex: none; height: auto; overflow: visible; }
  .team-sheet .sheet-step { flex: none; overflow: visible; }
  .team-sheet .roster-scroll { flex: none; overflow: visible; }
}

/* Announcements over the rink ("Plan your shot…", "Launch!", the winner). */
.field-banner {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 0 .75rem; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 12cqmin, 4.75rem); line-height: 1; text-align: center; color: var(--text);
  -webkit-text-stroke: .08em #101217; paint-order: stroke fill; text-shadow: 0 .375rem 1.125rem #000a; opacity: 0;
}
/* A foul's explanation, opened from its warning beside the boards; placed by updateFoulInfo. */
.foul-info {
  position: absolute; z-index: 40; transform: translate(-50%, -50%); box-sizing: border-box;
  overflow: auto; padding: .875rem 1rem .75rem;
  background: var(--elevated); color: var(--text); border: .125rem solid #ffb020;
  border-radius: .75rem; box-shadow: 0 1rem 2.5rem rgb(0 0 0 / .45); font: .8125rem/1.45 var(--font-body);
}
.foul-info[hidden] { display: none; }
.foul-info h3 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; font: 700 1.125rem/1.2 var(--font-display); }
.foul-info h3 svg { flex: none; width: 1.25rem; height: 1.25rem; fill: none; stroke: #ffb020; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.foul-info p { margin: 0 0 .5rem; color: var(--muted); }
.foul-info p:last-child { margin-bottom: 0; }
.foul-info p.act { color: #ffb020; font-weight: 700; }
.foul-info button {
  display: block; width: 100%; margin-top: .75rem; padding: .5625rem .75rem; border: 0; border-radius: .5rem;
  background: #ffb020; color: #101217; font: 700 .9375rem/1 var(--font-display); cursor: pointer;
}
.foul-info button:hover { background: #ffc24d; }
.rink-stage { container-type: size; }
.field-banner[data-tone="launch"] { color: var(--primary); }
.field-banner[data-tone="home"] { color: var(--team-home); }
.field-banner[data-tone="away"] { color: var(--team-away); }
.field-banner.show { animation: field-banner var(--banner-ms, 1200ms) ease both; }
@keyframes field-banner {
  0% { opacity: 0; transform: scale(.6); }
  12% { opacity: 1; transform: scale(1.08); }
  20% { transform: scale(1); }
  85% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}
/* The demo's flashing tag and the pointer that acts out Saffron's planning. */
.demo-badge {
  display: none; position: absolute; left: 50%; bottom: 3%; z-index: 5; transform: translateX(-50%); pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(.8125rem, 3.4cqmin, 1.375rem); letter-spacing: .2em; color: var(--text);
  animation: demo-flash 1.4s ease-in-out infinite;
}
body.demo-match[data-shot="home"] .rink-stage > .demo-badge {
  display: block; top: 22%; right: 9%; bottom: auto; left: auto; transform: none;
}
#skip-goal-replay {
  position: absolute; inset: 0; z-index: 6; width: 100%; border: 0; background: transparent; box-shadow: none;
}
#skip-goal-replay .demo-badge { display: block; width: max-content; max-width: 95%; letter-spacing: .06em; text-shadow: 0 .125rem .25rem #000; }
#skip-goal-replay:focus-visible .demo-badge { animation: none; }
@keyframes demo-flash { 50% { opacity: .2; } }
.demo-finger {
  position: absolute; z-index: 7; width: clamp(2.5rem, 12cqmin, 4rem); height: auto; pointer-events: none;
  /* The fingertip (9.5, 22 in the icon) sits on the target point. */
  transform: translate(-39.6%, -91.7%); transform-origin: 39.6% 91.7%; transition: transform .12s ease;
  fill: #fff; stroke: #000; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 .0625rem #fff) drop-shadow(0 0 .0625rem #fff) drop-shadow(0 .1875rem .25rem #0007);
}
.demo-finger.pressed { transform: translate(-39.6%, -91.7%) scale(.88); }
/* Home: the demo rink is one big Play button under the hook line. */
.demo-play {
  display: none; position: absolute; inset: 0; z-index: 6; flex-direction: column; align-items: center; justify-content: space-between; min-height: 0; padding: 0;
  border: 0; border-radius: inherit; background: none; box-shadow: none; cursor: pointer; pointer-events: auto;
}
body.demo-match[data-shot="home"] .demo-play { display: flex; }
.demo-play:hover { background: none; }
.demo-play:focus-visible { outline: .1875rem solid var(--primary); outline-offset: -.1875rem; }
.demo-hook, .demo-cta {
  padding: 0 .75rem; color: var(--text); font-family: var(--font-display); font-weight: 700; line-height: 1;
  -webkit-text-stroke: .08em #101217; paint-order: stroke fill; text-shadow: 0 .3125rem 1rem #000a; transition: scale .15s ease;
}
.demo-hook { margin-top: 5%; font-size: clamp(1.375rem, 7.5cqmin, 3.25rem); }
.demo-cta { margin-bottom: 5%; font-size: clamp(1rem, 4.5cqmin, 2rem); }
.demo-play:hover .demo-hook { scale: 1.04; }
@media (prefers-reduced-motion: reduce) { .field-banner.show { opacity: 1; } }


/* Scorebug, broadcast style (see index.html). The score cells sit centred over the rink, the logo and
   rules cells to their left and the turn cell to their right; the menu and tools keep to the corners.
   fitScorebug picks the largest size (data-size) whose sides clear the menu and tools: full, then
   rules as letters, then "T3" for "Turn 3", then a smaller bug, then tighter still; and it holds the turn cell at the
   widest text this mode can show, so nothing shifts. Text is centred on its capitals where the
   browser can trim to them. Portrait match headers stack the brand, scores and turn status.
   The short landscape sidebar keeps the turn between the scores. */
.scoreboard {
  position: relative; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center;
  padding: .5rem 3.625rem;
}
.match-tools { display: flex; gap: .375rem; position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); }
.bug-left { justify-self: end; display: flex; min-width: 0; }
.bug-center { display: flex; }
.bug-right { justify-self: start; display: flex; }
.bug-brand, .bug-modes, .bug-team, .bug-status { position: relative; z-index: 1; display: flex; align-items: center; height: 2.5rem; box-sizing: border-box; overflow: hidden; }
.bug-brand img { height: clamp(1.375rem, 2.4vw, 2.25rem); width: auto; display: block; }
.bug-modes { gap: .5625rem; padding: 0 .6875rem; border-left: 0; }
.bug-modes:empty { display: none; }
.bug-mode { color: var(--mode); font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1; }
.bug-mode[data-rule="classic"] { --mode: #E8CA48; }
.bug-mode[data-rule="pulse"] { --mode: #DA4DB5; }
.bug-mode[data-rule="blitz"] { --mode: #0066FF; }
.scoreboard[data-size="compact"] .bug-mode span { display: none; }
.scoreboard[data-size="compact"] .bug-mode b { display: inline; }
.bug-mode b, .turn-short { display: none; font-weight: inherit; font-style: normal; }
.turn-long { font-style: normal; }
.home { color: var(--team-home); }
.away { color: var(--team-away); }
.bug-team { min-width: 0; font-size: 1rem; line-height: 1; text-transform: uppercase; letter-spacing: .04em; }
body.online-match .bug-team { text-transform: none; letter-spacing: .01em; }
.bug-team > span:not(.bug-score) { min-width: 0; max-width: 12ch; padding: 0 .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bug-score { align-self: stretch; display: flex; align-items: center; justify-content: center; min-width: 2.625rem; padding: 0 .5rem; background: #00000047; color: #fff; }
.bug-score strong { font-size: 1.5rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.bug-score.scored { animation: bug-scored 1.1s ease-out; }
.bug-score.scored strong { animation: bug-score-pop .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bug-scored { 0%, 25% { background: #ffffffb3; } 100% { background: #00000047; } }
@keyframes bug-score-pop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.35); opacity: 1; } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .bug-score.scored strong { animation: none; } }
.bug-home { background: var(--team-home); color: #1d1600; }
.bug-away { background: var(--team-away); color: #fff; }
.bug-status { position: relative; justify-content: center; gap: .4375rem; min-width: var(--status-width, 0); padding: 0 .75rem; border-left: 0; border-radius: 0 .375rem .375rem 0; color: var(--muted); font-size: .875rem; line-height: 1; white-space: nowrap; }
.bug-status b { color: var(--text); font-weight: 700; }
#blitz-clock { color: #5b9bff; font-variant-numeric: tabular-nums; }
.bug-clock { position: absolute; left: 0; right: 0; bottom: 0; height: .1875rem; background: #ffffff14; }
.bug-clock i { display: block; height: 100%; width: 100%; background: #0066FF; transform-origin: left; }
@supports (text-box: trim-both cap alphabetic) {
  .bug-mode, .bug-team > span, .bug-score strong, .bug-status > :is(b, span) { text-box: trim-both cap alphabetic; }
}
.scoreboard:is([data-size="letters"], [data-size="short"], [data-size="small"], [data-size="tiny"]) .bug-mode span { display: none; }
.scoreboard:is([data-size="letters"], [data-size="short"], [data-size="small"], [data-size="tiny"]) .bug-mode b { display: inline; }
.scoreboard:is([data-size="short"], [data-size="small"], [data-size="tiny"]) .turn-long { display: none; }
.scoreboard:is([data-size="short"], [data-size="small"], [data-size="tiny"]) .turn-short { display: inline; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) :is(.bug-brand, .bug-modes, .bug-team, .bug-status) { height: 2rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-brand { padding: 0 .5rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-brand img { height: 1rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-modes { gap: .3125rem; padding: 0 .5rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-mode { font-size: .8125rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-team { font-size: .8125rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-team > span:not(.bug-score) { padding: 0 .5rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-score { min-width: 2rem; padding: 0 .375rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-score strong { font-size: 1.1875rem; }
.scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-status { gap: .3125rem; padding: 0 .5625rem; font-size: .75rem; }
/* Tiny: the narrowest desktop (team columns beside a small window) tightens the cell edges too. */
.scoreboard[data-size="tiny"] :is(.bug-brand, .bug-modes) { padding: 0 .375rem; }
.scoreboard[data-size="tiny"] .bug-modes { gap: .25rem; }
.scoreboard[data-size="tiny"] .bug-team > span:not(.bug-score) { padding: 0 .375rem; letter-spacing: .02em; }
.scoreboard[data-size="tiny"] .bug-status { gap: .25rem; padding: 0 .375rem; font-size: .6875rem; }
/* Event tabs: goals, cards, warnings, power plays, match point. They hang from the bug's bottom edge
   (placed by nextBugTab) and slide out from behind its cells. */
.bug-tab {
  position: absolute; top: 100%; left: 50%; z-index: 0; padding: .25rem .875rem; border-radius: 0 0 .5rem .5rem;
  background: var(--tab, #ffb020); color: var(--tab-ink, #2a1a00); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  transform: translate(-50%, -110%); opacity: 0; pointer-events: none; transition: transform .25s ease, opacity .25s ease;
}
.bug-tab.show { transform: translate(-50%, 0); opacity: 1; }
.bug-tab[data-tone="home"] { --tab: var(--team-home); --tab-ink: #1d1600; }
.bug-tab[data-tone="away"] { --tab: var(--team-away); --tab-ink: #fff; }
@media (prefers-reduced-motion: reduce) { .bug-tab { transition: opacity .2s; transform: translate(-50%, 0); } }
/* Compact: phones in landscape (the sidebar) and portrait. */
@media (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .scoreboard {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: 2rem 1.5rem 1.875rem; gap: .25rem 0;
    grid-template-areas: "pause pause tools" "left left left" "home status away"; padding: .375rem;
  }
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) :is(.bug-center, .bug-right) { display: contents; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .match-tools { grid-area: pause; justify-self: start; position: static; transform: none; gap: .125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .match-tools .stadium-tool-btn { width: 2rem; height: 2rem; min-height: 0; padding: .25rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .stadium-toolbar { grid-area: tools; position: static; transform: none; justify-self: end; gap: .125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium-toolbar .stadium-tool-btn { width: 1.75rem; height: 1.75rem; min-height: 0; padding: .3125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-left { grid-area: left; justify-self: center; align-items: center; gap: .375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) :is(.bug-brand, .bug-modes) { height: auto; padding: 0; background: none; border: 0; gap: .25rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-brand img { height: 1.375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-mode { font-size: .75rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-team { height: 1.875rem; justify-content: space-between; font-size: .8125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-team > span:not(.bug-score) { padding: 0 .375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-score { min-width: 1.625rem; padding: 0 .3125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-score strong { font-size: 1.375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .turn-long { display: none; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .turn-short { display: inline; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-home { grid-area: home; border-radius: .375rem 0 0 .375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-away { grid-area: away; border-radius: 0 .375rem .375rem 0; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) .bug-status {
    grid-area: status; height: 1.875rem;
    flex-wrap: wrap; justify-content: center; align-content: center; gap: 0 .25rem; padding: 0 .25rem; font-size: .625rem; line-height: .75rem;
  }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium:not(.portrait-mode) #blitz-clock { flex-basis: 100%; margin: 0; text-align: center; }
}
.portrait-roster { display: none; }
@media (orientation: portrait) {
  body:is([data-shot="match"], [data-shot="replay"]) .scoreboard {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "menu brand tools" "score score score" "status status status";
    gap: .25rem; padding: .1875rem .5rem;
  }
  body:is([data-shot="match"], [data-shot="replay"]) .portrait-roster {
    position: absolute; bottom: -.75rem; left: 50%; transform: translateX(-50%); z-index: 0;
    width: min(calc(100% - 1rem), 28rem);
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(5.75rem, 25%) minmax(0, 1fr);
    align-items: center;
    pointer-events: none;
  }
  .portrait-roster-group { display: flex; align-items: center; gap: .375rem; justify-self: center; pointer-events: none; }
  .portrait-roster-group.home { grid-column: 1; }
  .portrait-roster-group.away { grid-column: 3; }
  .portrait-pill {
    position: relative; width: 2rem; height: 2rem; min-height: 0; padding: 0;
    border: 0; border-radius: 50%; background: none; box-shadow: none; flex: none;
    pointer-events: auto;
  }
  .portrait-pill:hover { background: none; }
  .portrait-pill-ring {
    display: grid; place-items: center; width: 100%; height: 100%; padding: .15625rem; border-radius: 50%;
    background: conic-gradient(var(--ring-color, #ff7197) var(--meter, 0%), rgb(255 255 255 / .14) 0);
    transition: box-shadow .15s ease;
  }
  .portrait-pill[data-team="home"] { --ring-color: var(--team-home); }
  .portrait-pill[data-team="away"] { --ring-color: var(--team-away); }
  .portrait-pill.selected .portrait-pill-ring {
    box-shadow: 0 0 0 .125rem var(--primary), 0 0 .5rem color-mix(in srgb, var(--primary) 55%, transparent);
  }
  .portrait-pill.ready .portrait-pill-ring {
    background: linear-gradient(135deg, #ff7197, #ffd166);
    box-shadow: 0 0 .5rem rgba(255, 113, 151, .65);
  }
  .portrait-pill.armed .portrait-pill-ring {
    background: #ff7197;
    box-shadow: 0 0 .625rem #ff7197;
  }
  .portrait-pill.selected.ready .portrait-pill-ring,
  .portrait-pill.selected.armed .portrait-pill-ring {
    box-shadow: 0 0 0 .125rem var(--primary), 0 0 .625rem #ff7197;
  }
  .portrait-pill-art {
    display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--card);
  }
  .portrait-pill-super {
    position: absolute; left: -.1875rem; bottom: -.125rem; width: .9375rem; height: .9375rem;
    border-radius: 50%; background: #0b0d10; border: .0625rem solid var(--border);
    opacity: .72; pointer-events: none; transition: transform .15s ease, opacity .15s ease, border-color .15s ease;
  }
  .portrait-pill:is(.ready, .armed) .portrait-pill-super {
    opacity: 1; border-color: #ff7197; transform: scale(1.15);
  }
  .portrait-pill-state {
    position: absolute; right: -.1875rem; bottom: -.125rem; width: .9375rem; height: .9375rem;
    display: grid; place-items: center; border-radius: 50%;
    background: #0b0d10; border: .0625rem solid var(--border);
    pointer-events: none;
  }
  .portrait-pill-state .icon { width: .6875rem; height: .6875rem; stroke-width: 2.6; }
  .portrait-pill-state[data-state="aimed"] {
    color: #42c66b; border-color: #42c66b;
    box-shadow: 0 0 .375rem rgba(66, 198, 107, .45);
  }
  .portrait-pill-state[data-state="guard"] { color: #e8f1ff; border-color: #9bb8db; }
  .portrait-pill-state[data-state="iron-guard"] { color: #dce6f2; border-color: #6b7785; background: #1d242e; }
  .portrait-pill-state[data-state="stunned"] { color: #ffd166; border-color: #ffd166; }
  .portrait-pill-state[data-state="carded"] { border-color: #ffd166; }
  .portrait-state-card { display: block; width: .375rem; height: .5625rem; border-radius: .0625rem; background: #ffd166; }
  .portrait-pill:is(.carded, .stunned) .portrait-pill-ring { opacity: .45; filter: grayscale(.8); }
  .classic-match .portrait-pill-ring { background: rgb(255 255 255 / .14); }
  .classic-match .portrait-pill-super { display: none; }
  body:is([data-shot="match"], [data-shot="replay"]) .match-tools { grid-area: menu; justify-self: start; position: static; transform: none; gap: .125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .match-tools .stadium-tool-btn { width: 2rem; height: 2rem; min-height: 0; padding: .25rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium-toolbar { grid-area: tools; position: static; transform: none; justify-self: end; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-left { grid-area: brand; justify-self: center; flex-direction: column; align-items: center; gap: .125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) :is(.bug-brand, .bug-modes) { height: auto; padding: 0; gap: .25rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-brand img { height: 1.375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-mode { font-size: .75rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-center {
    grid-area: score; justify-self: center; width: min(100%, 28rem);
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-team { height: 2.625rem; justify-content: space-between; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-right { grid-area: status; justify-self: center; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-status { height: 1.5rem; border-radius: 0; font-size: .75rem; }
}

/* The score is the match HUD. Tools sit at the edges, and each layout gives the score its own space. */
.ball-page .scoreboard .bug-team { font-size: clamp(.875rem, 1.3vw, 1.125rem); }
.ball-page .scoreboard .bug-score strong { font-size: clamp(1.5rem, 2.8vw, 2.5rem); }
.scoreboard .bug-home { border-radius: .625rem 0 0 .625rem; }
.scoreboard .bug-away { border-radius: 0 .625rem .625rem 0; }
body:is([data-shot="home"], [data-shot="lobby"]) .scoreboard { padding-inline: .25rem; }
body:is([data-shot="match"], [data-shot="replay"]) .stadium-actions :is(.stadium-super-btn, #launch) { font-size: .9375rem; }
body:is([data-shot="match"], [data-shot="replay"]) #launch { height: 3rem; font-size: 1.0625rem; }
body:is([data-shot="match"], [data-shot="replay"]) .shot-buttons button { font-size: .8125rem; padding-inline: .375rem; }
@media (orientation: landscape) and (not ((pointer: coarse) and (max-height: 600px))) {
  .scoreboard { column-gap: .75rem; }
  .scoreboard .bug-team { height: clamp(2.625rem, 4.5vw, 3.625rem); }
  .bug-team > span:not(.bug-score) { width: clamp(7.75rem, 9.5vw, 10.5rem); max-width: none; padding: 0 .5rem; text-align: center; }
  .scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-team > span:not(.bug-score) { width: clamp(5.75rem, 8.5vw, 8.5rem); }
  .scoreboard .bug-score { min-width: clamp(2.25rem, 4vw, 3.5rem); }
  .bug-status { font-size: 1rem; }
  .match-tools .stadium-tool-btn { width: 2.625rem; height: 2.625rem; }
  .match-tools .stadium-tool-btn > svg { width: 1.25rem; height: 1.25rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium-actions { grid-template-columns: minmax(0, 10rem) minmax(0, 12rem) minmax(0, 13rem); }
  body:is([data-shot="match"], [data-shot="replay"]) #launch { height: 3.375rem; font-size: 1.1875rem; }
}
@media (orientation: portrait) and (max-width: 30rem) {
  body:is([data-shot="match"], [data-shot="replay"]) .stadium-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium-actions > .shot-controls { grid-row: span 2; }
  body:is([data-shot="match"], [data-shot="replay"]) .stadium-actions > :is(.stadium-super-controls, #launch) { grid-column: 2; }
}

/* Replay viewer: the timeline (goal and card marks above it) over the playback controls, in place
   of the planning controls. */
.replay-bar { display: none; flex: 1 1 100%; gap: .375rem; min-width: 0; }
body[data-shot="replay"] .replay-bar { display: grid; grid-column: 1 / -1; }
body[data-shot="replay"] .stadium-actions { grid-template-columns: minmax(0, 1fr); }
body[data-shot="replay"] .stadium-actions > :not(.replay-bar), body[data-shot="replay"] #field-spin { display: none !important; }
.replay-track { position: relative; padding-top: .875rem; }
#replay-seek { display: block; width: 100%; margin: 0; accent-color: var(--primary); }
.replay-marks { position: absolute; top: 0; left: .5rem; right: .5rem; height: .75rem; }
.replay-mark { position: absolute; top: 0; width: .75rem; height: .75rem; min-height: 0; margin-left: -.375rem; padding: 0; border: .125rem solid var(--card); border-radius: 50%; cursor: pointer; }
.replay-mark.home { background: var(--team-home); }
.replay-mark.away { background: var(--team-away); }
.replay-mark.card { top: .125rem; width: .375rem; height: .5625rem; margin-left: -.1875rem; border: 0; border-radius: .0625rem; background: #ffd166; pointer-events: none; }
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; }
.replay-controls .icon-button { color: var(--text); }
#replay-play .icon-play, #replay-play.paused .icon-pause { display: none; }
#replay-play.paused .icon-play { display: inline; }
.replay-export { display: inline-flex; align-items: center; gap: .375rem; }
.replay-export svg, .replays-tools svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#replay-export-open .icon { width: 1rem; height: 1rem; color: var(--muted); }
.replay-export-menu:popover-open { display: grid; gap: .125rem; min-width: 11.5rem; }
.replay-export-menu button { justify-content: flex-start; min-height: 2.25rem; border-radius: .5rem; background: none; font-size: .875rem; box-shadow: none; }
.replay-export-menu button:hover { background: var(--hover); }
.replay-time { min-width: 5.75rem; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; text-align: center; }
.game-select[data-for="replay-speed"] { min-height: 0; padding: .375rem .5rem; background: var(--elevated); color: var(--text); border: .0625rem solid var(--border); border-radius: .5rem; }
@media (orientation: portrait) and (max-height: 46rem) {
  body:is([data-shot="match"], [data-shot="replay"]) .scoreboard { gap: .125rem; padding: .125rem .375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-left { flex-direction: row; gap: .375rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-brand img { height: 1.1875rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-team { height: 2.125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .bug-status { height: 1.25rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .portrait-roster { bottom: -.625rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .portrait-pill { width: 1.75rem; height: 1.75rem; }
  body:is([data-shot="match"], [data-shot="replay"]) :is(.portrait-pill-super, .portrait-pill-state) { width: .8125rem; height: .8125rem; }
  body:is([data-shot="match"], [data-shot="replay"]) .portrait-pill-state .icon { width: .5625rem; height: .5625rem; }
  body[data-shot="match"] .stadium-actions { gap: .25rem .375rem; padding: .25rem .5rem .375rem; }
  body[data-shot="match"] .knob svg { width: min(100%, 2.5rem); }
  body[data-shot="match"] .stadium-actions :is(.stadium-super-btn, #launch) { height: 2.375rem; }
  body[data-shot="match"] #launch { height: 2.5rem; }
  body[data-shot="match"] .shot-buttons button { min-height: 1.5rem; }
}
@media (orientation: portrait) and (max-width: 40rem) {
  body[data-shot="replay"] .stadium-actions { padding: .25rem .5rem .5rem; }
  .replay-bar { gap: .25rem; }
  .replay-controls { gap: .25rem .375rem; }
  .replay-controls .icon-button { width: 2rem; height: 2rem; min-height: 0; padding: .3125rem; }
  .replay-controls button:not(.icon-button) { min-height: 2rem; padding: .25rem .5rem; font-size: .75rem; }
  .replay-time { min-width: 4.75rem; font-size: .75rem; }
  .game-select[data-for="replay-speed"] { min-height: 2rem; padding: .25rem .375rem; font-size: .75rem; }
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 600px) {
  body[data-shot="replay"] .stadium:not(.portrait-mode) > .stadium-actions {
    min-height: 0; max-height: 100%; overflow-y: auto; padding: .25rem .5rem .375rem;
  }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-bar { gap: .25rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-track { padding-top: .6875rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-controls { gap: .25rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-controls .icon-button { width: 1.75rem; height: 1.75rem; min-height: 0; padding: .25rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-controls button:not(.icon-button) { min-height: 1.75rem; padding: .1875rem .4375rem; font-size: .6875rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-export svg { width: .9375rem; height: .9375rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .replay-time { min-width: 4.5rem; font-size: .6875rem; }
  body[data-shot="replay"] .stadium:not(.portrait-mode) .game-select[data-for="replay-speed"] { min-height: 1.75rem; padding: .1875rem .375rem; font-size: .6875rem; }
}

/* Replay library. */
/* Anchored near the top, so deleting or restoring a replay changes only the bottom edge. */
.replays-dialog { width: min(35rem, calc(100% - 1.5rem)); margin: max(.75rem, calc(100dvh * 0.08)) auto auto; max-height: calc(100dvh - max(1.5rem, calc(100dvh * 0.16))); overflow: auto; padding: 1.5rem; border: .0625rem solid var(--border); border-radius: 1.375rem; background: var(--card); color: var(--text); }
.replays-dialog::backdrop { background: #000b; }
#replays-note.problem { color: var(--danger, #ff7a7a); }
.replays-list .replays-empty { display: block; color: var(--muted); }
.replays-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.replays-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .125rem .75rem; align-items: center; padding: .75rem; border: .0625rem solid var(--border); border-radius: .875rem; background: var(--elevated); }
.replays-list .replay-watch { grid-column: 1; grid-row: 1 / span 2; }
.replays-list .replay-heading, .replays-list .replay-name { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: .25rem; min-width: 0; }
.replays-list strong { min-width: 0; overflow-wrap: anywhere; }
.replays-list .replay-rename { width: auto; height: auto; min-height: 0; padding: .125rem; border-radius: .375rem; line-height: 0; }
.replays-list .replay-rename svg { width: 1em; height: 1em; }
.replays-list small { grid-column: 2; grid-row: 2; color: var(--muted); }
.replays-list .replay-actions { grid-column: 3; grid-row: 1 / span 2; display: flex; gap: .375rem; }
.replays-list .replay-watch { color: var(--primary-text, #1b1e26); }
.replays-list [aria-pressed="true"] { color: var(--primary); }
.replays-list li.pinned { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.replay-name { min-width: 0; padding: .375rem .5rem; border: .0625rem solid var(--border); border-radius: .5rem; background: var(--card); color: var(--text); font: inherit; font-weight: 700; }
.replays-tools { display: flex; flex-wrap: nowrap; align-items: center; gap: .5rem .75rem; margin-bottom: .75rem; }
.replays-tools .file-btn { display: inline-flex; align-items: center; gap: .375rem; cursor: pointer; }
.replays-tools .file-btn input { position: absolute; width: .0625rem; height: .0625rem; opacity: 0; pointer-events: none; }
/* Undo keeps its place in the toolbar while hidden, so the list does not move when it appears. */
.replays-undo { display: flex; align-items: center; gap: .5rem; min-width: 0; color: var(--muted); }
.replays-undo.idle { visibility: hidden; }
.replays-undo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replays-undo button { display: inline-flex; align-items: center; gap: .375rem; }
@media (orientation: portrait) and (max-width: 480px) {
  .replays-dialog { padding: 1rem; }
  .replays-list .replay-actions { grid-column: 2; grid-row: 3; }
}

/* Export: the range to export, then its progress and result. */
.export-dialog { width: min(26.25rem, calc(100% - 1.5rem)); padding: 1.5rem; border: .0625rem solid var(--border); border-radius: 1.375rem; background: var(--card); color: var(--text); }
.export-dialog::backdrop { background: #000b; }
.export-dialog h2 { margin: 0 0 .75rem; }
.export-options { display: grid; gap: .5rem; margin-bottom: .75rem; }
.export-options button { display: grid; justify-content: start; justify-items: start; gap: .125rem; padding: .75rem .875rem; border-radius: .875rem; text-align: left; }
.export-options .primary small { color: inherit; opacity: .75; }
.export-note { margin: -.375rem 0 .75rem; color: var(--muted); font-size: .875rem; }
.export-options strong { font-weight: 700; }
.export-options small { color: var(--muted); font-weight: 700; }
.export-private { display: flex; align-items: flex-start; gap: .625rem; margin-top: .25rem; padding: .25rem .125rem; cursor: pointer; }
.export-private input { width: 1.125rem; height: 1.125rem; margin: .125rem 0 0; accent-color: var(--primary); }
.export-private span { display: grid; gap: .125rem; }
#export-status:empty { display: none; }
#export-progress { width: 100%; height: .625rem; margin: .5rem 0 1rem; accent-color: var(--primary); }
.export-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.share-dialog { width: min(32.5rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); overflow: auto; }
.share-card { display: block; width: 100%; height: auto; margin-bottom: .5rem; border-radius: .75rem; }

/* Viewer guide toggles. */
.replay-toggle[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
/* Game & replay stats. */
.stats-dialog {
  --stats-selection: color-mix(in srgb, var(--text) 15%, var(--card));
  display: flex;
  flex-direction: column;
  width: min(var(--rink-w, 62.5rem), calc(100% - 1.5rem));
  box-sizing: border-box;
  height: 100dvh;
  max-height: 100%;
  overflow: hidden;
  padding: 1.5rem;
  border: .0625rem solid var(--border);
  border-radius: 1.375rem;
  background: var(--card);
  color: var(--text);
}
.stats-dialog:not([open]) { display: none; }
.stats-dialog > :not(#stats-box, #stats-log) { flex-shrink: 0; }
#stats-box, #stats-log { flex: 1; min-height: 0; }
#stats-box { overflow: auto; }
#stats-log { display: flex; flex-direction: column; }
#stats-log > :not(#stats-events) { flex-shrink: 0; }
#stats-events { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
@media (max-height: 30rem) and (orientation: landscape) {
  #stats-log { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: .75rem; }
  .stats-map-panel { min-height: 0; overflow-y: auto; }
}
.stats-dialog::backdrop { background: #000b; }
.stats-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .25rem;
}
.stats-heading h2 { margin: 0; font-size: 1.25rem; }
.stats-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.stats-dialog .summary-honours {
  margin: 0 0 .875rem;
  color: #ffd166;
  font-weight: 700;
}
.stats-dialog .summary-honours:empty { display: none; }
.stats-label { margin: .875rem 0 .375rem; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stats-label span { float: right; text-transform: none; letter-spacing: 0; }
.stats-control { display: flex; overflow: hidden; border-radius: .625rem; font-size: .8125rem; font-weight: 800; }
.stats-control span { min-width: max-content; padding: .375rem .625rem; white-space: nowrap; }
.stats-control .home { background: var(--team-home); color: #1b1e26; }
.stats-control .away { background: var(--team-away); color: #fff; text-align: right; }
.stats-table { position: relative; overflow-x: auto; max-width: 100%; margin: .5rem 0; }
.stats-table.can-scroll-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent);
}
.stats-table table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: .4375rem .375rem; text-align: right; border-bottom: .0625rem solid var(--border); white-space: nowrap; }
.stats-table th { color: var(--muted); font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stats-table th:nth-child(1), .stats-table th:nth-child(2) { text-align: left; }
.stats-table th:nth-child(2), .stats-table td.col-name { position: sticky; left: 0; z-index: 2; }
.stats-table th:nth-child(2) { background: var(--card); }
.stats-table.is-scrolled :is(th:nth-child(2), td.col-name) { box-shadow: .375rem 0 .5rem -.25rem rgb(0 0 0 / .45); }
.stats-table td.col-trophy { width: 2.25rem; text-align: center; padding: .375rem .25rem; }
.stats-table td.col-trophy.team-0-win,
.stats-table td.col-name.team-0 {
  background: var(--team-home);
  color: #1b1e26;
}
.stats-table td.col-trophy.team-1-win,
.stats-table td.col-name.team-1 {
  background: var(--team-away);
  color: #ffffff;
}
.stats-table td.col-trophy svg.icon { width: 1.125rem; height: 1.125rem; vertical-align: middle; }
.stats-table td.col-trophy.team-0-win svg.icon { stroke: #1b1e26; }
.stats-table td.col-trophy.team-1-win svg.icon { stroke: #ffffff; }
.stats-table td.col-name { white-space: nowrap; font-weight: 700; text-align: left; padding: .375rem .625rem; }
.stats-table .mvp-badge {
  display: inline-flex;
  align-items: center;
  margin-left: .375rem;
  padding: .0625rem .375rem;
  border-radius: 62.5rem;
  background: linear-gradient(90deg, #ff9954, #ff7197);
  color: #ffffff;
  font-size: .625rem;
  font-weight: 800;
  letter-spacing: .02em;
  vertical-align: middle;
}
.stats-more-details { display: flex; flex-direction: column; gap: .375rem; margin: .75rem 0; }
.stats-tabs, .stats-rounds, .stats-map-controls { display: flex; gap: .375rem; }
.stats-rounds, .stats-map-controls { margin: .375rem 0; }
.stats-rounds, .stats-map-controls { overflow: auto hidden; }
.stats-dialog :is(.stats-rounds, .stats-map-controls, .stats-header-actions) button:active:not(:disabled) {
  transform: none;
}
.stats-map-controls button { flex: 0 0 9em; white-space: nowrap; padding-inline: .375rem; }
#stats-highlights { margin-right: auto; }
.stats-rounds button { flex: 1 0 auto; white-space: nowrap; }
.stats-dialog button[aria-pressed=true] {
  border-color: var(--muted);
  background: var(--stats-selection);
}
.stats-dialog [data-team="0"] { --stats-team: var(--team-home); --stats-ink: #000; }
.stats-dialog [data-team="1"] { --stats-team: var(--team-away); --stats-ink: #fff; }
.stats-rounds button[data-team] { border-color: var(--stats-team); color: var(--stats-team); }
.stats-rounds button[data-team][aria-pressed=true], .stats-player { background: var(--stats-team); color: var(--stats-ink); }
.stats-map { display: block; width: min(80%, 94dvh); height: auto; margin: .25rem auto 0; }
@media (max-height: 30rem) and (orientation: landscape) {
  .stats-map { width: min(80%, 53dvh); }
}
.stats-map-detail { height: 2.75em; overflow: auto; margin: .25rem 0; color: var(--muted); font-size: .8125rem; text-align: center; white-space: pre-line; }
#stats-events h3 { margin: .875rem 0 .25rem; font-size: .9375rem; }
.stats-events { list-style: none; margin: 0; padding: 0; }
.stats-events li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; padding: .375rem .5rem; font-size: .8125rem; }
.stats-events li.major { background: var(--card); border-radius: .375rem; font-weight: 700; }
.stats-events li:is(.highlighted, :focus-within, :hover) { background: var(--stats-selection); border-radius: .375rem; }
.stats-event-time { min-width: 7.5rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; text-align: left; }
button.stats-event-time { padding: 0; min-height: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 400; text-decoration: underline; }
.stats-event-entry { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.stats-event-entry svg.icon { width: 1em; height: 1em; flex: none; }
.stats-player { display: inline-flex; align-items: center; gap: .25em; padding: 0 .45em 0 .2em; border-radius: 1em; white-space: nowrap; }
.stats-player img { display: block; width: 1em; height: 1em; }
.stats-note { margin: .5rem 0 0; color: var(--muted); font-size: .6875rem; }
#match-summary { text-align: center; }
#match-summary p { margin: .25rem 0; }
#match-summary p:empty { display: none; }
.summary-score { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 9vmin, 4rem); line-height: 1.1; }
.summary-winner { font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; overflow-wrap: anywhere; }
.summary-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
@media (orientation: portrait) and (max-width: 420px) {
  .stats-dialog { padding: 1rem; }
  .stats-table th, .stats-table td { padding: .375rem .1875rem; }
  .stats-heading { flex-wrap: wrap; gap: .5rem; }
  .stats-header-actions { margin-left: auto; }
}

@media (orientation: landscape) and (not ((pointer: coarse) and (max-height: 600px))) {
  /* Readable text: at least 0.8125rem (13 design px), body/labels >= 0.875rem */
  .card-titles strong { font-size: 1rem; }
  .card-titles small { font-size: .8125rem; }

  .stat-group-title { font-size: .8125rem; }
  .stat-row { font-size: .8125rem; }
  .stat-lbl { width: 5.25rem; font-size: .8125rem; }
  .stat-val { width: 1.75rem; font-size: .8125rem; }
  .stat-track { height: .5rem; }

  .super-row { font-size: .875rem; }
  .super-name-badge { font-size: .875rem; }
  .super-pct { font-size: .8125rem; }

  .knob small { font-size: .8125rem; }

  .setting-value, .setting-seg { font-size: .8125rem; }
  .bug-tab { font-size: .8125rem; }
  .scoreboard:is([data-size="small"], [data-size="tiny"]) .bug-status { font-size: .8125rem; }

  .stat-drawer .card-titles strong { font-size: 1.25rem; }
  .stat-drawer .card-titles small { font-size: .875rem; }
  .stat-drawer-super-title strong { font-size: .9375rem; }
  .stat-drawer-super .super-pct { font-size: .8125rem; }
  .stat-drawer-super-desc { font-size: .8125rem; }
  .stat-drawer-super-mastery { font-size: .8125rem; }
  .stat-drawer .stat-group-title { font-size: .8125rem; }
  .stat-drawer .stat-row, .stat-drawer .stat-lbl, .stat-drawer .stat-val { font-size: .875rem; }
  .stat-drawer .stat-lbl { width: 5.75rem; }
  .stat-drawer .stat-val { width: 2rem; }
  .stat-drawer .stat-track { height: .5rem; }

  .home-ubu small { font-size: .875rem; }
  .mint-entry-badge { font-size: .875rem; }
  .mint-entry-text { font-size: .875rem; }

  .formation-pos { font-size: .8125rem; }
  .formation-name strong { font-size: 1rem; }
  .formation-name small { font-size: .8125rem; }
  .formation-super { font-size: .875rem; }
  .formation-super span { font-size: .875rem; }
  .super-choice strong { font-size: .9375rem; }
  .super-choice small { font-size: .8125rem; }
  .lobby-note { font-size: .8125rem; }
  .roster-status { font-size: .8125rem; }

  .online-hint { font-size: .875rem; }
  .online-account { font-size: .875rem; }

  .stats-table th { font-size: .8125rem; }
  .stats-table td { font-size: .875rem; }
  .stats-table .mvp-badge { font-size: .8125rem; }
  .stats-label { font-size: .8125rem; }
  .stats-note { font-size: .8125rem; }

  .replay-time { font-size: .8125rem; }
  .export-note { font-size: .875rem; }
  .export-options small { font-size: .8125rem; }
}
