/* Snake Jr. — Neon Y2K / Chrome-Bubble theme */

:root {
  --neon-pink: #ff3bd4;
  --neon-cyan: #36f1ff;
  --neon-violet: #8a4bff;
  --neon-gold: #ffe066;
  --bg-deep: #0a0820;
  --bg-mid:  #2a1a55;
  --chrome-1: #ffffff;
  --chrome-2: #c8c8ff;
  --chrome-3: #6a7aff;
  --ink: #0a0820;

  --font-display: "Lilita One", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: radial-gradient(ellipse at top, var(--bg-mid), var(--bg-deep) 70%);
  color: #fff;
  font-family: var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* Drifting grid overlay */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  background:
    linear-gradient(rgba(138, 75, 255, 0.07) 1px, transparent 1px) 0 0 / 60px 60px,
    linear-gradient(90deg, rgba(54, 241, 255, 0.05) 1px, transparent 1px) 0 0 / 60px 60px;
  animation: drift 60s linear infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(60px, 60px); }
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

/* ===== Scene system ===== */
.scene {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 12px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 12px);
}
.scene.active { display: flex; }
/* Enter-only, and short: `.active` is re-added on every switch, so the
   animation replays by itself. Nothing animates on the way out — the scene is
   display:none the instant it loses `.active`. */
.scene.active { animation: sceneIn 240ms ease both; }
@keyframes sceneIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Buttons (chrome bubble) ===== */
.bubble-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 18px 32px;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #d8d8ff 45%, #7c8cff 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.9),
    inset 0 -4px 0 rgba(0,0,0,0.15),
    0 6px 0 #3a2b80,
    0 12px 24px rgba(255, 59, 212, 0.35),
    0 0 30px rgba(54, 241, 255, 0.25);
  transition: transform 80ms ease, box-shadow 80ms ease;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
.bubble-btn::before {
  content: "";
  position: absolute;
  inset: 4px 6px auto 6px;
  height: 38%;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
  border-radius: 999px;
  pointer-events: none;
}
.bubble-btn:hover { transform: translateY(-2px); }
.bubble-btn:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.9),
    inset 0 -2px 0 rgba(0,0,0,0.15),
    0 2px 0 #3a2b80,
    0 4px 12px rgba(255, 59, 212, 0.35);
}
.bubble-btn.pink {
  background: linear-gradient(180deg, #fff 0%, #ffc4ee 40%, #ff3bd4 100%);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.9),
    inset 0 -4px 0 rgba(0,0,0,0.15),
    0 6px 0 #6b0e60,
    0 12px 24px rgba(255, 59, 212, 0.55),
    0 0 30px rgba(255, 59, 212, 0.45);
}
.bubble-btn.cyan {
  background: linear-gradient(180deg, #fff 0%, #c4f6ff 40%, #36f1ff 100%);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.9),
    inset 0 -4px 0 rgba(0,0,0,0.15),
    0 6px 0 #0a6b78,
    0 12px 24px rgba(54, 241, 255, 0.55),
    0 0 30px rgba(54, 241, 255, 0.45);
}
.bubble-btn.small {
  font-size: 18px;
  padding: 10px 20px;
}
.bubble-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.icon-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 22px;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

/* ===== Title scene ===== */
#scene-title {
  justify-content: flex-start;
  gap: 14px;
  overflow-y: auto;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
#scene-title > * {
  flex-shrink: 0;
}
.title-mute {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
}
.logo {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: clamp(64px, 14vw, 140px);
  line-height: 0.9;
  text-align: center;
  letter-spacing: 0.02em;
  background:
    linear-gradient(180deg, #fff 0%, #ffe9fb 35%, #ff3bd4 70%, #8a4bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 #6b0e60) drop-shadow(0 14px 30px rgba(255, 59, 212, 0.45));
  transform: rotate(-3deg);
}
.logo .jr {
  display: inline-block;
  color: transparent;
  background:
    linear-gradient(180deg, #fff 0%, #c4f6ff 35%, #36f1ff 70%, #1474a3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 4px 0 #0a6b78);
  transform: rotate(6deg);
  margin-left: 0.2em;
}
/* Title mascot: an idle snake in the selected skin, drawn by src/main.js.
   Fixed CSS box so the layout never shifts as the canvas repaints. */
#mascot-canvas {
  display: block;
  width: min(320px, 70vw);
  height: 110px;
  margin: -6px 0 -4px;
  pointer-events: none;
}
.tagline {
  font-family: var(--font-display);
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.best-pill {
  font-family: var(--font-display);
  font-size: 20px;
  padding: 8px 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #c4f6ff 50%, #36f1ff);
  color: var(--ink);
  box-shadow: 0 4px 0 #0a6b78, 0 10px 20px rgba(54,241,255,0.4);
}
.unlock-progress-card {
  width: min(520px, 90vw);
  padding: 10px 14px 12px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 8px 22px rgba(0,0,0,0.24);
}
.unlock-progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.02em;
  color: #fff;
}
.unlock-progress-copy span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unlock-progress-copy span:last-child {
  flex: 0 0 auto;
  color: var(--neon-gold);
}
.unlock-progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(3, 4, 18, 0.65);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.unlock-progress-fill {
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-gold));
  box-shadow: 0 0 15px rgba(54,241,255,0.7);
  transition: width 320ms ease;
}
.unlock-progress-card.complete .unlock-progress-fill {
  background: linear-gradient(90deg, var(--neon-gold), #fff, var(--neon-gold));
}
.title-actions {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Cosmetic selects */
.skin-select-wrap,
.world-select-wrap {
  width: min(560px, 92vw);
  text-align: center;
}
.skin-select-wrap h3,
.world-select-wrap h3 {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  text-transform: uppercase;
  margin: 6px 0 10px;
}
#skin-select {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.skin-chip {
  position: relative;
  padding: 14px 8px;
  border: none;
  border-radius: 16px;
  color: #0a0820;
  font-family: var(--font-display);
  font-size: 16px;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.6), 0 4px 0 rgba(0,0,0,0.35);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.skin-preview {
  display: block;
  width: 100%;
  height: 34px;
  margin-bottom: 5px;
  pointer-events: none;
}
.skin-chip .skin-lock {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: rgba(0,0,0,0.6);
}
.skin-chip.locked { filter: grayscale(0.8) brightness(0.55); cursor: not-allowed; }
.skin-chip.selected { outline: 3px solid #fff; outline-offset: 2px; }

.world-select-wrap {
  width: min(680px, 94vw);
}
#world-select {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 3px 4px 9px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.world-chip {
  position: relative;
  flex: 0 0 106px;
  min-height: 72px;
  padding: 8px 6px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  color: #fff;
  font-family: var(--font-display);
  cursor: pointer;
  scroll-snap-align: center;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.18), 0 4px 0 rgba(0,0,0,0.35);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.world-chip .world-icon {
  display: block;
  font-size: 25px;
  line-height: 1;
  margin-bottom: 5px;
}
.world-chip .world-name {
  display: block;
  font-size: 14px;
  line-height: 1.05;
}
.world-chip .world-lock {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.72);
}
.world-chip.locked {
  filter: grayscale(0.85) brightness(0.5);
  cursor: not-allowed;
}
.world-chip.selected {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.25), 0 4px 0 rgba(0,0,0,0.35), 0 0 24px rgba(54,241,255,0.55);
}

.meme-strip {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}
.meme-strip span { color: var(--neon-cyan); }

/* ===== Game scene ===== */
#scene-game {
  padding: 0;
  overflow: hidden;
  display: none;
  flex-direction: row;
  align-items: stretch;
  justify-content: stretch;
  /* main.js stamps data-world here; the blocks below hand the HUD the same
     colour the canvas strokes around the playfield — that's worlds.js `border`,
     not its `accent`. Each world carries an -rgb twin so shadows and tints can
     vary the alpha without color-mix(), which is too new for older iPads. */
  --world-border: var(--neon-cyan);
  --world-border-rgb: 54, 241, 255;
}
#scene-game[data-world="backyard"]  { --world-border: #8dff8b; --world-border-rgb: 141, 255, 139; }
#scene-game[data-world="candy"]     { --world-border: #ff9ee8; --world-border-rgb: 255, 158, 232; }
#scene-game[data-world="jungle"]    { --world-border: #77f05a; --world-border-rgb: 119, 240, 90; }
#scene-game[data-world="arctic"]    { --world-border: #d8fbff; --world-border-rgb: 216, 251, 255; }
#scene-game[data-world="volcano"]   { --world-border: #ff6738; --world-border-rgb: 255, 103, 56; }
#scene-game[data-world="space"]     { --world-border: #7f9cff; --world-border-rgb: 127, 156, 255; }
#scene-game[data-world="arcade"]    { --world-border: #36f1ff; --world-border-rgb: 54, 241, 255; }
#scene-game[data-world="dimension"] { --world-border: #ffe066; --world-border-rgb: 255, 224, 102; }
/* The playfield gets a plain, faster fade — a sliding canvas reads as lag. */
#scene-game.active { display: block; animation: sceneFade 160ms ease both; }
@keyframes sceneFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  pointer-events: none;
  z-index: 3;
}
.hud-pill {
  font-family: var(--font-display);
  background: linear-gradient(180deg, #fff, #c8c8ff 50%, #6a7aff);
  color: var(--ink);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 22px;
  box-shadow: 0 4px 0 #3a2b80, 0 8px 16px rgba(var(--world-border-rgb), 0.42);
  transition: box-shadow 260ms ease;
}
.hud-pill.small { font-size: 14px; padding: 4px 10px; }
.hud-pill.newbest {
  background: linear-gradient(180deg, #fff, #ffe066 50%, #ffb020);
  box-shadow: 0 4px 0 #7a5a00, 0 8px 16px rgba(255, 224, 102, 0.5);
  animation: bestPulse 0.9s ease-in-out infinite alternate;
}
@keyframes bestPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.08); }
}
.hud-combo {
  font-family: var(--font-display);
  color: var(--neon-pink);
  font-size: 22px;
  text-shadow: 0 0 12px rgba(255, 59, 212, 0.8);
}
.hud-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hud-world {
  position: absolute;
  top: max(62px, calc(env(safe-area-inset-top) + 52px));
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  padding: 4px 12px;
  border: 1px solid rgba(var(--world-border-rgb), 0.55);
  border-radius: 999px;
  background: rgba(7, 7, 28, 0.48);
  color: rgba(255,255,255,0.9);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.05em;
  pointer-events: none;
  backdrop-filter: blur(5px);
  box-shadow: 0 0 14px rgba(var(--world-border-rgb), 0.3),
              inset 0 0 12px rgba(var(--world-border-rgb), 0.12);
  text-shadow: 0 0 9px rgba(var(--world-border-rgb), 0.6);
  transition: border-color 260ms ease, box-shadow 260ms ease, text-shadow 260ms ease;
}

#game-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

#banner {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-family: var(--font-display);
  font-size: clamp(50px, 14vw, 140px);
  letter-spacing: 0.04em;
  text-shadow: 0 6px 0 #6b0e60, 0 12px 32px rgba(255,255,255,0.4);
  pointer-events: none;
  opacity: 0;
  z-index: 4;
}
#banner.show {
  animation: bannerPop 1.4s cubic-bezier(.2,.8,.2,1) both;
}
#banner[data-color="pink"]   { color: var(--neon-pink); }
#banner[data-color="cyan"]   { color: var(--neon-cyan); }
#banner[data-color="violet"] { color: var(--neon-violet); }
#banner[data-color="gold"]   { color: var(--neon-gold); }

/* ===== Start countdown ===== */
#countdown {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(96px, 30vw, 260px);
  line-height: 1;
  color: var(--neon-cyan);
  text-shadow: 0 8px 0 #0b4a5c, 0 0 46px rgba(54, 241, 255, 0.75);
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
#countdown[data-step="go"] {
  color: var(--neon-gold);
  font-size: clamp(72px, 22vw, 200px);
  text-shadow: 0 8px 0 #7a5a00, 0 0 50px rgba(255, 224, 102, 0.8);
}
/* One beat is 700ms; hold the number legible for most of it, then drop it. */
#countdown.show {
  animation: countPop 680ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes countPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.9); }
  16%  { opacity: 1; transform: translate(-50%, -50%) scale(0.92); }
  30%  { transform: translate(-50%, -50%) scale(1.06); }
  55%  { transform: translate(-50%, -50%) scale(1); }
  85%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.88); }
}

/* Pause button lives inside the HUD, which is click-through by default. */
.hud-pause {
  pointer-events: auto;
  width: 40px; height: 40px;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Pause overlay ===== */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 24, 0.74);
  backdrop-filter: blur(6px);
}
.pause-overlay.show { display: flex; }
.pause-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 36px;
}
.pause-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(40px, 11vw, 76px);
  color: var(--neon-cyan);
  text-shadow: 0 0 24px rgba(54, 241, 255, 0.7);
}
.pause-sub {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-top: -10px;
}

@keyframes bannerPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
  35%  { transform: translate(-50%, -50%) scale(0.95) rotate(-1deg); }
  55%  { transform: translate(-50%, -50%) scale(1.05) rotate(0); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(1) rotate(0); }
}

/* ===== Submit scene ===== */
#scene-submit {
  justify-content: flex-start;
  gap: 18px;
  padding: 32px 20px;
  overflow-y: auto;
}
.panel {
  flex-shrink: 0;
  margin: auto 0;
  width: min(540px, 96vw);
  background: linear-gradient(180deg, rgba(40,22,100,0.7), rgba(15,8,50,0.85));
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
}
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  text-align: center;
  font-size: 28px;
  color: #fff;
  letter-spacing: 0.06em;
}
.score-big {
  text-align: center;
  font-family: var(--font-display);
  font-size: 84px;
  line-height: 1;
  margin: 6px 0 12px;
  background: linear-gradient(180deg, #fff, #ffe066 60%, #ff3bd4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,0.4));
}
.status-line {
  text-align: center;
  font-family: var(--font-display);
  color: var(--neon-gold);
  letter-spacing: 0.05em;
  min-height: 22px;
}
.unlocks-line {
  display: none;
  position: relative; /* anchors the sparkle burst */
  text-align: center;
  color: var(--neon-cyan);
  margin-top: 6px;
}
.unlocks-line.show { display: block; }
.unlocks-label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--neon-gold);
}
.reward-card {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 4px 3px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 224, 102, 0.55);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 224, 102, 0.24), rgba(255, 59, 212, 0.14));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 18px rgba(255, 224, 102, 0.4);
  font-family: var(--font-display);
  font-size: 15px;
  color: #fff;
  animation: rewardPop 260ms cubic-bezier(.2,.9,.3,1.5) both;
}
.reward-card .reward-icon { font-size: 17px; }
.reward-card .reward-name { color: var(--neon-gold); }
.reward-card .reward-kind {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
@keyframes rewardPop {
  from { opacity: 0; transform: scale(0.55) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
/* Sparkles are absolutely positioned and text-free: no layout, no textContent. */
.reward-spark {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 25%, var(--neon-gold) 70%, rgba(255,224,102,0));
  pointer-events: none;
  animation: rewardSpark 720ms ease-out both;
}
@keyframes rewardSpark {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.3); }
  18%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.85); }
}
.submit-progress {
  width: 100%;
  margin-top: 12px;
}
.submit-progress .unlock-progress-copy {
  align-items: flex-start;
  font-size: 14px;
}
.submit-progress .unlock-progress-copy span:first-child {
  overflow: visible;
  line-height: 1.2;
  text-overflow: clip;
  white-space: normal;
}

.field-label {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-transform: uppercase;
  margin: 14px 0 6px;
  text-align: center;
}

#emoji-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 4px 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.emoji-chip {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  font-size: 28px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
  scroll-snap-align: center;
  transition: transform 100ms ease;
}
.emoji-chip:active { transform: scale(0.9); }
.emoji-chip.selected {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(54,241,255,0.4), 0 0 18px rgba(54,241,255,0.6);
  background: rgba(54,241,255,0.15);
}

.initials-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}
.initial-slot {
  font-family: var(--font-display);
  font-size: 56px;
  width: 76px;
  height: 92px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #c8c8ff 50%, #6a7aff);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.7), 0 6px 0 #3a2b80;
}
.initial-slot.active {
  outline: 3px solid var(--neon-pink);
  outline-offset: 3px;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.7), 0 6px 0 #3a2b80, 0 0 24px rgba(255,59,212,0.7);
}
/* A-Z grid. 7 columns keeps every key past 40px wide at a 390px viewport,
   which is the smallest phone we care about. */
#letter-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 420px;
  margin: 14px auto 0;
}
/* 26 keys over 7 columns leaves 5 on the last row — nudge them to the middle. */
.letter-key:nth-child(22) { grid-column: 2; }
.letter-key {
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.17), rgba(255,255,255,0.05));
  color: #fff;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 3px 0 rgba(0,0,0,0.35);
  transition: transform 90ms ease, box-shadow 90ms ease, background 90ms ease;
}
.letter-key:active {
  transform: translateY(3px);
  background: linear-gradient(180deg, #fff, #c4f6ff 45%, #36f1ff);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 0 20px rgba(54,241,255,0.6);
}

.submit-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

/* ===== Leaderboard scene ===== */
#scene-leaderboard {
  padding: 22px 16px;
  /* keep the header clear of the iPhone dynamic island in fullscreen */
  padding-top: max(28px, calc(env(safe-area-inset-top) + 10px));
  overflow-y: auto;
}
#scene-leaderboard h2 {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 56px);
  margin: 6px 0 4px;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff, #ffe066 60%, #ff3bd4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.4));
}
.board-status {
  font-family: var(--font-display);
  color: rgba(255,255,255,0.75);
  margin: 8px 0 14px;
  text-align: center;
}
.board-status code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 6px;
}
#board-list {
  list-style: none;
  width: min(560px, 96vw);
  padding: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.board-row {
  display: grid;
  grid-template-columns: 56px 44px 1fr 110px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.12);
  font-family: var(--font-display);
}
.board-row .rank {
  font-size: 22px;
  text-align: center;
  color: rgba(255,255,255,0.7);
}
.board-row .avatar { font-size: 24px; text-align: center; }
.board-row .initials {
  font-size: 22px;
  letter-spacing: 0.1em;
  color: #fff;
}
.board-row .score {
  text-align: right;
  font-size: 24px;
  background: linear-gradient(180deg, #fff, #c8c8ff 50%, #6a7aff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.board-row.just-me {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 2px rgba(54,241,255,0.5), 0 0 24px rgba(54,241,255,0.45);
  background: linear-gradient(180deg, rgba(54,241,255,0.15), rgba(255,59,212,0.08));
  animation: meGlow 1.2s ease-in-out infinite alternate;
}
@keyframes meGlow {
  from { box-shadow: 0 0 0 2px rgba(54,241,255,0.5), 0 0 14px rgba(54,241,255,0.4); }
  to   { box-shadow: 0 0 0 3px rgba(255,59,212,0.6), 0 0 28px rgba(255,59,212,0.55); }
}

.board-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  #scene-title {
    gap: 11px;
    padding-left: 10px;
    padding-right: 10px;
  }
  .tagline {
    max-width: 88vw;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .unlock-progress-copy {
    font-size: 13px;
  }
  #skin-select {
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    gap: 8px;
  }
  .skin-chip {
    padding: 10px 5px;
    font-size: 14px;
  }
  .world-chip {
    flex-basis: 96px;
  }
  .meme-strip {
    padding-bottom: 4px;
    font-size: 14px;
  }
}

/* ===== Reduce Motion =====
   Everything that moves for decoration goes still; anything that carried
   information (banners, the countdown, the new-best pill) cross-fades instead
   so the moment still reads. The JS side lives in src/motion.js. */
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .bubble-btn { transition: none; }
  .bubble-btn:hover { transform: none; }
  .hud-pill.newbest { animation: none; }
  .board-row.just-me { animation: none; }
  #banner.show { animation: bannerFade 1.4s ease both; }
  #countdown.show { animation: countFade 680ms ease both; }
  .scene.active { animation: sceneFade 240ms ease both; }
  .letter-key { transition: none; }
  .letter-key:active { transform: none; }
  /* Rewards still arrive one by one — they just fade in place. */
  .reward-card { animation: sceneFade 260ms ease both; }
}
@keyframes bannerFade {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
@keyframes countFade {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  72%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
