/* =========================================================
   NEON INVADERS — stile glow / neon arcade
   ========================================================= */

:root {
  --cyan:    #35f6ff;
  --magenta: #ff3d9e;
  --violet:  #b07bff;
  --green:   #46ff9b;
  --amber:   #ffb433;
  --red:     #ff4b4b;
  --ink:     #dff6ff;
  --ink-dim: #7f93b8;

  --bg-0: #04050c;
  --bg-1: #0a0d1e;
  --panel: rgba(10,16,36,.62);
  --line: rgba(120,200,255,.16);

  --font-ui: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-0);
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* --- sfondo ambientale della pagina --- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 600px at 20% -10%, rgba(53,246,255,.10), transparent 60%),
    radial-gradient(800px 700px at 85% 110%, rgba(255,61,158,.12), transparent 62%),
    radial-gradient(600px 500px at 50% 50%, rgba(176,123,255,.07), transparent 70%),
    linear-gradient(180deg, #05060f 0%, #04050c 100%);
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(6px, 2vh, 22px);
}

.cabinet {
  width: min(100%, 1180px, calc((100vh - 175px) * 4 / 3));
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.1vh, 12px);
}

/* =========================================================
   HUD
   ========================================================= */
.hud {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 26px);
  padding: 10px clamp(12px, 2vw, 22px);
  background: linear-gradient(180deg, rgba(16,24,52,.85), rgba(8,12,28,.65));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 0 26px rgba(53,246,255,.07),
    0 10px 30px rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 74px;
}
.hud-cell--mid { flex: 1; align-items: center; text-align: center; }
.hud-cell--right { align-items: flex-end; }

.hud-label {
  font-size: 9.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 700;
}

.hud-value {
  font-family: var(--font-mono);
  font-size: clamp(16px, 2.4vw, 24px);
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(53,246,255,.75), 0 0 22px rgba(53,246,255,.35);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

/* banner di gioco in 3D */
.banner3d {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(20px, 4vw, 46px);
  letter-spacing: .16em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  text-shadow: 0 0 10px currentColor, 0 0 34px currentColor, 0 0 80px currentColor;
}

/* pop del punteggio */
.hud-value.score-pop { animation: scorePop .3s ease-out; }
@keyframes scorePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); color: #ffffff; }
  100% { transform: scale(1); }
}
.hud-value--sm {
  font-family: var(--font-ui);
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: .24em;
  color: var(--magenta);
  text-shadow: 0 0 10px rgba(255,61,158,.7);
}

.boss-bar {
  margin-top: 6px;
  width: min(360px, 60vw);
  height: 7px;
  border-radius: 99px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0,0,0,.7);
}
.boss-bar__fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--amber), var(--red));
  box-shadow: 0 0 12px rgba(255,75,75,.9), 0 0 24px rgba(255,180,51,.5);
  transition: width .18s ease-out;
}

.lives { display: flex; gap: 7px; align-items: center; height: 22px; }
.lives svg { display: block; filter: drop-shadow(0 0 5px rgba(53,246,255,.9)); transition: opacity .3s, transform .3s; }
.lives svg.is-lost { opacity: .16; filter: none; transform: scale(.8); }

.hud-tools { display: flex; gap: 6px; margin-left: auto; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: .18s;
}
.icon-btn:hover { border-color: rgba(53,246,255,.55); color: var(--cyan); box-shadow: 0 0 16px rgba(53,246,255,.35); }
.icon-btn.is-off { color: var(--ink-dim); opacity: .55; }

/* =========================================================
   STAGE
   ========================================================= */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-inline: auto;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(120,200,255,.2);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 60px rgba(53,246,255,.10),
    0 0 110px rgba(255,61,158,.07),
    0 24px 60px rgba(0,0,0,.7);
  background: #04050c;
  touch-action: none;
}
#game3d { display: block; width: 100%; height: 100%; }

/* flash a schermo intero per gli impatti */
.flash-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  opacity: 0;
  mix-blend-mode: screen;
  background: radial-gradient(70% 60% at 50% 50%, rgba(255,255,255,.9), rgba(255,60,90,.35) 65%, transparent 100%);
}

.badge3d {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .34em;
  color: var(--ink-dim);
  border: 1px solid rgba(120,200,255,.22);
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(255,255,255,.03);
}

.logo__l3 {
  font-size: clamp(18px, 3.4vw, 34px);
  font-weight: 800;
  letter-spacing: .5em;
  color: var(--amber);
  text-shadow:
    0 0 6px rgba(255,255,255,.8),
    0 0 18px var(--amber),
    0 0 46px rgba(255,180,51,.55);
  align-self: flex-end;
  margin-top: -2px;
}

/* scanline + vignette CRT */
.crt {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.035) 0px,
    rgba(255,255,255,.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: .55;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(120% 90% at 50% 50%, transparent 52%, rgba(0,0,0,.72) 100%);
}

/* =========================================================
   OVERLAY / SCHERMATE
   ========================================================= */
.overlay {
  position: absolute; inset: 0; z-index: 6;
  display: grid;
  pointer-events: none;
}
.screen {
  grid-area: 1 / 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: clamp(14px, 3vw, 40px);
  text-align: center;
  background: radial-gradient(70% 60% at 50% 45%, rgba(6,9,22,.72), rgba(3,4,11,.94));
  backdrop-filter: blur(3px);
  pointer-events: auto;
  animation: screenIn .28s ease-out both;
}
.screen.is-active { display: flex; }
@keyframes screenIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

/* Logo */
.logo { display: flex; flex-direction: column; line-height: .92; }
.logo__l1 {
  font-size: clamp(26px, 5.4vw, 56px);
  font-weight: 800;
  letter-spacing: .34em;
  color: var(--cyan);
  text-shadow:
    0 0 6px rgba(255,255,255,.9),
    0 0 18px var(--cyan),
    0 0 44px rgba(53,246,255,.65),
    0 0 90px rgba(53,246,255,.35);
}
.logo__l2 {
  font-size: clamp(30px, 6.6vw, 70px);
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--magenta);
  text-shadow:
    0 0 6px rgba(255,255,255,.85),
    0 0 20px var(--magenta),
    0 0 52px rgba(255,61,158,.6),
    0 0 100px rgba(255,61,158,.3);
  animation: hueShift 6s ease-in-out infinite;
}
@keyframes hueShift {
  0%,100% { filter: hue-rotate(0deg); }
  50%     { filter: hue-rotate(-28deg); }
}

.glow-title {
  margin: 0;
  font-size: clamp(30px, 6vw, 62px);
  font-weight: 800;
  letter-spacing: .14em;
}
.glow-title--cyan  { color: #eafcff; text-shadow: 0 0 8px #fff, 0 0 24px var(--cyan),    0 0 60px rgba(53,246,255,.6); }
.glow-title--red   { color: #ffecec; text-shadow: 0 0 8px #fff, 0 0 24px var(--red),     0 0 64px rgba(255,75,75,.6); }
.glow-title--green { color: #eafff4; text-shadow: 0 0 8px #fff, 0 0 24px var(--green),   0 0 64px rgba(70,255,155,.6); }

.tagline { margin: 0; color: var(--ink-dim); font-size: clamp(12px, 1.5vw, 15px); max-width: 46ch; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  font-size: 10px; letter-spacing: .2em; font-weight: 700;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(255,255,255,.03);
}
.chip--cyan    { color: var(--cyan);    box-shadow: 0 0 16px rgba(53,246,255,.35), inset 0 0 12px rgba(53,246,255,.12); }
.chip--magenta { color: var(--magenta); box-shadow: 0 0 16px rgba(255,61,158,.35), inset 0 0 12px rgba(255,61,158,.12); }
.chip--amber   { color: var(--amber);   box-shadow: 0 0 16px rgba(255,180,51,.35), inset 0 0 12px rgba(255,180,51,.12); }

.keys { display: flex; flex-direction: column; gap: 7px; color: var(--ink-dim); font-size: 12px; }
.keys__row { display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; }
.keys .sep { opacity: .4; }
kbd {
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 700;
  padding: 4px 8px; border-radius: 7px;
  color: #eafcff;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(120,200,255,.28);
  box-shadow: 0 0 10px rgba(53,246,255,.2), inset 0 -2px 0 rgba(0,0,0,.35);
}

/* Pulsanti */
.btn {
  font-family: var(--font-ui);
  font-size: clamp(11px, 1.4vw, 13px);
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  padding: 13px 26px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid rgba(120,200,255,.3);
  background: linear-gradient(180deg, rgba(30,44,90,.7), rgba(12,18,40,.7));
  transition: transform .16s, box-shadow .22s, border-color .2s, color .2s;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(53,246,255,.7); color: #fff; box-shadow: 0 0 26px rgba(53,246,255,.35); }
.btn:active { transform: translateY(0) scale(.985); }

.btn--primary {
  color: #06121a;
  border-color: transparent;
  background: linear-gradient(180deg, #bff9ff, var(--cyan) 45%, #12b6d6);
  box-shadow: 0 0 22px rgba(53,246,255,.65), 0 0 60px rgba(53,246,255,.32), inset 0 -3px 0 rgba(0,0,0,.18);
}
.btn--primary:hover { color: #041018; box-shadow: 0 0 34px rgba(53,246,255,.9), 0 0 80px rgba(53,246,255,.45); }

.btn--tiny { padding: 6px 12px; font-size: 9.5px; letter-spacing: .16em; border-radius: 8px; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.hint { font-size: 11px; color: rgba(127,147,184,.72); margin: 0; }

/* Briefing ondata */
.brief__tag {
  font-family: var(--font-mono);
  font-size: clamp(12px, 1.6vw, 16px);
  letter-spacing: .4em;
  color: var(--amber);
  text-shadow: 0 0 14px rgba(255,180,51,.8);
}
.brief__name {
  margin: 0;
  font-size: clamp(24px, 4.6vw, 46px);
  font-weight: 800;
  letter-spacing: .1em;
  color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 30px var(--cyan), 0 0 70px rgba(53,246,255,.55);
}
.brief__text { margin: 0; color: var(--ink-dim); max-width: 42ch; font-size: clamp(12px, 1.6vw, 15px); }
.brief__bar {
  width: min(360px, 60%); height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.1); overflow: hidden; margin-top: 6px;
}
.brief__bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); box-shadow: 0 0 14px rgba(53,246,255,.9); animation: briefFill 2.1s linear forwards; }
@keyframes briefFill { from { width: 0; } to { width: 100%; } }

/* Score finale */
.score-final { display: flex; gap: clamp(14px, 3vw, 40px); flex-wrap: wrap; justify-content: center; }
.score-final > div { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.score-final strong {
  font-family: var(--font-mono);
  font-size: clamp(20px, 3vw, 30px);
  color: #fff;
  text-shadow: 0 0 14px var(--cyan), 0 0 40px rgba(53,246,255,.5);
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   FOOTER + TOUCH
   ========================================================= */
.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-inline: 6px;
  font-size: 10.5px; letter-spacing: .1em; color: rgba(127,147,184,.6);
  text-transform: uppercase;
}
.fps { font-family: var(--font-mono); letter-spacing: 0; color: rgba(127,147,184,.45); }

.touch { display: none; }
.touch__btn {
  flex: 1;
  font-family: var(--font-ui);
  font-weight: 800;
  letter-spacing: .16em;
  font-size: 15px;
  padding: 16px 0;
  border-radius: 14px;
  color: var(--cyan);
  border: 1px solid rgba(53,246,255,.3);
  background: rgba(12,20,44,.75);
  box-shadow: 0 0 18px rgba(53,246,255,.18);
}
.touch__btn--fire { flex: 1.3; color: #06121a; background: linear-gradient(180deg, #bff9ff, var(--cyan)); border-color: transparent; }
.touch__btn:active { transform: scale(.97); }

@media (hover: none) and (pointer: coarse) {
  .touch { display: flex; gap: 10px; }
  .keys { display: none; }
}

/* schermi bassi: compatta */
@media (max-height: 620px) {
  .logo__l1 { font-size: 26px; }
  .logo__l2 { font-size: 30px; }
  .keys, .chips { display: none; }
  .screen { gap: 10px; }
}

/* =========================================================
   SPRITE SVG (classi applicate dentro l'SVG)
   ========================================================= */
.ship { color: var(--ink); }
.ship .body  { fill: currentColor; }
.ship .dark  { fill: rgba(4,8,20,.85); }
.ship .hi    { fill: #ffffff; opacity: .92; }
.ship .eye   { fill: rgba(6,12,26,.95); }
.ship .trim  { fill: none; stroke: currentColor; stroke-width: 4; stroke-linejoin: round; }

.enemy .body { transition: fill .12s; }

/* Reazioni */
.enemy.is-hit  { filter: brightness(2.6) saturate(.4); }
.enemy { will-change: transform; }

.fx-text {
  font-family: var(--font-mono);
  font-weight: 700;
  paint-order: stroke fill;
  stroke: rgba(3,6,14,.75);
  stroke-width: 4px;
  letter-spacing: .08em;
}

/* =========================================================
   GLOW degli sprite dentro l'SVG
   ========================================================= */
.enemy .ship {
  filter: drop-shadow(0 0 3px currentColor) drop-shadow(0 0 9px currentColor);
}
.player .ship {
  filter: drop-shadow(0 0 4px currentColor) drop-shadow(0 0 14px currentColor);
}
.boss .ship {
  filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 0 26px rgba(255,70,70,.55));
}
.bunker { filter: drop-shadow(0 0 4px rgba(46,230,176,.55)); }
.engine { mix-blend-mode: screen; }

/* brief: lascia intravedere l'arena */
.screen--brief {
  background: radial-gradient(60% 55% at 50% 50%, rgba(6,9,22,.42), rgba(3,4,11,.86));
}

/* DEMO attiva */
.btn.is-on {
  color: #06121a;
  background: linear-gradient(180deg, #bff9ff, var(--cyan));
  border-color: transparent;
  box-shadow: 0 0 18px rgba(53,246,255,.7);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
.screen { overflow-y: auto; }

@media (max-width: 680px) {
  #app { padding: 6px; }
  .cabinet { gap: 6px; }

  .hud { gap: 7px; padding: 7px 9px; border-radius: 11px; }
  .hud-cell { min-width: 0; }
  .hud-cell--mid { flex: 1 1 auto; }
  .hud-cell--mid .hud-value--sm { display: none; }
  .hud-value { font-size: 15px; }
  .hud-label { font-size: 7.5px; letter-spacing: .12em; }
  .hud-lives .lives { height: 17px; gap: 4px; }
  .hud-lives .lives svg { width: 16px; height: 16px; }
  .hud-lives .hud-label { display: none; }
  .icon-btn { width: 27px; height: 27px; font-size: 10px; border-radius: 8px; }
  .boss-bar { width: 100%; height: 5px; margin-top: 4px; }

  .footer { display: none; }
  .btn { padding: 11px 18px; letter-spacing: .14em; }
  .logo__l1 { font-size: 24px; letter-spacing: .26em; }
  .logo__l2 { font-size: 33px; letter-spacing: .12em; }
  .logo__l3 { font-size: 15px; letter-spacing: .34em; }
  .badge3d { display: none; }
  .tagline { font-size: 11.5px; }
  .chips { display: none; }
  .screen { gap: 10px; }
  .score-final { gap: 16px; }
}

@media (max-height: 560px) {
  .footer { display: none; }
}

/* accessibilità moto ridotto */
@media (prefers-reduced-motion: reduce) {
  .logo__l2 { animation: none; }
  .brief__bar i { animation: none; width: 100%; }
}
