@font-face {
  font-family: 'Broadway';
  src: url('fonts/Broadway-Regular.woff2') format('woff2');
  font-display: swap;
}

:root {
  --black: #0d0d0d;
  --charcoal: #1a1a1a;
  --mid: #2e2e2e;
  --grey: #4a4a4a;        /* lines, dots, surfaces — never text */
  --text-3: #8a8a8a;      /* tertiary text, 5.6:1 on black */
  --text-2: #a8a8a8;      /* secondary text, 8.2:1 */
  --light: #c8c8c8;
  --off-white: #e8e8e8;
  --font-brand: 'Broadway', Georgia, serif;
  --font-serif: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif', Georgia, 'Times New Roman', serif;
  --gutter: max(20px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--black);
  color: var(--off-white);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;       /* no magnifier / copy menu on a long press */
  overscroll-behavior: none;
}
button, a { touch-action: manipulation; }   /* no double-tap zoom */

canvas#sky {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
body.is-intro canvas#sky { cursor: default; }

/* ── frame ───────────────────────────────────────────────────────────── */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  padding: calc(22px + env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
  z-index: 2;
}
.wordmark {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 var(--gutter) calc(10px + env(safe-area-inset-bottom));
  z-index: 2;
  pointer-events: none;
}
.bottom > * { pointer-events: auto; }

.bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
body.is-intro .bar { visibility: hidden; }
body.is-sky #shuffle, body.is-sky .bar .hud { display: none; }

/* player controls: pause is the one obvious, filled button; shuffle sits quietly beside it */
.ctl {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--grey);
  border-radius: 50%;
  background: rgba(13, 13, 13, 0.55);
  color: var(--off-white);
  cursor: pointer;
  transition: border-color .3s ease, background .3s ease, transform .2s ease;
}
.ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ctl:hover, .ctl:focus-visible { border-color: var(--text-2); }
.ctl:active { transform: scale(0.94); }
.ctl.main { width: 52px; height: 52px; background: var(--off-white); border-color: var(--off-white); color: var(--black); }
.ctl.main svg { fill: currentColor; stroke: none; width: 24px; height: 24px; }
.ctl.main:hover, .ctl.main:focus-visible { background: #fff; }
.ctl .i-play { display: none; }
body.is-paused .ctl .i-play { display: block; }
body.is-paused .ctl .i-pause { display: none; }

.hud {
  min-height: 44px;
  padding: 10px 18px;
  background: none;
  border: 0;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.hud:hover, .hud:focus-visible { color: var(--off-white); }

.legal {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.legal a {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  padding: 0 6px;
  color: var(--text-3);
  text-decoration: none;
}
.legal a:hover, .legal a:focus-visible { color: var(--text-2); }

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--grey);
  border-radius: 999px;
  background: rgba(13, 13, 13, 0.6);
  color: var(--off-white);
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .3s ease, background .3s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--text-2); }
.btn.primary { background: var(--off-white); border-color: var(--off-white); color: var(--black); }
.btn.primary:hover, .btn.primary:focus-visible { background: #fff; }
.btn.ghost { border-color: transparent; color: var(--text-2); background: none; }
.btn.ghost:hover, .btn.ghost:focus-visible { color: var(--off-white); border-color: var(--grey); }
:focus-visible { outline: 1px solid var(--text-2); outline-offset: 3px; }

.linkish {
  background: none;
  border: 0;
  padding: 12px 4px;
  font: inherit;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ── intro ───────────────────────────────────────────────────────────── */
.intro {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px var(--gutter) 110px;
  text-align: center;
  z-index: 3;
  transition: opacity 1.4s ease;
}
.intro.out { opacity: 0; pointer-events: none; }
.intro h1 {
  margin: 0 0 18px;
  max-width: 18em;
  font-weight: 400;
  font-size: clamp(25px, 4.2vw, 40px);
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-wrap: balance;
}
/* "Somewhere in the dark," must fit one line, also on 320-px phones (iPhone SE) */
@media (max-width: 359px) { .intro h1 { font-size: 22px; } }
.intro-sub, .intro-extra {
  margin: 0 0 10px;
  max-width: 28em;
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.55;
  color: var(--text-2);
  text-wrap: balance;
}
.intro .btn { margin-top: 26px; }
.intro-hint {
  margin: 16px 0 0;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

/* ── hint + helpers ──────────────────────────────────────────────────── */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(128px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(26em, calc(100% - 40px));
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-2);
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
  z-index: 2;
}
.hint.on { opacity: 1; }

.reveal, .sound {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}
.reveal { bottom: calc(172px + env(safe-area-inset-bottom)); }
.sound  { top: calc(64px + env(safe-area-inset-top)); }

/* ── found card ──────────────────────────────────────────────────────── */
.card {
  position: fixed;
  left: 50%;
  bottom: calc(122px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  width: min(440px, calc(100% - 32px));
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 18px;
  background: rgba(13, 13, 13, 0.82);
  border: 1px solid var(--mid);
  border-radius: 6px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 1.1s ease, transform 1.1s ease;
  z-index: 3;
}
.card.top-side { bottom: auto; top: calc(64px + env(safe-area-inset-top)); }
.card.in { opacity: 1; transform: translate(-50%, 0); }
.c-zoom {
  position: relative;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  line-height: 0;
}
.c-cover {
  width: 96px;
  height: 96px;
  object-fit: cover;
  background: var(--charcoal);
  transition: filter .3s ease;
}
.c-zoom:hover .c-cover, .c-zoom:focus-visible .c-cover { filter: brightness(1.12); }
/* small expand mark in the corner: says "this opens larger" without words */
.c-zoom-i {
  position: absolute;
  right: 4px; bottom: 4px;
  width: 20px; height: 20px;
  padding: 3px;
  border-radius: 50%;
  background: rgba(13, 13, 13, 0.72);
  fill: none; stroke: var(--off-white); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
  background: rgba(13, 13, 13, 0.92);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .45s ease;
  cursor: zoom-out;
}
.lightbox.in { opacity: 1; }
.lb-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lb-img {
  width: min(86vw, 72vh, 640px);       /* Spotify artwork is 640 px: never upscale */
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--charcoal);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform .45s ease;
}
.lightbox.in .lb-img { transform: scale(1); }
.lb-fig figcaption { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.lb-title { font-size: 19px; letter-spacing: 0.02em; }
.lb-meta { font-size: 14px; color: var(--text-2); }
.lb-close { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; }
.c-body { min-width: 0; flex: 1; }
.c-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.c-title {
  margin: 0 0 4px;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0.02em;
}
.c-meta { margin: 0; font-size: 14px; color: var(--text-2); }
.c-note { margin: 10px 0 0; font-size: 14px; line-height: 1.5; color: var(--light); }
.c-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.c-actions .btn { font-size: 14px; padding: 0 16px; }

@media (max-width: 420px) {
  .card { flex-direction: column; gap: 12px; }
  .card .c-zoom { position: absolute; top: 18px; right: 18px; }
  .card .c-cover { width: 72px; height: 72px; }
  .card .c-title, .card .c-kicker, .card .c-meta { padding-right: 84px; }
  .c-actions .btn { flex: 1 1 auto; }
}

/* ── sky view ────────────────────────────────────────────────────────── */
.skyview {
  isolation: isolate;
  position: fixed;
  left: 50%;
  bottom: calc(118px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(460px, calc(100% - 32px));
  text-align: center;
  z-index: 3;
}
/* a soft pool of dark behind the text, so stars and lines never run through it */
.skyview::before {
  content: '';
  position: absolute;
  inset: -40px -60px -30px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(13, 13, 13, 0.88), rgba(13, 13, 13, 0.6) 60%, rgba(13, 13, 13, 0));
  pointer-events: none;
}
.sv-title {
  margin: 0 0 6px;
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.04em;
}
.sv-count { margin: 0 0 16px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.sv-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.sv-note { margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-3); }
.sv-note .linkish { font-size: 13px; color: var(--text-3); }

body.is-sky .hud, body.is-sky .hint, body.is-intro .hud { visibility: hidden; }

.tip {
  position: fixed;
  z-index: 4;
  padding: 10px 14px 4px;
  background: rgba(13, 13, 13, 0.88);
  border: 1px solid var(--mid);
  border-radius: 6px;
  transform: translate(-50%, calc(-100% - 14px));
  text-align: center;
  white-space: nowrap;
}
.tip-title { margin: 0; font-size: 16px; }
.tip-meta { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.tip-link {
  display: inline-block;
  min-height: 36px;
  line-height: 36px;
  font-size: 13px;
  color: var(--text-2);
}

.debug {
  position: fixed;
  top: 8px; left: 8px;
  font: 12px/1.4 ui-monospace, monospace;
  color: var(--light);
  background: rgba(0,0,0,.6);
  padding: 6px 8px;
  z-index: 9;
  pointer-events: none;
  white-space: pre;
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .intro, .card, .hint { transition-duration: .01s; }
}

/* text over the sky (nebulae can be brighter than the plain black): a dark halo keeps the contrast */
.intro h1, .intro-sub, .intro-extra, .intro-hint, .hint, .wordmark, .hud, .legal a, .sv-count, .sv-note {
  text-shadow: 0 0 12px rgba(13, 13, 13, 0.95), 0 0 3px rgba(13, 13, 13, 0.9);
}
