:root {
  --primary: #00ffaa;
  --primary-dark: #00cc88;
  --primary-glow: rgba(0, 255, 170, 0.5);
  --secondary: #ff3a5e;
  --secondary-glow: rgba(255, 58, 94, 0.5);
  --accent: #ffd32a;
  --accent-glow: rgba(255, 211, 42, 0.5);
  --bg-dark: #07070c;
  --bg-card: rgba(14, 15, 26, 0.96);
  --text: #ffffff;
  --text-dim: #8892b0;
  --speed-color: #00a8ff;
  --invincibility-color: #ffd32a;
  --magnet-color: #ff6b9d;
  --slowmo-color: #9b59b6;
  --shrink-color: #2ecc71;
  --ghost-color: #b49aff;
  --freeze-color: #8ad2ff;
  --multiplier-color: #ffd32a;
  --danger: #ff3a5e;
  --gold: #ffd700;
  --silver: #c0c6d1;
  --bronze: #cd7f32;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at top, rgba(0, 255, 170, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(180, 154, 255, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(255, 58, 94, 0.06) 0%, transparent 55%);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  position: relative;
  overflow: auto;
}

/* Animated Background Particles */
.particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0.3;
  box-shadow: 0 0 8px var(--primary-glow);
  animation: float 15s infinite ease-in-out;
}
.particle.alt { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.particle.alt2 { background: var(--ghost-color); box-shadow: 0 0 8px rgba(180,154,255,.5); }

@keyframes float {
  0%, 100% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.5; }
  90% { opacity: 0.5; }
  100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* CRT Vignette */
body::after {
  content: ''; position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, transparent 58%, rgba(0, 0, 0, 0.45) 100%);
  pointer-events: none; z-index: 999;
}

/* Scanlines */
body::before {
  content: ''; position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.025) 2px, rgba(0, 0, 0, 0.025) 4px);
  pointer-events: none; z-index: 998;
}

/* Main App Container */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  padding: 12px;
  margin: auto;
  transition: transform 0.05s ease;
  --board-size: min(calc(100vh - 300px), calc(100vw - 60px), 680px);
}

#app.shake { animation: shake 0.45s cubic-bezier(.25,.8,.25,1); }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-7px, 3px) rotate(-0.3deg); }
  30% { transform: translate(6px, -2px) rotate(0.25deg); }
  45% { transform: translate(-4px, 2px) rotate(-0.2deg); }
  60% { transform: translate(4px, -1px) rotate(0.15deg); }
  75% { transform: translate(-2px, 1px); }
  90% { transform: translate(1px, -1px); }
}

.game-wrapper {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 16px 20px;
  border: 1px solid rgba(0, 255, 170, 0.2);
  box-shadow:
    0 0 60px rgba(0, 255, 170, 0.12),
    inset 0 0 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.glow-border {
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  background: linear-gradient(45deg, var(--primary), var(--ghost-color), var(--accent), var(--secondary), var(--primary));
  background-size: 400% 400%;
  border-radius: 22px;
  z-index: -1;
  animation: gradientBorder 10s ease infinite;
  opacity: 0.55;
}
@keyframes gradientBorder {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Intro Screen */
.intro-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(0, 255, 170, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(255, 58, 94, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(180, 154, 255, 0.06) 0%, transparent 60%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  cursor: pointer;
  outline: none;
  overflow: hidden;
}

.intro-logo { text-align: center; animation: fadeInUp 1s ease; }

.dragon-icon {
  font-size: 80px;
  display: block;
  margin-bottom: 20px;
  animation: dragonFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 24px rgba(0,255,170,.55));
}
@keyframes dragonFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.1); }
}

.glitch {
  font-family: 'Orbitron', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 20px var(--primary-glow), 0 0 40px var(--primary-glow);
  position: relative;
  letter-spacing: 4px;
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.glitch::before { left: 2px; text-shadow: -2px 0 var(--secondary); clip: rect(24px, 550px, 90px, 0); animation: glitch-anim-1 2s infinite linear alternate-reverse; }
.glitch::after  { left: -2px; text-shadow: 2px 0 var(--accent); clip: rect(85px, 550px, 140px, 0); animation: glitch-anim-2 2s infinite linear alternate-reverse; }

@keyframes glitch-anim-1 {
  0% { clip: rect(30px, 9999px, 10px, 0); } 25% { clip: rect(15px, 9999px, 140px, 0); }
  50% { clip: rect(50px, 9999px, 75px, 0); } 75% { clip: rect(80px, 9999px, 110px, 0); }
  100% { clip: rect(5px, 9999px, 50px, 0); }
}
@keyframes glitch-anim-2 {
  0% { clip: rect(65px, 9999px, 100px, 0); } 25% { clip: rect(25px, 9999px, 60px, 0); }
  50% { clip: rect(90px, 9999px, 130px, 0); } 75% { clip: rect(10px, 9999px, 40px, 0); }
  100% { clip: rect(70px, 9999px, 120px, 0); }
}

.tagline {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-top: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.intro-hint {
  position: absolute;
  bottom: 50px;
  color: var(--text-dim);
  font-size: 1rem;
  display: flex; align-items: center; gap: 10px;
}

.intro-hint kbd {
  background: rgba(0, 255, 170, 0.2);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
}

.hint-icon { font-size: 1.2rem; animation: hintBounce 1s ease-in-out infinite; }
@keyframes hintBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.intro-bg-effects { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.intro-ring {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--primary);
  border-radius: 50%;
  opacity: 0.15;
}
.intro-ring.ring-1 { width: 300px; height: 300px; animation: ringPulse 4s ease-in-out infinite; }
.intro-ring.ring-2 { width: 450px; height: 450px; animation: ringPulse 4s ease-in-out infinite 0.5s; border-color: var(--accent); }
.intro-ring.ring-3 { width: 600px; height: 600px; animation: ringPulse 4s ease-in-out infinite 1s; border-color: var(--secondary); }

@keyframes ringPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.15; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.35; }
}

.intro-features {
  display: flex; gap: 14px;
  margin-top: 25px;
  flex-wrap: wrap; justify-content: center;
}

.intro-features span {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-dim);
  animation: featureFadeIn 0.5s ease forwards;
  opacity: 0;
  backdrop-filter: blur(4px);
}
.intro-features span:nth-child(1) { animation-delay: 0.4s; }
.intro-features span:nth-child(2) { animation-delay: 0.55s; }
.intro-features span:nth-child(3) { animation-delay: 0.7s; }
.intro-features span:nth-child(4) { animation-delay: 0.85s; }

@keyframes featureFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 255, 170, 0.2);
  margin-bottom: 14px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.dragon-icon-small { font-size: 32px; filter: drop-shadow(0 0 8px rgba(0,255,170,.4)); }

header h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
}
header h1 .accent { color: var(--primary); text-shadow: 0 0 20px var(--primary-glow); }
.header-right { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 17px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(.2,.9,.25,1);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover {
  background: rgba(0, 255, 170, 0.1);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(0,255,170,.2);
}

/* Level Selection */
.section-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.05rem;
  text-align: center;
  margin: 0 0 14px 0;
  color: var(--text-dim);
  letter-spacing: 3px;
}

.level-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 860px; margin: 0 auto; }

.level-card {
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.level-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, transparent 0%, rgba(0, 255, 170, 0.07) 100%);
  opacity: 0; transition: opacity 0.3s;
}

.level-card::after {
  content: ''; position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(from 0deg, transparent 0%, rgba(0,255,170,.2) 10%, transparent 20%);
  opacity: 0;
  animation: shine 4s linear infinite;
}

.level-card:hover::after, .level-card.selected::after { opacity: 0.5; }

@keyframes shine { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.level-card:hover, .level-card.selected {
  border-color: var(--primary);
  transform: translateY(-10px) scale(1.03);
  box-shadow:
    0 20px 40px rgba(0, 255, 170, 0.3),
    0 0 0 1px var(--primary),
    inset 0 0 30px rgba(0, 255, 170, 0.06);
}
.level-card:hover::before, .level-card.selected::before { opacity: 1; }
.level-card:hover .level-icon { animation: levelIconBounce 0.5s ease-in-out infinite; }

@keyframes levelIconBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.15); }
}

.level-card.featured {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 211, 42, 0.1) 0%, rgba(0, 0, 0, 0.5) 100%);
}
.level-card.featured:hover, .level-card.featured.selected {
  border-color: var(--accent);
  box-shadow: 0 20px 40px rgba(255, 211, 42, 0.25);
}
.level-card.danger:hover, .level-card.danger.selected {
  border-color: var(--secondary);
  box-shadow: 0 20px 40px rgba(255, 58, 94, 0.25);
}

.featured-badge {
  position: absolute; top: 10px; right: -30px;
  background: var(--accent);
  color: #000;
  padding: 5px 40px;
  font-size: 0.7rem;
  font-weight: 700;
  transform: rotate(45deg);
  z-index: 2;
}

.level-icon { font-size: 36px; margin-bottom: 8px; filter: drop-shadow(0 0 14px rgba(255,255,255,.15)); position: relative; z-index: 1; }

.level-card h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem; margin-bottom: 4px; color: var(--text);
  position: relative; z-index: 1;
}
.level-desc { color: var(--text-dim); font-size: 0.8rem; margin-bottom: 10px; position: relative; z-index: 1; }
.level-features { list-style: none; text-align: left; margin-bottom: 12px; position: relative; z-index: 1; }
.level-features li { padding: 3px 0; color: var(--text-dim); font-size: 0.78rem; display: flex; align-items: center; gap: 6px; }
.level-features i { color: var(--primary); font-size: 0.8rem; }
.level-card.danger .level-features i { color: var(--secondary); }

.difficulty-bar { display: flex; gap: 4px; justify-content: center; position: relative; z-index: 1; }
.difficulty-bar span { width: 24px; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
.difficulty-bar span.filled { background: linear-gradient(90deg, var(--primary), var(--accent)); box-shadow: 0 0 8px var(--primary-glow); }
.level-card.danger .difficulty-bar span.filled { background: linear-gradient(90deg, var(--accent), var(--secondary)); box-shadow: 0 0 8px var(--secondary-glow); }

/* Footer Stats */
footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.stats-bar { display: flex; justify-content: center; gap: 30px; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 0.95rem; }
.stat i { color: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: center;
  z-index: 1500;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid rgba(0, 255, 170, 0.3);
  border-radius: 20px;
  padding: 30px;
  max-width: 560px;
  width: 100%;
  position: relative;
  animation: modalIn 0.3s ease;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 80px rgba(0,255,170,.08);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.close-btn {
  position: absolute; top: 15px; right: 15px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text-dim);
  width: 34px; height: 34px; border-radius: 10px;
  font-size: 1rem; cursor: pointer;
  transition: all 0.25s;
  display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { color: var(--secondary); border-color: var(--secondary); background: rgba(255,58,94,.08); }

.modal h2 {
  font-family: 'Orbitron', sans-serif;
  color: var(--primary);
  margin-bottom: 22px;
  display: flex; align-items: center; gap: 10px;
  font-size: 1.4rem;
}

.help-section { margin-bottom: 20px; }
.help-section h3 { color: var(--text); font-size: 1rem; margin-bottom: 10px; }
.help-section p { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 8px; }

kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: monospace;
  font-size: 0.85rem;
  margin: 0 2px;
}

.powerup-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.powerup-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-dim); }
.pu-icon { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.pu-icon.speed { background: var(--speed-color); color: var(--speed-color); }
.pu-icon.invincibility { background: var(--invincibility-color); color: var(--invincibility-color); }
.pu-icon.magnet { background: var(--magnet-color); color: var(--magnet-color); }
.pu-icon.slowmo { background: var(--slowmo-color); color: var(--slowmo-color); }
.pu-icon.shrink { background: var(--shrink-color); color: var(--shrink-color); }
.pu-icon.extra-points { background: linear-gradient(135deg, var(--accent), #ff9f1a); color: var(--accent); }
.pu-icon.ghost { background: var(--ghost-color); color: var(--ghost-color); }
.pu-icon.freeze { background: var(--freeze-color); color: var(--freeze-color); }
.pu-icon.multiplier { background: linear-gradient(135deg, var(--accent), var(--secondary)); color: var(--accent); }

/* Leaderboard Modal */
.leaderboard-modal h2 .ach-count {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--text-dim);
  background: rgba(255,255,255,.05);
  padding: 4px 10px;
  border-radius: 10px;
}
.leaderboard-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.lb-tab {
  flex: 1;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text-dim);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.25s;
}
.lb-tab:hover { background: rgba(0,255,170,.08); color: var(--primary); }
.lb-tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #000; border-color: var(--primary); box-shadow: 0 6px 14px rgba(0,255,170,.25); }

.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  transition: all 0.25s;
}
.lb-row:hover { background: rgba(0,255,170,.06); border-color: rgba(0,255,170,.25); transform: translateX(3px); }
.lb-row.top { background: linear-gradient(90deg, rgba(255,211,42,.08), rgba(255,255,255,.02)); }
.lb-row.gold   { border-color: var(--gold); box-shadow: 0 0 18px rgba(255,215,0,.15); }
.lb-row.silver { border-color: var(--silver); }
.lb-row.bronze { border-color: var(--bronze); }

.lb-rank {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700; color: var(--text-dim);
  font-size: 1.2rem;
}
.lb-row.gold .lb-rank i { color: var(--gold); }
.lb-row.silver .lb-rank i { color: var(--silver); }
.lb-row.bronze .lb-rank i { color: var(--bronze); }
.lb-name { font-weight: 600; color: var(--text); }
.lb-score { font-family: 'Orbitron', sans-serif; font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.lb-details { font-size: 0.75rem; color: var(--text-dim); grid-column: 2 / -1; margin-top: -4px; }
.lb-details i { margin: 0 2px 0 6px; }

.leaderboard-empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.leaderboard-empty i { font-size: 3rem; margin-bottom: 14px; opacity: 0.4; display: block; }

/* Achievements Modal */
.achievements-modal h2 { justify-content: space-between; }
.achievements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ach-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 12px;
  transition: all 0.3s;
  opacity: 0.55;
}
.ach-card.unlocked {
  opacity: 1;
  background: linear-gradient(135deg, rgba(0,255,170,.08), rgba(255,211,42,.05));
  border-color: rgba(255,211,42,.4);
  box-shadow: 0 4px 14px rgba(255,211,42,.12);
}
.ach-icon {
  font-size: 1.6rem;
  filter: grayscale(100%);
  width: 44px; height: 44px;
  background: rgba(0,0,0,.25);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.ach-card.unlocked .ach-icon {
  filter: none;
  background: rgba(255,211,42,.15);
  box-shadow: 0 0 16px rgba(255,211,42,.3);
}
.ach-title { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.ach-desc { color: var(--text-dim); font-size: 0.78rem; margin-top: 2px; }
.ach-check {
  color: var(--primary);
  font-size: 1.1rem;
  text-shadow: 0 0 10px var(--primary-glow);
}

/* Game Header */
.game-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}
.back-btn, .pause-top-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex; align-items: center; gap: 8px;
}
.back-btn:hover, .pause-top-btn:hover {
  background: rgba(0, 255, 170, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}
.pause-top-btn { padding: 10px 14px; }

.level-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #000;
  padding: 8px 20px;
  border-radius: 20px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 6px 16px rgba(0,255,170,.25);
}
.level-badge.level-2 {
  background: linear-gradient(135deg, var(--accent), #ff9f1a);
  color: #000;
  box-shadow: 0 6px 16px rgba(255,211,42,.3);
}
.level-badge.level-3 {
  background: linear-gradient(135deg, var(--secondary), #ff0a3e);
  color: #fff;
  box-shadow: 0 6px 16px rgba(255,58,94,.3);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 auto 8px;
  width: var(--board-size);
  max-width: 100%;
}
.dashboard-item {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
  backdrop-filter: blur(4px);
}
.dashboard-item p {
  color: var(--text-dim);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 3px;
}
.dashboard-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  transition: transform 0.15s ease, text-shadow 0.15s ease;
  line-height: 1.2;
}
.dashboard-value.bumping {
  animation: scoreBump 0.28s ease;
}
@keyframes scoreBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); text-shadow: 0 0 22px var(--primary-glow); }
  100% { transform: scale(1); }
}
.dashboard-value.combo { color: var(--accent); }
.dashboard-value.combo.active {
  animation: comboGlow 0.5s ease infinite alternate;
  text-shadow: 0 0 15px var(--accent-glow);
}
@keyframes comboGlow {
  0%, 100% { text-shadow: 0 0 10px var(--accent-glow); }
  50% { text-shadow: 0 0 30px var(--accent-glow), 0 0 50px var(--accent-glow); }
}

.lives-display { display: flex; justify-content: center; gap: 6px; }
.life {
  width: 16px; height: 16px;
  background: var(--secondary);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--secondary-glow);
  transition: all 0.3s;
  position: relative;
}
.life::after {
  content: ''; position: absolute;
  top: 3px; left: 3px; width: 6px; height: 6px;
  background: rgba(255,255,255,.4);
  border-radius: 50%;
}
.life.lost { background: rgba(255, 255, 255, 0.1); box-shadow: none; }
.life.lost::after { display: none; }

/* Power-up bar (chips) */
.powerup-bar {
  display: flex; flex-wrap: wrap;
  gap: 8px;
  margin: 0 auto 15px;
  width: var(--board-size);
  max-width: 100%;
  justify-content: center;
}
.fx-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 18px;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.08);
  animation: fxChipIn 0.3s ease;
  backdrop-filter: blur(4px);
}
@keyframes fxChipIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.fx-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #000;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 0.72rem;
  box-shadow: 0 0 12px currentColor;
}
.fx-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.06em;
}
.fx-time {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.72rem;
  color: var(--text-dim);
  padding-left: 4px;
  border-left: 1px solid rgba(255,255,255,.08);
}

/* Wave banner */
.wave-banner {
  position: absolute;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  text-align: center;
  pointer-events: none;
}
.wave-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow), 0 0 48px var(--accent-glow);
  letter-spacing: 0.15em;
}
.wave-sub {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  text-shadow: 0 0 12px rgba(0,0,0,.6);
  letter-spacing: 0.15em;
}
.wave-banner-enter-active, .wave-banner-leave-active { transition: all 0.4s cubic-bezier(.2,.9,.25,1); }
.wave-banner-enter { opacity: 0; transform: translate(-50%, -30px) scale(0.85); }
.wave-banner-leave-to { opacity: 0; transform: translate(-50%, 20px) scale(1.2); }

/* Pre-game */
.pre-game { text-align: center; padding: 40px 0; animation: fadeInUp 0.5s ease; }
.pre-game-dragon {
  font-size: 4rem; display: block; margin-bottom: 10px;
  animation: dragonFloat 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 20px var(--primary-glow));
}
.pre-game h2 { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: var(--text); margin-bottom: 12px; }
.pre-game-tip {
  color: var(--accent); font-size: 0.95rem; margin-bottom: 25px;
  padding: 8px 16px;
  background: rgba(255, 211, 42, 0.1);
  border: 1px solid rgba(255,211,42,.2);
  border-radius: 8px;
  display: inline-block;
}
.controls-hint {
  margin-top: 20px;
  display: flex; flex-wrap: wrap;
  justify-content: center; gap: 16px;
  color: var(--text-dim); font-size: 0.8rem;
}
.controls-hint kbd {
  background: rgba(0, 255, 170, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.pulse-btn { animation: btnPulse 2s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50% { box-shadow: 0 0 0 12px transparent; }
}

.name-input-group { display: flex; justify-content: center; gap: 15px; margin-bottom: 30px; }
input[type="text"] {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 22px;
  color: var(--text);
  font-size: 1rem;
  font-family: 'Rajdhani', sans-serif;
  width: 260px;
  text-align: center;
  transition: all 0.3s;
}
input[type="text"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}
input[type="text"]::placeholder { color: var(--text-dim); }

.start-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: #000;
  padding: 14px 50px;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 8px 24px rgba(0,255,170,.25);
}
.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px var(--primary-glow);
}
.start-btn:active { transform: translateY(-1px); }

/* Board Stage */
.game-board-stage {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  margin: 0 auto 20px;
  transition: filter 0.3s ease;
}
.game-board-stage.fever-stage { filter: saturate(1.3) contrast(1.05); }

/* Game Board */
#game-board {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px var(--primary),
    0 0 40px var(--primary-glow),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.5s ease, filter 0.3s ease;
}

#game-board.level-1 { background: linear-gradient(135deg, #0a0f1a 0%, #101728 100%); }
#game-board.level-2 {
  background: linear-gradient(135deg, #1a1627 0%, #1e2a4a 100%);
  box-shadow: 0 0 0 3px var(--accent), 0 0 40px var(--accent-glow), inset 0 0 60px rgba(0, 0, 0, 0.5);
}
#game-board.level-3 {
  background: linear-gradient(135deg, #1a0a15 0%, #2d1720 100%);
  box-shadow: 0 0 0 3px var(--secondary), 0 0 40px var(--secondary-glow), inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.game-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

#game-board.board-pulse { animation: boardPulseHit 0.35s ease-out; }
@keyframes boardPulseHit {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.02); filter: brightness(1.2); }
  100% { transform: scale(1); filter: brightness(1); }
}

#game-board.fever-mode {
  animation: feverBoardPulse 0.5s ease-in-out infinite alternate;
}
@keyframes feverBoardPulse {
  from {
    box-shadow: 0 0 0 3px var(--primary), 0 0 40px var(--primary-glow), 0 0 80px rgba(255, 58, 94, 0.3);
    filter: saturate(1.2) brightness(1.05);
  }
  to {
    box-shadow: 0 0 0 3px var(--secondary), 0 0 60px var(--secondary-glow), 0 0 100px rgba(255, 211, 42, 0.3);
    filter: saturate(1.4) brightness(1.1) hue-rotate(10deg);
  }
}

#game-board.dash-active { filter: blur(1px) brightness(1.2) contrast(1.1); }
#game-board.freeze-mode { filter: hue-rotate(180deg) brightness(1.05); }
#game-board.freeze-mode::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at center, transparent 45%, rgba(138, 210, 255, 0.2) 100%);
  pointer-events: none;
  animation: freezeShimmer 2s linear infinite;
}
@keyframes freezeShimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}
#game-board.ghost-mode::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(180,154,255,.15) 0%, transparent 55%);
  pointer-events: none;
  animation: ghostShimmer 2s ease-in-out infinite;
}
@keyframes ghostShimmer { 0%,100% { opacity: 0.3; } 50% { opacity: 0.9; } }

/* Countdown Overlay */
.countdown-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: flex; justify-content: center; align-items: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  border-radius: 14px;
  z-index: 200;
}

.countdown-number {
  font-family: 'Orbitron', sans-serif;
  font-size: 8rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 40px var(--primary-glow), 0 0 80px var(--primary-glow);
  animation: countdownPop 0.8s ease-out;
}
.countdown-number.count-0 {
  font-size: 5rem;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow);
}
@keyframes countdownPop {
  0% { transform: scale(2); opacity: 0; }
  30% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Combo Display */
.combo-display {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}
.combo-display.show { animation: comboPopup 0.8s ease-out forwards; }
.combo-display.fever { color: var(--secondary); text-shadow: 0 0 30px var(--secondary-glow), 0 0 60px var(--accent-glow); }

/* Streak Messages */
.streak-message {
  position: absolute;
  top: 30%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  pointer-events: none;
  opacity: 0;
  z-index: 110;
}
.streak-message.show { animation: streakPopIn 1.5s ease-out forwards; }
@keyframes streakPopIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.25) rotate(5deg); }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1.1); }
}
.streak-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 15px var(--streak-color, #ff3a5e));
  animation: streakIconBounce 0.3s ease-in-out infinite alternate;
}
@keyframes streakIconBounce {
  from { transform: scale(1) rotate(-5deg); }
  to { transform: scale(1.15) rotate(5deg); }
}
.streak-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--streak-color, #ff3a5e);
  text-shadow: 0 0 20px var(--streak-color, #ff3a5e), 0 0 40px var(--streak-color, #ff3a5e);
  letter-spacing: 0.1em;
}

/* Dash Meter (HUD pill, no longer overlays gameplay) */
.dash-meter {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(4, 14, 22, 0.8), rgba(6, 22, 40, 0.6));
  border: 1px solid rgba(90, 200, 255, 0.28);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 14px rgba(90, 200, 255, 0.1);
  transition: all 0.25s ease;
}
.dash-meter.ready {
  border-color: var(--primary, #7fdfff);
  box-shadow: 0 0 22px var(--primary-glow, rgba(90, 200, 255, 0.55)), 0 0 36px rgba(90, 200, 255, 0.3);
  animation: dashReadyPulse 0.9s ease-in-out infinite alternate;
}
@keyframes dashReadyPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.015); }
}
.dash-meter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #a8e6ff;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 0 0 auto;
}
.dash-meter.ready .dash-meter-label { color: #ffffff; }
.dash-meter-label i {
  color: var(--primary, #7fdfff);
  text-shadow: 0 0 8px var(--primary-glow, rgba(90, 200, 255, 0.8));
}
.dash-meter-bar {
  position: relative;
  flex: 1 1 auto;
  height: 8px;
  background: rgba(20, 20, 30, 0.8);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.dash-meter-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--primary-dark, #3aa8d8), var(--primary, #7fdfff));
  border-radius: 6px;
  box-shadow: 0 0 14px var(--primary-glow, rgba(90, 200, 255, 0.7));
  transition: width 0.1s linear;
}
.dash-meter.ready .dash-meter-fill {
  background: linear-gradient(90deg, #ffffff, var(--primary, #7fdfff));
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.9);
}

@keyframes comboPopup {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* Pause Overlay */
.pause-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: center;
  z-index: 50;
  border-radius: 14px;
}
.pause-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px;
  padding: 30px 40px;
  background: rgba(15, 15, 25, 0.9);
  border: 1px solid var(--primary);
  border-radius: 16px;
  box-shadow: 0 0 40px var(--primary-glow);
}
.pause-overlay h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.5rem;
  color: var(--primary);
  text-shadow: 0 0 30px var(--primary-glow);
  margin-bottom: 0;
}
.pause-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.pause-stats > div {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.04);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.06);
}
.pause-stats label { color: var(--text-dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.2px; }
.pause-stats span { font-family: 'Orbitron', sans-serif; font-size: 1.1rem; color: var(--primary); font-weight: 700; }

.pause-buttons { display: flex; gap: 15px; }
.pause-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--primary);
  color: var(--primary);
  padding: 12px 26px;
  border-radius: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s;
}
.pause-btn:hover { background: var(--primary); color: #000; transform: translateY(-2px); }
.pause-btn.quit { border-color: var(--secondary); color: var(--secondary); }
.pause-btn.quit:hover { background: var(--secondary); color: #fff; }

/* Game Over Screen */
.game-over-overlay {
  position: fixed; inset: 0;
  z-index: 1600;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: rgba(5, 5, 12, 0.9);
  backdrop-filter: blur(14px);
  animation: fadeIn 0.45s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.game-over-card {
  width: 100%;
  max-width: 440px;
  max-height: min(94vh, 720px);
  overflow-y: auto;
  border-radius: 20px;
  padding: 28px 24px 26px;
  background: linear-gradient(165deg, rgba(22, 22, 38, 0.98) 0%, rgba(10, 10, 18, 0.99) 100%);
  border: 1px solid rgba(255, 211, 42, 0.4);
  box-shadow:
    0 0 0 1px rgba(0, 255, 170, 0.14),
    0 24px 80px rgba(0, 0, 0, 0.65),
    0 0 60px rgba(255, 211, 42, 0.1);
  animation: gameOverCardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes gameOverCardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.game-over-header { text-align: center; margin-bottom: 22px; }
.game-over-icon {
  font-size: 2.5rem; display: block; margin-bottom: 8px;
  filter: drop-shadow(0 0 14px rgba(0, 255, 170, 0.5));
  animation: dragonFloat 2.5s ease-in-out infinite;
}
.game-over-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  font-weight: 900;
  color: var(--secondary);
  letter-spacing: 0.12em;
  margin: 0 0 12px;
  line-height: 1.15;
  text-shadow: 0 0 24px var(--secondary-glow), 0 0 48px rgba(255, 58, 94, 0.25);
  animation: gameOverPulse 1.8s ease-in-out infinite;
}
@keyframes gameOverPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.game-over-overlay .player-name {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.08em;
  margin: 0 0 14px;
  text-shadow: 0 0 16px var(--primary-glow);
}
.game-over-overlay .player-label {
  display: block;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.star-rating {
  display: flex; justify-content: center; gap: 6px;
  margin: 10px 0 6px;
}
.star-rating i {
  color: rgba(255,255,255,.1);
  font-size: 1.4rem;
  transition: all 0.3s ease;
}
.star-rating i.filled {
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-glow);
  animation: starPop 0.5s ease;
}
.star-rating i.filled:nth-child(1) { animation-delay: 0.1s; }
.star-rating i.filled:nth-child(2) { animation-delay: 0.2s; }
.star-rating i.filled:nth-child(3) { animation-delay: 0.3s; }
.star-rating i.filled:nth-child(4) { animation-delay: 0.4s; }
.star-rating i.filled:nth-child(5) { animation-delay: 0.5s; }
@keyframes starPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1); }
}
.rating-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.final-stat {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.final-stat.featured-stat {
  grid-column: 1 / -1;
  padding: 18px 16px;
  background: rgba(0, 255, 170, 0.08);
  border-color: rgba(0, 255, 170, 0.22);
}
.final-stat label {
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
}
.final-stat .value {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 700;
  color: var(--primary);
}
.final-stat .value.combo-val { color: #5ce1e6; text-shadow: 0 0 12px rgba(92, 225, 230, 0.35); }
.final-stat .value.new-best { color: var(--accent); animation: newBestPulse 1s ease-in-out infinite; }
@keyframes newBestPulse {
  0%, 100% { text-shadow: 0 0 10px var(--accent-glow); }
  50% { text-shadow: 0 0 30px var(--accent-glow); }
}

/* Confetti */
.confetti-container { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1601; }
.confetti {
  position: absolute;
  top: -20px;
  left: var(--x, 50%);
  width: 10px; height: 10px;
  animation: confettiFall 3s ease-in-out forwards;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}
.confetti:nth-child(odd) { background: var(--primary); border-radius: 50%; }
.confetti:nth-child(even) { background: var(--accent); border-radius: 2px; transform: rotate(45deg); }
.confetti:nth-child(3n) { background: var(--secondary); width: 8px; height: 8px; }
.confetti:nth-child(5n) { background: var(--ghost-color); width: 12px; height: 12px; border-radius: 50%; }

@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(0); }
  10% { transform: translateY(10vh) rotate(180deg) scale(1); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.5); }
}

.game-over-overlay.new-record .game-over-card {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 24px 80px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(255, 211, 42, 0.25);
}
.game-over-overlay.new-record .game-over-title {
  background: linear-gradient(90deg, var(--secondary), var(--accent), var(--primary), var(--accent), var(--secondary));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 2s linear infinite;
}
@keyframes gradientShift {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.new-best-badge {
  display: inline-block;
  background: var(--accent);
  color: #000;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  margin-left: 10px;
  font-weight: 700;
}

.game-over-buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.restart-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: #000;
  padding: 14px 28px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  flex: 1 1 160px;
  min-width: 0;
}
.restart-btn:hover { transform: translateY(-3px); box-shadow: 0 10px 30px var(--primary-glow); }

.menu-btn {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: var(--text);
  padding: 14px 28px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  flex: 1 1 140px;
  min-width: 0;
}
.menu-btn:hover { border-color: var(--text); background: rgba(255, 255, 255, 0.08); }

/* Mobile Controls */
.controls-mobile {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  margin-top: 20px;
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
}
.control-btn {
  background: rgba(0, 255, 170, 0.1);
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 12px;
  padding: 16px;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; justify-content: center; align-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.control-btn:active { background: var(--primary); color: #000; transform: scale(0.95); }

.control-btn.up { grid-column: 2; grid-row: 1; }
.control-btn.left { grid-column: 1; grid-row: 2; }
.control-btn.dash-mobile {
  grid-column: 2; grid-row: 2;
  background: rgba(255, 211, 42, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.control-btn.dash-mobile.ready {
  background: linear-gradient(135deg, var(--accent), #ff9f1a);
  color: #000;
  animation: dashMobileReady 1s ease-in-out infinite;
}
@keyframes dashMobileReady {
  0%, 100% { box-shadow: 0 0 10px var(--accent-glow); }
  50% { box-shadow: 0 0 25px var(--accent-glow); }
}
.control-btn.right { grid-column: 3; grid-row: 2; }
.control-btn.down { grid-column: 2; grid-row: 3; }

/* Achievement Popup (in-game) */
.achievement-popup {
  position: fixed;
  top: 24px; right: 24px;
  background: linear-gradient(135deg, rgba(255, 211, 42, 0.22), rgba(255, 159, 26, 0.22));
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 14px 22px 14px 16px;
  display: flex; align-items: center; gap: 14px;
  z-index: 2000;
  box-shadow: 0 14px 40px rgba(255, 211, 42, 0.35), 0 0 30px rgba(255, 211, 42, 0.2);
  min-width: 260px;
  backdrop-filter: blur(10px);
}

.achievement-icon-wrap {
  font-size: 2rem;
  background: rgba(0,0,0,.3);
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 18px rgba(255,211,42,.4);
}

.achievement-content { display: flex; flex-direction: column; gap: 2px; }
.achievement-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-glow);
}
.achievement-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}
.achievement-desc { font-size: 0.82rem; color: var(--text-dim); }

.achievement-enter-active { animation: achievementIn 0.5s cubic-bezier(.2,.9,.25,1); }
.achievement-leave-active { animation: achievementOut 0.5s ease; }
@keyframes achievementIn {
  from { opacity: 0; transform: translateX(120%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes achievementOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(120%); }
}

/* Status Effect Overlay */
.status-effect {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.5s;
}

/* Responsive */
@media (max-width: 900px) {
  .level-cards { grid-template-columns: 1fr; max-width: 350px; margin: 0 auto; }
  .level-card.featured .featured-badge { top: 8px; right: -35px; font-size: 0.6rem; }
  .achievements-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  #app {
    padding: 8px;
    --board-size: min(calc(100vh - 320px), calc(100vw - 30px), 520px);
  }
  .game-wrapper { padding: 12px; }
  .glitch { font-size: 2.5rem; }
  header h1 { font-size: 1.3rem; }
  .header-right .icon-btn { width: 38px; height: 38px; font-size: 15px; }
  .dashboard { grid-template-columns: repeat(2, 1fr); }
  .controls-mobile { display: grid; }
  .stats-bar { flex-direction: column; gap: 10px; align-items: center; }
  .final-stats { grid-template-columns: 1fr; }
  .achievement-popup { top: 10px; right: 10px; left: 10px; min-width: 0; }
}

@media (max-width: 400px) {
  #app { --board-size: min(calc(100vh - 340px), calc(100vw - 20px), 400px); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }

/* ============================================================
   Dragon Chase — Advanced features: Fire Breath, Portals,
   Coins, Shop, Game Modes
   ============================================================ */

/* Coin badge in header */
.coin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(255, 211, 42, 0.18), rgba(255, 140, 26, 0.14));
  border: 1px solid rgba(255, 211, 42, 0.5);
  border-radius: 20px;
  color: #ffd32a;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 0 14px rgba(255, 211, 42, 0.25);
}
.coin-badge .coin-icon { font-size: 1.1rem; filter: drop-shadow(0 0 4px rgba(255, 211, 42, 0.7)); }
.coin-badge .coin-amount { letter-spacing: 1px; }

/* Coin value pill in dashboard & game-over card */
.dashboard-value.coin-val { color: #ffd32a; text-shadow: 0 0 12px rgba(255, 211, 42, 0.6); }
.final-stat.coins-earned .value.coin-val { color: #ffd32a; }
.dashboard-value.urgent {
  color: #ff3a5e;
  animation: urgentPulse 0.6s infinite alternate;
}
@keyframes urgentPulse {
  from { text-shadow: 0 0 8px rgba(255, 58, 94, 0.6); transform: scale(1); }
  to   { text-shadow: 0 0 22px rgba(255, 58, 94, 1);   transform: scale(1.06); }
}

/* Fire Breath charge meter (compact horizontal strip) */
/* Action HUD row: holds Fire Breath + Dash meters side-by-side above the board */
.action-hud {
  width: var(--board-size);
  max-width: var(--board-size);
  margin: 0 auto 6px auto;
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.fire-meter {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(20, 8, 4, 0.8), rgba(40, 10, 5, 0.6));
  border: 1px solid rgba(255, 122, 26, 0.35);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 14px rgba(255, 122, 26, 0.12);
  transition: all 0.2s ease;
}
.fire-meter.ready {
  border-color: #ffd32a;
  box-shadow: 0 0 26px rgba(255, 211, 42, 0.6), 0 0 40px rgba(255, 122, 26, 0.45);
  animation: fireReadyPulse 0.7s infinite alternate;
}
@keyframes fireReadyPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.015); }
}
.fire-meter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #ffb470;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 0 0 auto;
}
.fire-meter.ready .fire-meter-label { color: #ffd32a; }
.fire-meter-label i { color: #ff7a1a; text-shadow: 0 0 8px rgba(255, 122, 26, 0.8); }
.fire-meter-bar {
  position: relative;
  flex: 1 1 auto;
  height: 8px;
  background: rgba(20, 20, 30, 0.8);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.fire-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #ffd32a, #ff7a1a, #ff3a1a);
  border-radius: 6px;
  box-shadow: 0 0 14px rgba(255, 122, 26, 0.8);
  transition: width 0.18s ease-out;
}
.fire-meter.ready .fire-fill {
  background: linear-gradient(90deg, #ffffff, #ffd32a, #ff7a1a);
  box-shadow: 0 0 22px rgba(255, 211, 42, 1);
}

/* Game Mode selection (compact horizontal pills) */
.mode-select {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 860px;
  margin: 0 auto 18px auto;
}
.mode-card {
  flex: 1 1 170px;
  max-width: 240px;
  background: linear-gradient(145deg, rgba(14, 15, 26, 0.94), rgba(20, 22, 38, 0.88));
  border: 1px solid rgba(0, 255, 170, 0.2);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  position: relative;
}
.mode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 255, 170, 0.55);
  box-shadow: 0 4px 16px rgba(0, 255, 170, 0.16);
}
.mode-card.active {
  border-color: var(--primary);
  background: linear-gradient(145deg, rgba(0, 255, 170, 0.14), rgba(20, 22, 38, 0.88));
  box-shadow: 0 0 0 1px var(--primary), 0 4px 14px rgba(0, 255, 170, 0.25);
}
.mode-card .mode-icon {
  font-size: 1.4rem;
  flex: 0 0 auto;
  line-height: 1;
}
.mode-card .mode-name {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
  font-size: 0.85rem;
  line-height: 1.1;
}
.mode-card .mode-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.25;
  margin-top: 2px;
}

/* Shop Modal */
.shop-modal { max-width: 720px; }
.shop-modal h2 .shop-wallet {
  float: right;
  font-size: 0.95rem;
  padding: 4px 12px;
  border-radius: 14px;
  background: rgba(255, 211, 42, 0.12);
  border: 1px solid rgba(255, 211, 42, 0.4);
  color: #ffd32a;
}
.shop-sub {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 16px;
  text-align: center;
}
.shop-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.upgrade-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(14, 15, 26, 0.96), rgba(22, 22, 40, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.2s ease;
}
.upgrade-card:hover {
  border-color: rgba(255, 211, 42, 0.4);
  transform: translateX(2px);
}
.upgrade-card.owned {
  border-color: rgba(0, 255, 170, 0.6);
  background: linear-gradient(90deg, rgba(0, 255, 170, 0.08), rgba(22, 22, 40, 0.86));
}
.upgrade-card.affordable { border-color: rgba(255, 211, 42, 0.5); }
.upgrade-icon {
  font-size: 2rem;
  width: 56px; height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 211, 42, 0.15), rgba(255, 122, 26, 0.1));
  border-radius: 12px;
  filter: drop-shadow(0 0 6px rgba(255, 211, 42, 0.4));
}
.upgrade-card.owned .upgrade-icon {
  background: linear-gradient(135deg, rgba(0, 255, 170, 0.18), rgba(0, 180, 120, 0.1));
  filter: drop-shadow(0 0 6px rgba(0, 255, 170, 0.6));
}
.upgrade-name {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 2px;
}
.upgrade-desc { color: var(--text-dim); font-size: 0.85rem; }
.upgrade-btn {
  min-width: 88px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #ffd32a, #ff9f1a);
  color: #2b1600;
  border: none;
  border-radius: 8px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(255, 211, 42, 0.3);
}
.upgrade-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(255, 211, 42, 0.5);
}
.upgrade-btn:disabled {
  background: #2a2a38;
  color: #555;
  cursor: not-allowed;
  box-shadow: none;
}
.upgrade-btn.owned {
  background: linear-gradient(135deg, #00ffaa, #00b46b);
  color: #00281a;
  opacity: 0.9;
}

/* Pre-game mode pill */
.pre-game-mode {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 10px;
  margin: 0 auto 12px auto;
  background: linear-gradient(135deg, rgba(0, 255, 170, 0.08), rgba(0, 255, 170, 0.02));
  border: 1px solid rgba(0, 255, 170, 0.35);
  border-radius: 999px;
  font-family: 'Orbitron', sans-serif;
}
.pre-mode-label {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--text-dim);
  padding: 2px 8px;
  border-right: 1px solid rgba(255,255,255,0.12);
}
.pre-mode-pill {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 8px rgba(0,255,170,0.5);
  letter-spacing: 1px;
}

/* Leaderboard mode-tabs secondary row */
.leaderboard-tabs.mode-tabs {
  margin-top: -4px;
  margin-bottom: 14px;
}
.lb-tab.mode-tab {
  font-size: 0.75rem;
  padding: 6px 12px;
}

/* Mobile tweaks */
@media (max-width: 900px) {
  .mode-select { grid-template-columns: 1fr; max-width: 340px; }
}
@media (max-width: 768px) {
  .coin-badge { padding: 4px 10px; font-size: 0.8rem; }
  .shop-modal { max-width: 95vw; }
  .upgrade-card { grid-template-columns: 48px 1fr auto; padding: 10px 12px; gap: 10px; }
  .upgrade-icon { width: 48px; height: 48px; font-size: 1.6rem; }
  .fire-meter { padding: 5px 10px; }
  .fire-meter-label { font-size: 0.65rem; }
  .dash-meter { padding: 5px 10px; }
  .dash-meter-label { font-size: 0.65rem; }
  .action-hud { gap: 6px; flex-wrap: wrap; }
}
