/*
 * Overlay.
 *
 * The 3D scene had a design and the DOM on top of it did not — default
 * buttons, a monospace debug readout, and boxes with square corners. That gap
 * is what made a finished scene still read as a test build.
 *
 * The language here is instrument rather than interface: hairline rules, small
 * tracked-out labels, panels that are glass rather than boxes, and nothing
 * that moves unless it has a reason to. Ink and scrim are set from the
 * background's luminance at runtime (see main.js), because two palettes are
 * nearly black and two nearly white.
 */

:root {
  --ease: cubic-bezier(0.2, 0.85, 0.25, 1);
  --fast: 180ms var(--ease);
  --slow: 420ms var(--ease);

  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Overridden at runtime per palette. These are the dark-world defaults. */
  --ink: #dfe5f0;
  --ink-soft: #93a0b5;
  --ink-done: #ffd9a8;
  --ink-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  --scrim: rgba(6, 8, 14, 0.84);
  --glass: rgba(16, 20, 28, 0.5);
  --glass-line: rgba(255, 255, 255, 0.14);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --focus: #8ab4ff;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Several components below set an explicit display, which silently beats the
   UA stylesheet's [hidden] rule. Without this the mute button shows before
   audio has started. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d12;
  color: var(--ink);
  font: 400 13px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* manipulation, not none: it still kills the 300ms double-tap delay, but it
     leaves pinch-zoom alive on the chrome. The canvas and the stick opt back
     out below, because there a pinch would fight the drag control. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The world itself takes every gesture: a drag is the control, and a pinch
   starting here would fight it. Everything outside the canvas stays zoomable. */
canvas { display: block; touch-action: none; }

/*
 * The veil. See --veil in main.js for why it exists.
 *
 * Body pseudo-elements rather than markup, because it is presentation with no
 * content and nothing should be able to focus it or read it aloud. Sits under
 * every control and over the canvas.
 */
body::before,
body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  pointer-events: none;
}
body::before {
  top: 0;
  height: 132px;
  background: linear-gradient(to bottom, var(--veil, transparent), transparent 100%);
}
body::after {
  bottom: 0;
  height: 215px;
  background: linear-gradient(to top, var(--veil, transparent), transparent 100%);
}
#stick { touch-action: none; }

/* Visually hidden, still read by screen readers. The canvas is opaque to
   assistive tech, so the page needs a real heading and description somewhere. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/*
 * Two treatments, and the split is the whole idea.
 *
 * A panel that carries text over unpredictable terrain has to be legible
 * against cream ground and near-black ground in the same session, and only a
 * scrim does that reliably. Those keep the frosted glass.
 *
 * Everything else — the controls — is drawn rather than filled: hairlines,
 * rings and tick marks — the drawing on an astronomical almanac, which is
 * what you would have used to predict a syzygy before you could compute one.
 * That is a better place to get the chrome from than the frosted lozenge every
 * component library has shipped since 2019, and it puts far less opaque
 * furniture between the viewer and the world, which is the thing they came
 * for.
 */
.glass,
/*
 * The marker keeps a scrim, because it is the one label that has to stay
 * readable over cream ground and near-black ground in the same session. It
 * loses the pill radius: a plate, squared off, reading as an annotation
 * rather than as a chat bubble.
 */
#marker {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.24);
}

/* Drawn bezels. The two round controls are a pair and read as one family. */
.icon-btn,
#jump {
  background: none;
  border: 1px solid var(--ink);
  box-shadow: none;
  text-shadow: var(--ink-shadow);
}
/*
 * A soft pool of shade under the jump control.
 *
 * It sits higher than the rest of the chrome, above the edge veil, and in the
 * daylit palette that put a 9.5px label over bright green ground at 3.25:1 —
 * a real AA failure, and one that was there before the chrome was redrawn.
 * A radial wash reads as shade rather than as a panel and takes it to 5.9.
 */
#jump::after {
  content: "";
  position: absolute;
  inset: -34px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--veil, transparent), transparent 100%);
  pointer-events: none;
}

/* An inner hairline, offset, the way a dial has a second scribe line. */
#jump::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 999px;
  border: 1px solid currentColor;
  opacity: 0.28;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ brand */

#brand {
  position: fixed;
  z-index: 6;
  top: max(18px, env(safe-area-inset-top));
  left: 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
}

#brand .mark {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  color: var(--ink);
  opacity: 0.55;
  position: relative;
}

/* A dot on the ring: the marble on its world, at 13 pixels. */
#brand .mark::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  top: -2.5px;
  left: 50%;
  margin-left: -2px;
}

#brand .by {
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0.7;
  text-decoration: none;
  text-shadow: var(--ink-shadow);
  pointer-events: auto;
  padding: 6px 2px;
  /* Small text over the world, so this is measured, not chosen: see the
     contrast table in the README. */
  border-bottom: 1px solid transparent;
  transition: opacity var(--fast), border-color var(--fast);
}
#brand .by:hover,
#brand .by:focus-visible {
  opacity: 0.85;
  border-bottom-color: currentColor;
}
#brand .by::before {
  /* A hairline separator that is punctuation, not a character, so it is not
     read aloud between the two halves of the credit. */
  content: "";
  display: inline-block;
  width: 12px;
  height: 1px;
  background: currentColor;
  vertical-align: middle;
  opacity: 0.5;
  margin-right: 9px;
}

#brand .word {
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.82;
  text-shadow: var(--ink-shadow);
}

/* --------------------------------------------------------------- progress */

#progress {
  position: fixed;
  z-index: 6;
  /* Pulled up by the pips' own padding, so the dots stay on the same line
     they were on before they grew a 40px hit area around them. */
  top: calc(max(18px, env(safe-area-inset-top)) - 15px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  align-items: center;
  pointer-events: none;
}

/*
 * A 40px target around a 9px dot.
 *
 * The dot is the right size to read as a row of pips; 9px is not a control
 * anybody can hit. Padding gives it the target without changing the drawing,
 * which is the usual answer and the right one here.
 */
#progress .pip-link {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  position: relative;
  text-decoration: none;
  color: inherit;
  /* Not clickable until it is a link. Until then the row is a readout. */
  pointer-events: none;
}
#progress .pip-link.on {
  pointer-events: auto;
  cursor: pointer;
}

/* The project name, on hover or focus only. The row is a readout first. */
#progress .pip-name {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%) translateY(-3px);
  white-space: nowrap;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: var(--ink-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast), transform var(--fast);
}
#progress .pip-link.on:hover .pip-name,
#progress .pip-link.on:focus-visible .pip-name {
  opacity: 0.95;
  transform: translateX(-50%) translateY(0);
}
#progress .pip-link.on:hover .pip,
#progress .pip-link.on:focus-visible .pip { transform: scale(1.45); }

#progress .pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  opacity: 0.38;
  position: relative;
  transition: opacity var(--slow), border-color var(--slow), transform var(--slow);
}

#progress .pip::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: currentColor;
  transform: scale(0);
  transition: transform 520ms var(--ease);
}

#progress .pip.on {
  opacity: 1;
  border-color: currentColor;
  /* A hair larger, so the row reads even in a screenshot. */
  transform: scale(1.18);
}

#progress .pip.on::after { transform: scale(1); }

/* ----------------------------------------------------------------- marker */

#marker {
  position: fixed;
  z-index: 8;
  left: 0;
  top: 0;
  transform: translate(-50%, -190%);
  padding: 8px 14px;
  border-radius: 3px;
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  /* Not clickable until it is a link — see #marker.lit. Otherwise it would
     swallow drags that were meant to steer. */
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--fast), border-color var(--slow), transform var(--slow);
}

/*
 * A leader line down to the thing being labelled, not a speech nib.
 *
 * The nib made this a tooltip, and a tooltip is a thing that explains an
 * interface. This is an annotation on a plate: a hairline dropping to the
 * object, ending in a small open circle exactly where the monument is. Same
 * job, and it belongs to the same drawn-instrument family as the controls
 * rather than to a component library.
 */
#marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 15px;
  margin-left: -0.5px;
  background: currentColor;
  opacity: 0.5;
}

#marker::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 13px);
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.7;
}

#marker .mk-name {
  display: block;
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

#marker .mk-blurb {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 15rem;
  white-space: normal;
}

#marker .mk-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--glass-line);
  width: 100%;
  justify-content: center;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-done);
}

#marker.lit { border-color: color-mix(in srgb, var(--ink-done) 45%, transparent); }
#marker.lit.shown { pointer-events: auto; cursor: pointer; }
#marker.lit.shown:hover { transform: translate(-50%, -196%); }

/* -------------------------------------------------------------- wayfinder */

#wayfinder {
  position: fixed;
  z-index: 5;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--slow);
}

#wayfinder.on { opacity: 0.66; }

#wayfinder span {
  display: block;
  width: 100%;
  height: 100%;
  /* --a is written by the Wayfinder each frame. */
  transform: rotate(calc(-1 * var(--a, 0rad)));
  background: currentColor;
  color: var(--ink);
  filter: drop-shadow(0 0 4px rgba(128, 128, 128, 0.4));
  clip-path: polygon(100% 50%, 34% 100%, 50% 50%, 34% 0%);
}

/* ------------------------------------------------------------------ stick */

#stick {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--fast);
}

#stick .base,
#stick .knob {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent);
}

#stick .base {
  width: 112px;
  height: 112px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}

#stick .knob {
  width: 44px;
  height: 44px;
  background: color-mix(in srgb, var(--ink) 16%, transparent);
  transition: none;
}

/* --------------------------------------------------------------- controls */

#controls {
  position: fixed;
  z-index: 7;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
}

/*
 * The palette selector, as a scale on an instrument.
 *
 * It used to be a glass pill with a sliding capsule behind the active label,
 * which is a perfectly good control and belongs to every component library
 * written since 2019. The world it sits over does not look like anything else;
 * the chrome did, and it is a third of the frame.
 *
 * So: four labels tracked out along a hairline rule, with a mark that slides
 * under the live one. Almanacs and ephemerides are pages of engraved scales
 * and ruled tables, and that is where this comes from rather than from a
 * profile in the design library.
 *
 * The moving mark is still a single element that slides rather than four that
 * fade, for the original reason — one object moving reads as one control,
 * four fading reads as four buttons.
 */
#pal {
  position: relative;
  display: flex;
  padding: 0 0 9px;
}

/* The rule the scale is drawn on. */
#pal::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  height: 1px;
  background: var(--ink);
  opacity: 0.22;
  pointer-events: none;
}

#pal .seg-bg {
  position: absolute;
  bottom: 4px;
  left: 0;
  height: 9px;
  border-radius: 0;
  background: none;
  opacity: 1;
  transition: transform var(--slow), width var(--slow);
  pointer-events: none;
}

/* The mark itself: a short heavy tick centred in the slot, not a filled slab.
   A slab is a pill by another name. */
#pal .seg-bg::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 2px;
  height: 9px;
  margin-left: -1px;
  background: var(--ink);
}

#pal button {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.78;
  padding: 0 13px;
  height: 40px;
  min-height: 40px;
  cursor: pointer;
  text-shadow: var(--ink-shadow);
  transition: opacity var(--fast), letter-spacing var(--slow);
  /* 0.62, not 0.5. Over the veil this clears AA against both inks; without
     the veil it did not, and "it looked fine on the palette I was testing"
     is how contrast bugs ship. */
  white-space: nowrap;
}

/* Every label is a minor tick on the rule. */
#pal button::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 1px;
  height: 4px;
  background: currentColor;
  opacity: 0.45;
}

#pal button:hover { opacity: 0.92; }

#pal button[aria-pressed="true"] {
  opacity: 1;
  /* Nothing is inverted any more, because nothing sits on a filled pill. The
     live label reads as live by being brighter and slightly wider. */
  letter-spacing: 0.16em;
}
#pal button[aria-pressed="true"]::after { opacity: 0; }

.icon-btn,
#jump {
  appearance: none;
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  transition: opacity var(--fast), transform var(--fast);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  opacity: 0.75;
}

.icon-btn:hover { opacity: 1; }
.icon-btn:active { transform: scale(0.94); }

.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn svg path:first-child { fill: currentColor; stroke: none; }
.icon-btn .slash { opacity: 0; transition: opacity var(--fast); }
.icon-btn[aria-pressed="true"] .wave,
.icon-btn[aria-pressed="true"] .wave2 { opacity: 0; }
.icon-btn[aria-pressed="true"] .slash { opacity: 1; }

/* Jump lives on the opposite side from the thumbstick, which spawns wherever
   the finger lands — usually the left. */
/* One-time label beside the sound button. An offer, not chrome. */
#soundhint {
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.7s var(--ease);
  white-space: nowrap;
}

#soundhint.gone { opacity: 0; }

@media (max-width: 560px) {
  #soundhint { display: none; }
}

#jump {
  position: fixed;
  z-index: 7;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px);
  width: 66px;
  height: 66px;
  border-radius: 999px;
  font: inherit;
  font-size: 9.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  opacity: 0.9;
}
#jump:hover { opacity: 1; }
#jump:active { transform: scale(0.95); }

#jump:active { transform: scale(0.93); opacity: 1; }

/* ------------------------------------------------------------------- hint */

/*
 * The hint sits low on the screen, which means it sits over the *ground* — and
 * the ground is bright orange in Dusk and pale cream in Riso while the sky
 * above is nearly black. Ink chosen from background luminance is exactly wrong
 * for it, and a text-shadow was not enough.
 *
 * So it carries its own surface. A pill guarantees contrast over anything the
 * camera happens to be pointing at.
 */
#hint {
  position: fixed;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  max-width: calc(100vw - 32px);
  padding: 7px 15px;
  /* No capsule. It is one line of instruction, and wrapping it in a frosted
     lozenge was the single loudest piece of component-library furniture on
     the page. The shadow is what makes it legible over bright ground. */
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: var(--ink-shadow);
  opacity: 0.95;
  pointer-events: none;
  transition: opacity var(--slow);
}

/* ---------------------------------------------------------------- beacons */

#beacons {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

/* World-anchored project labels, revealed at dawn. Positioned by transform
   only — writing left/top would invalidate layout for four elements every
   frame, and transform stays on the compositor. */
.beacon {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px 7px 10px;
  /* Squared to match the marker: these are the same object at the end of the
     piece, and a pill here would put two different label languages on screen
     at once. */
  border-radius: 3px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

/* Staggered reveal — .on is added one at a time from Beacons.reveal(). */
.beacon:not(.on) { visibility: hidden; }

.beacon .bc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 9px currentColor;
  flex: 0 0 auto;
}

.beacon .bc-text { display: grid; }

.beacon .bc-name {
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink);
}

.beacon .bc-blurb {
  font-size: 10px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.beacon:hover { border-color: currentColor; }

/* Parked for reading. Overrides the per-frame transform written by Beacons. */
.beacon.pinned {
  transform: translate(-50%, 0) !important;
  left: 50%;
  top: auto;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 108px);
  opacity: 1 !important;
  border-color: currentColor;
}

/* ------------------------------------------------------------- run clock */

#clock {
  position: fixed;
  z-index: 6;
  top: calc(max(18px, env(safe-area-inset-top)) + 20px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ink-done);
  text-shadow: var(--ink-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s var(--ease);
  font-variant-numeric: tabular-nums;
}

#clock.on { opacity: 0.8; }
/* A standing best, before the run starts. Present, not insistent. */
#clock.idle { opacity: 0.45; color: var(--ink); }
/*
 * A new best. The only celebratory thing in the piece, and it is one word and
 * a colour — anything more would be a badge, and a badge would be the first
 * thing here that treats the player as someone to be rewarded rather than
 * someone to be shown something.
 */
#clock.record {
  opacity: 1;
  letter-spacing: 0.3em;
}

#again {
  position: fixed;
  z-index: 7;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px);
  appearance: none;
  font: inherit;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  padding: 11px 16px;
  min-height: 40px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--fast);
}

#again:hover { opacity: 1; }

/* ------------------------------------------------------------------ intro */

#intro {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
  transition: opacity 0.85s var(--ease);
}

#intro.gone { opacity: 0; }

/* The card lands wherever the marble happens to be, and the marble is the
   brightest thing on screen. A soft radial scrim guarantees contrast without
   reading as a panel. */
#intro::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 46% 38% at 50% 50%,
    var(--scrim) 0%,
    transparent 100%
  );
}

#intro .card {
  position: relative;
  max-width: 30rem;
  text-align: center;
  animation: introIn 1.15s var(--ease) both;
}

#intro .eyebrow {
  margin: 0 0 1.15rem;
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

#intro h2 {
  margin: 0;
  font-size: clamp(2.1rem, 11vw, 3.6rem);
  font-weight: 300;
  letter-spacing: 0.3em;
  /* letter-spacing pads the right of the last glyph; nudge back to true centre */
  text-indent: 0.3em;
  text-transform: lowercase;
  line-height: 1;
  color: var(--ink);
}

#intro .lede {
  margin: 1.5rem auto 0;
  max-width: 24rem;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-soft);
}

#intro .go {
  margin: 2.4rem 0 0;
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink);
}

#intro .go span {
  display: inline-block;
  padding-bottom: 7px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 34%, transparent);
  animation: breathe 3.6s ease-in-out infinite;
}

@keyframes introIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ---------------------------------------------------------------- loading */

#loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: #0b0d12;
}

#loading .spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(223, 229, 240, 0.18);
  border-top-color: rgba(223, 229, 240, 0.75);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/*
 * The look-control line in the intro card.
 *
 * Two spans and a media query rather than sniffing the user agent: `hover:
 * none` asks the question that actually matters — whether this device has a
 * pointer that can right-click — instead of guessing from a string.
 */
#intro .look {
  margin: 10px 0 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.5;
}
#intro .look .for-touch { display: none; }
@media (hover: none) {
  #intro .look .for-pointer { display: none; }
  #intro .look .for-touch { display: inline; }
}

#ctxlost {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(6, 8, 13, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #eef2f8;
}
#ctxlost p { max-width: 34ch; margin: 0 auto 8px; line-height: 1.6; }
#ctxlost p:last-child { opacity: 0.72; font-size: 12.5px; }

#nowebgl {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: none;
  place-items: center;
  padding: 28px;
  background: #0b0d12;
  color: #dfe5f0;
  text-align: center;
  line-height: 1.7;
}

#nowebgl p { margin: 0 0 0.6rem; }
#nowebgl p + p { color: #93a0b5; font-size: 12.5px; }

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

#hud {
  position: fixed;
  top: 54px;
  left: 20px;
  z-index: 5;
  margin: 0;
  padding: 9px 11px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  color: #c9cdd6;
  font: 11px/1.55 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: pre;
  pointer-events: none;
}

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

@media (max-width: 560px) {
  #brand { left: 14px; }
  #brand .word { font-size: 10px; letter-spacing: 0.28em; }
  /* At 375px the credit would push the mark off the left edge. It stays in
     the ending links and in the page description, so nothing is lost. */
  #brand .by { display: none; }
  #controls { gap: 7px; }
  #pal { padding: 3px; }
  /* Narrower, not shorter. Four palettes fit across 375px by losing padding;
     losing height would take the target under 40px, which is the one dimension
     that is not ours to trade. */
  #pal button { padding: 0 9px; font-size: 9.5px; letter-spacing: 0.08em; height: 40px; min-height: 40px; }
  /* 40px is the floor everywhere, including here. Shrinking the mute button
     to claw back two pixels of a row that already fits is a bad trade. */
  .icon-btn { width: 40px; height: 40px; }
  #jump { width: 58px; height: 58px; right: 14px; }
  #hint { font-size: 9px; letter-spacing: 0.1em; padding: 6px 12px; }
}

/* Touch devices get no hover lift on the marker — it would fire on tap and
   shift the thing being tapped out from under the finger. */
@media (hover: none) {
  #marker.lit.shown:hover { transform: translate(-50%, -190%); }
}

@media (prefers-reduced-motion: reduce) {
  #intro .card,
  #intro .go span,
  #loading .spinner { animation: none; }
  #intro .go span { opacity: 0.9; }
  #loading .spinner { border-top-color: rgba(223, 229, 240, 0.5); }
  * { transition-duration: 1ms !important; }
}

/*
 * The crystal tally.
 *
 * Sits under the clock and only exists once you have rung one — a counter
 * reading 0/6 before you know crystals are a thing is a target you did not
 * agree to, and the piece is not a checklist. After the first, it is a tally
 * of something you found.
 */
#crystals {
  position: fixed;
  z-index: 6;
  top: calc(max(18px, env(safe-area-inset-top)) + 38px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ink-done);
  text-shadow: var(--ink-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s var(--ease);
  font-variant-numeric: tabular-nums;
}

#crystals.on { opacity: 0.62; }

/* The beat where one is struck. Brief, and it settles back on its own. */
#crystals.hit {
  opacity: 0.95;
  transition: opacity 0.12s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  #crystals { transition: none; }
}

/*
 * The leaderboard entry.
 *
 * Built on the same glass as the other panels rather than a new surface: it
 * appears at the one moment the piece has already stopped, and a card that
 * looked like a different application would break that.
 */
#board {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 92px);
  transform: translateX(-50%);
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 6px;
  padding: 18px 20px 16px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--ink-faint);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: boardIn 0.5s var(--ease) both;
}

#board[hidden] { display: none; }

@keyframes boardIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#board h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink);
}

#board-time {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-done);
  font-variant-numeric: tabular-nums;
}

#board label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

#board input {
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink-done);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--ink-faint);
  border-radius: 8px;
  /* 44px so it is a real target on a phone, which is where this gets used. */
  min-height: 44px;
  padding: 0 12px;
}

#board input::placeholder { color: var(--ink-faint); }

#board input:focus-visible,
#board button:focus-visible {
  outline: 2px solid var(--ink-done);
  outline-offset: 2px;
}

.board-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#board button {
  flex: 1;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--ink-done);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--ink-faint);
  transition: background 0.25s var(--ease);
}

#board button:hover { background: rgba(255, 255, 255, 0.13); }
#board #board-skip { color: var(--ink); background: transparent; }

#board-note {
  margin: 4px 0 0;
  min-height: 13px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  #board { animation: none; }
}
