:root {
  --bg: #05070f;
  --bg-2: #0a0e1a;
  --panel: rgba(10, 14, 26, 0.55);
  --cyan: #00d4ff;
  --cyan-dim: #0891b2;
  --magenta: #ff2ee0;
  --magenta-dim: #a21caf;
  --text: #e2f0ff;
  --text-dim: #7a8fa8;
  --green: #4ade80;
  --red: #f87171;
  --f-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-display);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 60px;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Full-bleed animated grid + neon glow wash — deliberately not confined to
   the centered content column, so the page reads as an environment rather
   than a boxed card floating on a blank background. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  animation: grid-drift 24s linear infinite;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 40% at 50% -5%, rgba(255, 46, 224, 0.14), transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(0, 212, 255, 0.12), transparent 60%);
  pointer-events: none;
}
@keyframes grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 42px 42px, 42px 42px; }
}

::selection { background: var(--magenta); color: #fff; }

.marquee-title {
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: clamp(2rem, 8vw, 3.4rem);
  color: var(--cyan);
  text-shadow:
    0 0 10px rgba(0, 212, 255, 0.65),
    0 0 32px rgba(0, 212, 255, 0.3),
    2px 0 rgba(255, 46, 224, 0.45),
    -2px 0 rgba(0, 212, 255, 0.45);
  text-align: center;
  margin: 8px 0 4px;
}

.subtitle {
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 28px;
  font-family: var(--f-mono);
  font-size: 0.9rem;
}

.bulbs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.bulbs span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: twinkle 1.6s infinite ease-in-out;
}
.bulbs span:nth-child(odd) { animation-delay: 0.3s; }
.bulbs span:nth-child(3n) { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); animation-delay: .6s; }
@keyframes twinkle { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

.mode-grid {
  display: grid;
  gap: 20px;
  width: 100%;
  max-width: 760px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .mode-card:nth-child(1) { transform: translateY(-6px) rotate(-0.5deg); }
  .mode-card:nth-child(2) { transform: translateY(8px) rotate(0.7deg); }
  .mode-card:nth-child(3) { transform: translateY(4px) rotate(-0.4deg); }
  .mode-card:nth-child(4) { transform: translateY(-4px) rotate(0.5deg); }
}

.mode-card {
  background: linear-gradient(160deg, rgba(0, 212, 255, 0.07), rgba(255, 46, 224, 0.05));
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 4px;
  padding: 22px 20px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.mode-card:hover, .mode-card:focus {
  transform: translateY(-8px) scale(1.015) rotate(0deg);
  border-color: var(--magenta);
  box-shadow: 0 0 28px rgba(255, 46, 224, 0.3), 0 0 44px rgba(0, 212, 255, 0.15);
}
.mode-card h2 {
  font-family: var(--f-mono);
  color: var(--cyan);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 0 8px;
  font-size: 1.25rem;
}
.mode-card p { margin: 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; }
.mode-card .emoji { font-size: 1.8rem; margin-bottom: 6px; display: block; }

.arcade-wrap {
  width: 100%;
  max-width: 640px;
}

.arcade-progress {
  text-align: center;
  color: var(--cyan);
  font-family: var(--f-mono);
  letter-spacing: 1px;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* HUD strip breaks out to full viewport width — a cockpit-dashboard feel
   instead of a boxed stat row squeezed into the content column. */
.arcade-hud {
  display: flex;
  justify-content: space-between;
  color: var(--cyan);
  font-family: var(--f-mono);
  letter-spacing: 0.5px;
  font-size: 1rem;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 0 24px 12px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.25);
}

.arcade-timerbar {
  height: 5px;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  border-radius: 0;
  background: rgba(0, 212, 255, 0.08);
  overflow: hidden;
  margin-bottom: 20px;
}
.arcade-timerfill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  box-shadow: 0 0 12px var(--cyan);
  transition: width 0.1s linear;
}

.arcade-card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 6px;
  padding: 34px 22px;
  text-align: center;
  margin-bottom: 20px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.arcade-prompt {
  font-family: var(--f-display);
  font-size: clamp(1.2rem, 3.4vw, 1.7rem);
  line-height: 1.4;
}
.arcade-card.flash-correct { animation: flashCyan 0.5s ease; border-color: var(--green); }
.arcade-card.flash-wrong { animation: shake 0.4s ease; border-color: var(--red); }
@keyframes flashCyan { 0% { box-shadow: 0 0 0 rgba(74,222,128,0); } 40% { box-shadow: 0 0 40px rgba(74,222,128,0.5); } 100% { box-shadow: 0 0 0 rgba(74,222,128,0); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }

.arcade-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 520px) {
  .arcade-options { grid-template-columns: 1fr 1fr; }
}
.arcade-option {
  background: rgba(0, 212, 255, 0.04);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--text);
  padding: 14px 12px;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: var(--f-display);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
}
.arcade-option:hover:not(:disabled) { border-color: var(--cyan); background: rgba(0,212,255,0.1); transform: translateY(-2px); box-shadow: 0 0 16px rgba(0,212,255,0.2); }
.arcade-option:disabled { cursor: default; opacity: 0.85; }
.arcade-option.is-correct { border-color: var(--green); background: rgba(74,222,128,0.15); box-shadow: 0 0 16px rgba(74,222,128,0.3); }
.arcade-option.is-wrong { border-color: var(--red); background: rgba(248,113,113,0.15); box-shadow: 0 0 16px rgba(248,113,113,0.25); }

.arcade-reveal {
  text-align: center;
  margin-top: 10px;
  font-size: 1.05rem;
  font-family: var(--f-mono);
}
@keyframes glitchIn {
  0% { opacity: 0; transform: translateX(-4px); }
  40% { opacity: 1; transform: translateX(2px); }
  60% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}
.reveal-correct { color: var(--green); font-weight: bold; font-size: 1.25rem; text-shadow: 0 0 10px rgba(74,222,128,0.5); animation: glitchIn 0.3s ease; }
.reveal-wrong { color: var(--red); font-weight: bold; animation: glitchIn 0.3s ease; }

.end-screen {
  text-align: center;
  width: 100%;
  max-width: 520px;
}
.end-screen .final-score {
  font-family: var(--f-mono);
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(0,212,255,0.35));
  margin: 6px 0;
}
.end-screen .final-streak {
  color: var(--magenta);
  margin-bottom: 22px;
  font-family: var(--f-mono);
}

.name-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.name-form input {
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid rgba(0, 212, 255, 0.4);
  background: rgba(0, 212, 255, 0.05);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.95rem;
  width: 200px;
}
.btn {
  padding: 10px 18px;
  border-radius: 4px;
  border: 1px solid var(--cyan);
  background: linear-gradient(160deg, rgba(0,212,255,0.25), rgba(255,46,224,0.15));
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--f-mono);
  letter-spacing: 0.5px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:hover { box-shadow: 0 0 18px rgba(0,212,255,0.35); transform: translateY(-1px); }
.btn.secondary { border-color: rgba(226,240,255,0.3); background: rgba(226,240,255,0.04); }
.btn.secondary:hover { border-color: var(--magenta); box-shadow: 0 0 18px rgba(255,46,224,0.3); }

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  border: 1px solid rgba(0, 212, 255, 0.25);
  overflow: hidden;
  font-family: var(--f-mono);
}
.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.1);
}
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-list li .rank { color: var(--cyan); font-weight: bold; width: 28px; }

.back-link {
  color: var(--text-dim);
  text-decoration: none;
  margin-top: 6px;
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 0.85rem;
}
.back-link:hover { color: var(--cyan); }

footer {
  margin-top: auto;
  padding-top: 40px;
  opacity: 0.5;
  font-size: 0.75rem;
  font-family: var(--f-mono);
  text-align: center;
}

.action-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Pack picker (decade/genre chips) */
.pack-picker { text-align: center; }
.pack-picker-label { color: var(--text-dim); margin-bottom: 10px; font-family: var(--f-mono); font-size: 0.85rem; }
.pack-picker-note { color: var(--magenta); opacity: 0.9; font-size: 0.8rem; margin: 10px 0 16px; min-height: 1.2em; font-family: var(--f-mono); }
.chip-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 255, 0.3);
  background: rgba(0, 212, 255, 0.04);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.chip:hover { border-color: var(--cyan); transform: translateY(-1px); }
.chip.active { border-color: var(--magenta); background: rgba(255,46,224,0.18); box-shadow: 0 0 14px rgba(255,46,224,0.3); font-weight: bold; }

/* Challenge-a-friend */
.challenge-result {
  margin: 4px 0 18px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--f-mono);
  border: 1px solid rgba(226,240,255,0.15);
  background: var(--panel);
}
.challenge-result.won { border-color: var(--green); color: var(--green); box-shadow: 0 0 16px rgba(74,222,128,0.2); }
.challenge-result.tied { border-color: var(--cyan); color: var(--cyan); }
.challenge-result.lost { border-color: var(--red); color: var(--text); }
.challenge-link {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.challenge-link input {
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid rgba(0, 212, 255, 0.4);
  background: rgba(0, 212, 255, 0.05);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.8rem;
  width: 260px;
  max-width: 60vw;
}

/* Achievement toast */
.achievement-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -30px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(160deg, rgba(10,14,26,0.95), rgba(5,7,15,0.95));
  backdrop-filter: blur(8px);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  padding: 10px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 24px rgba(0,212,255,0.35);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.85rem;
  opacity: 0;
  z-index: 10000;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.achievement-toast.show { opacity: 1; transform: translate(-50%, 0); }
.achievement-toast-icon { font-size: 1.8rem; }
.achievement-toast b { color: var(--magenta); }

/* Badge shelf */
.badge-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 10px 0 20px;
}
.badge {
  text-align: center;
  padding: 14px 8px;
  border-radius: 6px;
  border: 1px solid rgba(226,240,255,0.12);
  background: var(--panel);
  backdrop-filter: blur(6px);
}
.badge.unlocked { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,212,255,0.2); background: linear-gradient(160deg, rgba(0,212,255,0.1), rgba(255,46,224,0.05)); }
.badge.locked { opacity: 0.35; filter: grayscale(0.7); }
.badge-icon { display: block; font-size: 1.8rem; margin-bottom: 4px; }
.badge-name { display: block; font-size: 0.7rem; font-family: var(--f-mono); }

.mute-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  background: rgba(10,14,26,0.6);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--text);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.1rem;
  z-index: 10;
}

canvas#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}
