:root {
  --accent: #8fa8ff;
  --bg: #03040a;
  --fg: #eef0ff;
  --muted: rgba(238, 240, 255, 0.55);
  --line: rgba(238, 240, 255, 0.12);
  --glass: rgba(10, 12, 26, 0.55);
  --display: "Syne", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 100%; height: 100%; fill: currentColor; }

/* ---------- Intro ---------- */
#intro {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  pointer-events: none;
  transition: opacity 0.4s;
}
#intro .eyebrow {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}
#intro h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(48px, 11vw, 150px);
  line-height: 0.9;
  letter-spacing: -0.03em;
  text-shadow: 0 0 60px rgba(143, 168, 255, 0.35);
}
#intro #site-subtitle {
  margin-top: 20px;
  font-size: clamp(13px, 1.6vw, 16px);
  color: var(--muted);
  max-width: 36ch;
}
.scroll-hint {
  position: absolute;
  bottom: max(36px, env(safe-area-inset-bottom));
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.mouse {
  width: 22px;
  height: 34px;
  border: 1.5px solid var(--muted);
  border-radius: 12px;
  position: relative;
}
.mouse::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 3px;
  height: 7px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--fg);
  animation: wheel 1.6s infinite;
}
@keyframes wheel {
  0% { transform: translateY(0); opacity: 1; }
  80% { transform: translateY(10px); opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- Panel ---------- */
#panel {
  position: fixed;
  top: 50%;
  right: clamp(16px, 5vw, 80px);
  width: min(420px, 38vw);
  max-height: 84vh;
  transform: translateY(-50%) translateX(30px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
}
#panel.visible {
  opacity: 1;
  transform: translateY(-50%);
  pointer-events: auto;
}
.panel-inner {
  overflow-y: auto;
  padding: 28px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.15em;
}
.tag {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tag:empty { display: none; }
#p-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-top: 18px;
}
#p-artist {
  font-family: var(--display);
  font-weight: 500;
  font-size: 20px;
  margin-top: 8px;
  color: var(--accent);
}
.meta { font-size: 12px; color: var(--muted); margin-top: 10px; letter-spacing: 0.04em; }
#p-note {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(238, 240, 255, 0.8);
  border-left: 2px solid var(--accent);
  padding-left: 12px;
}
#p-note:empty { display: none; }

/* Player */
#player {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
#player.hidden { display: none; }
#play-btn {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #05060c;
  padding: 10px;
  transition: transform 0.2s;
}
#play-btn:hover { transform: scale(1.08); }
#play-btn .i-pause, .playing #play-btn .i-play { display: none; }
.playing #play-btn .i-pause { display: block; }
.player-info { flex: 1; min-width: 0; }
.now { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
#p-track {
  font-size: 13px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar { height: 3px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
#p-progress { height: 100%; width: 0; background: var(--accent); }
#eq { display: flex; align-items: flex-end; gap: 3px; height: 20px; width: 21px; }
#eq i {
  width: 3px;
  height: 20%;
  background: var(--accent);
  border-radius: 2px;
  transition: height 0.08s;
}

/* Tracklist */
#panel h3 {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 10px;
}
#p-tracks { list-style: none; counter-reset: t; }
#p-tracks li {
  counter-increment: t;
  display: flex;
  gap: 12px;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(238, 240, 255, 0.82);
}
#p-tracks li::before {
  content: counter(t, decimal-leading-zero);
  color: var(--muted);
  font-size: 11px;
  padding-top: 1px;
}
#p-tracks li span { flex: 1; }
#p-tracks li time { color: var(--muted); font-size: 11px; }
#p-tracks li.current {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--fg);
}
#p-tracks li.current::before { content: "♪"; color: var(--accent); }
#p-tracks li.has-preview { cursor: pointer; }
#p-tracks li.has-preview:hover { background: rgba(255, 255, 255, 0.05); }
#p-link {
  display: inline-block;
  margin-top: 18px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.05em;
}
#p-link:hover { text-decoration: underline; }
#p-link[hidden] { display: none; }

/* ---------- Nav ---------- */
#nav {
  position: fixed;
  left: clamp(14px, 2.5vw, 36px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 11px;
  color: var(--muted);
}
#nav button::before {
  content: "";
  width: 14px;
  height: 1.5px;
  background: currentColor;
  transition: width 0.3s, background 0.3s;
}
#nav button span {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}
#nav button:hover span { opacity: 1; transform: none; }
@media (min-width: 1280px) {
  #nav button.active span { opacity: 1; transform: none; }
}
#nav button.active { color: var(--fg); }
#nav button.active::before { width: 30px; background: var(--accent); }

#hud {
  position: fixed;
  left: clamp(16px, 2.5vw, 36px);
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--muted);
}
#mute-btn { width: 20px; height: 20px; color: var(--fg); opacity: 0.7; }
#mute-btn:hover { opacity: 1; }
#mute-btn .i-off, .muted #mute-btn .i-on { display: none; }
.muted #mute-btn .i-off { display: block; }

/* ---------- Gate ---------- */
#gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(3, 4, 10, 0.55), rgba(3, 4, 10, 0.95));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.8s;
  z-index: 10;
}
#gate.gone { opacity: 0; pointer-events: none; }
.gate-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; text-align: center; }
.loader { width: 200px; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
#loader-bar { height: 100%; width: 0; background: var(--fg); transition: width 0.3s; }
#loader-text { font-size: 12px; color: var(--muted); letter-spacing: 0.1em; }
#start-btn {
  margin-top: 8px;
  padding: 16px 44px;
  border-radius: 999px;
  border: 1px solid rgba(238, 240, 255, 0.4);
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: background 0.3s, color 0.3s, opacity 0.3s, transform 0.3s;
}
#start-btn:disabled { opacity: 0.25; cursor: default; }
#start-btn:not(:disabled):hover { background: var(--fg); color: var(--bg); transform: scale(1.04); }
.gate-hint { font-size: 11px; color: var(--muted); }

/* ---------- Mobile ---------- */
@media (max-aspect-ratio: 9/10) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-height: 50vh;
    padding: 0 12px max(12px, env(safe-area-inset-bottom));
    transform: translateY(30px);
  }
  #panel.visible { transform: none; }
  .panel-inner { padding: 20px 18px; border-radius: 18px; width: 100%; }
  #p-title { font-size: 26px; margin-top: 12px; }
  #p-artist { font-size: 17px; }
  #nav { display: none; }
  #hud { top: max(16px, env(safe-area-inset-top)); bottom: auto; left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .mouse::after { animation: none; }
}
