:root {
  --bg: #050506;
  --ink: #f3f0e8;
  --dim: #8a8896;
  --line: rgba(243, 240, 232, 0.12);
  --lime: #d4ff3a;
  --glass: rgba(10, 10, 14, 0.55);
  --display: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --serif: 'Instrument Serif', Georgia, serif;
  --gut: clamp(16px, 3vw, 40px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; }
body { color: var(--ink); font: 400 16px/1.5 var(--display); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; border-radius: 6px; }

/* ---------- the film / world ---------- */
.stage { position: fixed; inset: 0; touch-action: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mode-site .stage { cursor: grab; }
.mode-site .stage.dragging { cursor: grabbing; }
.mode-site.fine-pointer .stage.own-cursor { cursor: none; } /* the canvas draws its own */


/* ---------- top bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) var(--gut) 14px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 16px/1 var(--display); letter-spacing: 0.2em; }
.brand img { border-radius: 9px; }
.actions { margin-left: auto; display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font: 500 12px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  transition: border-color 0.2s, background 0.2s, color 0.2s, opacity 0.4s;
}
.pill:hover { border-color: var(--lime); }
.pill[aria-pressed='true'] { color: var(--lime); }
.pill.icon svg { width: 18px; height: 18px; flex: none; }
#sound .i-on, #sound[aria-pressed='true'] .i-off { display: none; }
#sound[aria-pressed='true'] .i-on { display: block; }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 3px; height: 4px; background: currentColor; border-radius: 1px; }
[aria-pressed='true'] .eq i { animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

.nav {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 4px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.nav button {
  position: relative; height: 32px; padding: 0 14px; border-radius: 999px;
  font: 500 13px/1 var(--display); letter-spacing: 0.02em; color: var(--dim);
  transition: color 0.25s, background 0.35s var(--ease);
}
.nav button:hover { color: var(--ink); }
.nav button[aria-current='true'] { color: #07070a; background: var(--lime); }
.nav button .n { font: 700 10px/1 var(--mono); margin-right: 6px; opacity: 0.6; }

/* ---------- countdown ---------- */
.gate {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 26px;
  padding: 96px var(--gut) calc(48px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at center, rgba(5, 5, 6, 0.05), rgba(5, 5, 6, 0.7) 75%);
  transition: opacity 0.8s var(--ease), visibility 0.8s;
  pointer-events: none;
}
.kicker { font: 700 12px/1.4 var(--mono); letter-spacing: 0.14em; color: var(--lime); text-transform: uppercase; }
.count { position: relative; width: clamp(150px, 22vmin, 220px); aspect-ratio: 1; display: grid; place-items: center; }
.count svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.count circle { fill: none; stroke: rgba(243, 240, 232, 0.12); stroke-width: 1.5; }
.count #count-ring { stroke: var(--lime); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 339.3; filter: drop-shadow(0 0 6px rgba(212, 255, 58, 0.7)); }
#count-num { font: 600 clamp(72px, 12vmin, 120px)/1 var(--display); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
#count-num.tick { animation: tick 0.9s var(--ease); }
@keyframes tick { from { opacity: 0; transform: scale(1.35); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.loading { font: 500 12px/1 var(--mono); color: var(--dim); letter-spacing: 0.1em; text-transform: uppercase; }
.ready .loading { display: none; }
.sound-hint { font: 500 12px/1.4 var(--mono); color: var(--dim); letter-spacing: 0.06em; }
.sound-hint b { color: var(--ink); font-weight: 700; }
.sound-on .sound-hint { visibility: hidden; }

/* ---------- film progress ---------- */
.progress { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; z-index: 6; background: rgba(243, 240, 232, 0.08); }
.progress i { display: block; height: 100%; width: 0; background: var(--lime); box-shadow: 0 0 12px var(--lime); }

/* ---------- interactive site ---------- */
.panel {
  position: fixed; z-index: 6; left: var(--gut); bottom: calc(var(--gut) + 28px + env(safe-area-inset-bottom));
  width: min(460px, calc(100vw - 2 * var(--gut)));
  padding: 28px 28px 24px; border-radius: 22px;
  border: 1px solid var(--line); background: linear-gradient(160deg, rgba(20, 20, 26, 0.72), rgba(8, 8, 11, 0.62));
  -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  display: grid; gap: 14px;
}
.panel h2 { font: 600 clamp(28px, 3.2vw, 44px)/1.02 var(--display); letter-spacing: -0.03em; }
.panel h2 em { font: italic 400 1.1em/1 var(--serif); color: var(--lime); letter-spacing: -0.01em; }
.panel .body { color: rgba(243, 240, 232, 0.78); font-size: 15px; line-height: 1.6; }
.try { display: flex; align-items: center; gap: 10px; font: 600 13px/1.4 var(--mono); color: var(--lime); }
.try::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 0 rgba(212, 255, 58, 0.6); animation: ping 1.6s ease-out infinite; }
@keyframes ping { 70%, 100% { box-shadow: 0 0 0 10px rgba(212, 255, 58, 0); } }
.tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); font: 500 11px/1 var(--mono); letter-spacing: 0.04em; color: var(--dim); }
.links { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.links a { padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font: 500 12px/1 var(--mono); transition: background 0.2s, color 0.2s, border-color 0.2s; }
.links a:hover { background: var(--lime); border-color: var(--lime); color: #07070a; }
.panel > * { transition: opacity 0.5s var(--ease), transform 0.6s var(--ease); }
.panel.swap > * { opacity: 0; transform: translateY(10px); transition-duration: 0.18s; }
.panel > :nth-child(2) { transition-delay: 0.04s; }
.panel > :nth-child(3) { transition-delay: 0.08s; }
.panel > :nth-child(4) { transition-delay: 0.12s; }
.panel > :nth-child(5) { transition-delay: 0.16s; }
.hint { position: fixed; z-index: 6; right: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); font: 500 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.hint .touch { display: none; }
@media (hover: none) { .hint .desk { display: none; } .hint .touch { display: inline; } }

/* ---------- modes ---------- */
.gate, .progress, .panel, .hint, .nav, #skip, #replay, #sound { transition: opacity 0.7s var(--ease), transform 0.9s var(--ease), visibility 0.7s; }
.mode-gate .nav, .mode-gate #replay,
.mode-intro .nav, .mode-intro #replay,
.mode-site #skip { opacity: 0; visibility: hidden; pointer-events: none; }
.mode-intro .gate, .mode-site .gate { opacity: 0; visibility: hidden; pointer-events: none; }
.mode-gate .progress, .mode-site .progress { opacity: 0; }
.mode-gate .panel, .mode-intro .panel, .mode-gate .hint, .mode-intro .hint { opacity: 0; visibility: hidden; transform: translateY(24px); pointer-events: none; }
.mode-site .panel, .mode-site .hint { transition-delay: 0.5s; }
.mode-intro .brand { opacity: 0.85; }

/* hidden actions shouldn't hold space in the bar */
.mode-site #skip, .mode-gate #replay, .mode-intro #replay { display: none; }

/* ---------- mid-size screens: icon-only actions so they never crowd the nav ---------- */
@media (max-width: 1500px) {
  .pill.icon { width: 38px; padding: 0; justify-content: center; }
  .pill.icon .lbl { display: none; }
}

/* ---------- small / portrait screens ---------- */
@media (max-width: 860px), (orientation: portrait) {
  .bar { flex-wrap: wrap; row-gap: 10px; }
  .nav {
    position: static; transform: none; order: 3; width: 100%;
    overflow-x: auto; scrollbar-width: none; justify-content: flex-start;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { flex: none; }
  .mode-gate .nav, .mode-intro .nav { display: none; }
  .panel {
    left: 0; right: 0; bottom: 0; width: auto;
    max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 22px var(--gut) calc(20px + env(safe-area-inset-bottom));
  }
  .panel h2 { font-size: clamp(26px, 7vw, 36px); }
  .hint { display: none; }
  .pill { height: 40px; padding: 0 12px; }
  .pill.icon { width: 40px; padding: 0; justify-content: center; }
  .pill.icon svg { width: 20px; height: 20px; }
  .pill .lbl { display: none; }
  #sound[aria-pressed='false'] { color: var(--ink); border-color: rgba(243, 240, 232, 0.35); }
  #skip { padding: 0 14px; }
}
@media (max-width: 380px) {
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .eq i, #count-num.tick { animation: none !important; }
  * { transition-duration: 0.01s !important; }
}
