:root {
  --bg: #02010a;
  --neon-cyan: #4ef0ff;
  --neon-magenta: #ff3ec8;
  --neon-violet: #a855f7;
  --neon-green: #39ff14;
  --neon-blue: #44d7ff;
  --bezel: rgba(4, 2, 18, 0.55);
  --arcade: 'Press Start 2P', 'Share Tech Mono', monospace;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #e8f7ff;
  font-family: var(--arcade);
}

/* Fallback si CSS partiel / font lente */
body {
  background-color: #02010a;
}

#crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 5;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px
    ),
    radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
  mix-blend-mode: multiply;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(88, 20, 120, 0.35), transparent 55%),
    radial-gradient(ellipse at 50% 80%, rgba(20, 60, 140, 0.25), transparent 50%),
    var(--bg);
}

#playfield {
  position: relative;
  width: min(100vw, calc(100vh * 0.75));
  height: min(100vh, calc(100vw / 0.75));
  max-width: 100vw;
  max-height: 100vh;
  box-shadow:
    0 0 0 2px rgba(78, 240, 255, 0.25),
    0 0 40px rgba(168, 85, 247, 0.35),
    0 0 80px rgba(255, 62, 200, 0.15);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  image-rendering: pixelated;
}

/* —— HUD —— */
#hud {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  gap: 0.5rem;
}

#hudLevel {
  text-align: center;
  flex: 1;
}

#hudLevel .hud-label {
  color: #ffe566;
  text-shadow: 0 0 8px rgba(255, 229, 102, 0.7);
}

#levelValue {
  font-size: clamp(0.65rem, 2.2vw, 0.9rem);
  color: #ffe566;
  text-shadow:
    0 0 6px rgba(255, 229, 102, 0.8),
    0 0 16px rgba(255, 200, 50, 0.4);
}

.hud-label {
  display: block;
  font-size: 0.45rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.45rem;
  opacity: 0.85;
}

#hudScore .hud-label {
  color: var(--neon-green);
  text-shadow: 0 0 8px var(--neon-green);
}

#scoreValue {
  font-size: clamp(0.7rem, 2.4vw, 1rem);
  color: var(--neon-green);
  text-shadow:
    0 0 6px var(--neon-green),
    0 0 18px rgba(57, 255, 20, 0.55);
}

#hudLives {
  text-align: right;
}

#hudLives .hud-label {
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue);
}

.lives-row {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  min-height: 1rem;
  align-items: flex-end;
}

.life-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.life-unit.is-empty {
  opacity: 0.28;
}

.life-unit.is-empty .life-kadett {
  filter: none;
}

/* Mini Opel Kadett (vue de dessus, CSS) */
.life-kadett {
  display: inline-block;
  width: 1.05rem;
  height: 1.55rem;
  position: relative;
  filter: drop-shadow(0 0 4px var(--neon-blue));
}

.life-kadett::before {
  content: '';
  position: absolute;
  left: 15%;
  right: 15%;
  top: 8%;
  bottom: 28%;
  border: 2px solid var(--neon-blue);
  border-radius: 2px 2px 1px 1px;
  box-shadow: inset 0 0 4px rgba(68, 215, 255, 0.4);
}

.life-kadett::after {
  content: '';
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 6%;
  height: 18%;
  border: 2px solid var(--neon-blue);
  border-radius: 1px;
}

.life-pips {
  display: flex;
  gap: 2px;
  height: 5px;
}

.life-pips i {
  display: block;
  width: 0.32rem;
  height: 5px;
  border-radius: 1px;
  background: rgba(68, 215, 255, 0.18);
  border: 1px solid rgba(68, 215, 255, 0.35);
  box-sizing: border-box;
}

.life-pips i.is-on {
  background: var(--neon-blue);
  border-color: #b8f7ff;
  box-shadow:
    0 0 4px var(--neon-blue),
    0 0 8px rgba(68, 215, 255, 0.65);
}

/* —— Overlay READY / GAMEOVER —— */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 1rem;
  background: rgba(2, 1, 10, 0.55);
  pointer-events: auto;
  cursor: pointer;
}

#overlay.is-hidden {
  display: none;
  pointer-events: none;
}

#overlayTitle {
  font-size: clamp(0.7rem, 2.8vw, 1.05rem);
  line-height: 1.5;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    0 0 8px var(--neon-magenta),
    0 0 22px var(--neon-violet);
  margin-bottom: 1rem;
}

#overlay.ready #overlayTitle {
  color: var(--neon-cyan);
  text-shadow:
    0 0 8px var(--neon-cyan),
    0 0 24px var(--neon-violet);
}

#overlay.gameover #overlayTitle {
  color: #ff4d6d;
  text-shadow:
    0 0 8px #ff4d6d,
    0 0 22px #ff2244;
}

#overlay.win #overlayTitle {
  color: var(--neon-green);
  text-shadow:
    0 0 8px var(--neon-green),
    0 0 22px rgba(57, 255, 20, 0.55);
}

#overlaySub {
  font-size: clamp(0.55rem, 2vw, 0.78rem);
  letter-spacing: 0.08em;
  color: #ffe566;
  text-shadow: 0 0 10px rgba(255, 229, 102, 0.7);
  line-height: 1.6;
}

.overlay-hint {
  margin-top: 1.25rem;
  font-size: 0.38rem;
  line-height: 1.7;
  color: rgba(180, 220, 255, 0.65);
  letter-spacing: 0.04em;
}

.overlay-hint-mobile {
  display: none;
}

/* —— Mobile pad —— */
#mobileControls {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.55rem;
  z-index: 5;
  padding: 0 0.55rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.4rem;
  pointer-events: none;
}

.mobile-left,
.mobile-right,
.mobile-center {
  display: flex;
  gap: 0.45rem;
  pointer-events: auto;
  align-items: center;
}

.mobile-center {
  flex: 1;
  justify-content: center;
}

.touch-btn {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(78, 240, 255, 0.4);
  border-radius: 10px;
  background: rgba(4, 2, 18, 0.82);
  color: var(--neon-cyan);
  font-family: var(--arcade);
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

.touch-btn:active,
.touch-btn.is-active {
  transform: scale(0.96);
  background: rgba(78, 240, 255, 0.18);
  border-color: var(--neon-magenta);
  color: #fff;
}

.touch-btn-main {
  width: 60px;
  height: 60px;
  color: #ff6b9d;
  border-color: rgba(255, 62, 200, 0.55);
}

.touch-btn-start {
  width: auto;
  min-width: 72px;
  padding: 0 0.65rem;
  font-size: 0.42rem;
  letter-spacing: 0.08em;
  color: #ffe566;
  border-color: rgba(255, 229, 102, 0.5);
}

body.is-playing .touch-btn-start {
  visibility: hidden;
  pointer-events: none;
}

@media (hover: none), (pointer: coarse), (max-width: 720px) {
  #mobileControls {
    display: flex;
  }

  .overlay-hint {
    display: none;
  }

  .overlay-hint-mobile {
    display: block;
  }

  #playfield {
    /* laisse de la place au pad */
    height: min(calc(100vh - 4.5rem), calc(100vw / 0.75));
  }

  #hud {
    padding-bottom: 4.2rem;
  }
}

.blink {
  animation: neonBlink 1.05s steps(1, end) infinite;
}

@keyframes neonBlink {
  0%,
  45% {
    opacity: 1;
  }
  46%,
  100% {
    opacity: 0.15;
  }
}

#backHub {
  position: fixed;
  left: 1rem;
  top: 1rem;
  bottom: auto;
  z-index: 6;
  color: var(--neon-cyan);
  text-decoration: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

#backHub:hover {
  opacity: 1;
  text-shadow: 0 0 10px var(--neon-cyan);
}
