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

:root {
  --font-display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  /* Comic lettering for shouty UI text (logo, headings, buttons, countdown); numbers stay in --font-display */
  --font-comic: 'Bangers', 'Impact', var(--font-display);
  --font-ui: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gold: #ffd84a;
  --gold-deep: #c98a0c;
  --blue: #8fa8ff;
  --blue-deep: #4b5fc4;
  --ink: #1d1a2b;
  --pow-red: #ff3b3b;
  /* Comic ink: hard black outlines and offset shadows, no blur */
  --line: #0b0916;
  /* Ben-Day halftone dots */
  --halftone: radial-gradient(rgba(255, 255, 255, 0.07) 1.4px, transparent 1.6px) 0 0 / 10px 10px;
  /* Reserved banner strip under the board (set by src/debug.js ?ad= for now) */
  --ad-h: 0px;
  --ad-gap: 0px;
  /* Play area: safe-area insets + the banner strip */
  --stage-top: env(safe-area-inset-top, 0px);
  --stage-left: env(safe-area-inset-left, 0px);
  --stage-right: env(safe-area-inset-right, 0px);
  --stage-bottom: calc(var(--ad-h) + var(--ad-gap) + env(safe-area-inset-bottom, 0px));
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #0b0916;
  color: #fff;
  font-family: var(--font-ui);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas { display: block; touch-action: none; }

#stage, .overlay, .intro {
  position: fixed;
  top: var(--stage-top);
  left: var(--stage-left);
  right: var(--stage-right);
  bottom: var(--stage-bottom);
}
#stage { overflow: hidden; }

#ad-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  height: var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
#ad-bar[data-mock]::before {
  content: attr(data-mock);
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, var(--ad-w, 320px));
  height: 100%;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  font: 600 12px var(--font-ui);
  letter-spacing: 1px;
}

#rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  #rotate {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--halftone), #0b0916;
    font-family: var(--font-comic);
    font-size: 34px;
    letter-spacing: 1.5px;
    color: var(--gold);
    -webkit-text-stroke: 3px var(--line);
    paint-order: stroke fill;
    text-shadow: 3px 4px 0 var(--line);
    text-align: center;
    padding: 16px;
  }
}

.overlay {
  display: flex;
  justify-content: center;
  background:
    var(--halftone),
    radial-gradient(ellipse at 50% 40%, rgba(60, 40, 110, 0.55), rgba(5, 3, 12, 0.85) 70%);
  backdrop-filter: blur(4px);
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  transition: opacity 0.25s;
}
/* margin:auto centres the panel but lets it scroll from the top when taller than the screen */
/* First load: opaque, so the empty board isn't visible behind the menu (same look as the blurred overlay over #0b0916) */
.overlay.solid {
  background: var(--halftone), radial-gradient(ellipse at 50% 40%, #261a46, #06040d 70%);
  backdrop-filter: none;
}
.overlay > .panel { margin: auto 0; }
#overlay-ready, #overlay-ready.solid {
  --rays: repeating-conic-gradient(from 0deg at 50% 32%, rgba(170, 150, 255, 0.09) 0deg 5.625deg, transparent 5.625deg 11.25deg);
  background:
    var(--halftone),
    radial-gradient(ellipse at 50% 32%, transparent 20%, rgba(5, 3, 12, 0.75) 80%),
    var(--rays),
    radial-gradient(ellipse at 50% 32%, rgba(70, 44, 140, 0.7), rgba(11, 9, 22, 0.92) 75%);
}
#overlay-ready.solid { background-color: #0b0916; }
/* Room for the logo to burst out over the top of the panel */
#overlay-ready { padding-top: 96px; }
.overlay.hidden { opacity: 0; pointer-events: none; }

#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.overlay.hidden .panel { transform: scale(0.85) translateY(20px); }

.panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  text-align: center;
  background: linear-gradient(180deg, #2e2850 0%, #1d1a2b 60%, #17142a 100%);
  border: 4px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px 22px;
  box-shadow:
    inset 0 0 0 3px #5a4f8c,
    inset 0 5px 0 3px rgba(255, 255, 255, 0.1),
    8px 8px 0 var(--line),
    0 24px 60px rgba(0, 0, 0, 0.7);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

/* Light sweep across the results panel as it lands (class toggled by playOverIntro) */
#overlay-over .panel::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.16) 48%, rgba(255, 255, 255, 0.05) 54%, transparent 65%) no-repeat;
  background-size: 300% 100%;
  background-position: 100% 0;
  opacity: 0;
}
#overlay-over .panel.sweep::after { animation: panel-sweep 0.9s ease-out 0.35s; }
@keyframes panel-sweep {
  0% { background-position: 100% 0; opacity: 1; }
  100% { background-position: 0 0; opacity: 1; }
}

/* ----- Title: comic POW² on a starburst ----- */
h1 {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 170px;
  margin: -112px -10px -6px;
  font-family: var(--font-comic);
  font-weight: 400;
  line-height: 1;
}
/* Starburst: an ink layer offset behind a halftoned red-to-gold fill */
h1::before, h1::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 300px;
  height: 180px;
  margin: -90px 0 0 -150px;
  clip-path: polygon(50% 0%, 58% 22%, 75% 4%, 74% 27%, 98% 18%, 84% 40%, 100% 52%, 81% 60%, 93% 84%, 69% 74%, 62% 100%, 51% 78%, 38% 98%, 33% 74%, 9% 88%, 19% 62%, 0% 50%, 18% 39%, 4% 15%, 28% 25%, 26% 3%, 41% 22%);
  animation: burst 2.4s ease-in-out infinite;
}
h1::before { background: var(--line); translate: 6px 6px; }
h1::after {
  background:
    radial-gradient(rgba(255, 255, 255, 0.35) 1.5px, transparent 1.8px) 0 0 / 8px 8px,
    radial-gradient(circle, var(--gold) 0%, #ffb020 45%, var(--pow-red) 80%);
  scale: 0.94;
}
@keyframes burst {
  0%, 100% { rotate: -2deg; }
  50% { rotate: 2deg; }
}
h1 .t1 {
  position: relative;
  z-index: 1;
  font-size: 92px;
  letter-spacing: 3px;
  color: #fff;
  -webkit-text-stroke: 4px var(--line);
  paint-order: stroke fill;
  text-shadow: 4px 5px 0 var(--line);
  transform: rotate(-6deg);
  animation: bob 2.4s ease-in-out infinite;
}
h1 .t2 {
  position: relative;
  top: -0.2em;
  margin-left: 2px;
  font-size: 54px;
  vertical-align: top;
  color: var(--gold);
}
@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}

h2 {
  font-family: var(--font-comic);
  font-weight: 400;
  font-size: 36px;
  color: #fff;
  letter-spacing: 1.5px;
  -webkit-text-stroke: 3px var(--line);
  paint-order: stroke fill;
  text-shadow: 3px 4px 0 var(--line);
}

/* Narration caption, like the yellow boxes in a comic panel */
.panel p.caption {
  margin: 6px 4px 22px;
  padding: 8px 12px;
  background: #fff1a8;
  color: var(--line);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  border: 3px solid var(--line);
  box-shadow: 4px 4px 0 var(--line);
  transform: rotate(-1.5deg);
}
.panel p {
  margin: 18px 0 20px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.45;
  font-size: 15px;
  font-weight: 500;
}

/* ----- Results ----- */
.score-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 88px;
  margin: 6px 0 16px;
  border: 3px solid var(--line);
  border-radius: 12px;
  /* Action lines radiating from the score */
  background:
    radial-gradient(ellipse at center, rgba(255, 216, 74, 0.22), transparent 65%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 216, 74, 0.12) 0deg 5deg, transparent 5deg 13deg),
    #2a1d4e;
  box-shadow: 5px 5px 0 var(--line);
  transform: rotate(-1deg);
}
.final-score {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 56px;
  color: var(--gold);
  -webkit-text-stroke: 5px var(--line);
  paint-order: stroke fill;
  filter: drop-shadow(4px 4px 0 var(--line));
  font-variant-numeric: tabular-nums;
  transform-origin: center;
  will-change: transform;
}
.final-score.long { font-size: 44px; }
/* Expanding rings behind the score on a big finish */
.pulse-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow: 0 0 24px rgba(255, 216, 74, 0.6);
  opacity: 0;
  pointer-events: none;
}

.stats { display: flex; gap: 10px; margin-bottom: 16px; }
.stats div {
  flex: 1;
  background: #2b2547;
  border: 3px solid var(--line);
  border-radius: 10px;
  padding: 9px 4px 7px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08), 3px 3px 0 var(--line);
}
.stats div:nth-child(odd) { transform: rotate(-1.5deg); }
.stats div:nth-child(even) { transform: rotate(1.5deg); }
.stats span { display: block; font-family: var(--font-display); font-size: 24px; letter-spacing: 0.5px; }
.stats label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
}

.best { font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.65); margin-bottom: 18px; min-height: 1em; }
.best.new {
  font-family: var(--font-comic);
  font-size: 24px;
  letter-spacing: 1.5px;
  color: var(--gold);
  -webkit-text-stroke: 3px var(--line);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--line);
  animation: bob 1.2s ease-in-out infinite;
}

/* ----- Buttons: chunky 3D ----- */
button {
  --face: var(--gold);
  --edge: var(--gold-deep);
  font-family: var(--font-comic);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 1.2px;
  color: #3a2300;
  background: linear-gradient(180deg, color-mix(in srgb, var(--face), #fff 30%) 0%, var(--face) 55%);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 13px 28px;
  cursor: pointer;
  width: 100%;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -4px 0 var(--edge),
    5px 5px 0 var(--line);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.1s;
}
@media (hover: hover) {
  button:hover { filter: brightness(1.08); transform: translate(-2px, -2px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.55), inset 0 -4px 0 var(--edge), 7px 7px 0 var(--line); }
}
button:active { transform: translate(4px, 4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.55), inset 0 -2px 0 var(--edge), 1px 1px 0 var(--line); }

.modes { display: flex; flex-direction: column; gap: 16px; }
button.mode {
  position: relative;
  text-align: left;
  padding: 14px 18px 14px 64px;
  rotate: -1deg;
}
button.mode.alt { rotate: 1deg; }
button.mode::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  width: 38px;
  height: 38px;
  margin-top: -19px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55) center / 22px no-repeat;
  border: 2px solid var(--line);
  box-shadow: 2px 2px 0 var(--line);
}
button.mode[data-mode='timed']::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233a2300' stroke-width='3' stroke-linecap='round'%3E%3Ccircle cx='12' cy='13' r='8'/%3E%3Cpath d='M12 9v4l3 2M9 2h6'/%3E%3C/svg%3E");
}
button.mode[data-mode='endless']::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23101a4a' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 8a4 4 0 1 0 0 8c2.5 0 3.5-2 6-4s3.5-4 6-4a4 4 0 1 1 0 8c-2.5 0-3.5-2-6-4S8.5 8 6 8z'/%3E%3C/svg%3E");
}
button.mode strong { display: block; font-weight: 400; font-size: 26px; }
button.mode small {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  opacity: 0.8;
  margin-top: 1px;
  letter-spacing: 0;
}
button.mode.alt { --face: var(--blue); --edge: var(--blue-deep); color: #101a4a; }

button.secondary {
  --edge: #0d0b18;
  margin-top: 12px;
  background: #2b2547;
  color: rgba(255, 255, 255, 0.8);
  font-size: 19px;
  padding: 10px 28px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.1), inset 0 -3px 0 var(--edge), 4px 4px 0 var(--line);
}

.mode-tag {
  display: inline-block;
  font-family: var(--font-comic);
  font-size: 15px;
  letter-spacing: 1.5px;
  border: 2px solid var(--line);
  text-transform: uppercase;
  color: #3a2300;
  background: var(--gold);
  border-radius: 999px;
  padding: 4px 14px 3px;
  margin-bottom: 10px;
  box-shadow: 3px 3px 0 var(--line);
  transform: rotate(-2deg);
}
.mode-tag.endless { background: var(--blue); color: #101a4a; }

/* ----- Floating menu balls ----- */
/* overflow:hidden keeps off-screen balls from adding scrollable overflow to the overlay */
.deco { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.deco i {
  position: absolute;
  left: var(--x);
  bottom: -120px;
  width: var(--s);
  height: var(--s);
  margin-left: calc(var(--s) / -2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-family: var(--font-display);
  font-size: calc(var(--s) * 0.42);
  color: var(--f, #fff);
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--c), #fff 45%), var(--c) 55%, color-mix(in srgb, var(--c), #000 25%));
  border: 3px solid var(--line);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15), 4px 4px 0 var(--line);
  opacity: 0.85;
  animation: rise 9s linear var(--d) infinite;
}
.deco i:nth-child(4) { font-size: calc(var(--s) * 0.28); }
@keyframes rise {
  0% { transform: translateY(0) rotate(-20deg); }
  100% { transform: translateY(calc(-100vh - 240px)) rotate(25deg); }
}
@media (max-width: 420px) { .deco i { opacity: 0.5; } }

/* Sound-effect stickers beside the panel (hidden when the panel fills the screen) */
.sticker {
  position: absolute;
  font-family: var(--font-comic);
  font-weight: 400;
  font-size: 54px;
  letter-spacing: 2px;
  color: #fff;
  -webkit-text-stroke: 5px var(--line);
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--line);
  padding: 30px 38px;
  isolation: isolate;
  rotate: var(--r);
  animation: sticker-wobble 2.6s ease-in-out var(--d, 0s) infinite;
}
.sticker.small { font-size: 40px; padding: 24px 30px; }
.sticker::before, .sticker::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  clip-path: polygon(50% 0%, 60% 20%, 80% 6%, 76% 28%, 100% 24%, 86% 44%, 100% 58%, 80% 64%, 90% 88%, 66% 76%, 56% 100%, 46% 80%, 30% 96%, 28% 74%, 4% 82%, 16% 60%, 0% 46%, 18% 36%, 6% 12%, 26% 24%, 30% 2%, 40% 18%);
}
.sticker::before { background: var(--line); translate: 6px 6px; }
.sticker::after {
  background: radial-gradient(rgba(255, 255, 255, 0.3) 1.5px, transparent 1.8px) 0 0 / 7px 7px, var(--c);
  scale: 0.92;
}
@keyframes sticker-wobble {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06) rotate(3deg); }
}
@media (max-width: 760px) { .sticker { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .deco i, h1 .t1, h1::before, h1::after, .sticker { animation: none; }
  .deco { display: none; }
}

/* ----- Intro pop-up: objective + countdown over the live board ----- */
.intro {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.3s;
}
.intro.hidden { opacity: 0; }
.intro-card {
  min-width: 200px;
  text-align: center;
  padding: 14px 22px 10px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(46, 40, 80, 0.94), rgba(23, 20, 42, 0.94));
  border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px #8a6a1c, 6px 6px 0 var(--line), 0 18px 40px rgba(0, 0, 0, 0.55);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.intro.endless .intro-card { box-shadow: inset 0 0 0 3px var(--blue-deep), 6px 6px 0 var(--line), 0 18px 40px rgba(0, 0, 0, 0.55); }
.intro:not(.hidden) .intro-card { animation: intro-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
.intro.hidden .intro-card { transform: scale(0.8) translateY(-16px); }
@keyframes intro-pop {
  0% { transform: scale(0.6) translateY(24px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.intro .mode-tag { margin-bottom: 6px; }
.intro-goal {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.3px;
  color: var(--gold);
  text-shadow: 0 2px 0 #6b3a00;
}
.intro.endless .intro-goal { color: var(--blue); text-shadow: 0 2px 0 #101a4a; }
.intro-count {
  height: 64px;
  font-family: var(--font-comic);
  font-size: 60px;
  line-height: 64px;
  letter-spacing: 2px;
  color: #fff;
  -webkit-text-stroke: 4px var(--line);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--line);
  font-variant-numeric: tabular-nums;
}
/* The final "POW!" lands tilted in red, like a comic sound effect */
.intro-count.go { color: var(--pow-red); rotate: -8deg; font-size: 68px; }
.intro.endless .intro-count.go { color: var(--blue); }
@media (prefers-reduced-motion: reduce) {
  .intro:not(.hidden) .intro-card { animation: none; }
}

/* ----- Weekly rank on the results card ----- */
.weekly-rank { font-size: 14px; font-weight: 700; color: var(--blue); margin: -10px 0 16px; min-height: 1.2em; }
.weekly-rank:empty { margin: 0; min-height: 0; }
.weekly-rank.new { color: var(--gold); text-shadow: 2px 2px 0 var(--line); }
.btn-row { display: flex; gap: 10px; }
.btn-row button { padding-left: 10px; padding-right: 10px; }

/* ----- Leaderboard overlay ----- */
.panel.board {
  max-width: 400px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  padding: 20px 18px 18px;
}
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  margin-bottom: 10px;
  flex-shrink: 0;
}
.seg button {
  font-size: 19px;
  padding: 6px 6px 5px;
  border: 2px solid transparent;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  box-shadow: none;
}
.seg button:hover { transform: none; box-shadow: none; filter: none; color: #fff; }
.seg button:active { transform: translateY(1px); box-shadow: none; }
.seg button.on { color: #3a2300; background: var(--gold); border-color: var(--line); box-shadow: inset 0 -3px 0 var(--gold-deep); }
.board.endless .seg button.on { color: #101a4a; background: var(--blue); box-shadow: inset 0 -3px 0 var(--blue-deep); }
.seg-small { border-width: 2px; }
.seg-small button { font-family: var(--font-ui); font-weight: 600; font-size: 13px; letter-spacing: 0; padding: 3px 6px; }
.board-reset { font-size: 12px !important; margin: 2px 0 8px !important; color: rgba(255, 255, 255, 0.55) !important; }

.board-list {
  list-style: none;
  overflow-y: auto;
  flex: 0 1 auto;
  min-height: 0;
  margin: 0 -6px 12px;
  padding: 0 6px;
  text-align: left;
}
.board-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 12px;
  font-weight: 600;
}
.board-list li:nth-child(odd):not(.msg):not(.gap) { background: rgba(255, 255, 255, 0.04); }
.board-list li.me { background: rgba(255, 216, 74, 0.16) !important; box-shadow: inset 0 0 0 2px var(--gold), 3px 3px 0 var(--line); }
.board-list li.msg { justify-content: center; padding: 28px 10px; color: rgba(255, 255, 255, 0.6); text-align: center; }
.board-list li.gap { justify-content: center; padding: 0; color: rgba(255, 255, 255, 0.4); }
/* Your own standing, pinned under the top 5 */
.board-list li.you { margin-top: 10px; position: relative; }
.board-list li.you::before { content: ''; position: absolute; left: 10px; right: 10px; top: -7px; border-top: 2px dashed rgba(255, 255, 255, 0.15); }
.board-list li.you .rank { width: auto; min-width: 28px; } /* ranks can run to 4+ digits */
.board-list .rank { width: 28px; text-align: center; font-family: var(--font-comic); font-size: 20px; color: rgba(255, 255, 255, 0.65); flex-shrink: 0; }
/* Podium ranks as inked medal badges */
.board-list .rank[class*='top'] {
  height: 28px;
  line-height: 25px;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: var(--line);
  box-shadow: 2px 2px 0 var(--line);
}
.board-list .rank.top1 { background: var(--gold); }
.board-list .rank.top2 { background: #d7dbe6; }
.board-list .rank.top3 { background: #e0975a; }
.board-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .score { font-family: var(--font-display); font-size: 17px; font-variant-numeric: tabular-nums; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  color: #fff;
  border: 2px solid var(--line);
}

/* ----- Account section ----- */
.account { border-top: 2px solid rgba(255, 255, 255, 0.08); padding-top: 12px; flex-shrink: 0; }
.account .who { display: flex; align-items: center; gap: 10px; text-align: left; }
.account .who .avatar { width: 36px; height: 36px; font-size: 18px; }
.who-name { flex: 1; min-width: 0; }
.who-name strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-name small { display: block; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.account .hint, .account .notice { font-size: 13px !important; margin: 10px 0 !important; }
.account .notice { color: #ff8a7a !important; }
.signin { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 4px; }
.gsi { min-height: 44px; }

button.mini {
  width: auto;
  flex-shrink: 0;
  font-size: 16px;
  padding: 5px 14px 4px;
  border-width: 2px;
  border-radius: 9px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -3px 0 var(--edge), 3px 3px 0 var(--line);
}
button.mini.ghost { --edge: #0d0b18; background: #2b2547; color: rgba(255, 255, 255, 0.8); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.1), 3px 3px 0 var(--line); }
.account > button.mini { margin-top: 10px; }
button.discord {
  --face: #5865f2;
  --edge: #3640a8;
  width: 260px;
  max-width: 100%;
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -3px 0 var(--edge), 4px 4px 0 var(--line);
}

.rename { flex: 1; display: flex; gap: 8px; min-width: 0; }
.rename input {
  flex: 1;
  min-width: 0;
  font: 600 16px var(--font-ui);
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border: 3px solid var(--line);
  border-radius: 9px;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5), 0 0 0 2px #5a4f8c;
  padding: 5px 10px;
  user-select: text;
  -webkit-user-select: text;
}
.rename input:focus { outline: none; box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5), 0 0 0 2px var(--gold); }
.panel.board > .mode-tag { align-self: center; }
/* Opens on top of the menu/results overlays: a darker scrim keeps those from bleeding through. */
#overlay-board, #overlay-merge { background: var(--halftone), radial-gradient(ellipse at 50% 40%, rgba(40, 26, 80, 0.85), rgba(5, 3, 12, 0.96) 70%); }

/* ----- Leaderboard scrollbar ----- */
.board-list { scrollbar-width: thin; scrollbar-color: #5a4f8c transparent; }
.board-list::-webkit-scrollbar { width: 8px; }
.board-list::-webkit-scrollbar-track { background: transparent; }
.board-list::-webkit-scrollbar-thumb { background: #5a4f8c; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.board-list::-webkit-scrollbar-thumb:hover { background-color: var(--gold); }
.board.endless .board-list::-webkit-scrollbar-thumb:hover { background-color: var(--blue); }

/* ----- Small screens ----- */
@media (max-height: 640px) {
  .panel { padding: 18px 18px 16px; }
  #overlay-ready { padding-top: 64px; }
  h1 { height: 124px; margin-top: -80px; }
  h1::before, h1::after { width: 220px; height: 124px; margin: -62px 0 0 -110px; }
  h1 .t1 { font-size: 66px; }
  h1 .t2 { font-size: 40px; }
  .panel p.caption { margin: 4px 4px 16px; font-size: 13px; }
  .panel p { margin: 12px 0 14px; font-size: 14px; }
  .modes { gap: 12px; }
  button { padding: 11px 24px; font-size: 20px; }
  button.mode { padding: 10px 16px 10px 60px; }
  .score-wrap { height: 68px; margin-bottom: 10px; }
  .final-score { font-size: 44px; }
  .final-score.long { font-size: 36px; }
  .best { margin-bottom: 12px; }
}
@media (max-width: 360px) {
  .stats span { font-size: 20px; }
  .stats label { font-size: 9px; letter-spacing: 0.4px; }
}
