:root {
  --bg: #07080c;
  --ink: #e7eaf3;
  --muted: rgba(231, 234, 243, 0.44);
  --label: rgba(231, 234, 243, 0.30);
  --faint: rgba(231, 234, 243, 0.16);
  --hairline: rgba(231, 234, 243, 0.10);

  /* the colour of the breath, rewritten three times a cycle by main.js */
  --breath: #ccc4eb;
  --pad: clamp(18px, 4vw, 40px);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  cursor: default;
}

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

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* soft darkening toward the corners — keeps the eye at the centre */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 46%, transparent 38%, rgba(4, 5, 9, 0.55) 78%, rgba(3, 4, 7, 0.9) 100%);
}

.ui {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--pad);
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
  padding-top: max(var(--pad), env(safe-area-inset-top));
  pointer-events: none;
}
.ui > * { pointer-events: auto; }

.top {
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 7px;
}

/* The one link on this page. It sits at the top, furthest from the light, and
   is quiet enough to ignore — a door for the curious, not a thing to read
   before you can start. */
.aside {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-transform: uppercase;
  color: rgba(231, 234, 243, 0.2);
  text-decoration: none;
  transition: color 1.2s ease;
}
.aside:hover,
.aside:focus-visible { color: rgba(231, 234, 243, 0.55); }
body.is-idle .aside { color: rgba(231, 234, 243, 0.1); }
@media (hover: none) { body.is-idle .aside { color: rgba(231, 234, 243, 0.2); } }

.mark {
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 400;
  letter-spacing: 0.42em;
  text-indent: 0.42em;   /* balance the trailing letter-space so it centres */
  text-transform: uppercase;
  color: rgba(231, 234, 243, 0.34);
  user-select: none;
  transition: color 1.2s ease;
}
body.is-idle .mark { color: rgba(231, 234, 243, 0.18); }

/* A touch screen never fires pointermove, so it goes idle six seconds after
   load and stays there — which left the wordmark invisible on every phone.
   Nothing is "idle" without a pointer, so don't dim it there at all. */
@media (hover: none) {
  body.is-idle .mark { color: rgba(231, 234, 243, 0.34); }
  body.is-idle .icon-btn { color: var(--muted); }
}

/* ---- centre cue ------------------------------------------------------- */

.center {
  display: grid;
  place-items: end center;
  padding-bottom: clamp(24px, 9vh, 80px);
  pointer-events: none;
}

.cue {
  margin: 0;
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 300;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* balance the trailing letter-space */
  text-transform: uppercase;
  color: var(--muted);
  color: color-mix(in oklab, var(--breath) 62%, var(--muted));
  white-space: nowrap;
  transition: opacity 900ms ease;
  user-select: none;
}
.cue.dim { opacity: 0; }
.cue { transition: opacity 900ms ease, color 1.6s ease; }

/* ---- bottom hud ------------------------------------------------------- */

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 16px;
}

.stats {
  grid-column: 2;
  margin: 0;
  display: flex;
  gap: clamp(28px, 7vw, 72px);
  align-items: flex-start;
  justify-content: center;
}

.stat {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 0;
}

.stat dd {
  margin: 0;
  font-size: clamp(22px, 4.2vw, 34px);
  font-weight: 200;
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 0 30px rgba(200, 200, 230, 0.18);
  text-shadow: 0 0 30px color-mix(in oklab, var(--breath) 30%, transparent);
  transition: text-shadow 1.6s ease;
}

.stat dt {
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--label);
  white-space: nowrap;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.012);
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: color 300ms ease, border-color 300ms ease, background 300ms ease, transform 300ms ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.icon-btn:hover { color: var(--ink); border-color: rgba(238, 241, 248, 0.24); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 1px solid rgba(238, 241, 248, 0.5); outline-offset: 3px; }
.icon-btn svg { width: 18px; height: 18px; }

#sound { justify-self: start; }
#share { justify-self: end; grid-column: 3; }

/* three bars that stand still when muted and sway when playing */
.icon-sound {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}
.icon-sound i {
  display: block;
  width: 1.5px;
  height: 5px;
  border-radius: 1px;
  background: currentColor;
  transition: height 400ms ease;
}
#sound[aria-pressed="true"] .icon-sound i { animation: sway 3.4s ease-in-out infinite; }
#sound[aria-pressed="true"] .icon-sound i:nth-child(2) { animation-delay: -1.1s; }
#sound[aria-pressed="true"] .icon-sound i:nth-child(3) { animation-delay: -2.2s; }
@keyframes sway {
  0%, 100% { height: 4px; }
  50%      { height: 14px; }
}

/* the one nudge we allow ourselves: a slow halo on the sound button
   until it has been touched once */
#sound.hint::after {
  content: "";
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(238, 241, 248, 0.3);
  animation: ripple 4s ease-out infinite;
  pointer-events: none;
}
#sound { position: relative; }
@keyframes ripple {
  0%   { transform: scale(1);   opacity: 0.5; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* ---- toast ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--pad) + 84px);
  transform: translate(-50%, 8px);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(12, 14, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease, transform 400ms ease;
  white-space: nowrap;
  max-width: calc(100vw - 2 * var(--pad));
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .hud { grid-template-columns: 1fr auto 1fr; }
  .stat dt { font-size: 8.5px; letter-spacing: 0.2em; }
}

@media (prefers-reduced-motion: reduce) {
  #sound[aria-pressed="true"] .icon-sound i,
  #sound.hint::after { animation: none; }
}

body.is-idle { cursor: none; }
body.is-idle .icon-btn { color: rgba(238, 241, 248, 0.22); }
