/* ============================================================
   SPACE INVADERS 3D · GLOW EDITION — stile neon / CRT (Three.js)
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --cyan:   #7df9ff;
  --pink:   #ff5db1;
  --green:  #53ff6e;
  --red:    #ff3355;
  --yellow: #ffe14a;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #010104;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 20%, #071022 0%, #010104 65%);
}

/* ---------- Cabinet / stage ---------- */
#stage {
  position: relative;
  width: min(97vw, calc(97vh * 9 / 7));
  aspect-ratio: 9 / 7;
  background: #020208;
  border: 1px solid #12304a;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 30px rgba(125, 249, 255, 0.12),
    0 0 90px rgba(255, 93, 177, 0.07),
    inset 0 0 70px rgba(0, 0, 0, 0.9);
}

#game { position: absolute; inset: 0; }
#game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  font-family: "Consolas", "Courier New", monospace;
  font-weight: bold;
  text-transform: uppercase;
  color: #cfefff;
  user-select: none;
}
.hud-top, .hud-bottom {
  position: absolute; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 24px;
  font-size: clamp(10px, 1.8vh, 16px);
  letter-spacing: 2px;
}
.hud-top    { top: 0; }
.hud-bottom { bottom: 0; }
.hud-item   { display: flex; align-items: center; gap: 10px; }

.glow-text {
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(125,249,255,.9), 0 0 18px rgba(125,249,255,.45);
}

#livesBox { display: inline-flex; gap: 6px; align-items: center; }
#livesBox svg { height: 2.4vh; filter: drop-shadow(0 0 4px rgba(125,249,255,.8)); }

#beamMeter {
  width: clamp(80px, 14vh, 150px); height: 10px;
  border: 1px solid rgba(125,249,255,.55);
  background: rgba(3, 30, 40, .8);
  box-shadow: 0 0 8px rgba(125,249,255,.25) inset;
}
#beamFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #0d5f70, var(--cyan), #ffffff);
  box-shadow: 0 0 10px rgba(125,249,255,.9);
  transition: width .15s linear;
}
#beamMeter.ready { animation: meterPulse .6s infinite alternate; border-color: #fff; }
@keyframes meterPulse {
  from { box-shadow: 0 0 6px rgba(125,249,255,.5); }
  to   { box-shadow: 0 0 22px rgba(125,249,255,1); }
}
#beamHint { color: #fff; font-size: .85em; }
#sndState { pointer-events: auto; cursor: pointer; color: var(--yellow); }

/* ---------- Overlay screens ---------- */
#overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2.4vh;
  text-align: center;
  font-family: "Consolas", "Courier New", monospace;
  font-weight: bold;
  color: #d8f4ff;
  background: radial-gradient(ellipse at center, rgba(2,8,20,.78) 0%, rgba(1,2,8,.92) 100%);
  pointer-events: auto;
  cursor: pointer;
  padding: 2vh 4vw;
}
#overlay.hidden { display: none; }

.title {
  font-size: clamp(28px, 7.2vh, 64px);
  letter-spacing: 8px;
  color: #ffffff;
  text-shadow:
    0 0 8px  var(--cyan), 0 0 24px var(--cyan),
    0 0 48px rgba(125,249,255,.5),
    0 0 90px var(--pink);
  animation: titleFlicker 3.2s infinite;
}
.title.pink {
  color: #fff;
  text-shadow:
    0 0 8px var(--pink), 0 0 24px var(--pink),
    0 0 48px rgba(255,93,177,.5),
    0 0 90px var(--cyan);
}
@keyframes titleFlicker {
  0%, 100% { opacity: 1; }
  92%      { opacity: 1; }
  93%      { opacity: .55; }
  94%      { opacity: 1; }
  96%      { opacity: .7; }
  97%      { opacity: 1; }
}

.subtitle {
  font-size: clamp(12px, 2.2vh, 18px);
  letter-spacing: 4px;
  color: var(--green);
  text-shadow: 0 0 8px rgba(83,255,110,.8);
}
.subtitle.warn { color: var(--red); text-shadow: 0 0 8px rgba(255,51,85,.9); }
.subtitle.cool  { color: var(--cyan); text-shadow: 0 0 8px rgba(125,249,255,.9); }

.roster { display: flex; flex-direction: column; gap: 1vh; margin: .5vh 0; }
.roster-row { display: flex; align-items: center; gap: 18px; font-size: clamp(11px, 1.9vh, 15px); letter-spacing: 2px; }
.roster-row svg { height: 3.2vh; filter: drop-shadow(0 0 6px currentColor); }
.roster-row .pts { color: #fff; min-width: 4ch; text-align: left; }

.controls {
  font-size: clamp(10px, 1.8vh, 14px);
  letter-spacing: 2px;
  color: #9fd4e8;
  line-height: 2;
}
.controls b { color: #fff; text-shadow: 0 0 6px rgba(125,249,255,.8); }

.blink { animation: blink 1.15s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .12; } }

.press {
  font-size: clamp(13px, 2.6vh, 20px);
  letter-spacing: 4px;
  color: var(--yellow);
  text-shadow: 0 0 10px rgba(255,225,74,.9);
  margin-top: 1vh;
}

.hiscore { color: var(--pink); text-shadow: 0 0 8px rgba(255,93,177,.8); letter-spacing: 3px; }

.bigscore {
  font-size: clamp(20px, 4.6vh, 36px);
  color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 30px rgba(125,249,255,.6);
  letter-spacing: 4px;
}

/* ---------- CRT overlays ---------- */
#scanlines {
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.14) 0px, rgba(0, 0, 0, 0.14) 1px,
    rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
}
#vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,10,.5) 100%);
}

/* ---------- Avviso WebGL / caricamento ---------- */
#webgl-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-family: "Consolas", "Courier New", monospace;
  color: #ff5db1; font-size: 18px; letter-spacing: 2px;
  padding: 4vw;
}

#boot-msg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-family: "Consolas", "Courier New", monospace;
  color: #7df9ff; font-size: 15px; letter-spacing: 2px;
  line-height: 2;
  padding: 4vw;
  animation: blink 1.15s infinite;
}
#boot-msg small { color: #9fd4e8; font-size: 12px; letter-spacing: 1px; }
