:root {
  --cyan: #00f0ff;
  --magenta: #ff2fd6;
  --orange: #ff9e3d;
  --void: #0a0616;
  --panel: rgba(16, 12, 34, .82);
  --text: #eaf6ff;
  --dim: #8f8ab5;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--void);
  font-family: 'Nunito', sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: max(20px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: center;
  pointer-events: none; z-index: 5;
}
#score {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800; font-size: clamp(46px, 11vw, 76px);
  color: var(--text);
  text-shadow:
    0 0 8px rgba(0,240,255,.9),
    0 0 24px rgba(0,240,255,.55),
    0 0 60px rgba(255,47,214,.35);
  line-height: 1;
  transition: transform .12s ease-out;
}
#score.pop { transform: scale(1.25); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(43,16,84,.45), rgba(6,4,16,.78));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn .4s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay.closing { animation: fadeOut .35s ease-in forwards; }
@keyframes fadeOut { to { opacity: 0; } }

.title-card {
  text-align: center;
  padding: 38px 46px;
  background: var(--panel);
  border: 1px solid rgba(0,240,255,.28);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(255,47,214,.12),
    0 0 34px rgba(0,240,255,.18),
    0 24px 60px rgba(0,0,0,.6),
    inset 0 1px 0 rgba(255,255,255,.08);
  animation: cardIn .55s cubic-bezier(.34,1.56,.64,1);
  max-width: min(88vw, 420px);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(40px) scale(.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.game-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: clamp(34px, 9vw, 52px);
  letter-spacing: 4px;
  color: var(--text);
  line-height: 1;
  text-shadow: 0 0 12px rgba(0,240,255,.8), 0 0 34px rgba(0,240,255,.4);
}
.game-title span { display: inline-block; }
.game-title .accent {
  color: var(--magenta);
  margin-left: 12px;
  text-shadow: 0 0 12px rgba(255,47,214,.9), 0 0 34px rgba(255,47,214,.45);
  animation: flicker 3.2s linear infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: .55; }
  94% { opacity: 1; }
  96% { opacity: .7; }
  97% { opacity: 1; }
}

.subtitle { color: var(--dim); font-weight: 700; margin-top: 10px; font-size: 14px; letter-spacing: 1px; }

.over-title {
  font-family: 'Orbitron', sans-serif; font-weight: 800;
  font-size: clamp(30px, 8vw, 44px); color: var(--text);
  letter-spacing: 3px;
  text-shadow: 0 0 12px rgba(255,47,214,.8), 0 0 30px rgba(255,47,214,.4);
}

.bird-hint { margin: 28px auto 6px; position: relative; height: 64px; width: 64px; }
.tap-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid var(--cyan);
  box-shadow: 0 0 14px rgba(0,240,255,.7), inset 0 0 10px rgba(0,240,255,.4);
  animation: ring 1.6s ease-out infinite;
}
@keyframes ring {
  0%   { transform: scale(.55); opacity: 1; }
  70%  { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.15); opacity: 0; }
}
.hint-text {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; color: var(--dim); font-weight: 700; font-size: 12px; letter-spacing: 1px;
}

.btn {
  margin-top: 56px;
  font-family: 'Orbitron', sans-serif; font-weight: 800;
  font-size: 17px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--void);
  background: linear-gradient(135deg, var(--cyan), #6dffe8);
  border: none; border-radius: 14px;
  padding: 15px 40px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(0,240,255,.55), 0 0 46px rgba(0,240,255,.25), 0 8px 24px rgba(0,0,0,.5);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 26px rgba(0,240,255,.75), 0 0 60px rgba(0,240,255,.35), 0 12px 28px rgba(0,0,0,.55);
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 12px rgba(0,240,255,.5), 0 4px 12px rgba(0,0,0,.5); }
.btn:focus-visible { outline: 2px solid var(--magenta); outline-offset: 3px; }

.best-label { margin-top: 18px; color: var(--dim); font-weight: 700; font-size: 13px; letter-spacing: 1px; }
.best-label span { color: var(--cyan); font-family: 'Orbitron', sans-serif; }

/* Game over score boxes */
.score-row { display: flex; gap: 14px; justify-content: center; margin-top: 24px; }
.score-box {
  background: rgba(8, 6, 22, .8);
  border: 1px solid rgba(0,240,255,.22);
  border-radius: 14px; padding: 12px 26px;
  box-shadow: inset 0 0 18px rgba(0,240,255,.08);
}
.score-box-label { font-size: 11px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 2px; }
.score-box-value {
  font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 30px;
  color: var(--text); line-height: 1.2;
  text-shadow: 0 0 10px rgba(0,240,255,.6);
}

.new-best {
  margin-top: 16px;
  display: inline-block;
  font-family: 'Orbitron', sans-serif; font-weight: 800;
  color: var(--void); background: var(--magenta);
  padding: 7px 18px; border-radius: 999px; font-size: 13px; letter-spacing: 1px;
  box-shadow: 0 0 18px rgba(255,47,214,.7);
  animation: bestPulse 1s ease-in-out infinite;
}
@keyframes bestPulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.08);} }

/* Ready flash */
.ready-flash {
  position: fixed; top: 32%; left: 0; right: 0; z-index: 6;
  text-align: center; pointer-events: none;
  font-family: 'Orbitron', sans-serif; font-weight: 800;
  font-size: clamp(22px, 5vw, 32px); letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 12px rgba(0,240,255,.9), 0 0 34px rgba(0,240,255,.4);
  animation: readyFade 1.1s ease forwards;
}
@keyframes readyFade {
  0% { opacity: 0; transform: translateY(14px); }
  25% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

@media (prefers-reduced-motion: reduce) {
  .tap-ring, .game-title .accent, .new-best { animation: none; }
}
