/* ==================================================================
   STERNENSTURM — Roguelite-Space-Shooter (2026)
   Wellen überstehen, Sternenstaub sammeln, NOVA zünden,
   nach Schlüsselwellen 1 von 3 Upgrades wählen.
   ================================================================== */

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

:root {
  --card: rgba(240, 246, 255, 0.05);
  --card-hi: rgba(240, 246, 255, 0.1);
  --edge: rgba(232, 193, 90, 0.16);
  --edge-soft: rgba(240, 246, 255, 0.09);
  --ink: #eef2f8;
  --muted: #8b98ad;
  --gold: #e8c15a;
  --cyan: #56d5e8;
  --magenta: #e86aa8;
  --gold-glow: rgba(232, 193, 90, 0.4);
  --foil: linear-gradient(115deg, #8a6a1c 0%, #e8c15a 25%, #fff3c4 50%, #e8c15a 75%, #8a6a1c 100%);
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Outfit", system-ui, -apple-system, sans-serif;
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
}

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: radial-gradient(130% 100% at 50% -20%, #131a33 0%, #0a0e1f 45%, #05070f 100%);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar / HUD ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.topbar h1 {
  flex: 1;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 1.5rem;
}
.foil {
  background: var(--foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: foil-sheen 5.5s ease-in-out infinite;
}
@keyframes foil-sheen {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.btn-back {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
  flex-shrink: 0;
}
button {
  font-family: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s var(--ease-spring);
}
button:active { transform: scale(0.94); }
.btn-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.05rem;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
  flex-shrink: 0;
}

.hud { display: flex; gap: 8px; margin-bottom: 8px; }
.hud-item {
  flex: 1;
  background: linear-gradient(175deg, var(--card-hi), var(--card));
  border-radius: 12px;
  padding: 6px 10px;
  text-align: center;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
}
.hud-item span {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
#hud-hearts { color: var(--magenta); letter-spacing: 0.06em; }
.hud-item label {
  color: var(--muted);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

/* ---------- Bühne ---------- */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--edge) inset, 0 14px 40px -18px rgba(0,0,0,0.9);
  background: linear-gradient(180deg, #070b18 0%, #0b1124 60%, #131a33 100%);
  touch-action: none;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Nova ---------- */
#nova-ui {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
#nova-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(240, 246, 255, 0.08);
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
  overflow: hidden;
}
#nova-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8a6a1c, var(--gold), #fff3c4);
  transition: width 0.2s ease;
}
#nova-btn {
  pointer-events: auto;
  background: linear-gradient(160deg, #f0cd6e, var(--gold) 45%, #c39a30);
  color: #1a1508;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(255,230,160,0.4) inset, 0 0 24px -4px var(--gold-glow);
  animation: nova-pulse 0.8s ease-in-out infinite;
}
@keyframes nova-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 1px rgba(255,230,160,0.4) inset, 0 0 18px -4px var(--gold-glow); }
  50% { transform: scale(1.07); box-shadow: 0 0 0 1px rgba(255,230,160,0.4) inset, 0 0 34px -2px var(--gold-glow); }
}

/* ---------- Wellen-Banner ---------- */
#wave-banner {
  position: absolute;
  left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 2rem;
  white-space: nowrap;
  background: var(--foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: banner-in 2.2s ease forwards, foil-sheen 2.2s linear;
  pointer-events: none;
}
@keyframes banner-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 10, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 18px;
  animation: overlay-in 0.25s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.panel {
  background: linear-gradient(180deg, #141b30, #0b1020);
  border-radius: 22px;
  box-shadow: 0 0 0 1px var(--edge) inset, 0 24px 70px -24px rgba(0,0,0,0.95);
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  animation: panel-up 0.4s var(--ease-spring);
  text-align: center;
}
@keyframes panel-up {
  from { transform: translateY(46px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.panel h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 1.7rem;
  margin-bottom: 6px;
}
.panel .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 16px; line-height: 1.55; }
.panel .sub b { color: var(--gold); font-weight: 600; }

.go-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3.2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: foil-sheen 5.5s ease-in-out infinite;
  margin: 6px 0 2px;
}
.go-best-badge {
  display: inline-block;
  background: rgba(232, 193, 90, 0.14);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(232,193,90,0.3) inset;
  margin-bottom: 10px;
}
.go-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0 10px;
}
.go-rank { color: var(--muted); font-size: 0.95rem; margin-bottom: 16px; min-height: 1.3em; }
.go-rank b { color: var(--gold); }

.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #f0cd6e 0%, var(--gold) 40%, #c39a30 100%);
  color: #1a1508;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 15px;
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(255, 230, 160, 0.35) inset, 0 10px 30px -10px var(--gold-glow);
  margin-bottom: 10px;
}
.btn-secondary {
  background: var(--card-hi);
  color: var(--ink);
  font-size: 1rem;
  padding: 13px;
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
}
.panel input[type="text"] {
  font-family: inherit;
  font-size: 1.15rem;
  text-align: center;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--edge-soft);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  margin-bottom: 14px;
}
.panel input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.18);
}

/* Upgrade-Auswahl */
.upg-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.upg {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--card-hi);
  color: var(--ink);
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
}
.upg:active { box-shadow: 0 0 0 2px var(--gold) inset; }
.upg .u-icon {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  border-radius: 12px;
  background: rgba(232, 193, 90, 0.12);
  box-shadow: 0 0 0 1px var(--edge) inset;
  flex-shrink: 0;
}
.upg .u-name { font-weight: 700; }
.upg .u-desc { color: var(--muted); font-size: 0.82rem; margin-top: 2px; line-height: 1.35; }
.upg .u-lvl { margin-left: auto; color: var(--gold); font-size: 0.78rem; flex-shrink: 0; }

.lb-list { list-style: none; text-align: left; margin: 6px 0 16px; }
.lb-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--edge-soft);
  font-size: 0.98rem;
}
.lb-list li:last-child { border-bottom: 0; }
.lb-rank { width: 34px; flex-shrink: 0; text-align: center; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-list li:nth-child(-n+3) .lb-rank { font-size: 1.15rem; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list li.me .lb-name { color: var(--gold); font-weight: 700; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-empty { color: var(--muted); padding: 18px 0; }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
