*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cyan: #00f5ff;
  --green: #00ff88;
  --pink: #ff006e;
  --gold: #ffd166;
  --ice: #8be9ff;
  --dark: #050a10;
  --darker: #020508;
  --panel: rgba(0, 20, 40, 0.7);
  --border: rgba(0, 245, 255, 0.2);
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--darker);
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }
.hidden { display: none !important; }

/* ── Décor ── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,245,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,245,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 8s ease-in-out infinite;
}
.orb1 { width: 400px; height: 400px; background: rgba(0,245,255,0.07); top: -100px; left: -100px; }
.orb2 { width: 300px; height: 300px; background: rgba(0,255,136,0.06); bottom: -80px; right: -80px; animation-delay: -4s; }
@keyframes orbFloat {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(30px, 20px); }
}

/* ── Layout ── */
.wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  width: 100%;
  max-width: 480px;
}

header { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }

.logo {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(24px, 8vw, 42px);
  font-weight: 900;
  letter-spacing: clamp(4px, 2vw, 12px);
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0,245,255,0.6), 0 0 60px rgba(0,245,255,0.3);
}
.logo span { color: var(--green); text-shadow: 0 0 20px rgba(0,255,136,0.8); }

/* ── HUD ── */
.hud {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 6px;
  backdrop-filter: blur(10px);
  width: 100%;
  justify-content: space-evenly;
}
.hud-block { display: flex; flex-direction: column; align-items: center; padding: 0 clamp(4px, 2.5vw, 16px); gap: 2px; }
.hud-buttons { flex-direction: row; gap: 4px; }
.hud-label {
  font-size: clamp(8px, 2vw, 10px);
  letter-spacing: 2px;
  color: rgba(0,245,255,0.5);
  font-family: 'Orbitron', sans-serif;
}
.hud-value {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(16px, 5vw, 22px);
  font-weight: 700;
  color: #fff;
  transition: color 0.2s;
  font-variant-numeric: tabular-nums;
}
.hud-value.bump { color: var(--green); text-shadow: 0 0 10px var(--green); }
.hud-divider { width: 1px; height: 36px; background: var(--border); }

.icon-btn {
  background: rgba(0,245,255,0.06);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 18px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
  line-height: 1;
}
.icon-btn:hover { transform: scale(1.08); background: rgba(0,245,255,0.14); }
.icon-btn.muted { opacity: 0.4; filter: grayscale(1); }

/* ── Barre de statut (combo / progression / effet) ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  min-height: 18px;
}
.combo { color: rgba(255,255,255,0.4); white-space: nowrap; transition: color 0.2s, text-shadow 0.2s; }
.combo b { font-size: 13px; }
.combo.active { color: var(--gold); text-shadow: 0 0 10px rgba(255,209,102,0.7); }
.progress { flex: 1; height: 6px; background: rgba(0,245,255,0.08); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--green)); transition: width 0.25s; box-shadow: 0 0 8px var(--green); }
.effect { color: var(--ice); text-shadow: 0 0 10px var(--ice); white-space: nowrap; animation: blink 0.8s ease-in-out infinite alternate; }
@keyframes blink { from { opacity: 1; } to { opacity: 0.45; } }

/* ── Canvas ── */
.canvas-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  touch-action: none;
  box-shadow:
    0 0 0 1px var(--border),
    0 0 40px rgba(0,245,255,0.1),
    0 0 80px rgba(0,245,255,0.05);
}
#gameCanvas { display: block; width: 100%; height: 100%; background: #060d15; }

@keyframes levelFlash {
  0%   { box-shadow: 0 0 0 2px var(--green), 0 0 60px rgba(0,255,136,0.6); }
  100% { box-shadow: 0 0 0 1px var(--border), 0 0 40px rgba(0,245,255,0.1); }
}
.canvas-wrap.level-up { animation: levelFlash 0.8s ease-out; }

/* ── Écrans (overlays) ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,10,16,0.86);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease-out;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  width: 100%;
  max-width: 360px;
}
.overlay-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(24px, 8vw, 36px);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(0,245,255,0.8);
  letter-spacing: 6px;
}
.overlay-title.over { color: var(--pink); text-shadow: 0 0 30px rgba(255,0,110,0.8); }
.overlay-sub { font-size: clamp(13px, 3.5vw, 15px); color: rgba(255,255,255,0.55); letter-spacing: 1px; }
.overlay-hint { font-size: 12px; color: rgba(255,255,255,0.4); text-align: center; line-height: 1.8; }
kbd {
  background: rgba(0,245,255,0.1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  color: var(--cyan);
}

.modes { display: flex; gap: 8px; width: 100%; }
.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  background: rgba(0,245,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: #fff;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.mode-btn:hover { transform: translateY(-2px); }
.mode-btn.selected { border-color: var(--green); background: rgba(0,255,136,0.08); box-shadow: 0 0 18px rgba(0,255,136,0.15); }
.mode-name { font-family: 'Orbitron', sans-serif; font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--cyan); }
.mode-btn.selected .mode-name { color: var(--green); }
.mode-desc { font-size: 12px; color: rgba(255,255,255,0.55); line-height: 1.3; }
.mode-best { font-size: 12px; color: rgba(255,255,255,0.45); }
.mode-best b { color: var(--gold); }

.main-btn, .ghost-btn {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(11px, 3vw, 13px);
  letter-spacing: 3px;
  padding: 10px 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(0,245,255,0.1);
  min-width: 190px;
}
.main-btn:hover { background: rgba(0,245,255,0.1); box-shadow: 0 0 30px rgba(0,245,255,0.3); transform: scale(1.04); }
.main-btn:active, .ghost-btn:active { transform: scale(0.97); }
.ghost-btn { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.6); box-shadow: none; }
.ghost-btn:hover { border-color: rgba(255,255,255,0.5); color: #fff; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: 12px; color: rgba(255,255,255,0.55); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
.dot.apple { background: #ff4d8f; box-shadow: 0 0 6px #ff006e; }
.dot.gold  { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.dot.ice   { background: var(--ice); box-shadow: 0 0 6px var(--ice); border-radius: 2px; transform: rotate(45deg); }

.record {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
  text-shadow: 0 0 14px rgba(255,209,102,0.8);
  animation: blink 0.6s ease-in-out infinite alternate;
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  width: 100%;
  background: rgba(0,245,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 4px;
}
.stats div { display: flex; justify-content: space-between; font-size: 14px; color: rgba(255,255,255,0.55); }
.stats b { font-family: 'Orbitron', sans-serif; font-size: 13px; color: #fff; }

/* ── D-pad (uniquement sur tactile) ── */
.dpad {
  display: none;
  grid-template-columns: repeat(3, clamp(54px, 16vw, 66px));
  grid-template-rows: repeat(3, clamp(54px, 16vw, 66px));
  gap: 6px;
  margin-top: 2px;
}
.dpad-btn {
  width: 100%;
  height: 100%;
  background: rgba(0, 245, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--cyan);
  font-size: clamp(16px, 5vw, 20px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
  touch-action: manipulation;
}
.dpad-btn:active, .dpad-btn.pressed { background: rgba(0, 245, 255, 0.25); transform: scale(0.92); }
.dpad-center { color: rgba(0,245,255,0.45); font-size: 12px; }

.touch-only { display: none; }

@media (hover: none) and (pointer: coarse) {
  .dpad { display: grid; }
  .touch-only { display: block; }
  .desktop-only { display: none; }
}

@media (max-width: 420px) {
  body { align-items: flex-start; padding-top: 6px; }
  .wrapper { gap: 8px; padding: 8px; }
  .mode-desc { font-size: 11px; }
}
@media (max-height: 760px) and (hover: none) {
  .logo { display: none; }
}

/* Focus clavier visible mais dans le thème */
button:focus { outline: none; }
button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--cyan), 0 0 24px rgba(0,245,255,0.35); }

/* ── Animations des écrans ── */
/* Le contenu de chaque écran arrive en cascade */
.overlay-inner > * { animation: entreeEcran .45s cubic-bezier(.22,.9,.32,1) backwards; }
.overlay-inner > :nth-child(2) { animation-delay: 0.06s; }
.overlay-inner > :nth-child(3) { animation-delay: 0.12s; }
.overlay-inner > :nth-child(4) { animation-delay: 0.18s; }
.overlay-inner > :nth-child(5) { animation-delay: 0.24s; }
.overlay-inner > :nth-child(6) { animation-delay: 0.30s; }
.overlay-inner > :nth-child(7) { animation-delay: 0.36s; }
.overlay-inner > :nth-child(8) { animation-delay: 0.42s; }
@keyframes entreeEcran { from { opacity: 0; transform: translateY(14px); } }

/* GAME OVER : le titre s'écrase sur l'écran */
.overlay-title.over { animation: titreFin .6s cubic-bezier(.2,1.4,.4,1) backwards; }
@keyframes titreFin {
  0%   { opacity: 0; transform: scale(1.9); letter-spacing: 22px; filter: blur(8px); }
  60%  { opacity: 1; filter: blur(0); }
}

/* Les statistiques se retournent une par une */
.stats > div { animation: statEntree .4s cubic-bezier(.22,.9,.32,1) backwards; }
.stats > :nth-child(1) { animation-delay: 0.25s; }
.stats > :nth-child(2) { animation-delay: 0.30s; }
.stats > :nth-child(3) { animation-delay: 0.35s; }
.stats > :nth-child(4) { animation-delay: 0.40s; }
.stats > :nth-child(5) { animation-delay: 0.45s; }
.stats > :nth-child(6) { animation-delay: 0.50s; }
@keyframes statEntree { from { opacity: 0; transform: translateX(-12px); } }

/* Nouveau record : pulsation lumineuse */
.record:not(.hidden) { animation: entreeEcran .45s .1s backwards, recordPulse 1.2s .6s ease-in-out infinite alternate; }
@keyframes recordPulse { to { text-shadow: 0 0 18px currentColor, 0 0 36px currentColor; transform: scale(1.06); } }

/* Boutons principaux : reflet qui traverse au survol */
.main-btn { position: relative; overflow: hidden; }
.main-btn::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
  transform: skewX(-20deg); transition: left .5s ease;
}
.main-btn:hover::after { left: 120%; }

@media (prefers-reduced-motion: reduce) {
  .overlay, .overlay-inner > *, .overlay-title.over, .stats > div, .record:not(.hidden) { animation: none !important; }
  .main-btn::after { display: none; }
}

