/* Aurora Defense — Styles (Task 7: Glas-UI wie Spike, Letterbox, Min-Fenster).
 * Canvas: logische 1200×800 (canvas.width/height), CSS skaliert als
 * Replaced-Element 3:2 → Letterbox; Resize ändert KEINE Spielpositionen.
 * UI-Overlays: pointer-events durchlässig, außer blockende Screens. */

html, body {
  height: 100%;
  margin: 0;
  background: #02040f;
}

body {
  overflow: hidden;
  /* Min-Fenster (Ruling 2 / Task-1-Review) */
  min-width: 1024px;
  min-height: 640px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #02040f;
}

canvas#game {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1200 / 800; /* 3:2 Letterbox */
  background: #030512;
  cursor: crosshair;
}

/* ══ UI-Grundgerüst (Spike-Glas: rgba(10,16,40,.45) + Neon-Rand) ═══════════ */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  color: #cfe0ff;
  pointer-events: none; /* Canvas-Maus bleibt überall frei … */
  user-select: none;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Blockende Screens (menu/intro/end): fangen Maus ab, dämpfen den
   Hintergrund dezent, damit die Glas-Panels lesbar bleiben. */
.screen.block {
  pointer-events: auto;
  background: radial-gradient(ellipse at center, rgba(2,4,15,0.10) 0%, rgba(2,4,15,0.55) 100%);
}

.glass {
  background: rgba(10, 16, 40, 0.45);
  border: 1px solid rgba(120, 160, 255, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 40px rgba(80, 120, 255, 0.15), inset 0 0 20px rgba(80, 120, 255, 0.05);
  border-radius: 14px;
}

#ui .glass,
#ui .btn,
#ui .ibtn,
#ui .slot,
#ui .card {
  pointer-events: auto;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font: inherit;
  color: #cfe0ff;
  background: rgba(20, 30, 70, 0.55);
  border: 1px solid rgba(120, 160, 255, 0.35);
  border-radius: 10px;
  padding: 9px 20px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, background 0.15s;
}
.btn:hover:not(:disabled) {
  border-color: rgba(150, 195, 255, 0.8);
  box-shadow: 0 0 18px rgba(90, 140, 255, 0.35);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: rgba(40, 80, 190, 0.55);
  border-color: rgba(140, 180, 255, 0.65);
  text-shadow: 0 0 8px rgba(140, 190, 255, 0.8);
}
.btn.ghost { background: rgba(10, 16, 40, 0.30); }
.btn.danger {
  border-color: rgba(255, 120, 140, 0.5);
  color: #ffc3cb;
}
.btn.danger:hover:not(:disabled) {
  border-color: rgba(255, 150, 165, 0.85);
  box-shadow: 0 0 18px rgba(255, 90, 110, 0.30);
}

.btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }

/* ── Bildschirm: Menu / Level-Karten ─────────────────────────────────────── */
.title {
  margin: 0 0 6px;
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 14px;
  color: #bfe0ff;
  text-shadow: 0 0 18px rgba(120, 180, 255, 0.9), 0 0 50px rgba(90, 130, 255, 0.5);
}
.subtitle {
  margin: 0 0 34px;
  font-size: 14px;
  letter-spacing: 3px;
  opacity: 0.7;
}

.cards { display: flex; gap: 22px; }

.card {
  width: 250px;
  padding: 20px 22px 18px;
  text-align: left;
  font: inherit;
  color: #cfe0ff;
  background: rgba(10, 16, 40, 0.55);
  border: 1px solid rgba(120, 160, 255, 0.28);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 40px rgba(80, 120, 255, 0.12), inset 0 0 20px rgba(80, 120, 255, 0.05);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover:not(.locked) {
  transform: translateY(-5px);
  border-color: rgba(150, 195, 255, 0.75);
  box-shadow: 0 0 34px rgba(90, 140, 255, 0.4), inset 0 0 24px rgba(80, 120, 255, 0.08);
}
.card.locked {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.8);
}
.card-idx {
  display: block;
  font-size: 11px;
  letter-spacing: 3px;
  opacity: 0.65;
}
.card-name {
  display: block;
  margin: 6px 0 10px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #dceaff;
}
.card-stars { display: block; font-size: 22px; letter-spacing: 4px; }
.card-stars .on {
  color: #ffd166;
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.8);
}
.card-stars .off { color: rgba(150, 175, 230, 0.35); }
.card-meta { display: block; margin-top: 8px; font-size: 12px; opacity: 0.7; }
.card-lock {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #9fb4d8;
  opacity: 0.9;
}

/* ── Bildschirm: Intro-Card ──────────────────────────────────────────────── */
.intro-card {
  padding: 44px 64px;
  text-align: center;
}
.intro-card h1 {
  margin: 0 0 10px;
  font-size: 40px;
  letter-spacing: 10px;
  color: #bfe0ff;
  text-shadow: 0 0 16px rgba(120, 180, 255, 0.9);
}
.intro-card p { margin: 0; font-size: 14px; letter-spacing: 1px; opacity: 0.75; }

/* ── HUD (Play) ──────────────────────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 14px;
  padding: 10px 14px;
  min-width: 190px;
}
#hud-left { left: 14px; }
#hud-right { right: 14px; text-align: right; }

.hud-title {
  font-size: 12px;
  letter-spacing: 3px;
  color: #9fd0ff;
  text-shadow: 0 0 10px rgba(120, 180, 255, 0.7);
  margin-bottom: 8px;
}
.hud-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 16px;
  margin: 3px 0;
}
#hud-left .hud-row { justify-content: flex-start; }
.hud-icon { font-size: 15px; color: #9fd0ff; text-shadow: 0 0 8px rgba(120, 180, 255, 0.8); }
.hud-icon.hp { color: #ff8a9a; text-shadow: 0 0 8px rgba(255, 110, 130, 0.8); }
.hud-val { font-weight: 600; color: #e8f1ff; }

/* GEFAHR-Balken (Ruling 10: Farbe folgt Pfad #4da6ff → #ff4d5e) */
.danger { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.danger-state {
  font-size: 10px;
  letter-spacing: 2px;
  min-width: 62px;
  color: #cfe0ff;
}
.danger-bar {
  width: 130px;
  height: 6px;
  border-radius: 3px;
  background: rgba(120, 160, 255, 0.12);
  overflow: hidden;
}
.danger-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: #4da6ff;
  box-shadow: 0 0 10px rgba(77, 166, 255, 0.7);
  transition: width 0.2s linear;
}

/* Welle + Vorschau (Spec §9:294) */
.hud-wave {
  font-size: 15px;
  letter-spacing: 2px;
  color: #dceaff;
  margin-bottom: 6px;
}
.wave-preview {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: 18px;
  margin-bottom: 8px;
}
.wave-preview .pv-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #bcd2ff;
}
.wave-preview .pv-count { font-size: 11px; opacity: 0.85; }
.wave-preview .pv-none { font-size: 12px; opacity: 0.55; letter-spacing: 1px; }

/* Gegner-Icons (Wellen-Vorschau) — rein CSS, je Typ Form + Farbe */
.eicon {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: #888;
}
.eicon.drohne    { background: #ff8a5c; clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.eicon.scout     { background: #ffd166; width: 10px; height: 10px; clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.eicon.panzer    { background: #9fb4ff; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.eicon.splitter  { background: #7dff5d; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.eicon.brut      { background: #a8ff6e; width: 9px; height: 9px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.eicon.schild    { background: #6ee7ff; clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); box-shadow: 0 0 0 2px rgba(150, 225, 255, 0.55); }
.eicon.miniboss  { background: #ff5db1; width: 16px; height: 16px; clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.eicon.finalboss { background: #ff5db1; width: 19px; height: 19px; clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); box-shadow: 0 0 8px rgba(255, 93, 177, 0.8); }

/* Tempo / Pause / Mute */
.hud-btns { display: flex; gap: 6px; justify-content: flex-end; }
.ibtn {
  font: inherit;
  font-size: 13px;
  min-width: 34px;
  padding: 5px 8px;
  color: #9fd0ff;
  background: rgba(20, 32, 75, 0.5);
  border: 1px solid rgba(120, 160, 255, 0.30);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.ibtn:hover { border-color: rgba(150, 195, 255, 0.7); box-shadow: 0 0 12px rgba(90, 140, 255, 0.3); }
.ibtn.active {
  color: #eaf3ff;
  border-color: rgba(160, 200, 255, 0.9);
  box-shadow: 0 0 14px rgba(100, 150, 255, 0.45);
  background: rgba(45, 80, 180, 0.55);
}
.ibtn.off { color: #6f83b3; text-decoration: line-through; }
.ibtn.paused {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.7);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.35);
}

/* Früh-Start-Button */
.early {
  position: absolute;
  bottom: 148px;
  left: 50%;
  transform: translateX(-50%);
  letter-spacing: 2px;
  font-size: 15px;
  animation: early-pulse 2.2s ease-in-out infinite;
}
@keyframes early-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(90, 140, 255, 0.25); }
  50%      { box-shadow: 0 0 26px rgba(120, 170, 255, 0.55); }
}

/* ── Turm-Panel ──────────────────────────────────────────────────────────── */
.panel {
  position: absolute;
  right: 14px;
  top: 132px;
  width: 250px;
  padding: 14px 16px;
}
#tp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
#tp-name {
  margin: 0;
  font-size: 17px;
  letter-spacing: 2px;
  color: #dceaff;
}
.tp-tier { font-size: 11px; letter-spacing: 1px; opacity: 0.7; white-space: nowrap; }
.tp-stats {
  list-style: none;
  margin: 10px 0 2px;
  padding: 0;
  font-size: 12.5px;
}
.tp-stats li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(120, 160, 255, 0.10);
  color: #b8c9ef;
}
.tp-stats li b { color: #eaf3ff; font-weight: 600; }
.panel .btn-row { margin-top: 12px; flex-direction: column; gap: 8px; }
.panel .btn { width: 100%; padding: 8px 10px; font-size: 13.5px; }

/* ── Turm-Palette ────────────────────────────────────────────────────────── */
.palette {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 10px 14px 7px;
  max-width: calc(100% - 28px);
}
#palette-slots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.slot {
  width: 96px;
  padding: 8px 6px 7px;
  font: inherit;
  color: #cfe0ff;
  background: rgba(16, 26, 62, 0.55);
  border: 1px solid rgba(120, 160, 255, 0.25);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.slot:hover:not(.locked) {
  border-color: rgba(150, 195, 255, 0.7);
  box-shadow: 0 0 16px rgba(90, 140, 255, 0.35);
  transform: translateY(-2px);
}
.slot.selected {
  border-color: rgba(170, 210, 255, 0.95);
  box-shadow: 0 0 20px rgba(110, 160, 255, 0.55), inset 0 0 12px rgba(110, 160, 255, 0.25);
}
.slot.locked { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.7); }
.slot-icon {
  display: block;
  width: 26px;
  height: 26px;
  margin: 0 auto 5px;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}
.slot-icon.pulsar    { background: #6ee7ff; box-shadow: 0 0 10px rgba(110, 231, 255, 0.7); }
.slot-icon.nebel     { background: #7dffc8; }
.slot-icon.komet     { background: #ffb454; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.slot-icon.plasma    { background: #c77dff; clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); }
.slot-icon.waechter  { background: #8affa3; }
.slot-icon.nova      { background: #ff5db1; clip-path: circle(50% at 50% 50%); }
.slot-icon.wurm      { background: #7dff5d; clip-path: circle(42% at 50% 50%); }
.slot-icon.schwarzes { background: #b15dff; clip-path: circle(46% at 50% 50%); box-shadow: 0 0 10px rgba(177, 93, 255, 0.8); }
.slot-name { display: block; font-size: 12px; letter-spacing: 0.5px; white-space: nowrap; }
.slot-cost { display: block; margin-top: 3px; font-size: 11.5px; color: #ffd166; }
.slot.locked .slot-cost { color: #9fb4d8; }
.palette-hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  opacity: 0.55;
}

/* ── Wellen-Banner (Spec §8:278: großes Cinematic-Text) ─────────────────── */
.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  text-align: center;
  pointer-events: none;
}
#banner-wave {
  font-size: 58px;
  font-weight: 700;
  letter-spacing: 16px;
  color: #eaf3ff;
  text-shadow: 0 0 22px rgba(120, 180, 255, 0.95), 0 0 60px rgba(90, 130, 255, 0.6);
}
#banner-danger {
  margin-top: 8px;
  font-size: 16px;
  letter-spacing: 6px;
  color: #9fd0ff;
  text-shadow: 0 0 12px rgba(120, 180, 255, 0.8);
}
.banner.anim { animation: banner-in 1.8s ease-out forwards; }
@keyframes banner-in {
  0%   { opacity: 0; transform: scale(1.25); }
  14%  { opacity: 1; transform: scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: scale(0.98); }
}

/* ── Bildschirm: Ende (Glas-Panel über eingefrorenem Feld, Spec §8:280) ─── */
.end-card {
  padding: 40px 62px;
  text-align: center;
  min-width: 380px;
}
#end-title {
  margin: 0;
  font-size: 44px;
  letter-spacing: 12px;
  color: #bfe0ff;
  text-shadow: 0 0 18px rgba(120, 180, 255, 0.9);
}
#end-title.lost {
  color: #ffb3bd;
  text-shadow: 0 0 18px rgba(255, 90, 110, 0.8);
}
.stars { margin: 14px 0 2px; font-size: 40px; letter-spacing: 10px; min-height: 44px; }
.stars .on { color: #ffd166; text-shadow: 0 0 14px rgba(255, 209, 102, 0.9); }
.stars .off { color: rgba(150, 175, 230, 0.35); }
.end-score { font-size: 16px; letter-spacing: 2px; color: #dceaff; margin-bottom: 4px; }
.end-btns { justify-content: center; }
