/* ============================================================
   FLAPPY://NEON-3D — Cyberpunk 3D Flappy Bird
   ============================================================ */

:root {
  --bg: #05030f;
  --bg-deep: #02010a;
  --neon-cyan: #00f0ff;
  --neon-pink: #ff2bd6;
  --neon-purple: #b026ff;
  --neon-yellow: #ffe600;
  --neon-green: #39ff14;
  --neon-orange: #ff8a3d;
  --text: #e7e9ff;
  --text-dim: #8d8fb0;
  --panel: rgba(15, 8, 36, 0.72);
  --panel-border: rgba(176, 38, 255, 0.45);
  --panel-glow: rgba(0, 240, 255, 0.35);
  --hud-shadow: 0 0 24px rgba(0, 240, 255, 0.18), 0 0 64px rgba(176, 38, 255, 0.22);

  --font-display: "Orbitron", "Rajdhani", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, "Menlo", "Consolas", monospace;
  --font-body: "Rajdhani", "Inter", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.theme-cyber {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(176, 38, 255, 0.22), transparent 60%),
    radial-gradient(ellipse at 20% 0%, rgba(0, 240, 255, 0.18), transparent 50%),
    radial-gradient(ellipse at 80% 0%, rgba(255, 43, 214, 0.16), transparent 50%),
    var(--bg-deep);
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  pointer-events: none;
  font-family: var(--font-mono);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 22px;
}
.hud-right { justify-content: flex-end; }

.hud-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.hud-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--neon-cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.brand-mini {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 4px;
  font-size: 13px;
  color: var(--neon-purple);
  text-shadow: 0 0 14px var(--neon-purple);
  padding: 6px 14px;
  border: 1px solid rgba(176, 38, 255, 0.5);
  border-radius: 2px;
  background: rgba(20, 6, 40, 0.5);
  backdrop-filter: blur(6px);
}

.btn-icon {
  pointer-events: auto;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--neon-pink);
  background: rgba(20, 6, 40, 0.5);
  border: 1px solid rgba(255, 43, 214, 0.5);
  padding: 8px 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 36px;
}
.btn-icon:hover {
  background: rgba(255, 43, 214, 0.15);
  box-shadow: 0 0 16px rgba(255, 43, 214, 0.4);
}

/* ---------- Powerups Bar ---------- */
.powerups {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 19;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.pu-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px 4px;
  min-width: 56px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  backdrop-filter: blur(8px);
  font-family: var(--font-mono);
  position: relative;
  overflow: hidden;
  animation: puIn 0.25s ease;
}

@keyframes puIn {
  from { transform: translateY(-8px) scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.pu-chip .pu-icon {
  font-size: 14px;
  line-height: 1;
  filter: drop-shadow(0 0 6px currentColor);
}

.pu-chip .pu-time {
  font-size: 11px;
  color: var(--text);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.pu-chip .pu-bar {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  transition: width 0.1s linear;
}

.pu-shield  { color: var(--neon-cyan); }
.pu-magnet  { color: var(--neon-purple); }
.pu-slow    { color: var(--neon-green); }
.pu-double  { color: var(--neon-yellow); }
.pu-tiny    { color: var(--neon-pink); }

/* ---------- Overlay base ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(20, 6, 40, 0.4), rgba(2, 1, 10, 0.85));
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay.hidden { display: none; }
.hud.hidden, .powerups.hidden { display: none !important; }

.overlay-card {
  width: min(640px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 30px 32px;
  box-shadow: var(--hud-shadow);
  backdrop-filter: blur(12px);
  position: relative;
}

.overlay-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  pointer-events: none;
  background: linear-gradient(135deg, transparent 0%, transparent 50%, rgba(0, 240, 255, 0.04) 100%);
}

.overlay-card.small { width: min(380px, 92vw); text-align: center; }

/* ---------- Logo ---------- */
.logo {
  text-align: center;
  margin-bottom: 6px;
  position: relative;
}

.logo-glitch {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 68px);
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--neon-cyan);
  text-shadow:
    0 0 16px rgba(0, 240, 255, 0.85),
    0 0 36px rgba(0, 240, 255, 0.4);
  position: relative;
}

.logo-glitch::before,
.logo-glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.logo-glitch::before {
  color: var(--neon-pink);
  transform: translate(-2px, 0);
  mix-blend-mode: screen;
  animation: glitchA 3.2s infinite steps(20);
  opacity: 0.7;
}
.logo-glitch::after {
  color: var(--neon-purple);
  transform: translate(2px, 0);
  mix-blend-mode: screen;
  animation: glitchB 4.1s infinite steps(20);
  opacity: 0.7;
}

@keyframes glitchA {
  0%, 92%, 100% { transform: translate(-2px, 0); }
  93% { transform: translate(-6px, 1px); }
  95% { transform: translate(3px, -1px); }
  97% { transform: translate(-2px, 0); }
}
@keyframes glitchB {
  0%, 90%, 100% { transform: translate(2px, 0); }
  91% { transform: translate(6px, -1px); }
  93% { transform: translate(-3px, 1px); }
  96% { transform: translate(2px, 0); }
}

.logo-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--neon-pink);
  margin-top: -4px;
  text-shadow: 0 0 10px rgba(255, 43, 214, 0.6);
}

.tagline {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  margin: 6px 0 20px;
  letter-spacing: 1px;
}

/* ---------- How to play ---------- */
.how-to {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 2px solid var(--neon-cyan);
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.how-row { display: flex; align-items: center; gap: 6px; color: var(--text); }
.how-row span { margin-left: 8px; color: var(--text-dim); }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 3px;
  text-align: center;
}

/* ---------- Powerup legend ---------- */
.powerup-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--neon-purple);
  margin-bottom: 22px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.pu-item { display: flex; align-items: center; gap: 8px; color: var(--text-dim); }
.pu-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}
.pu-dot.pu-shield  { background: var(--neon-cyan);   color: var(--neon-cyan); }
.pu-dot.pu-magnet  { background: var(--neon-purple); color: var(--neon-purple); }
.pu-dot.pu-slow    { background: var(--neon-green);  color: var(--neon-green); }
.pu-dot.pu-double  { background: var(--neon-yellow); color: var(--neon-yellow); }
.pu-dot.pu-tiny    { background: var(--neon-pink);   color: var(--neon-pink); }

/* ---------- Buttons ---------- */
.btn-primary {
  display: block;
  width: 100%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 4px;
  padding: 14px 18px;
  color: #02010a;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple));
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow:
    0 0 16px rgba(0, 240, 255, 0.6),
    0 0 32px rgba(176, 38, 255, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 22px rgba(0, 240, 255, 0.85),
    0 0 44px rgba(176, 38, 255, 0.6);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: block;
  width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 3px;
  padding: 10px 14px;
  margin-top: 10px;
  color: var(--neon-pink);
  background: transparent;
  border: 1px solid rgba(255, 43, 214, 0.5);
  border-radius: 3px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s ease;
}
.btn-ghost:hover {
  background: rgba(255, 43, 214, 0.12);
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.4);
}

/* ---------- Leaderboard ---------- */
.leaderboard-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(176, 38, 255, 0.25);
}

.lb-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--neon-cyan);
  margin-bottom: 12px;
}
.lb-bar { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--neon-purple), transparent); }

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  max-height: 240px;
  overflow-y: auto;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(176, 38, 255, 0.15);
  color: var(--text);
}
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-list li .lb-rank { color: var(--neon-yellow); font-weight: 700; }
.leaderboard-list li .lb-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list li .lb-score { color: var(--neon-cyan); font-weight: 700; font-variant-numeric: tabular-nums; }

.leaderboard-list li.me {
  background: rgba(0, 240, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.3);
}
.leaderboard-list li.me .lb-name { color: var(--neon-cyan); }

.leaderboard-list li.lb-empty {
  display: block;
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
  font-style: italic;
}

/* ---------- Pause ---------- */
.pause-title {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 8px;
  margin: 0 0 20px;
  color: var(--neon-yellow);
  text-shadow: 0 0 20px rgba(255, 230, 0, 0.7);
}

/* ---------- Game Over ---------- */
.gameover-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 6px;
  margin: 0 0 18px;
  text-align: center;
  color: var(--neon-pink);
  text-shadow: 0 0 24px rgba(255, 43, 214, 0.8);
  animation: gameOverPulse 2s ease-in-out infinite;
}

@keyframes gameOverPulse {
  0%, 100% { text-shadow: 0 0 24px rgba(255, 43, 214, 0.8); }
  50%      { text-shadow: 0 0 36px rgba(255, 43, 214, 1), 0 0 64px rgba(255, 43, 214, 0.5); }
}

.final-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 2px solid var(--neon-pink);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
}
.stat-label { color: var(--text-dim); letter-spacing: 2px; font-size: 11px; }
.stat-value { color: var(--neon-cyan); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }

.new-best {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 4px;
  font-size: 18px;
  color: var(--neon-yellow);
  background: rgba(255, 230, 0, 0.1);
  border: 1px solid rgba(255, 230, 0, 0.5);
  padding: 8px;
  border-radius: 3px;
  margin: 10px 0;
  animation: newBestPulse 1.2s ease-in-out infinite;
}
@keyframes newBestPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 230, 0, 0.5); }
  50%      { box-shadow: 0 0 24px rgba(255, 230, 0, 0.9); }
}
.new-best.hidden { display: none; }

.go-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }

/* ---------- Loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bg-deep);
  font-family: var(--font-mono);
  color: var(--neon-cyan);
}
.loader.hidden { display: none; }

.loader-bar {
  width: 260px;
  height: 3px;
  background: rgba(0, 240, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.loader-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), var(--neon-pink), transparent);
  transform: translateX(-100%);
  animation: loaderSlide 1.1s ease-in-out infinite;
}
@keyframes loaderSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.loader-text {
  letter-spacing: 4px;
  font-size: 12px;
  color: var(--text-dim);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

/* ---------- Scrollbars ---------- */
.overlay-card::-webkit-scrollbar,
.leaderboard-list::-webkit-scrollbar { width: 6px; }
.overlay-card::-webkit-scrollbar-track,
.leaderboard-list::-webkit-scrollbar-track { background: transparent; }
.overlay-card::-webkit-scrollbar-thumb,
.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(176, 38, 255, 0.4);
  border-radius: 3px;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .hud { padding: 12px 14px; gap: 8px; }
  .hud-value { font-size: 22px; }
  .brand-mini { font-size: 11px; padding: 4px 8px; }
  .overlay-card { padding: 22px 18px; }
  .powerup-legend { grid-template-columns: 1fr; }
}
