:root {
  --bg: #000000;
  --fg: #f2f2f2;
  --fg-2: #a3a3a3;
  --fg-3: #7a7a7a;
  --line: rgba(255, 255, 255, 0.12);
  --surface: rgba(255, 255, 255, 0.04);

  --font-mono: "Sono", "Ubuntu Sans Mono", "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 40px;
  --space-5: 64px;
  --space-6: 96px;

  --radius-sm: 6px;
  --radius-pill: 999px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 160ms;
  --dur: 260ms;
  --dur-slow: 700ms;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--fg); color: var(--bg); }

/* ---------- background layers ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* CSS-only fallback when WebGL is unavailable */
.bg.fallback {
  background:
    radial-gradient(60% 50% at 30% 40%, rgba(255, 255, 255, 0.16), transparent 70%),
    radial-gradient(50% 60% at 70% 65%, rgba(255, 255, 255, 0.1), transparent 70%),
    #000;
  background-size: 200% 200%;
  animation: drift 26s ease-in-out infinite alternate;
}

.grid {
  position: fixed;
  inset: -12%;
  z-index: 1;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1.4px);
  background-size: 28px 28px;
  opacity: 0.16;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 20%, transparent 80%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 20%, transparent 80%);
  will-change: transform;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.03) 0 1px,
    transparent 1px 3px
  );
}

/* ---------- stage / card ---------- */

.stage {
  position: relative;
  z-index: 3;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-3);
  perspective: 1100px;
}

.card {
  text-align: center;
  transform-style: preserve-3d;
  will-change: transform;
}

.logo {
  position: relative;
  margin: 0;
  font-size: clamp(2.1rem, 10.5vw, 7.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  white-space: nowrap;
  color: var(--fg);
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.35), 0 0 28px rgba(255, 255, 255, 0.16);
}

.logo .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em) scale(0.92);
  animation: rise var(--dur-slow) var(--ease-out) forwards;
}

.logo .ch-dot { color: var(--fg-2); }

/* glitch: two monochrome ghost copies sliced with clip-path */
.logo.glitch::before,
.logo.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  text-shadow: none;
}
.logo.glitch::before {
  color: #ffffff;
  clip-path: polygon(0 0, 100% 0, 100% 38%, 0 38%);
  animation: glitch-a 340ms steps(3) 1;
}
.logo.glitch::after {
  color: #8c8c8c;
  clip-path: polygon(0 62%, 100% 62%, 100% 100%, 0 100%);
  animation: glitch-b 340ms steps(3) 1;
}

.tagline {
  margin: var(--space-2) 0 0;
  min-height: 1.5em;
  color: var(--fg-2);
  font-size: clamp(13px, 1.5vw, 17px);
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}
body.ready .tagline { opacity: 1; }

.tagline .chev { color: var(--fg-3); }

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.15em;
  vertical-align: -0.12em;
  border-radius: 2px;
  background: currentColor;
  animation: blink 1s steps(2, start) infinite;
}
.cursor.done { display: none; }

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--fg-2);
}
.hud-top { top: 0; padding-top: max(var(--space-2), env(safe-area-inset-top)); }
.hud-bottom { bottom: 0; padding-bottom: max(var(--space-2), env(safe-area-inset-bottom)); }

.win { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.win .dot { width: 10px; height: 10px; border-radius: 50%; background: #2e2e2e; }
.win .dot:nth-child(1) { background: #7a7a7a; }
.win .dot:nth-child(2) { background: #4d4d4d; }
.win-title { margin-left: 6px; color: var(--fg-3); }

.controls { display: flex; gap: 4px; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur), background-color var(--dur);
}
.btn:hover { color: var(--fg); border-color: var(--line); background: var(--surface); }
.btn:active { background: rgba(255, 255, 255, 0.08); }
.btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-play { color: var(--fg); }
.btn-play .ic-play { fill: currentColor; }
.btn-play .ic-pause { display: none; }
.btn-play.playing .ic-play { display: none; }
.btn-play.playing .ic-pause { display: block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* volume slider */
.vol {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px 0 10px;
  color: var(--fg-2);
  transition: opacity var(--dur);
}
.vol-label {
  min-width: 3.4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 104px;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --v: 20%;
}
.vol input[type="range"]:focus { outline: none; }
.vol input[type="range"]:focus-visible { outline: 2px solid var(--fg); outline-offset: -6px; border-radius: 8px; }

.vol input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--fg) var(--v), rgba(255, 255, 255, 0.18) var(--v));
}
.vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.6);
  transition: transform var(--dur-fast);
}
.vol input[type="range"]:hover::-webkit-slider-thumb,
.vol input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.25); }

.vol input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}
.vol input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--fg);
}
.vol input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--fg);
}

.np { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; }
.np-text {
  overflow: hidden;
  max-width: min(60vw, 560px);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.np .dim { color: var(--fg-3); }
.np[hidden] { display: none; }

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i {
  display: block;
  width: 2px;
  height: 100%;
  border-radius: 1px;
  background: var(--fg-2);
  transform-origin: bottom;
  animation: eq 0.9s ease-in-out infinite;
}
.eq i:nth-child(2) { animation-delay: 0.2s; }
.eq i:nth-child(3) { animation-delay: 0.4s; }
.np.paused .eq i { animation: none; transform: scaleY(0.25); background: var(--fg-3); }

.copy { color: var(--fg-3); white-space: nowrap; }

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  z-index: 4;
  transform: translateX(-50%);
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.55);
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: pulse 2.4s ease-in-out infinite;
}
.hint:hover { color: var(--fg); }
.hint:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.hint[hidden] { display: none; }

/* ---------- keyframes ---------- */

@keyframes rise {
  to { opacity: 1; transform: none; }
}
@keyframes blink {
  to { visibility: hidden; }
}
@keyframes eq {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@keyframes drift {
  to { background-position: 100% 100%; }
}
@keyframes glitch-a {
  0% { transform: translate(-6px, -2px); opacity: 0.9; }
  50% { transform: translate(4px, 1px); opacity: 0.6; }
  100% { transform: translate(-2px, 0); opacity: 0; }
}
@keyframes glitch-b {
  0% { transform: translate(5px, 2px); opacity: 0.8; }
  50% { transform: translate(-5px, -1px); opacity: 0.5; }
  100% { transform: translate(2px, 0); opacity: 0; }
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .stage { padding: var(--space-5) var(--space-2); }
  .hud { padding-left: var(--space-2); padding-right: var(--space-2); }
  .btn { padding: 0 10px; }
  .controls { gap: 0; }
  .vol { gap: 8px; padding: 0 4px 0 6px; }
  .vol input[type="range"] { width: 72px; }
  .copy { display: none; }
  .np-text { max-width: 78vw; }
  .win-title { display: none; }
  .hint { white-space: normal; text-align: center; max-width: 80vw; }
}

@media (max-height: 480px) {
  .stage { padding-top: var(--space-5); padding-bottom: var(--space-5); }
  .logo { font-size: clamp(2rem, 12vh, 6rem); }
}

/* Motion is intentional and always on for this brand splash (per request). */
