:root {
  --bg: #0e1015;
  --panel: rgba(18, 21, 30, 0.82);
  --ink: #f4f6fb;
  --muted: #97a0b5;
  --stage-metal-dark: #090b12;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Bar is a block in flow at the top; the canvas overlays the whole viewport so
   brush tips can poke up over the bar. */
#stage {
  position: fixed;
  inset: 0;
  background: #0a0b10;
  isolation: isolate;
  overflow: hidden;
}

/* Full-bleed: the canvas now covers the whole viewport, so the old arcade frame
   and its decorative layers are retired. */
#stage::before,
#stage::after {
  display: none;
}

#stage::before {
  z-index: -2;
  background:
    repeating-linear-gradient(36deg, transparent 0 46px, rgba(255, 111, 55, 0.18) 47px 49px, transparent 50px 98px),
    repeating-linear-gradient(124deg, transparent 0 62px, rgba(255, 196, 86, 0.1) 63px 64px, transparent 65px 126px),
    linear-gradient(180deg, rgba(255, 88, 49, 0.08), rgba(255, 146, 59, 0.16));
  opacity: 0.82;
}

#stage::after {
  z-index: -1;
  box-shadow:
    inset 0 0 110px rgba(0, 0, 0, 0.76),
    inset 0 -34px 88px rgba(224, 71, 34, 0.16);
}

/* Canvas overlays the whole viewport (above the bar). Its play area is rendered
   below the bar; brush sprites are drawn unclipped so tips lean over the bar.
   pointer-events:none keeps the bar/settings underneath clickable. */
#game {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: block;
  background: transparent;
  pointer-events: none;
}

/* Pre-round countdown: Spirit Crown stage over the board. The server freezes
   players during this phase; this overlay is visual only. */
#countdown {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s ease;
}
#countdown.show { opacity: 1; }
#countdown.pop .sc-stage { animation: cd-pop-stage 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes cd-pop-stage {
  0%   { transform: translate(-50%, calc(-50% - var(--sc-lift))) scale(0.45); }
  55%  { transform: translate(-50%, calc(-50% - var(--sc-lift))) scale(1.14); }
  100% { transform: translate(-50%, calc(-50% - var(--sc-lift))) scale(1); }
}
.sc-stage {
  --sc-a: #ff4d8d;
  --sc-b: #ffd23f;
  --sc-ink: #07080d;
  --sc-lift: 9%;
  position: absolute;
  left: calc(var(--cd-left, 0px) + var(--cd-w, 100vw) / 2);
  top: calc(var(--cd-top, 40px) + var(--cd-h, calc(100vh - 40px)) / 2);
  width: min(72vw, var(--cd-w, 540px), 540px);
  aspect-ratio: 1.62 / 1;
  z-index: 1;
  isolation: isolate;
  overflow: visible;
  background: transparent;
  transform: translate(-50%, calc(-50% - var(--sc-lift)));
}
.sc-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  background: none;
}
.sc-stage[data-value="GO!"] {
  --sc-a: #ff4d8d;
  --sc-b: #36d8ff;
  --sc-disk-speed: 0.16s;
}
.sc-stage[data-value="GO!"]::before {
  background: none;
}
.sc-stage[data-value="3"] {
  --sc-disk-speed: 0.55s;
}
.sc-stage[data-value="2"] {
  --sc-disk-speed: 0.4s;
}
.sc-stage[data-value="1"] {
  --sc-disk-speed: 0.24s;
}
.sc-beam,
.sc-ring,
.sc-swash,
.sc-sparkle,
.sc-sprite {
  position: absolute;
  pointer-events: none;
}
.sc-beam {
  left: calc(var(--cd-left, 0px) + var(--cd-w, 100vw) / 2);
  top: var(--cd-top, 40px);
  height: calc(var(--cd-h, calc(100vh - 40px)) * 0.68);
  width: min(26vw, 360px);
  z-index: 0;
  filter: blur(9px);
  mix-blend-mode: screen;
  clip-path: polygon(49.2% 0, 50.8% 0, 100% 100%, 0 100%);
  /* Feather the sides so only the bright central cone reads -- the wide wedge
     edges fade into the dark instead of splaying out as hard "disco" rays. */
  -webkit-mask-image: linear-gradient(90deg, transparent 4%, #000 33%, #000 67%, transparent 96%);
          mask-image: linear-gradient(90deg, transparent 4%, #000 33%, #000 67%, transparent 96%);
  transform-origin: 50% 0;
  will-change: transform, opacity;
  animation: sc-beam-bobble var(--beam-speed, 3.2s) ease-in-out infinite alternate;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--beam) 46%, transparent) 0%,
      color-mix(in srgb, var(--beam) 20%, transparent) 42%,
      transparent 100%
    );
}
.sc-beam-a {
  --beam: #ff4d8d;
  --beam-rot: -11deg;
  --beam-low: 0.18;
  --beam-high: 0.34;
  --bobble-x: 2.8%;
  --beam-speed: 3s;
}
.sc-beam-b {
  --beam: #ffd23f;
  --beam-rot: 0deg;
  --beam-low: 0.14;
  --beam-high: 0.28;
  --bobble-x: 2.2%;
  --beam-speed: 3.8s;
  width: min(20vw, 280px);
  animation-delay: -1.1s;
  animation-direction: alternate-reverse;
}
.sc-beam-c {
  --beam: #36d8ff;
  --beam-rot: 11deg;
  --beam-low: 0.12;
  --beam-high: 0.26;
  --bobble-x: 2.8%;
  --beam-speed: 4.4s;
  width: min(24vw, 330px);
  animation-delay: -0.55s;
}
#countdown.go .sc-beam-b {
  --beam: #ffffff;
  --beam-low: 0.12;
  --beam-high: 0.26;
}
.sc-ring {
  display: none;
  inset: 7% 12% 19%;
  z-index: 1;
  border: 3px solid color-mix(in srgb, var(--sc-a) 70%, rgba(255, 255, 255, 0.22));
  border-radius: 50%;
  box-shadow:
    inset 0 0 24px color-mix(in srgb, var(--sc-a) 18%, transparent),
    0 0 30px color-mix(in srgb, var(--sc-a) 38%, transparent);
}
.sc-stage[data-value="GO!"] .sc-ring {
  border-color: rgba(255, 77, 141, 0.82);
  box-shadow:
    inset 0 0 24px rgba(255, 77, 141, 0.16),
    0 0 30px rgba(54, 216, 255, 0.28);
}
.sc-swash {
  z-index: 2;
  left: 10%;
  right: 10%;
  bottom: 2%;
  height: 34%;
  overflow: hidden;
  border-radius: 50%;
  clip-path: none;
  background: transparent;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16),
    0 18px 24px rgba(0, 0, 0, 0.34),
    0 0 24px rgba(54, 216, 255, 0.12);
  opacity: 0.96;
  transform: perspective(560px) rotateX(64deg) translateY(5%);
  transform-origin: 50% 88%;
  transform-style: preserve-3d;
}
.sc-swash::before,
.sc-swash::after {
  position: absolute;
  pointer-events: none;
  content: "";
  border-radius: 50%;
}
.sc-swash::before {
  inset: 0;
  --sc-angle: 0deg;
  background:
    conic-gradient(from var(--sc-angle) at 50% 50%,
      #ff315c 0deg 30deg,
      #ff9c00 30deg 60deg,
      #ffe600 60deg 88deg,
      #57e000 88deg 118deg,
      #25f35d 118deg 150deg,
      #5fffe5 150deg 178deg,
      #0873ff 178deg 214deg,
      #6148ff 214deg 248deg,
      #aa19ff 248deg 286deg,
      #f000b0 286deg 322deg,
      #ff315c 322deg 360deg);
  opacity: 1;
  filter: saturate(1.18) brightness(1.06);
  will-change: background;
  animation: sc-disk-spin var(--sc-disk-speed, 1.45s) linear infinite;
}
.sc-swash::after {
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 9%, rgba(255, 255, 255, 0.44) 0 9%, rgba(255, 255, 255, 0.14) 25%, transparent 54%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 48%, rgba(0, 0, 0, 0.12));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.24),
    inset 0 -8px 12px rgba(0, 0, 0, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  opacity: 0.64;
}
.sc-stage[data-value="GO!"] .sc-swash {
  opacity: 1;
  filter: saturate(1.18) drop-shadow(0 0 18px rgba(54, 216, 255, 0.24));
}
/* Spin the COLORS inside the fixed disk shape, not the shape itself.
   The disk is a very wide ellipse (~3.8:1); rotating the elliptical ::before
   layer swept its footprint into a narrow vertical bar near 90deg/270deg,
   leaving the sides dark. Animating the conic-gradient angle keeps the whole
   disk painted every frame while the rainbow rotates in place. */
@property --sc-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
@keyframes sc-disk-spin {
  to { --sc-angle: 360deg; }
}
.sc-digit {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 4%;
  color: #fff7ee;
  font-family: Impact, "Avenir Next Condensed", "Arial Black", sans-serif;
  font-size: clamp(88px, 22vh, 198px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: clamp(5px, 0.8vh, 9px) var(--sc-ink);
  text-shadow:
    0 9px 0 rgba(0, 0, 0, 0.52),
    0 0 26px color-mix(in srgb, var(--sc-a) 58%, transparent),
    0 0 54px color-mix(in srgb, var(--sc-b) 28%, transparent);
}
.sc-stage[data-value="GO!"] .sc-digit {
  padding-bottom: 4%;
  font-size: clamp(88px, 22vh, 198px);
  color: #fff0c9;
  -webkit-text-stroke-width: clamp(5px, 0.8vh, 9px);
}
.sc-sprite {
  --row: 0;
  --col: 0;
  z-index: 5;
  width: var(--size, 86px);
  aspect-ratio: 192 / 208;
  background-image: url("/assets/brush-spirit.png");
  background-repeat: no-repeat;
  background-size: 800% 900%;
  background-position:
    calc(var(--col) * 100% / 7)
    calc(var(--row) * 100% / 8);
  image-rendering: auto;
  filter:
    drop-shadow(0 8px 0 rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 12px color-mix(in srgb, var(--sc-a) 46%, transparent));
  transform-origin: 50% 76%;
}
.sc-sprite-main {
  --size: min(13vw, 76px);
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%);
}
.sc-sprite-second {
  --size: min(10.5vw, 62px);
  left: 23%;
  bottom: 15%;
  transform: scaleX(-1);
}
.sc-sprite-third {
  --size: min(10.5vw, 62px);
  right: 23%;
  bottom: 15%;
}
.sc-sparkle {
  z-index: 6;
  left: var(--spark-x);
  top: var(--spark-y);
  width: var(--spark-size, 6px);
  height: var(--spark-size, 6px);
  border-radius: 50%;
  background: var(--spark-color, #fff);
  box-shadow: 0 0 10px 2px color-mix(in srgb, var(--spark-color, #fff) 62%, transparent);
  will-change: transform, opacity;
  animation: sc-spark-float var(--spark-speed, 3s) ease-in-out infinite;
  animation-delay: var(--spark-delay, 0s);
}
.sc-sparkle::after {
  content: "";
  position: absolute;
  inset: -80%;
  background:
    linear-gradient(90deg, transparent 42%, color-mix(in srgb, var(--spark-color, #fff) 86%, transparent) 47% 53%, transparent 58%),
    linear-gradient(0deg, transparent 42%, color-mix(in srgb, var(--spark-color, #fff) 86%, transparent) 47% 53%, transparent 58%);
  opacity: 0.58;
}
.sc-sparkle-a {
  --spark-x: 19%;
  --spark-y: 25%;
  --spark-size: 6px;
  --spark-color: #ff4d8d;
  --spark-dx: 24px;
  --spark-dy: -20px;
  --spark-speed: 3.3s;
}
.sc-sparkle-b {
  --spark-x: 68%;
  --spark-y: 18%;
  --spark-size: 10px;
  --spark-color: #ffffff;
  --spark-dx: -20px;
  --spark-dy: 24px;
  --spark-speed: 3.8s;
  --spark-delay: -1.2s;
}
.sc-sparkle-c {
  --spark-x: 84%;
  --spark-y: 38%;
  --spark-size: 5px;
  --spark-color: #36d8ff;
  --spark-dx: -28px;
  --spark-dy: -12px;
  --spark-speed: 4.2s;
  --spark-delay: -0.65s;
}
.sc-sparkle-d {
  --spark-x: 29%;
  --spark-y: 70%;
  --spark-size: 9px;
  --spark-color: #ffffff;
  --spark-dx: 16px;
  --spark-dy: -26px;
  --spark-speed: 3.6s;
  --spark-delay: -1.7s;
}
.sc-sparkle-e {
  --spark-x: 76%;
  --spark-y: 71%;
  --spark-size: 6px;
  --spark-color: #ffd23f;
  --spark-dx: -22px;
  --spark-dy: -16px;
  --spark-speed: 4.7s;
  --spark-delay: -2.1s;
}
@keyframes sc-beam-bobble {
  0% {
    opacity: var(--beam-low);
    transform: translateX(calc(-50% - var(--bobble-x))) rotate(calc(var(--beam-rot) - 2deg));
  }
  52% { opacity: var(--beam-high); }
  100% {
    opacity: var(--beam-high);
    transform: translateX(calc(-50% + var(--bobble-x))) rotate(calc(var(--beam-rot) + 2deg));
  }
}
@keyframes sc-spark-float {
  0%, 100% {
    opacity: 0.24;
    transform: translate3d(0, 0, 0) scale(0.72);
  }
  45% {
    opacity: 1;
    transform: translate3d(var(--spark-dx), var(--spark-dy), 0) scale(1.15);
  }
  70% {
    opacity: 0.7;
    transform: translate3d(0, var(--spark-dy), 0) scale(0.92);
  }
}

@media (max-width: 700px) {
  .sc-stage {
    --sc-lift: 6%;
    width: min(86vw, 430px);
    aspect-ratio: 1.2 / 1;
  }
  .sc-digit {
    font-size: clamp(78px, 19vh, 166px);
  }
  .sc-stage[data-value="GO!"] .sc-digit {
    font-size: clamp(78px, 19vh, 166px);
  }
  .sc-sprite-main { --size: min(17vw, 72px); }
  .sc-sprite-second,
  .sc-sprite-third { --size: min(14vw, 58px); }
}

/* Timer: a centered chip with a layered "electric border" (displaced ring +
   stacked glow rings + ambient bloom). The core is lightning-white and flickers;
   color shifts with urgency -- white -> purple (<30s) -> red (<10s) -- and it
   breathes faster toward 0 (JS sets --eb-speed). */
#timer {
  position: relative;
  flex: none;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 18px;
  border-radius: 10px;
  background: rgba(6, 8, 12, 0.62);
  font-variant-numeric: tabular-nums;
  isolation: isolate;
  --eb: #f2f5ff;          /* core border color -- lightning white by default */
  --eb-light: #cdd8ff;    /* halo tint (faint cool cast, like real lightning) */
  --eb-glow: 0.62;        /* glow strength */
  --eb-speed: 2.4s;       /* breathing period (shortened by JS near 0) */
}
#timer > span:not(.timer-val) {
  position: absolute; inset: 0; border-radius: 10px; pointer-events: none;
}
#timer .eb-base   { border: 1.5px solid color-mix(in srgb, var(--eb) 38%, transparent); }
#timer .eb-main   { border: 1.5px solid var(--eb); filter: url(#eb-displace) drop-shadow(0 0 2px var(--eb)); }
#timer .eb-glow-1 { border: 2px solid var(--eb);         filter: blur(2px); opacity: var(--eb-glow);
                    animation: eb-flicker 2.7s ease-in-out infinite; }   /* electric flicker (calm state) */
#timer .eb-glow-2 { border: 2.5px solid var(--eb-light); filter: blur(7px); opacity: calc(var(--eb-glow) * 0.7); }
#timer .eb-bg {
  inset: -5px; border-radius: 14px; z-index: -1;
  transform: scale(1.05); filter: blur(14px);
  opacity: calc(var(--eb-glow) * 0.6);
  background: linear-gradient(-30deg, var(--eb-light), transparent 45%, var(--eb));
}
#timer .timer-val { position: relative; z-index: 2; color: #f4f6ff; text-shadow: 0 0 6px var(--eb-light), 0 1px 5px rgba(0, 0, 0, 0.75); }

/* Urgency: purple under 30s, red under 10s; glow rises. */
#timer.warn   { --eb: #b15cff; --eb-light: #e3ccff; --eb-glow: 0.9; }
#timer.danger { --eb: #ff3b3b; --eb-light: #ffb3b3; --eb-glow: 1; }
#timer.warn .timer-val   { color: #f0e0ff; }
#timer.danger .timer-val { color: #ffd0d0; }

/* Breathing (scale + glow pulse) only in the final 30s; --eb-speed intensifies it
   and replaces the calm flicker on the glow. */
#timer.warn, #timer.danger { animation: eb-breathe var(--eb-speed) ease-in-out infinite; }
#timer.warn   .eb-glow-1, #timer.warn   .eb-glow-2, #timer.warn   .eb-bg,
#timer.danger .eb-glow-1, #timer.danger .eb-glow-2, #timer.danger .eb-bg {
  animation: eb-pulse var(--eb-speed) ease-in-out infinite;
}
@keyframes eb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes eb-pulse   { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes eb-flicker {
  0%, 100% { opacity: var(--eb-glow); }
  28% { opacity: calc(var(--eb-glow) * 0.55); }
  32% { opacity: calc(var(--eb-glow) * 0.95); }
  53% { opacity: calc(var(--eb-glow) * 0.68); }
  58% { opacity: var(--eb-glow); }
  79% { opacity: calc(var(--eb-glow) * 0.6); }
  83% { opacity: calc(var(--eb-glow) * 0.9); }
}

.score-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.score-row.me { font-weight: 700; }
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.score-name { flex: 1; color: var(--muted); }
.score-row.me .score-name { color: var(--ink); }
.score-pct { font-weight: 700; margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 13, 0.55);
  backdrop-filter: blur(3px);
  z-index: 5;
}
.overlay.hidden { display: none; }
.card {
  text-align: center;
  padding: 28px 40px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#spectate {
  inset: auto auto 14px 14px;
  width: min(330px, calc(100% - 28px));
  height: auto;
  align-items: flex-end;
  justify-content: flex-start;
  background: transparent;
  backdrop-filter: none;
}
#spectate.hidden { display: none; }
#spectate .card {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  border-radius: 10px;
  background: rgba(18, 21, 30, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}
#spectate .big {
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.12em;
  margin-bottom: 5px;
}
#spectate .sub {
  font-size: 12px;
  line-height: 1.35;
  margin-top: 0;
}
.big {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.sub { color: var(--muted); font-size: 16px; margin-top: 12px; }

#result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 0;
  width: 100%;
  min-width: 220px;
}
.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.result-row .score-name { text-align: left; }
.result-row .score-pct { font-weight: 400; }

#hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  padding: 7px 14px;
  border-radius: 8px;
  pointer-events: none;
}
.key {
  display: inline-block;
  background: #2a2f3d;
  color: var(--ink);
  border-radius: 4px;
  padding: 1px 7px;
  margin: 0 1px;
  font-weight: 700;
  box-shadow: 0 2px 0 #1a1d27;
}

/* ===========================================================================
   shadcn-style UI layer (vanilla CSS). Neutral zinc chrome with one warm paint
   accent that ties to the arcade stage frame. The canvas/stage stays untouched.
   =========================================================================== */
:root {
  --st-card: rgba(17, 18, 23, 0.92);
  --st-card-solid: #131418;
  --st-fg: #f4f4f5;
  --st-muted-fg: #a1a1aa;
  --st-border: rgba(255, 255, 255, 0.10);
  --st-border-strong: rgba(255, 255, 255, 0.18);
  --st-primary: #ff6a3d;
  --st-primary-hover: #ff7e57;
  --st-primary-fg: #ffffff;
  --st-ring: rgba(255, 122, 79, 0.55);
  --st-secondary: rgba(255, 255, 255, 0.055);
  --st-secondary-hover: rgba(255, 255, 255, 0.10);
  --st-radius: 12px;
  --st-radius-ctl: 10px;
  --st-control-h: 40px;
  --st-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Cards (results, spectate base, start) -> shadcn surface */
.card {
  text-align: center;
  padding: 24px 28px;
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 16px;
  box-shadow: var(--st-shadow);
  backdrop-filter: blur(10px);
}

/* (timer + its electric border are styled with the base #timer rule) */

/* Block-level top bar: settings (left), full ranking split around the centered
   timer. Entries are sorted by coverage and smoothly re-shuffle (FLIP). */
#topbar {
  position: relative;       /* block element in the document flow */
  z-index: 3;               /* under the canvas overlay (4); brush tips draw over it */
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: #14171f;      /* = ARENA_BG in client.js: the bar blends seamlessly into the board */
  font-variant-numeric: tabular-nums;
  overflow: hidden;         /* clip ranking chips if they exceed the width */
}
.rank-group {
  flex: 1;
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}
#rank-left { justify-content: flex-end; }     /* hug the timer from the left */
#rank-right { justify-content: flex-start; }   /* hug the timer from the right */
/* Pads the gear side so the timer stays truly centered between the two rank
   groups: legend(133) - gear(34) - the extra flex gap(8) ≈ 91. Tune if the
   legend button changes size. */
.topbar-balance { width: 91px; flex: none; }
/* Lifetime multiplayer stats (Wins / Streak): floats just right of the
   gear, OUT of the flex flow so the .topbar-balance centering math stays exact.
   Landing only (body.in-menu) -- in a match the bar stays clean. renderStats()
   fills it; it stays :empty (so invisible) until a first real match is recorded. */
#topbar .stats {
  display: none;
  position: absolute;
  left: 48px;                    /* bar padding(10) + gear(30) + flex gap(8) */
  top: 50%;
  transform: translateY(-50%);
}
body.in-menu #topbar .stats { display: flex; }
body.in-menu #topbar .stats:empty { display: none; }

.lb-item {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 2px 9px 3px; font-size: 13px; line-height: 1.25; border-radius: 8px;
  transition: transform 0.45s ease;          /* FLIP slide when ranks shuffle */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}
.lb-item.me { font-weight: 700; background: rgba(255, 255, 255, 0.08); }
.lb-crown { width: 15px; height: 15px; object-fit: contain; flex: none; }
.lb-rank { color: var(--st-muted-fg); font-size: 11px; font-weight: 700; min-width: 13px; text-align: center; }
.lb-name { color: var(--st-fg); max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pct { color: var(--st-fg); font-weight: 700; }
.lb-item .swatch { width: 11px; height: 11px; }

/* Settings dropdown */
#settings-menu {
  position: absolute;
  top: 46px;
  left: 8px;
  width: 210px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  box-shadow: var(--st-shadow);
  z-index: 6;
}
#settings-menu.hidden { display: none; }
.settings-title { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--st-muted-fg); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--st-fg); }
/* Fixed label column so every slider starts at the same x and spans the same width. */
.settings-row > span { flex: none; width: 52px; }
.settings-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--st-primary); cursor: pointer; }
/* Players stepper -- landing only (a real match is always server-filled to 6). */
.settings-row-players { display: none; }
body.in-menu .settings-row-players { display: flex; }
.stepper { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.stepper-btn { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 7px; background: rgba(255, 255, 255, 0.08); color: var(--st-fg); font-size: 10px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.stepper-btn:hover { background: rgba(255, 255, 255, 0.16); }
.stepper-btn:disabled { opacity: 0.3; cursor: default; }
.stepper-val { min-width: 16px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.settings-btn-sm {
  appearance: none; border: 1px solid var(--st-border-strong); background: transparent;
  color: var(--st-fg); font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 8px; cursor: pointer;
}
.settings-btn-sm:hover { background: rgba(255, 255, 255, 0.06); }

/* Results panel rows (full standings at round end) */
.score-row { font-size: 13.5px; letter-spacing: 0.2px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
.score-name { color: var(--st-muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 116px; }
.score-row.me .score-name { color: var(--st-fg); }
.score-pct { color: var(--st-fg); }
.swatch { border-radius: 5px; box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 0 10px -2px currentColor; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--st-border-strong);
  background: transparent;
  color: var(--st-fg);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.06s ease, box-shadow 0.14s ease;
  pointer-events: auto;
}
.btn:hover { background: rgba(255, 255, 255, 0.06); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  border-color: transparent;
  background: var(--st-primary);
  color: var(--st-primary-fg);
  box-shadow: 0 8px 22px -8px var(--st-ring), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-primary:hover { background: var(--st-primary-hover); }
.btn-ghost {
  border-color: var(--st-border);
  color: var(--st-muted-fg);
  font-size: 13px;
  padding: 7px 14px;
  margin-top: 14px;
}
.btn-ghost:hover { color: var(--st-fg); }

/* Inputs */
.input {
  appearance: none;
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--st-fg);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--st-border-strong);
  border-radius: 10px;
  padding: 11px 14px;
  text-align: center;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.input::placeholder { color: var(--st-muted-fg); }

/* Focus rings */
.btn:focus-visible,
.input:focus-visible,
.icon-btn:focus-visible,
.nav-btn:focus-visible,
.play-btn:focus-visible,
.link-btn:focus-visible {
  outline: none;
  border-color: var(--st-primary);
  box-shadow: 0 0 0 2px var(--st-ring);
}
.start-form .input:focus-visible { border-color: var(--st-primary); }

/* Icon button (HUD mute) */
/* Settings gear in the top bar (Mac-toolbar style) */
.icon-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--st-muted-fg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--st-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--st-fg); }
.icon-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.12); color: var(--st-fg); }

.link-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--st-muted-fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--st-fg); }

/* ---- Landing -------------------------------------------------------------- */
/* The landing runs the local single-brush tutorial sim full-bleed on the canvas
   behind the menu UI (see "Landing tutorial sim" in client.js): WASD steers,
   power-ups spawn with the full ceremony and teach themselves via #sim-toast. */

/* Landing-only bottom bar (toggled by body.in-menu from setNavVisible): brand on
   the left, poster-scale start prompt + controls on the right. */
#bottom-nav {
  --landing-control-h: 64px;
  --landing-title-size: 106px;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 7;
  display: none;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 18px 28px;
  padding: 22px 28px;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(8, 9, 13, 0.96) 0%, rgba(8, 9, 13, 0.74) 62%, rgba(8, 9, 13, 0) 100%);
  pointer-events: none;          /* gaps pass through to the game; children re-enable */
}
body.in-menu #bottom-nav { display: flex; }
#bottom-nav > * { pointer-events: auto; }
.nav-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.nav-right {
  position: relative;
  display: flex;
  flex: 1 1 680px;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  margin-left: auto;
  isolation: isolate;
}
.landing-title {
  position: relative;
  z-index: 0;
  max-width: 100%;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: var(--landing-title-size);
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: 0;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.34),
    0 0 30px rgba(255, 255, 255, 0.12);
}
.nav-control-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
}
.nav-actions { display: flex; align-items: center; gap: 10px; }

/* Secondary control surface shared by the X link + settings gear. */
.nav-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--landing-control-h);
  width: auto;
  padding: 0 18px;
  background: var(--st-secondary);
  border: 1px solid var(--st-border);
  color: var(--st-fg);
  font: inherit;
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--st-radius-ctl);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.06s ease;
}
.nav-btn:hover { background: var(--st-secondary-hover); border-color: var(--st-border-strong); }
.nav-btn:active { transform: scale(0.97); }
/* Icon-only square (settings gear) -- the rightmost action, so the popover anchors over it. */
.nav-icon-btn { width: var(--landing-control-h); padding: 0; flex: none; color: var(--st-muted-fg); }
.nav-icon-btn:hover { color: var(--st-fg); }
.nav-icon-btn[aria-expanded="true"] { background: var(--st-secondary-hover); border-color: var(--st-border-strong); color: var(--st-fg); }
/* Social link -- lowest emphasis (muted until hover). Left padding shaved so the
   leading X glyph sits optically centered against the handle. */
.nav-link { color: var(--st-muted-fg); font-weight: 500; padding: 0 20px 0 16px; }
.nav-link:hover { color: var(--st-fg); }
.nav-icon {
  width: 25px;
  height: 25px;
  flex: none;
  opacity: 0.95;
  transform-box: fill-box;
  transform-origin: center;
}
.nav-icon-play { transform: translateX(1px); }
.nav-icon-x { transform: translateX(-0.5px); }
.nav-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Landing floating gear: RETIRED while the top bar lives on the landing (its
   gear + default-anchored popover serve both scenes). Kept in the markup for
   an easy revival if the bar ever leaves the landing again. */
#landing-settings { display: none; }
/* Power-up legend: an avatar-stack button at the top bar's right end (both
   scenes -- the landing sim and matches) that opens a cheat-sheet popover
   naming every pickup. Icons are cells of the powerups spritesheet picked by
   --pu-col (14 cols x 2 rows; row 0 = active art). */
#legend {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
}
#legend-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px 0 7px;
  background: var(--st-secondary);
  border: 1px solid var(--st-border);
  color: var(--st-fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.06s ease;
}
#legend-btn:hover { background: var(--st-secondary-hover); border-color: var(--st-border-strong); }
#legend-btn:active { transform: scale(0.97); }
#legend-btn[aria-expanded="true"] { background: var(--st-secondary-hover); border-color: var(--st-border-strong); }
#legend-btn .pu-avatar { --pu-size: 20px; box-shadow: 0 0 0 1px var(--st-card-solid); }
.legend-stack { display: inline-flex; }
.legend-stack .pu-avatar:not(:first-child) { margin-left: -7px; }
.pu-avatar {
  --pu-size: 34px;
  width: var(--pu-size);
  height: var(--pu-size);
  flex: none;
  border-radius: 50%;
  background-color: var(--st-card-solid);
  background-image: url("/assets/powerups.png?v=powerups-14x2-r1");
  background-repeat: no-repeat;
  /* 14x2 sheet scaled so one cell fills the circle; x lands on cell N via the
     percentage-position rule (N/13 spreads 14 cells across 0..100%). */
  background-size: 1400% 200%;
  background-position: calc(var(--pu-col, 0) * 100% / 13) 0;
  box-shadow: 0 0 0 2px var(--st-card-solid);
}
#legend-menu {
  /* FIXED so the bar's overflow:hidden can't clip it; anchored just below the
     bar at its right edge. */
  position: fixed;
  top: 46px;
  right: 8px;
  z-index: 8;
  width: 348px;
  max-height: min(68vh, 620px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--st-card);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  box-shadow: var(--st-shadow);
}
#legend-menu.hidden { display: none; }
.legend-title { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--st-muted-fg); }
.legend-group {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7ddc8e;
}
.legend-group-bad { margin-top: 8px; color: #ff8d8d; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--st-fg); }
.legend-row .pu-avatar { --pu-size: 28px; box-shadow: 0 0 0 1px var(--st-border); }
.legend-name { flex: none; font-weight: 700; }
.legend-desc { color: var(--st-muted-fg); }
/* Landing tutorial line, perched directly above the START MULTIPLAYER
   headline (absolute against .nav-right so it tracks the title across
   breakpoints and hides with the nav in a match). Plain paragraph text -- no
   card -- with the power-up icon inline: "[icon] Name — effect". Class is set
   by client.js: 'hint' (no icon), 'boon' (green name) or 'bad' (red name).
   pointer-events off so it never steals clicks from the sim underneath. */
#sim-toast {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 2;
  display: block;
  text-align: right;
  font-size: 15px;
  line-height: 1.45;
  color: var(--st-fg);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#sim-toast.hidden { display: none; }
#sim-toast.pop { animation: sim-toast-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.18); }
@keyframes sim-toast-pop {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
#sim-toast .pu-avatar {
  --pu-size: 24px;
  display: inline-block;
  vertical-align: -6px;
  margin-right: 8px;
  box-shadow: 0 0 0 1px var(--st-border);
}
.sim-toast-text { display: inline; }
.sim-toast-name { font-weight: 700; }
.sim-toast-name::after { content: " — "; font-weight: 400; color: var(--st-muted-fg); }
#sim-toast.boon .sim-toast-name { color: #7ddc8e; }
#sim-toast.bad .sim-toast-name { color: #ff8d8d; }
.sim-toast-desc { color: var(--st-fg); }
#sim-toast.hint .sim-toast-desc { color: var(--st-muted-fg); }
/* Context note (e.g. "A rival grabbed this one.") sits on its own line above. */
.sim-toast-note { display: block; font-size: 12px; color: var(--st-fg); }
/* Round-result variant: the leader crown rides inline before "You win!". */
.sim-result-crown { height: 22px; display: inline-block; vertical-align: -5px; margin-right: 8px; }
/* Brand lockup: the full "Battle Painter" wordmark SVG carries the brand on its
   own (script lettering + brush + splashes), so no companion text element. */
.brand { display: inline-flex; align-items: center; }
.brand-mark {
  width: auto;
  height: 175px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

/* Name + Play: the primary action, pushed to the right edge of the bar. */
.start-form { display: flex; flex: 1 1 auto; flex-direction: row; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; }
.start-form .input {
  width: 520px;
  max-width: 100%;
  height: var(--landing-control-h);
  min-height: 0;
  padding: 0 28px;
  text-align: left;
  font-size: 24px;
  font-weight: 700;
  border-radius: var(--st-radius-ctl);
  background: rgba(255, 255, 255, 0.045);
  border: 3px solid var(--st-primary);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(0, 0, 0, 0.38),
    0 0 22px rgba(255, 106, 61, 0.12);
}
.start-form .input::placeholder { color: var(--st-muted-fg); }
.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--landing-control-h);
  min-height: 0;
  width: auto;
  padding: 0 30px 0 24px;   /* optical: shave the icon (left) side so ▶ + label reads centered */
  font-size: 28px;
  font-weight: 800;
  border-radius: var(--st-radius-ctl);
  border-color: transparent;
  background: var(--st-primary);
  color: var(--st-primary-fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.play-btn:hover {
  background: var(--st-primary-hover);
  box-shadow: 0 2px 10px -2px var(--st-ring), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@media (max-width: 1100px) {
  /* The sim's rank chips (hugging the timer) reach the stats pill's spot here. */
  body.in-menu #topbar .stats { display: none; }
  #bottom-nav {
    --landing-control-h: 56px;
    --landing-title-size: 82px;
    padding: 18px 22px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .start-form .input {
    width: 390px;
    padding-inline: 22px;
    font-size: 20px;
  }
  .play-btn,
  .nav-btn {
    font-size: 20px;
  }
  .nav-icon {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 760px) {
  #bottom-nav {
    --landing-control-h: 50px;
    --landing-title-size: 58px;
    align-items: stretch;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 12px;
    max-width: 100vw;
    overflow: hidden;
    padding: 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .nav-left {
    width: 100%;
  }
  .brand-mark {
    height: 120px;
  }
  /* In-bar legend goes icon-only on small screens; the balance shrinks with it. */
  #legend-btn .legend-label { display: none; }
  #legend-btn { padding: 0 7px; gap: 0; }
  #legend-menu { width: min(348px, calc(100vw - 16px)); right: 6px; }
  .topbar-balance { width: 31px; }
  .nav-right {
    flex-basis: 100%;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .landing-title {
    display: block;
    width: 100%;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .nav-control-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-top: 10px;
    max-width: 100%;
  }
  .start-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    max-width: 100%;
  }
  .start-form .input {
    width: 100%;
    min-width: 0;
    padding-inline: 16px;
    font-size: 18px;
  }
  .play-btn {
    padding: 0 20px 0 16px;
    font-size: 19px;
  }
  .nav-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
  }
  .nav-link {
    flex: 1 1 auto;
    min-width: 0;
  }
  .nav-btn {
    font-size: 17px;
  }
  .nav-icon {
    width: 20px;
    height: 20px;
  }
  /* Tutorial line tightens up on small screens (still above the headline). */
  #sim-toast { font-size: 13px; }
  #sim-toast .pu-avatar { --pu-size: 20px; vertical-align: -5px; margin-right: 6px; }
}

@media (max-width: 430px) {
  #bottom-nav {
    --landing-title-size: 40px;
  }
  .brand-mark {
    height: 90px;
  }
  .start-form {
    gap: 8px;
  }
  .start-form .input,
  .play-btn,
  .nav-btn {
    font-size: 16px;
  }
  .start-form .input {
    border-width: 2px;
  }
}

/* Stats as a bare debug-style readout (think network/FPS overlay): one tiny
   "WINS n  STREAK n" line, no chrome at all. Floats over the .topbar-balance
   dead zone, so it never costs the bar width. */
.stats {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
}
.stats:empty { display: none; }
.stats .stat {
  display: flex;
  flex-direction: row-reverse;   /* DOM is value,label -- show label left, value right */
  align-items: baseline;
  gap: 4px;
}
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
/* Type scale mirrors the leaderboard chips: 13px values (.lb-pct) over 11px
   muted secondary text (.lb-rank). */
.stat-value { font-size: 13px; font-weight: 700; line-height: 1.1; color: var(--st-fg); }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.1;
  color: color-mix(in srgb, var(--st-muted-fg) 85%, transparent);
}

/* Round-end results */
#results {
  z-index: 2147483000;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 224, 93, 0.16), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(22, 215, 199, 0.15), transparent 27%),
    rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(5px);
}
#results-confetti {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  width: 100vw;
  height: 100vh;
  filter: none;
  backdrop-filter: none;
  mix-blend-mode: normal;
  pointer-events: none;
}
.round-end-card {
  position: relative;
  z-index: 2;
  overflow: hidden;
  width: min(760px, calc(100vw - 36px));
  min-height: min(610px, calc(100vh - 36px));
  padding: clamp(22px, 4vw, 48px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(21, 23, 28, 0.96), rgba(9, 10, 13, 0.92));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
  isolation: isolate;
}
.round-end-card::before {
  position: absolute;
  inset: 16px;
  z-index: -1;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
}
.round-end-card::after {
  position: absolute;
  right: -84px;
  bottom: -64px;
  z-index: -1;
  width: 330px;
  height: 330px;
  content: "";
  background: conic-gradient(from 20deg, #16d7c7, #ffe05d, #ff5b51, #a8ff78, #16d7c7);
  filter: blur(24px);
  opacity: 0.2;
  transform: rotate(12deg);
}
.result-kicker {
  display: inline-flex;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #a9a99d;
  background: rgba(0, 0, 0, 0.24);
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
}
#result-title.big {
  max-width: 10ch;
  margin: 30px 0 30px;
  color: #ffe05d;
  font-size: clamp(54px, 9vw, 132px);
  font-weight: 950;
  line-height: 0.84;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-align: left;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 #fff7bd,
    0 12px 0 rgba(0, 0, 0, 0.24),
    0 0 34px rgba(255, 224, 93, 0.25);
}
#results[data-outcome="loser"] #result-title.big,
#results[data-outcome="neutral"] #result-title.big {
  color: #d4d7df;
  text-shadow:
    0 1px 0 #ffffff,
    0 12px 0 rgba(0, 0, 0, 0.34),
    0 0 28px rgba(212, 215, 223, 0.12);
}
#results[data-outcome="tie"] #result-title.big {
  color: #16d7c7;
  text-shadow:
    0 1px 0 #c7fff8,
    0 12px 0 rgba(0, 0, 0, 0.26),
    0 0 32px rgba(22, 215, 199, 0.22);
}
#results #result-list {
  display: grid;
  gap: 10px;
  width: 100%;
  margin: 0;
}
#results .result-row {
  display: grid;
  grid-template-columns: 16px minmax(110px, 210px) minmax(160px, 1fr) 64px;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-shadow: none;
}
#results .result-row.me {
  border-color: rgba(255, 224, 93, 0.52);
  background: rgba(255, 224, 93, 0.1);
}
#results .swatch {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
}
#results .score-name {
  min-width: 0;
  max-width: none;
  overflow: hidden;
  color: var(--st-fg);
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
#results .result-bar {
  position: relative;
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
#results .result-bar span {
  display: block;
  width: var(--pct);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bar-color), color-mix(in srgb, var(--bar-color), white 30%));
}
#results .score-pct {
  margin: 0;
  color: var(--st-fg);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}
.result-empty {
  color: #a9a99d;
  font-size: 14px;
  text-transform: uppercase;
}
.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  margin-top: 22px;
}
#results .sub {
  margin: 0;
  color: #a9a99d;
  font-size: 13px;
  text-transform: uppercase;
}
#results .btn-ghost {
  margin: 0;
  border-radius: 7px;
}

@media (max-width: 640px) {
  #results {
    padding: 10px;
  }
  .round-end-card {
    width: calc(100vw - 20px);
    min-height: min(540px, calc(100vh - 20px));
    padding: 24px 18px;
  }
  #result-title.big {
    margin: 24px 0;
    font-size: clamp(48px, 17vw, 86px);
  }
  #results .result-row {
    grid-template-columns: 16px minmax(72px, 1fr) 58px;
  }
  #results .result-bar {
    display: none;
  }
  .result-footer {
    align-items: stretch;
    flex-direction: column;
  }
}
