:root {
  --bg: #040407;
  --panel: rgba(16, 16, 24, 0.52);
  --border: rgba(255, 255, 255, 0.09);
  --neon: #00e5ff;
  --pink: #ff2e88;
  --yellow: #ffd400;
  --green: #39ff88;
  --text: #f2f2f7;
  --muted: #7a7a90;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.stage-open { overflow: hidden; }

/* 2D-Fallback, falls WebGL / CDN nicht verfuegbar */
body.no-webgl #webgl-canvas { display: none; }
body.no-webgl {
  background:
    radial-gradient(1200px 800px at 72% 18%, rgba(0, 229, 255, 0.13), transparent 60%),
    radial-gradient(1000px 700px at 18% 82%, rgba(255, 46, 136, 0.12), transparent 60%),
    radial-gradient(900px 900px at 50% 50%, rgba(255, 212, 0, 0.05), transparent 55%),
    var(--bg);
}

#webgl-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
}

/* 2D FALLBACK WARP OVERLAY (nur aktiv falls WebGL blockiert ist) */
#fallback-warp {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.35), rgba(255, 46, 136, 0.2), transparent 70%);
  transition: opacity 0.35s ease, transform 0.55s ease;
}
body.warping #fallback-warp {
  opacity: 1;
  transform: scale(1.35);
}

/* IGLOO HUD FRAME */
.hud-frame {
  position: fixed;
  inset: 14px;
  border: 1px solid var(--border);
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 22px;
}

.hud-top, .hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 10px;
}

.hud-bottom a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.hud-bottom a:hover {
  color: var(--neon);
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 600;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#np-track {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--neon);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  background: rgba(10, 10, 16, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-decoration: none;
  transition: all 0.2s;
}
.pill-btn:hover, .pill-btn.active {
  border-color: var(--neon);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.25);
  color: #fff;
}

.dot-onair {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3b30;
  transition: all 0.3s;
  flex-shrink: 0;
}
.dot-onair.playing {
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 50% { opacity: 0.3; } }

.vol-slider {
  width: 70px;
  accent-color: var(--neon);
  cursor: pointer;
}

/* SCROLL WAYPOINTS */
main {
  position: relative;
  z-index: 5;
  transition: opacity 0.32s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
body.warping main {
  opacity: 0.18;
  transform: scale(1.08);
}

.waypoint {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: 0 9vw;
}
.waypoint:nth-child(even) { justify-content: flex-end; }

.shard-card {
  max-width: 500px;
  background: var(--panel);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border);
  padding: 34px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.shard-card:hover {
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 32px rgba(0, 229, 255, 0.08);
}
.shard-index {
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--neon);
  margin-bottom: 10px;
  display: block;
}
.shard-card h1, .shard-card h2 {
  font-size: clamp(26px, 3.6vw, 42px);
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
  margin-bottom: 14px;
}
.shard-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 22px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
}
.tool-btn {
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tool-btn:hover {
  border-color: var(--neon);
  background: rgba(0, 229, 255, 0.1);
  transform: translateY(-2px);
}

/* IN-PAGE STUDIO OVERLAY */
#peStage {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 4, 7, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
}
#peStage.active { display: flex; }
.stage-bar {
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 20px;
  font-family: monospace;
  font-size: 12px;
}
/* iOS-Iframe-Fix: Wrapper scrollt, Iframe wird per Breiten-Trick gezwungen */
.stage-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
#peStageFrame {
  display: block;
  border: none;
  width: 1px;
  min-width: 100%;
  height: 100%;
}

/* ================= MOBILE ================= */
@media (max-width: 860px) {
  .hud-frame {
    inset: 8px;
    padding: 10px 12px;
  }
  .hud-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .hud-controls { width: 100%; }
  .pill-btn {
    padding: 6px 11px;
    font-size: 10px;
    min-height: 32px;
  }
  .vol-slider { display: none; }
  #np-track { max-width: 140px; }
  #hud-coords { display: none; }
  .hud-bottom { font-size: 9px; gap: 6px; }
  .waypoint {
    padding: 190px 6vw 96px;
    align-items: flex-start;
  }
  .waypoint:nth-child(even) { justify-content: flex-start; }
  .shard-card {
    max-width: none;
    width: 100%;
    padding: 22px;
  }
  .stage-bar { padding: 6px 10px; font-size: 10px; }
}

@media (max-width: 420px) {
  .brand-bar span { font-size: 12px; }
  .shard-card h1, .shard-card h2 { font-size: 24px; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
}
