/* ============================================================
   PONG PROTOCOL — Scoped Styles
   All tokens live under #citadel-arcade to avoid main.css bleed
   ============================================================ */

#citadel-arcade {
  /* Scoped token map — resolves the missing var crisis */
  --primary: var(--accent-cyan, #00f3ff);
  --accent: #ff0055;
  --font-mono: var(--font-body, 'IBM Plex Mono', 'Share Tech Mono', monospace);
  --font-header: var(--font-header, 'Space Grotesk', 'Orbitron', system-ui, sans-serif);

  margin: 80px auto;
  max-width: 1100px;
  width: 95%;
  padding: 0;
  display: block;
}

#game-container {
  width: 100%;
  height: 60vh;
  max-height: 600px;
  min-height: 400px;
  border: 1px solid rgba(0, 243, 255, 0.3);
  background: #020408;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- INIT / RESTART BUTTON ---- */
.btn-arcade-init {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 15px 40px;
  font-family: var(--font-header);
  font-size: 0.9rem;
  letter-spacing: 4px;
  cursor: pointer;
  transition: 0.3s;
  margin-top: 30px;
  z-index: 100;
  text-transform: uppercase;
}

.btn-arcade-init:hover,
.btn-arcade-init:focus-visible {
  background: var(--primary);
  color: #000;
  box-shadow: 0 0 20px var(--primary);
}

/* ---- HUD ---- */
.hud {
  height: 50px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.2);
  background: rgba(0, 243, 255, 0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 25px;
  font-family: var(--font-header);
  font-size: 0.65rem;
  color: var(--primary);
  letter-spacing: 2px;
  min-height: 44px; /* touch target floor */
}

#score {
  font-size: 1.5rem;
  font-family: var(--font-mono);
  letter-spacing: 12px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

#threat-level {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ---- VIEWPORT & CANVAS ---- */
#viewport {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #0a141d 0%, #000 100%);
  overflow: hidden;
  outline: none;
}

#viewport.active {
  cursor: none;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  /* GPU hint — tells browser this element re-renders every frame */
  will-change: contents;
}

/* ---- SCANLINES (gated behind reduced-motion) ---- */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 3px
  );
  pointer-events: none;
  z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  .scanlines {
    display: none;
  }
}

/* ---- UI OVERLAY (Game Over / Start) ---- */
#ui-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 8, 0.95);
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  backdrop-filter: blur(8px);
  transition: opacity 0.5s;
}

#ui-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---- COUNTDOWN OVERLAY ---- */
#countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

#countdown-overlay span {
  font-family: var(--font-mono);
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 30px var(--primary);
  opacity: 0;
  transform: scale(1.5);
  transition: opacity 0.3s, transform 0.3s;
}

#countdown-overlay span.visible {
  opacity: 1;
  transform: scale(1);
}

/* ---- MOBILE ---- */
@media (max-width: 600px) {
  .hud {
    padding: 0 10px;
    font-size: 0.5rem;
  }

  #score {
    font-size: 1rem;
    letter-spacing: 5px;
  }

  #viewport.active {
    cursor: auto;
  }
}

/* ---- REDUCED MOTION: kill cursor-hiding + scanlines ---- */
@media (prefers-reduced-motion: reduce) {
  #viewport.active {
    cursor: auto;
  }
}

/* ---- LITE MODE: strip atmospheric layers ---- */
[data-lite] .scanlines {
  display: none !important;
}