/* =============================================================
   NEON VOID — styles.css
   Cyberpunk / glassmorphism UI shell around a full-bleed canvas.
   The game world itself is drawn on <canvas>; everything here is
   chrome: HUD, menus, overlays and touch controls.
   ============================================================= */

:root {
  --bg:        #05060f;
  --cyan:      #2ff3ff;
  --magenta:   #ff2bd6;
  --violet:    #8a5cff;
  --green:     #4dff9e;
  --amber:     #ffcf4d;
  --danger:    #ff4d6d;
  --glass:     rgba(18, 22, 45, 0.45);
  --glass-brd: rgba(120, 160, 255, 0.25);
  --text:      #d7e3ff;
  --text-dim:  #7e8db5;
  --font:      'Rajdhani', 'Segoe UI', 'Inter', system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* stop mobile pull-to-refresh / rubber-band scroll & overscroll glow */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 800px at 50% -10%, rgba(60,40,120,0.35), transparent 60%),
    radial-gradient(900px 700px at 90% 110%, rgba(0,120,140,0.25), transparent 60%),
    var(--bg);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* canvas handles its own touch steering */
  /* subtle vignette + scanline feel applied via the canvas itself */
}

/* ----------------------------------------------------------------
   Shared button + glass styling
   ---------------------------------------------------------------- */
.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 18px;
  padding: 32px 36px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 20px 60px rgba(0,0,0,0.55),
    0 0 60px rgba(47,243,255,0.08);
  text-align: center;
  max-width: 92vw;
  animation: panel-in .45s cubic-bezier(.2,.9,.25,1);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-panel  { width: 420px; }
.wide-panel  { width: 720px; }

.btn {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 14px 20px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--text);
  background: rgba(40, 50, 90, 0.35);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
  text-transform: uppercase;
}
.btn:hover {
  transform: translateY(-2px);
  background: rgba(60, 80, 140, 0.45);
  box-shadow: 0 0 22px rgba(47,243,255,0.35);
}
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary {
  background: linear-gradient(100deg, var(--cyan), var(--violet));
  color: #04121c;
  border: none;
  box-shadow: 0 0 28px rgba(47,243,255,0.5);
}
.btn-primary:hover { box-shadow: 0 0 40px rgba(138,92,255,0.7); }
.btn-ghost { background: transparent; }

/* ----------------------------------------------------------------
   Titles
   ---------------------------------------------------------------- */
.title {
  /* inline-block + nowrap so the box shrink-wraps the whole word. NO max-width:
     capping the box re-clips the trailing letter (background-clip:text won't
     paint anything outside the box). Font is sized with comfortable margin so
     it never needs to overflow the panel. */
  display: inline-block;
  white-space: nowrap;
  font-size: clamp(34px, 8.5vw, 50px);
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(47,243,255,0.25);
  animation: hue 8s linear infinite;
}
@keyframes hue { to { filter: hue-rotate(360deg); } }

.subtitle {
  color: var(--text-dim);
  letter-spacing: 4px;
  font-size: 14px;
  margin: 6px 0 22px;
  text-transform: uppercase;
}
.panel-title {
  font-size: 32px;
  letter-spacing: 5px;
  margin-bottom: 14px;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(47,243,255,0.5);
}
.panel-title.danger  { color: var(--danger); text-shadow: 0 0 18px rgba(255,77,109,.6); }
.panel-title.success { color: var(--green);  text-shadow: 0 0 18px rgba(77,255,158,.6); }

.menu-buttons { margin-top: 8px; }
.menu-footer { margin-top: 18px; color: var(--text-dim); letter-spacing: 2px; font-size: 14px; }
.menu-footer strong { color: var(--amber); }

/* ----------------------------------------------------------------
   Overlays
   ---------------------------------------------------------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  background: rgba(3, 4, 12, 0.55);
  backdrop-filter: blur(2px);
  /* allow vertical scroll when a panel is taller than a short landscape phone,
     plus safe-area padding so nothing hides behind notches */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
/* margin:auto inside a flex container centers the child but degrades to
   scrollable (no top/bottom clipping) once it exceeds the viewport. */
.overlay > * { margin: auto; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------
   HUD
   ---------------------------------------------------------------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  padding: calc(18px + env(safe-area-inset-top)) calc(22px + env(safe-area-inset-right))
           calc(18px + env(safe-area-inset-bottom)) calc(22px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hud-row { display: flex; gap: 14px; }
.hud-top { justify-content: flex-start; flex-wrap: wrap; }
.hud-bottom { align-items: flex-end; justify-content: space-between; }

.hud-panel {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  padding: 8px 16px;
  backdrop-filter: blur(10px);
  min-width: 92px;
}
.hud-label { font-size: 11px; letter-spacing: 3px; color: var(--text-dim); }
.hud-value { font-size: 24px; font-weight: 700; letter-spacing: 1px; color: #fff; }
.hud-wave .hud-value  { color: var(--violet); }
.hud-combo .hud-value { color: var(--amber); }
.hud-combo.flash { animation: combo-flash .3s ease; }
@keyframes combo-flash { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* the two bars are grouped so they stay together (left) and the upgrade list
   sits opposite (right) — avoids a stranded middle bar from space-between */
.hud-bars { display: flex; gap: 16px; align-items: flex-end; }
.hud-health { display: flex; flex-direction: column; gap: 4px; }
.health-bar {
  width: 200px;
  max-width: 38vw;
  height: 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-brd);
  overflow: hidden;
}
.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  box-shadow: 0 0 14px rgba(77,255,158,.6);
  transition: width .2s ease;
}
.health-bar.shield .health-fill {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 14px rgba(138,92,255,.6);
}

.hud-upgrades { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 40vw; }
.upgrade-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px; letter-spacing: 1px;
  backdrop-filter: blur(8px);
}
.upgrade-chip .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

/* ----------------------------------------------------------------
   Settings + toggles
   ---------------------------------------------------------------- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 14px 0;
}
.setting-row label { letter-spacing: 2px; font-size: 14px; color: var(--text-dim); }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 200px; height: 6px; border-radius: 4px;
  background: rgba(255,255,255,0.12); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--cyan); cursor: pointer;
  box-shadow: 0 0 12px var(--cyan);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: var(--cyan); cursor: pointer; box-shadow: 0 0 12px var(--cyan);
}
.toggle {
  padding: 6px 18px; border-radius: 20px; cursor: pointer;
  font-family: var(--font); font-weight: 700; letter-spacing: 2px;
  background: rgba(77,255,158,.15); color: var(--green);
  border: 1px solid rgba(77,255,158,.4);
}
.toggle[data-on="false"] { background: rgba(255,77,109,.12); color: var(--danger); border-color: rgba(255,77,109,.4); }

/* ----------------------------------------------------------------
   How-to
   ---------------------------------------------------------------- */
.howto-list { list-style: none; text-align: left; margin: 0 auto 18px; max-width: 340px; }
.howto-list li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); letter-spacing: 1px; }
.accent { color: var(--cyan); }
kbd {
  display: inline-block; padding: 2px 8px; margin: 0 2px;
  background: rgba(255,255,255,0.08); border: 1px solid var(--glass-brd);
  border-radius: 6px; font-family: var(--font); font-size: 13px; color: #fff;
}

/* ----------------------------------------------------------------
   Upgrade cards
   ---------------------------------------------------------------- */
.upgrade-grid, .ship-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 22px 0;
}
.upgrade-card, .ship-card {
  background: rgba(30, 38, 72, 0.5);
  border: 1px solid var(--glass-brd);
  border-radius: 14px; padding: 18px 14px; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
  text-align: center;
}
.upgrade-card:hover, .ship-card:hover:not(.locked) {
  transform: translateY(-4px);
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(47,243,255,0.3);
}
.upgrade-card .uc-icon, .ship-card .sc-icon { font-size: 34px; margin-bottom: 8px; }
.upgrade-card .uc-name, .ship-card .sc-name { font-weight: 700; letter-spacing: 2px; color: #fff; }
.upgrade-card .uc-desc, .ship-card .sc-desc { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }
.ship-card.locked { opacity: .45; cursor: not-allowed; }
.ship-card.selected { border-color: var(--green); box-shadow: 0 0 26px rgba(77,255,158,.35); }
.ship-card canvas { width: 80px; height: 80px; }

/* ----------------------------------------------------------------
   Result stats
   ---------------------------------------------------------------- */
.result-stats { display: flex; justify-content: center; gap: 28px; margin: 18px 0 8px; }
.result-stats div { display: flex; flex-direction: column; }
.result-stats span { font-size: 12px; letter-spacing: 2px; color: var(--text-dim); }
.result-stats strong { font-size: 30px; color: #fff; }

/* ----------------------------------------------------------------
   Toasts (achievements)
   ---------------------------------------------------------------- */
#toast-layer {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%);
  z-index: 25; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--glass); border: 1px solid var(--glass-brd);
  border-radius: 12px; padding: 10px 20px; backdrop-filter: blur(10px);
  letter-spacing: 2px; font-weight: 700;
  box-shadow: 0 0 24px rgba(47,243,255,0.25);
  animation: toast-in .4s ease, toast-out .4s ease 2.6s forwards;
}
.toast .t-title { color: var(--amber); font-size: 12px; }
.toast .t-name  { color: #fff; font-size: 16px; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-14px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-14px); } }

/* ----------------------------------------------------------------
   In-game controls
   ---------------------------------------------------------------- */
.icon-btn {
  position: absolute; top: calc(18px + env(safe-area-inset-top)); right: calc(22px + env(safe-area-inset-right)); z-index: 22;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--glass-brd);
  color: #fff; font-weight: 700; cursor: pointer; backdrop-filter: blur(10px);
}
.icon-btn:hover { box-shadow: 0 0 18px rgba(47,243,255,.4); }

#touch-controls {
  position: absolute; inset: auto 0 0 0; z-index: 21;
  display: flex; justify-content: space-between; align-items: flex-end;
  /* respect notches / home indicators on phones */
  padding: 22px calc(22px + env(safe-area-inset-right))
           calc(22px + env(safe-area-inset-bottom)) calc(22px + env(safe-area-inset-left));
  pointer-events: none;
}
.touch-group { display: flex; gap: 14px; pointer-events: none; }
.touch-pad, .touch-fire {
  pointer-events: auto;
  background: var(--glass); border: 1px solid var(--glass-brd);
  backdrop-filter: blur(8px); color: var(--cyan);
  display: grid; place-items: center; font-weight: 700; letter-spacing: 2px;
  user-select: none; touch-action: none;
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}
.touch-pad { width: 74px; height: 74px; border-radius: 50%; font-size: 28px; }
.touch-fire { width: 100px; height: 100px; border-radius: 50%; font-size: 18px; color: var(--magenta); }
/* pressed-state feedback */
.touch-pad.active { background: rgba(47,243,255,0.25); box-shadow: 0 0 22px rgba(47,243,255,.5); transform: scale(.94); }
.touch-fire.active { background: rgba(255,43,214,0.25); box-shadow: 0 0 26px rgba(255,43,214,.55); transform: scale(.94); }

/* ----------------------------------------------------------------
   Rotate-to-landscape prompt (mobile portrait)
   ---------------------------------------------------------------- */
#rotate { z-index: 60; background: rgba(3,4,12,0.92); }
.rotate-inner { text-align: center; letter-spacing: 3px; }
.rotate-inner p { font-size: 22px; font-weight: 700; color: var(--cyan); margin: 14px 0 6px; }
.rotate-inner span { color: var(--text-dim); font-size: 13px; }
.rotate-icon { font-size: 64px; color: var(--cyan); animation: rotate-spin 2.4s ease-in-out infinite; text-shadow: 0 0 24px var(--cyan); }
@keyframes rotate-spin { 0%,100% { transform: rotate(-15deg); } 50% { transform: rotate(105deg); } }

@media (max-width: 720px) {
  .title { font-size: clamp(32px, 9vw, 44px); letter-spacing: 3px; }
  .wide-panel { width: 92vw; }
  .upgrade-grid, .ship-grid { grid-template-columns: repeat(2, 1fr); }
  .hud-value { font-size: 18px; }
  .hud-panel { min-width: 70px; padding: 6px 10px; }
  .health-bar { width: 150px; }
}

/* ----------------------------------------------------------------
   Touch-device layout
   The on-screen pads (bottom-left) and FIRE button (bottom-right) own the
   bottom corners, so re-home the HUD around them:
     - HULL/SHIELD bars stack vertically, bottom-left, lifted above the pads
     - upgrade chips move to the TOP-right (under the pause button) so they
       never collide with the FIRE button
   ---------------------------------------------------------------- */
body.touch .hud-bars {
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  margin-bottom: 86px; /* clear the movement pads */
}
body.touch .health-bar { width: 168px; max-width: 44vw; }

body.touch .hud-upgrades {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  right: calc(20px + env(safe-area-inset-right));
  max-width: 52vw;
}
body.touch .upgrade-chip { padding: 4px 10px; font-size: 11px; }

/* Short landscape phones: shrink chrome so nothing overlaps the playfield,
   and compact the menus/panels so they fit the limited vertical space. */
@media (max-height: 560px) {
  /* panels / menus */
  .glass-panel { padding: 16px 26px; border-radius: 14px; }
  .menu-panel { width: 360px; }
  .title { font-size: clamp(26px, 8vh, 40px); letter-spacing: 4px; }
  .subtitle { margin: 4px 0 10px; font-size: 12px; }
  .panel-title { font-size: 22px; margin-bottom: 8px; }
  .btn { padding: 9px 16px; font-size: 15px; margin: 6px 0; }
  .menu-buttons { margin-top: 4px; }
  .menu-footer { margin-top: 10px; font-size: 12px; }
  .result-stats { gap: 18px; margin: 12px 0 4px; }
  .result-stats strong { font-size: 22px; }
  .howto-list { margin-bottom: 10px; }
  .howto-list li { padding: 4px 0; font-size: 13px; }
  .setting-row { margin: 9px 0; }
  .upgrade-grid, .ship-grid { gap: 10px; margin: 12px 0; }
  .upgrade-card, .ship-card { padding: 12px 10px; }
  .ship-card canvas { width: 56px; height: 56px; }
}

@media (max-height: 480px) {
  .hud { padding-top: calc(8px + env(safe-area-inset-top)); }
  .hud-value { font-size: 16px; }
  .hud-label { font-size: 9px; }
  .hud-panel { min-width: 58px; padding: 5px 9px; }
  .touch-pad { width: 58px; height: 58px; font-size: 22px; }
  .touch-fire { width: 78px; height: 78px; font-size: 15px; }
  body.touch .hud-bars { margin-bottom: 66px; }
  body.touch .health-bar { width: 150px; height: 11px; }
  body.touch .hud-upgrades { top: calc(54px + env(safe-area-inset-top)); }
  /* even tighter menu spacing for very short screens */
  .btn { padding: 7px 14px; font-size: 14px; margin: 5px 0; }
  .glass-panel { padding: 12px 22px; }
  .title { font-size: clamp(24px, 7.5vh, 34px); }
}
