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

:root {
  --court: #1d4e89;        /* pickleball court blue */
  --court-dark: #122f52;
  --clay: #ffb347;         /* warm accent */
  --line: #f5f1e6;         /* court line white */
  --ball: #d9ff3f;         /* electric pickleball lime */
  --mint: #3bf0c9;
  --ink: #04070f;          /* deep night navy */
  --glass: rgba(255, 255, 255, 0.06);
  --glass-line: rgba(255, 255, 255, 0.14);
  --font-display: "Bungee", "Arial Black", sans-serif;
  --font-body: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #123056 0%, var(--ink) 70%);
  font-family: var(--font-body);
  color: var(--line);
  user-select: none;
  -webkit-user-select: none;
}

#game-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  display: flex;
  flex-direction: column;
}

/* ================= HUD ================= */

#hud {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(8, 18, 38, 0.95), rgba(5, 11, 24, 0.9));
  border-bottom: 1px solid var(--glass-line);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  font-weight: 600;
  letter-spacing: 2px;
  font-size: clamp(9px, 2.2vw, 12px);
  text-transform: uppercase;
  color: rgba(245, 241, 230, 0.55);
  flex-wrap: wrap;
  z-index: 5;
  animation: hud-drop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

@keyframes hud-drop {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* glowing scan line sweeping along the HUD bottom edge */
#hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ball), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: hud-scan 4s ease-in-out infinite;
  opacity: 0.6;
  pointer-events: none;
}

@keyframes hud-scan {
  0%   { background-position: -40% 0; }
  50%  { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}

.hud-item { position: relative; }

.hud-item span {
  display: inline-block;
  color: var(--ball);
  margin-left: 6px;
  font-weight: 700;
  font-size: clamp(11px, 2.6vw, 15px);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(217, 255, 63, 0.45);
}

#canvas-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
}

/* gameplay needs touch-action: none for paddle drags, but when the overlay
   (intro / score / pause) is open it must not block overlay scrolling —
   iOS Safari can honour the ancestor's none over the child's pan-y */
#canvas-wrap:has(#overlay:not(.hidden)) {
  touch-action: pan-y;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ================= overlay (start / pause / score) ================= */

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(61, 240, 201, 0.10), transparent 55%),
    radial-gradient(ellipse at 50% 110%, rgba(217, 255, 63, 0.08), transparent 50%),
    linear-gradient(180deg, rgba(3, 8, 18, 0.82), rgba(3, 8, 18, 0.92));
  backdrop-filter: blur(10px) saturate(1.25);
  -webkit-backdrop-filter: blur(10px) saturate(1.25);
  text-align: center;
  transition: opacity 0.35s ease;
  overflow-y: auto;
  /* #canvas-wrap sets touch-action: none for gameplay — re-enable vertical
     scrolling here so tall content (phone screens) can reach START MATCH */
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* center when the content fits, scroll from the top when it doesn't —
   justify-content: center would clip the top of an overflowing overlay */
#overlay > :first-child { margin-top: auto; }
#overlay > :last-child { margin-bottom: auto; }

#overlay.hidden { opacity: 0; pointer-events: none; }

/* drifting particle fields — two tiled dot layers rising at different speeds */
#overlay::before,
#overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

#overlay::before {
  background-image:
    radial-gradient(circle, rgba(217, 255, 63, 0.55) 1.5px, transparent 1.6px),
    radial-gradient(circle, rgba(61, 240, 201, 0.45) 1.5px, transparent 1.6px);
  background-size: 210px 210px, 330px 330px;
  background-position: 30px 0, 120px 80px;
  animation: drift-a 16s linear infinite;
  opacity: 0.30;
}

#overlay::after {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.5) 1px, transparent 1.2px),
    radial-gradient(circle, rgba(255, 179, 71, 0.5) 1.5px, transparent 1.6px);
  background-size: 160px 160px, 260px 260px;
  background-position: 80px 40px, 10px 120px;
  animation: drift-b 10s linear infinite;
  opacity: 0.22;
}

@keyframes drift-a { to { background-position: 30px -210px, 120px -250px; } }
@keyframes drift-b { to { background-position: 80px -120px, 10px -140px; } }

/* staggered rise-in every time the overlay opens */
#overlay:not(.hidden) > * {
  position: relative;
  z-index: 1;
  animation: rise-in 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}
#overlay:not(.hidden) > *:nth-child(2) { animation-delay: 0.06s; }
#overlay:not(.hidden) > *:nth-child(3) { animation-delay: 0.12s; }
#overlay:not(.hidden) > *:nth-child(4) { animation-delay: 0.18s; }
#overlay:not(.hidden) > *:nth-child(5) { animation-delay: 0.24s; }
#overlay:not(.hidden) > *:nth-child(6) { animation-delay: 0.30s; }
#overlay:not(.hidden) > *:nth-child(7) { animation-delay: 0.36s; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#overlay h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(26px, 6.5vw, 56px);
  letter-spacing: 2px;
  line-height: 1.05;
  background: linear-gradient(110deg, #ffffff 20%, var(--ball) 40%, #ffffff 55%, var(--ball) 75%, #ffffff 90%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 26px rgba(217, 255, 63, 0.35));
  animation: title-shimmer 4s linear infinite, title-sway 5s ease-in-out infinite;
}

@keyframes title-shimmer {
  0%   { background-position: 125% 0; }
  100% { background-position: -125% 0; }
}

@keyframes title-sway {
  0%, 100% { transform: rotate(-0.6deg) scale(1); }
  50%      { transform: rotate(0.6deg) scale(1.015); }
}

#overlay .subtitle {
  font-size: clamp(10px, 2.4vw, 14px);
  text-transform: uppercase;
  letter-spacing: 5px;
  color: var(--clay);
  font-weight: 700;
  text-shadow: 0 0 16px rgba(255, 179, 71, 0.35);
  animation: neon-flicker 4s linear infinite;
}

@keyframes neon-flicker {
  0%, 100% { opacity: 1; }
  3%       { opacity: 0.6; }
  5%       { opacity: 1; }
  42%      { opacity: 1; }
  44%      { opacity: 0.55; }
  46%      { opacity: 1; }
  70%      { opacity: 0.85; }
  72%      { opacity: 1; }
}

#overlay-msg {
  font-size: clamp(13px, 3.4vw, 18px);
  max-width: 88vw;
  color: rgba(245, 241, 230, 0.85);
}

.controls-hint {
  font-size: clamp(10px, 2.6vw, 13px);
  color: rgba(245, 241, 230, 0.5);
  letter-spacing: 1px;
  max-width: 92vw;
}

/* ================= buttons ================= */

#start-btn {
  position: relative;
  margin-top: 10px;
  padding: 16px 52px;
  /* flex centering: font metric differences (esp. the webfont on iOS) leave
     the baseline off-center with plain padding */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #0a1206;
  background: linear-gradient(135deg, #eaff70 0%, var(--ball) 45%, #8fdc1f 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  box-shadow:
    0 0 30px rgba(217, 255, 63, 0.35),
    0 10px 28px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.4), box-shadow 0.18s;
  animation: cta-pulse 2.2s ease-in-out infinite, cta-wiggle 6s ease-in-out infinite;
}

#start-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: cta-shine 3s ease-in-out infinite;
}

#start-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 0 46px rgba(217, 255, 63, 0.55),
    0 14px 32px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

#start-btn:active { transform: translateY(1px) scale(0.98); }

@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 26px rgba(217, 255, 63, 0.30), 0 10px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.55); }
  50%      { box-shadow: 0 0 44px rgba(217, 255, 63, 0.55), 0 10px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.55); }
}

@keyframes cta-wiggle {
  0%, 88%, 100% { transform: rotate(0deg); }
  90%  { transform: rotate(-2deg) scale(1.03); }
  92%  { transform: rotate(2deg) scale(1.05); }
  94%  { transform: rotate(-1.5deg) scale(1.04); }
  96%  { transform: rotate(1deg) scale(1.02); }
  98%  { transform: rotate(0deg) scale(1); }
}

@keyframes cta-shine {
  0%, 55%  { left: -80%; }
  85%, 100% { left: 130%; }
}

#footer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 14px;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(245, 241, 230, 0.35);
  background: rgba(4, 7, 15, 0.9);
  border-top: 1px solid var(--glass-line);
  animation: footer-breathe 3.5s ease-in-out infinite;
}

/* "Made by Code Crush" credit — mirrors the agency's own in-game footer
   (cc-website OutroPage) */
.cc-credit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(245, 241, 230, 0.55);
  font-weight: 700;
  letter-spacing: 2px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.cc-credit:hover { color: var(--ball); }

.cc-credit img { display: block; }

@keyframes footer-breathe {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* ================= 3D edition effects ================= */

#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: #fff;
  transition: opacity 0.35s ease-out;
}

/* death veil: monochrome red wash over the 3D scene when a ball is lost —
   "color" blend re-hues everything red while keeping luminosity (Ace Breaker style) */
#death-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: #e01414;
  mix-blend-mode: color;
}

#banner {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(24px, 7vw, 54px);
  letter-spacing: 4px;
  background: linear-gradient(180deg, #fff 20%, var(--ball) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 30px rgba(217, 255, 63, 0.6));
  pointer-events: none;
  transition: none;
}

#banner.hidden { display: none; }

#banner.pop { animation: banner-pop 1.4s cubic-bezier(0.2, 1.4, 0.3, 1) forwards; }

@keyframes banner-pop {
  0%   { transform: scale(0.2) rotate(-8deg); opacity: 0; }
  15%  { transform: scale(1.2) rotate(3deg); opacity: 1; }
  28%  { transform: scale(0.96) rotate(-1.5deg); }
  40%  { transform: scale(1.02) rotate(0.8deg); }
  50%  { transform: scale(1) rotate(0deg); }
  75%  { opacity: 1; transform: scale(1.02); }
  100% { transform: scale(1.1) translateY(-14px); opacity: 0; }
}

.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 20px;
  color: var(--ball);
  text-shadow: 0 0 14px rgba(217, 255, 63, 0.8);
  pointer-events: none;
  animation: float-up 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes float-up {
  0%   { opacity: 0; margin-top: 10px; transform: translate(-50%, -50%) scale(0.6); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
  45%  { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; margin-top: -70px; transform: translate(-50%, -50%) scale(0.95); }
}

/* ================= power-up chips ================= */

#active-fx {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.fx-chip {
  background: rgba(8, 16, 32, 0.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(217, 255, 63, 0.6);
  box-shadow: 0 0 14px rgba(217, 255, 63, 0.25), inset 0 1px 0 rgba(255,255,255,0.12);
  color: var(--ball);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  animation: chip-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both, chip-glow 1.4s ease-in-out infinite;
}

@keyframes chip-in {
  from { transform: translateX(-24px) scale(0.7); opacity: 0; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes chip-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(217, 255, 63, 0.2), inset 0 1px 0 rgba(255,255,255,0.12); }
  50%      { box-shadow: 0 0 20px rgba(217, 255, 63, 0.5), inset 0 1px 0 rgba(255,255,255,0.12); }
}

/* ================= charge meter ================= */

#charge-wrap {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 12px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(4, 8, 16, 0.7);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 1px 3px rgba(0,0,0,0.6);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

#charge-wrap.visible { opacity: 1; animation: charge-enter 0.25s cubic-bezier(0.2, 1.4, 0.4, 1); }

@keyframes charge-enter {
  from { transform: translateX(-50%) translateY(14px) scaleX(0.6); }
  to   { transform: translateX(-50%) translateY(0) scaleX(1); }
}

#charge-bar {
  height: 100%;
  width: 0%;
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,0.35) 0 8px, transparent 8px 16px),
    linear-gradient(90deg, #eaff70, var(--ball));
  background-size: 24px 100%, 100% 100%;
  box-shadow: 0 0 14px rgba(217, 255, 63, 0.7);
  border-radius: 999px;
  transition: background 0.1s;
  animation: charge-stripes 0.6s linear infinite;
}

@keyframes charge-stripes {
  to { background-position: 24px 0, 0 0; }
}

#charge-bar.drive {
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,0.35) 0 8px, transparent 8px 16px),
    linear-gradient(90deg, #ff7a5c, #f04a4a);
  background-size: 24px 100%, 100% 100%;
  box-shadow: 0 0 14px rgba(240, 74, 74, 0.8);
  animation: charge-stripes 0.3s linear infinite;
}

/* ================= court selector ================= */

#court-select {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.court-btn {
  padding: 10px 22px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(245, 241, 230, 0.75);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.18s ease;
}

.court-btn:hover {
  border-color: rgba(245, 241, 230, 0.6);
  color: #fff;
  transform: translateY(-2px) scale(1.04);
}

.court-btn:active { transform: scale(0.96); }

.court-btn.active {
  color: #0a1206;
  background: linear-gradient(135deg, #eaff70, var(--ball));
  border-color: transparent;
  animation: court-active-glow 1.8s ease-in-out infinite;
}

@keyframes court-active-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(217, 255, 63, 0.35); }
  50%      { box-shadow: 0 0 24px rgba(217, 255, 63, 0.65); }
}

/* ================= power-up showcase (start screen) ================= */

#bonus-showcase { margin-top: 8px; }

.bonus-intro {
  font-weight: 700;
  letter-spacing: 4px;
  color: rgba(245, 241, 230, 0.55);
  font-size: clamp(10px, 2.6vw, 13px);
  text-transform: uppercase;
}

#bonus-grid {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.bonus {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 96px;
  padding: 14px 6px 12px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  animation: bonus-bob 3.4s ease-in-out infinite;
}

.bonus:nth-child(2n) { animation-delay: -0.9s; }
.bonus:nth-child(3n) { animation-delay: -1.7s; }

.bonus:hover {
  transform: translateY(-6px) scale(1.06);
  border-color: var(--c);
  box-shadow: 0 0 22px color-mix(in srgb, var(--c) 45%, transparent), inset 0 1px 0 rgba(255,255,255,0.12);
}

.bonus svg {
  width: clamp(34px, 11vw, 52px);
  height: clamp(34px, 11vw, 52px);
  fill: var(--c);
  filter: drop-shadow(0 0 10px var(--c));
  transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.bonus:hover svg { transform: rotate(360deg) scale(1.2); }

.bonus span {
  font-size: clamp(7px, 1.9vw, 9.5px);
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(245, 241, 230, 0.85);
}

@keyframes bonus-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* ================= countdown + tutorial hint ================= */

#countdown {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(60px, 20vw, 120px);
  background: linear-gradient(180deg, #fff 20%, var(--ball) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 44px rgba(217, 255, 63, 0.55));
  pointer-events: none;
}

#countdown.hidden { display: none; }

#countdown.pop { animation: cd-pop 0.7s cubic-bezier(0.2, 1.3, 0.3, 1) forwards; }

@keyframes cd-pop {
  0%   { transform: scale(1.8) rotate(6deg); opacity: 0; }
  20%  { transform: scale(0.92) rotate(-2deg); opacity: 1; }
  32%  { transform: scale(1.04) rotate(1deg); }
  45%  { transform: scale(1) rotate(0deg); }
  80%  { opacity: 1; }
  100% { transform: scale(0.85) translateY(-10px); opacity: 0; }
}

#tut-hint {
  position: absolute;
  top: 58%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(10px, 3vw, 15px);
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--line);
  text-shadow: 0 0 18px rgba(245, 241, 230, 0.4);
  pointer-events: none;
  animation: tut-pulse 1.2s ease-in-out infinite;
}

#tut-hint.hidden { display: none; }

@keyframes tut-pulse {
  0%, 100% { opacity: 0.45; transform: translateY(0); }
  50%      { opacity: 0.95; transform: translateY(-3px); }
}

/* ================= lives ball icons + score tick ================= */

#lives { display: inline-flex; gap: 5px; margin-left: 6px; vertical-align: middle; }

.ball-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #f2ff9e, var(--ball) 60%, #9dbf1e);
  box-shadow: 0 0 10px rgba(217, 255, 63, 0.75);
  display: inline-block;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
  animation: dot-heartbeat 1.8s ease-in-out infinite;
}

.ball-dot:nth-child(2) { animation-delay: 0.2s; }
.ball-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-heartbeat {
  0%, 100% { box-shadow: 0 0 8px rgba(217, 255, 63, 0.6); transform: scale(1); }
  10%      { box-shadow: 0 0 14px rgba(217, 255, 63, 0.95); transform: scale(1.15); }
  20%      { box-shadow: 0 0 8px rgba(217, 255, 63, 0.6); transform: scale(1); }
}

.ball-dot.lost {
  background: #3a4150;
  box-shadow: none;
  transform: scale(0.8);
  animation: none;
}

.ball-dot.pop { animation: dot-pop 0.4s ease-out; }

@keyframes dot-pop {
  0% { transform: scale(1.8); }
  100% { transform: scale(0.8); }
}

#score { display: inline-block; }

#score.tick { animation: score-tick 0.18s ease-out; }

@keyframes score-tick {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ================= score screen ================= */

#overlay.score-mode {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(61, 240, 201, 0.12), transparent 55%),
    radial-gradient(ellipse at 50% 105%, rgba(217, 255, 63, 0.14), transparent 55%),
    linear-gradient(180deg, rgba(3, 8, 18, 0.6), rgba(3, 8, 18, 0.78));
  backdrop-filter: blur(9px) saturate(1.3);
  -webkit-backdrop-filter: blur(9px) saturate(1.3);
}

/* celebration sparks: denser + brighter on the game-over screen */
#overlay.score-mode::before { opacity: 0.55; animation-duration: 9s; }
#overlay.score-mode::after { opacity: 0.4; animation-duration: 6s; }

#overlay.score-mode h1 {
  font-size: clamp(18px, 4vw, 28px);
  letter-spacing: 8px;
  padding-left: 8px; /* compensate trailing letter-spacing */
  filter: drop-shadow(0 0 18px rgba(217, 255, 63, 0.3));
}

.big-score {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(52px, 14vw, 104px);
  line-height: 1;
  letter-spacing: 2px;
  background: linear-gradient(110deg, #ffffff 20%, var(--ball) 40%, #ffffff 55%, var(--ball) 75%, #ffffff 90%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 34px rgba(217, 255, 63, 0.4));
  animation:
    score-land 0.6s cubic-bezier(0.2, 1.2, 0.3, 1.1) both,
    title-shimmer 3.5s linear 0.6s infinite,
    score-float 3s ease-in-out 0.6s infinite;
}

@keyframes score-land {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes score-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.sub-score {
  display: inline-block;
  margin-top: 14px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(245, 241, 230, 0.85);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  animation: sub-score-in 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) 0.35s both;
}

@keyframes sub-score-in {
  from { transform: translateY(14px) scale(0.85); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* "powerup" — NOT "bonus": .bonus is taken by the showcase tiles (width: 96px) */
#banner.powerup {
  font-size: clamp(18px, 4.5vw, 38px);
  letter-spacing: 10px;
  padding-left: 10px; /* compensate trailing letter-spacing so text centers */
}

/* long labels like DEFENSIVE WALL must fit narrow screens on one line */
@media (max-width: 480px) {
  #banner.powerup {
    letter-spacing: 4px;
    padding-left: 4px;
  }
}

/* respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
  }
}

/* ================= rank message, auth & leaderboard ================= */

#rank-msg.hidden,
#leaderboard.hidden,
#google-btn.hidden,
#player-chip.hidden { display: none; }

#rank-msg {
  font-size: clamp(12px, 3vw, 16px);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--ball);
  text-shadow: 0 0 18px rgba(217, 255, 63, 0.5);
  animation: rank-pop 0.5s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}

@keyframes rank-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

#auth-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

#google-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 26px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #3c4043;
  background: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.4), box-shadow 0.18s;
}

#google-btn svg { width: 18px; height: 18px; flex: none; }

#google-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 24px rgba(255, 255, 255, 0.25);
}

#google-btn:active { transform: translateY(1px) scale(0.98); }

#player-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ball);
  box-shadow: 0 0 8px rgba(217, 255, 63, 0.8);
  animation: dot-heartbeat 1.8s ease-in-out infinite;
}

#signout-btn {
  background: none;
  border: none;
  color: rgba(245, 241, 230, 0.45);
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
}

#signout-btn:hover { color: #fff; transform: scale(1.2); }

/* ---- leaderboard panel (start + game-over screens) ---- */

#leaderboard {
  width: min(340px, 86vw);
  padding: 14px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 10px 26px rgba(0, 0, 0, 0.35);
}

#leaderboard h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 4px;
  color: rgba(245, 241, 230, 0.55);
  margin-bottom: 8px;
}

#leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 255, 63, 0.4) transparent;
}

#leaderboard-more {
  display: block;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--ball);
  text-decoration: none;
  text-shadow: 0 0 10px rgba(217, 255, 63, 0.35);
  transition: transform 0.15s ease, text-shadow 0.15s ease;
}

#leaderboard-more:hover {
  transform: translateY(-1px);
  text-shadow: 0 0 16px rgba(217, 255, 63, 0.65);
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
  animation: lb-row-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.lb-row:nth-child(2) { animation-delay: 0.05s; }
.lb-row:nth-child(3) { animation-delay: 0.10s; }
.lb-row:nth-child(4) { animation-delay: 0.15s; }
.lb-row:nth-child(5) { animation-delay: 0.20s; }
.lb-row:nth-child(6) { animation-delay: 0.25s; }
.lb-row:nth-child(7) { animation-delay: 0.30s; }
.lb-row:nth-child(8) { animation-delay: 0.35s; }
.lb-row:nth-child(9) { animation-delay: 0.40s; }
.lb-row:nth-child(10) { animation-delay: 0.45s; }

@keyframes lb-row-in {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: translateX(0); }
}

.lb-rank {
  width: 24px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(245, 241, 230, 0.45);
}

.lb-row:nth-child(1) .lb-rank { color: #ffd54a; text-shadow: 0 0 10px rgba(255, 213, 74, 0.6); }
.lb-row:nth-child(2) .lb-rank { color: #d7e0e6; text-shadow: 0 0 10px rgba(215, 224, 230, 0.5); }
.lb-row:nth-child(3) .lb-rank { color: #e8a06a; text-shadow: 0 0 10px rgba(232, 160, 106, 0.5); }

.lb-name {
  flex: 1;
  text-align: left;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ball);
  text-shadow: 0 0 10px rgba(217, 255, 63, 0.35);
}

.lb-row.you {
  background: rgba(217, 255, 63, 0.12);
  box-shadow: inset 0 0 0 1px rgba(217, 255, 63, 0.45);
}

/* overlay grew: keep the staggered rise-in going for the extra children */
#overlay:not(.hidden) > *:nth-child(8)  { animation-delay: 0.40s; }
#overlay:not(.hidden) > *:nth-child(9)  { animation-delay: 0.46s; }
#overlay:not(.hidden) > *:nth-child(10) { animation-delay: 0.52s; }
