:root {
  --bg-deep: #05070f;
  --bg-panel: rgba(9, 14, 29, 0.84);
  --border-glow: rgba(34, 242, 255, 0.28);
  --cyan: #22f2ff;
  --pink: #ff2e93;
  --amber: #ffb830;
  --emerald: #2cf59b;
  --danger: #ff4757;
  --text-main: #eef6ff;
  --text-dim: #8ea3c4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #0d1630 0%, var(--bg-deep) 72%);
  color: var(--text-main);
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* HUD */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 7, 15, 0.82) 0%, rgba(5, 7, 15, 0) 100%);
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-right {
  pointer-events: auto;
}

.stat-block {
  display: flex;
  flex-direction: column;
  min-width: 72px;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  font-weight: 700;
}

.stat-value {
  font-family: "Orbitron", monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.accent-cyan {
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(34, 242, 255, 0.55);
}

.accent-pink {
  color: var(--pink);
  text-shadow: 0 0 14px rgba(255, 46, 147, 0.55);
}

.hud-center {
  flex: 1;
  max-width: 300px;
}

.bars-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-tag {
  width: 48px;
  font-family: "Orbitron", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.bar-track {
  flex: 1;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 120ms ease-out;
}

.hull-fill {
  background: linear-gradient(90deg, #ff4757, #ff8c42);
  box-shadow: 0 0 10px rgba(255, 71, 87, 0.65);
}

.shield-fill {
  background: linear-gradient(90deg, #00b8ff, var(--cyan));
  box-shadow: 0 0 10px rgba(34, 242, 255, 0.65);
}

.ability-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(12, 20, 38, 0.78);
  border: 1px solid rgba(34, 242, 255, 0.24);
  font-size: 11px;
  pointer-events: none;
}

.ability-key {
  font-family: "Orbitron", monospace;
  font-size: 10px;
  color: var(--cyan);
  background: rgba(34, 242, 255, 0.12);
  padding: 2px 5px;
  border-radius: 4px;
}

.ability-name {
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
}

.ability-meter {
  width: 36px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.ability-fill {
  width: 100%;
  height: 100%;
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(44, 245, 155, 0.7);
}

.nova-count {
  font-family: "Orbitron", monospace;
  font-weight: 700;
  color: var(--amber);
  font-size: 13px;
  min-width: 14px;
  text-align: center;
}

.icon-btn {
  cursor: pointer;
  font-family: "Orbitron", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: rgba(12, 20, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 7px 10px;
  transition: all 140ms ease;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(34, 242, 255, 0.25);
}

.icon-btn.active {
  color: var(--cyan);
  border-color: rgba(34, 242, 255, 0.55);
  background: rgba(34, 242, 255, 0.12);
}

/* Wave Banner */
.wave-banner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  text-align: center;
  pointer-events: none;
  animation: bannerPulse 2.2s ease forwards;
}

.banner-sub {
  font-family: "Orbitron", monospace;
  font-size: 12px;
  letter-spacing: 0.34em;
  color: var(--pink);
  margin-bottom: 6px;
}

.banner-title {
  font-family: "Orbitron", monospace;
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--text-main);
  text-shadow: 0 0 24px rgba(34, 242, 255, 0.7);
}

@keyframes bannerPulse {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.95); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(1.03); }
}

/* Boss HUD */
.boss-hud {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 40px));
  z-index: 11;
  pointer-events: none;
  background: rgba(9, 14, 29, 0.8);
  border: 1px solid rgba(255, 46, 147, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 0 28px rgba(255, 46, 147, 0.22);
}

.boss-header {
  display: flex;
  justify-content: space-between;
  font-family: "Orbitron", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--pink);
  margin-bottom: 6px;
}

.boss-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--amber));
  box-shadow: 0 0 12px rgba(255, 46, 147, 0.8);
  transition: width 100ms linear;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(6, 10, 24, 0.45), rgba(3, 5, 12, 0.82));
  backdrop-filter: blur(6px);
}

.panel {
  width: 100%;
  max-width: 560px;
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  padding: 32px 30px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65), inset 0 0 32px rgba(34, 242, 255, 0.05);
  text-align: center;
}

.compact-panel {
  max-width: 360px;
}

.badge {
  display: inline-block;
  font-family: "Orbitron", monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--cyan);
  background: rgba(34, 242, 255, 0.1);
  border: 1px solid rgba(34, 242, 255, 0.3);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 14px;
}

.badge.danger {
  color: var(--danger);
  background: rgba(255, 71, 87, 0.12);
  border-color: rgba(255, 71, 87, 0.4);
}

.game-title {
  font-family: "Orbitron", monospace;
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.05;
  margin-bottom: 14px;
  color: var(--text-main);
  text-shadow: 0 0 30px rgba(34, 242, 255, 0.35);
}

.game-title span {
  color: var(--cyan);
  text-shadow: 0 0 28px rgba(34, 242, 255, 0.75);
}

.panel-heading {
  font-family: "Orbitron", monospace;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.14em;
  margin-bottom: 20px;
}

.subtitle {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 22px;
}

.subtitle strong {
  color: var(--pink);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.control-item span {
  margin-left: auto;
  color: var(--text-main);
  font-weight: 500;
}

kbd {
  font-family: "Orbitron", monospace;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--cyan);
  background: rgba(34, 242, 255, 0.12);
  border: 1px solid rgba(34, 242, 255, 0.28);
}

.action-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  cursor: pointer;
  font-family: "Orbitron", monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border-radius: 12px;
  padding: 13px 24px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.btn-primary {
  border: none;
  color: #04101a;
  background: linear-gradient(135deg, var(--cyan), #4cf7b8);
  box-shadow: 0 0 24px rgba(34, 242, 255, 0.45);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 34px rgba(34, 242, 255, 0.72);
}

.btn-secondary {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-secondary:hover {
  border-color: var(--cyan);
  background: rgba(34, 242, 255, 0.1);
}

.btn-ghost {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text-main);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.summary-val {
  font-family: "Orbitron", monospace;
  font-size: 22px;
  font-weight: 700;
}

.record-pill {
  display: inline-block;
  margin-bottom: 14px;
  font-family: "Orbitron", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--amber);
  background: rgba(255, 184, 48, 0.14);
  border: 1px solid rgba(255, 184, 48, 0.45);
  border-radius: 999px;
  padding: 5px 14px;
}

.leaderboard-box {
  margin-top: 20px;
  margin-bottom: 20px;
  text-align: left;
  background: rgba(4, 8, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
}

.lb-title {
  font-family: "Orbitron", monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.lb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-list li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-main);
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.lb-rank {
  color: var(--cyan);
  font-family: "Orbitron", monospace;
  margin-right: 8px;
}

.lb-meta {
  color: var(--text-dim);
  font-size: 12px;
}

/* Mobile Touch Controls */
.touch-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.touch-stick {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(34, 242, 255, 0.08);
  border: 2px solid rgba(34, 242, 255, 0.35);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.touch-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(34, 242, 255, 0.45);
  border: 2px solid var(--cyan);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.touch-actions {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  font-family: "Orbitron", monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(10, 18, 36, 0.8);
  border: 2px solid rgba(34, 242, 255, 0.5);
}

.touch-btn.accent {
  color: var(--amber);
  border-color: rgba(255, 184, 48, 0.6);
}

@media (max-width: 760px) {
  .hud {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .hud-center {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }
  .ability-pill {
    display: none;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
  .stat-value {
    font-size: 18px;
  }
}
