/* NOVA BLADE — retro arcade shooter styles.
   All DOM is built by assets/game.js; this file only styles the classes
   that game.js creates.

   MOBILE: .stage is a CSS size container, and every rule INSIDE the stage
   sizes itself with container units (cqh = 1% of the stage height, cqw =
   1% of the stage width). On phones the stage box is far shorter than the
   viewport, so viewport units (vh) made every screen overflow — container
   units track the real stage. A narrow-stage container query then re-lays
   the title, ship select (swipeable carousel) and story screens. */

:root {
  --neon-cyan: #17e6ff;
  --neon-pink: #ff2f8e;
  --neon-gold: #ffd23f;
  --neon-green: #3dff6e;
  --bg-dark: #05060f;
  --panel-bg: rgba(6, 10, 26, 0.92);
  --font-arcade: "Consolas", "Lucida Console", "Courier New", ui-monospace, monospace;
}

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

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #0b1029 0%, var(--bg-dark) 60%, #000 100%);
  font-family: var(--font-arcade);
  color: #dfe9ff;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vh, 12px);
  padding: clamp(4px, 1.2vh, 14px);
}

/* ===== Stage & canvas ===== */
.stage {
  position: relative;
  height: min(100%, calc((100vw - 24px) * 1.3333));
  aspect-ratio: 720 / 960;
  border: 3px solid var(--neon-cyan);
  border-radius: 8px;
  box-shadow: 0 0 18px rgba(23, 230, 255, 0.35), inset 0 0 40px rgba(4, 8, 30, 0.8);
  overflow: hidden;
  background: #02030a;
  /* size container: everything inside scales with cqh/cqw */
  container-type: size;
  container-name: stage;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* CRT scanline + vignette overlay */
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.16) 0px,
      rgba(0, 0, 0, 0.16) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
  mix-blend-mode: multiply;
  z-index: 30;
}

/* ===== Screens (title / pause / game over) ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.8cqh, 20px);
  background: rgba(2, 4, 14, 0.82);
  backdrop-filter: blur(2px);
  text-align: center;
  padding: clamp(10px, 3cqh, 28px);
}

.screen.hidden { display: none; }

.hidden { display: none !important; }

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.6cqh, 18px);
  background: var(--panel-bg);
  border: 2px solid var(--neon-cyan);
  border-radius: 10px;
  box-shadow: 0 0 24px rgba(23, 230, 255, 0.25);
  padding: clamp(14px, 3cqh, 30px) clamp(16px, 4cqw, 40px);
  max-width: 94%;
  max-height: 94%;
  overflow: auto;
}

.title-logo {
  font-size: clamp(24px, 7.2cqh, 64px);
  font-weight: bold;
  letter-spacing: 0.12em;
  color: #fff;
  text-transform: uppercase;
  text-shadow:
    0 0 6px #fff,
    0 0 14px var(--neon-cyan),
    0 0 34px var(--neon-cyan),
    4px 4px 0 var(--neon-pink);
  animation: flicker 3.2s infinite;
}

.title-sub {
  font-size: clamp(9px, 1.7cqh, 15px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--neon-pink);
  text-shadow: 0 0 10px rgba(255, 47, 142, 0.8);
}

.title-ship {
  width: clamp(64px, 14cqh, 130px);
  height: auto;
  filter: drop-shadow(0 0 12px rgba(23, 230, 255, 0.7));
  animation: bob 2.6s ease-in-out infinite;
}

.screen-text {
  font-size: clamp(10px, 1.9cqh, 16px);
  line-height: 1.7;
  color: #b8c8ee;
  letter-spacing: 0.08em;
}

.screen-text b { color: var(--neon-gold); }

.hi-score {
  font-size: clamp(10px, 1.9cqh, 16px);
  color: var(--neon-gold);
  letter-spacing: 0.15em;
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.6);
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.55; }
  94% { opacity: 1; }
  96% { opacity: 0.7; }
  97% { opacity: 1; }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== Buttons ===== */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 1.4cqh, 14px);
}

.btn {
  font-family: var(--font-arcade);
  font-size: clamp(11px, 2cqh, 17px);
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #04121a;
  background: linear-gradient(to bottom, #45f3ff, #0aa8c9);
  border: 2px solid #eafcff;
  border-radius: 6px;
  padding: clamp(8px, 1.5cqh, 13px) clamp(14px, 3cqw, 26px);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(23, 230, 255, 0.55), 0 4px 0 #05627a;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.06s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 12px rgba(23, 230, 255, 0.55), 0 1px 0 #05627a; }

.btn.more {
  color: #1a0210;
  background: linear-gradient(to bottom, #ff6ab0, #e11d74);
  border-color: #ffe1ef;
  box-shadow: 0 0 14px rgba(255, 47, 142, 0.6), 0 4px 0 #7c0d44;
}
.btn.more:active { box-shadow: 0 0 14px rgba(255, 47, 142, 0.6), 0 1px 0 #7c0d44; }

.btn.ghost {
  color: var(--neon-cyan);
  background: transparent;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 10px rgba(23, 230, 255, 0.3);
}

/* ===== HUD ===== */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(6px, 1.2cqh, 12px) clamp(8px, 1.6cqw, 16px);
  pointer-events: none;
  font-size: clamp(9px, 1.5cqh, 14px);
  letter-spacing: 0.1em;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 0 12px currentColor;
}

.hud-col { display: flex; flex-direction: column; gap: 3px; }
.hud-col.right { text-align: right; }
.hud-col.center { text-align: center; }

.hud-label { color: #7f92c4; text-transform: uppercase; font-size: 0.82em; }
.hud-value { color: #fff; font-weight: bold; }
.hud-value.score { color: var(--neon-cyan); }
.hud-value.wave { color: var(--neon-pink); }
.hud-value.cash { color: var(--neon-gold); }

.hud-lives { display: flex; gap: 4px; justify-content: flex-end; margin-top: 2px; flex-wrap: nowrap; max-width: 100%; overflow: hidden; }
.hud-lives img {
  width: clamp(14px, 2.2cqh, 22px);
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 4px rgba(23, 230, 255, 0.8));
}
.hud-lives-more {
  color: var(--neon-cyan);
  font-weight: bold;
  align-self: center;
  font-size: clamp(10px, 1.8cqh, 15px);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 0 12px currentColor;
}

/* Boss health bar */
.boss-bar-wrap {
  position: absolute;
  top: clamp(44px, 7cqh, 70px);
  left: 10%;
  right: 10%;
  z-index: 15;
  pointer-events: none;
}
.boss-bar-wrap.hidden { display: none; }
.boss-bar-label {
  text-align: center;
  font-size: clamp(8px, 1.3cqh, 12px);
  color: #ff9dbd;
  letter-spacing: 0.3em;
  margin-bottom: 3px;
  text-shadow: 0 0 8px rgba(255, 47, 142, 0.8);
}
.boss-bar {
  height: clamp(8px, 1.4cqh, 13px);
  border: 2px solid var(--neon-pink);
  border-radius: 4px;
  background: rgba(40, 2, 16, 0.7);
  overflow: hidden;
}
.boss-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(to bottom, #ff7fb2, #d40f68);
  box-shadow: 0 0 10px rgba(255, 47, 142, 0.9);
  transition: width 0.12s linear;
}

/* Wave banner */
.banner {
  position: absolute;
  top: 38%;
  left: 0; right: 0;
  z-index: 16;
  text-align: center;
  font-size: clamp(18px, 4.6cqh, 42px);
  font-weight: bold;
  letter-spacing: 0.22em;
  color: #fff;
  text-shadow: 0 0 8px #fff, 0 0 22px var(--neon-cyan), 3px 3px 0 var(--neon-pink);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-transform: uppercase;
}
.banner.show { opacity: 1; }

/* Mute button (top-right corner of stage) */
.mute-btn {
  position: absolute;
  bottom: clamp(6px, 1.2cqh, 12px);
  right: clamp(6px, 1.2cqw, 12px);
  z-index: 25;
  background: rgba(4, 10, 28, 0.75);
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
  font-family: var(--font-arcade);
  font-size: clamp(9px, 1.4cqh, 12px);
  letter-spacing: 0.12em;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0.85;
}
.mute-btn:hover { opacity: 1; }

/* Loading bar */
.load-wrap { width: min(60%, 320px); }
.load-bar {
  height: 14px;
  border: 2px solid var(--neon-cyan);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(4, 10, 30, 0.8);
}
.load-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #0aa8c9, #45f3ff);
  transition: width 0.2s ease;
}
.load-text {
  margin-top: 8px;
  font-size: clamp(10px, 1.6cqh, 13px);
  color: #8fa4d6;
  letter-spacing: 0.2em;
}

/* Footer strip — OUTSIDE the stage: viewport units are correct here */
.footer {
  font-size: clamp(9px, 1.4vh, 12px);
  color: #5f6f9d;
  letter-spacing: 0.12em;
  text-align: center;
}
.footer b { color: #9db1e4; }

/* ===== Armory shop ===== */
.shop-items {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1cqh, 10px);
  width: min(100%, 400px);
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(10, 16, 40, 0.85);
  border: 1px solid rgba(23, 230, 255, 0.4);
  border-radius: 6px;
  padding: clamp(6px, 1cqh, 10px) clamp(8px, 1.4cqw, 14px);
}

.shop-item .s-name {
  font-size: clamp(10px, 1.8cqh, 15px);
  letter-spacing: 0.1em;
  color: #dfe9ff;
  text-align: left;
}

.shop-item .s-name small {
  display: block;
  color: #7f92c4;
  font-size: 0.72em;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.btn.small {
  font-size: clamp(10px, 1.6cqh, 13px);
  padding: clamp(6px, 1cqh, 9px) clamp(10px, 1.8cqw, 14px);
  color: #2a1800;
  background: linear-gradient(to bottom, #ffe08a, #f0a416);
  border-color: #fff6d8;
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.4), 0 3px 0 #7a5a00;
}

.btn.small:active { box-shadow: 0 0 8px rgba(255, 210, 63, 0.4), 0 1px 0 #7a5a00; }
.btn.small:disabled { opacity: 0.45; cursor: default; }

/* ===== Story screens (intro / ending) ===== */
.story-title {
  font-family: var(--font-arcade);
  font-size: clamp(14px, 2.8cqh, 24px);
  letter-spacing: 0.3em;
  color: #45f3ff;
  text-shadow: 0 0 12px rgba(69, 243, 255, 0.8);
  margin-bottom: clamp(6px, 1.2cqh, 12px);
}

.story-img {
  width: min(100%, 430px);
  max-height: 32cqh;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 2px solid rgba(69, 243, 255, 0.75);
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(69, 243, 255, 0.35);
  display: block;
  margin: 0 auto clamp(8px, 1.6cqh, 16px);
  background: #060b1e;
}

.story-text {
  width: min(100%, 480px);
  min-height: 7.5em;
  white-space: pre-line;
  font-size: clamp(10px, 1.9cqh, 15px);
  line-height: 1.7;
  letter-spacing: 0.14em;
  color: #cfe6ff;
  text-align: left;
  text-shadow: 0 0 8px rgba(69, 243, 255, 0.5);
}

.story-hint {
  margin-top: clamp(6px, 1.2cqh, 14px);
  font-size: clamp(10px, 1.7cqh, 14px);
  color: #ffd23f;
  letter-spacing: 0.18em;
}

.story-stats { margin-top: clamp(8px, 1.6cqh, 16px); }
.story-newhi {
  margin-top: 6px;
  font-size: clamp(10px, 1.8cqh, 15px);
  letter-spacing: 0.16em;
  color: #8fa4d6;
}

.blinkme { animation: blinkme 1.1s steps(2, start) infinite; }
@keyframes blinkme { 50% { opacity: 0; } }

/* ===== ship select screen =====
   Uniform cards: pilot banner on top (name overlaid), ship sprite on a
   glowing plate, gun tag, and segmented stat bars in the ship's color
   (accent color arrives via the --c custom property set from JS). */
.ship-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(8px, 1.2cqw, 14px);
  width: min(980px, 100%);
}
.ship-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  padding: 0 0 10px;
  background: linear-gradient(180deg, rgba(12, 20, 40, 0.92), rgba(7, 12, 26, 0.95));
  border: 2px solid rgba(120, 200, 255, 0.22);
  border-radius: 12px;
  color: #cfe6ff;
  cursor: pointer;
  font-family: var(--font-arcade);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.ship-card:hover {
  border-color: rgba(160, 230, 255, 0.55);
  transform: translateY(-3px);
}
.ship-card.selected {
  border-color: var(--c, var(--neon-gold));
  box-shadow: 0 0 20px -4px var(--c, var(--neon-gold));
  background: linear-gradient(180deg, rgba(30, 44, 78, 0.95), rgba(10, 18, 36, 0.95));
  transform: translateY(-3px);
}
.ship-top { position: relative; width: 100%; }
.ship-pilot {
  display: block;
  width: 100%;
  height: clamp(46px, 6.5cqw, 64px);
  object-fit: cover;
  object-position: center 25%;
  border-bottom: 2px solid var(--c, rgba(120, 200, 255, 0.5));
  opacity: 0.92;
}
.ship-pilot-name {
  margin-top: 2px;
  font-size: clamp(6px, 1.1cqh, 8px);
  letter-spacing: 0.08em;
  color: #8fa4d6;
}
.ship-plate {
  position: relative;
  z-index: 1;
  margin: -16px auto 0;
  width: clamp(48px, 6cqw, 62px);
  height: clamp(48px, 6cqw, 62px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 42%, #16223f 0%, #0a1224 72%);
  border: 2px solid var(--c, rgba(120, 200, 255, 0.5));
  border-radius: 50%;
  box-shadow: 0 0 14px -3px var(--c, rgba(120, 200, 255, 0.6));
}
.ship-img { width: 68%; height: 68%; object-fit: contain; }
.ship-name {
  margin-top: 5px;
  font-weight: bold;
  color: var(--c, var(--neon-gold));
  font-size: clamp(9px, 1.7cqh, 13px);
  letter-spacing: 0.06em;
}
.ship-gun {
  margin: 4px 10px 6px;
  font-size: clamp(6px, 1.2cqh, 8px);
  letter-spacing: 0.05em;
  color: #bfe3ff;
  border: 1px solid rgba(120, 200, 255, 0.35);
  background: rgba(120, 200, 255, 0.08);
  border-radius: 999px;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  margin-top: 3px;
}
.stat-l {
  flex: 0 0 auto;
  width: 30px;
  text-align: left;
  font-size: clamp(6px, 1.2cqh, 8px);
  letter-spacing: 0.1em;
  color: #8fa4d6;
  text-transform: uppercase;
}
.stat-bar {
  display: flex;
  flex: 1;
  gap: 2px;
  height: clamp(7px, 1.3cqh, 9px);
}
.stat-bar i {
  flex: 1;
  border-radius: 1px;
  background: rgba(120, 200, 255, 0.13);
  border: 1px solid rgba(120, 200, 255, 0.15);
}
.stat-bar i.on {
  background: var(--c, #9fdcff);
  border-color: transparent;
  box-shadow: 0 0 5px -1px var(--c, #9fdcff);
}
.ship-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c, var(--neon-gold));
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.ship-check::after {                 /* css-drawn check mark */
  content: '';
  position: absolute;
  left: 4px;
  top: 6px;
  width: 8px;
  height: 4px;
  border-left: 2px solid #08111f;
  border-bottom: 2px solid #08111f;
  transform: rotate(-45deg);
}
.ship-card.selected .ship-check { opacity: 1; transform: scale(1); }

/* pilot portrait in the HUD */
.hud-pilot {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(140, 200, 255, 0.4);
  object-fit: cover;
  margin-bottom: 6px;
  background: #0a1428;
}

/* select screen scrolls when the 5 cards exceed a short stage */
#selectScreen {
  justify-content: flex-start;
  overflow-y: auto;
  touch-action: pan-y;
}
#selectScreen .title-logo {
  font-size: clamp(14px, 4cqh, 26px);   /* one line — saves the height for the cards */
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  text-shadow: 0 0 6px #fff, 0 0 14px var(--neon-cyan);  /* no hard pink offset — reads doubled at this size */
}
#selectScreen .panel {
  margin: auto;
  flex-shrink: 0;
  max-height: none;
  max-width: none;
  overflow: visible;
  touch-action: pan-y;
}

/* ===== combo chain ===== */
.hud-combo {
  font-size: clamp(11px, 1.9cqh, 15px);
  color: var(--neon-gold);
  letter-spacing: 0.12em;
  min-height: 1.2em;
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.6);
}
.hud-combo.hot {
  color: var(--neon-pink);
  animation: blinkme 0.6s steps(2, start) infinite;
}

/* title screen endless unlock line */
.title-unlock {
  font-size: clamp(9px, 1.5cqh, 13px);
  color: #8fa4d6;
  letter-spacing: 0.14em;
  min-height: 1.2em;
}
.title-unlock b { color: var(--neon-gold); }

/* ============================================================
   NARROW STAGE (phones in portrait): re-layout title, ship
   select (swipe carousel), story screens and shop for the
   small box — bigger relative type, chunkier touch targets.
   ============================================================ */
@container stage (max-width: 620px) {
  .panel { padding: 12px 10px; border-radius: 8px; }
  .title-logo { letter-spacing: 0.08em; }
  .title-ship { width: 15cqh; }
  .screen-text { line-height: 1.5; }

  /* buttons pair up into a tidy grid instead of ragged wrapping */
  .btn-row .btn {
    flex: 1 1 44%;
    min-width: 44%;
    padding: 10px 6px;
    letter-spacing: 0.08em;
  }
  .btn-row .btn.more { flex: 1 1 100%; }

  /* ship select: 2-column grid — every ship visible, no hidden swiping;
     the 5th ship spans the full row so nothing feels squeezed */
  #selectScreen .title-logo {
    font-size: 14px;
    letter-spacing: 0.04em;
    text-shadow: 0 0 5px #fff, 0 0 10px var(--neon-cyan);
  }
  .ship-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
  }
  .ship-card:nth-child(5) { grid-column: 1 / -1; }
  .ship-pilot { height: 46px; }
  .ship-pilot-name { font-size: 7px; }
  .ship-plate { width: 46px; height: 46px; margin-top: -15px; }
  .ship-name { font-size: 10px; }
  .ship-gun { font-size: 7px; margin: 3px 8px 4px; }
  .stat { padding: 0 8px; }
  .stat-l { width: 28px; font-size: 7px; }
  .stat-bar { height: 7px; }

  .story-img { max-height: 28cqh; }
  .story-text { font-size: 2.5cqh; line-height: 1.6; }
  .story-title { letter-spacing: 0.2em; }
  .shop-item .s-name { font-size: 2.5cqh; }
  .hud-pilot { width: 34px; height: 34px; }
  .banner { letter-spacing: 0.14em; }
}

/* short stage: drop non-essentials so panels always fit */
@container stage (max-height: 560px) {
  .title-ship { display: none; }
  .story-img { max-height: 22cqh; }
  .story-text { min-height: 0; }
  .ship-pilot { height: 44px; }
  .ship-plate { width: 46px; height: 46px; margin-top: -14px; }
}
