:root {
  --ink: #f4ead9;
  --ink-dim: rgba(244, 234, 217, 0.62);
  --accent: #ffc27a;
  --bg: #18222c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 120% 90% at 50% 55%,
    transparent 60%,
    rgba(12, 18, 26, 0.45) 100%
  );
}

.title {
  position: fixed;
  top: max(env(safe-area-inset-top), clamp(24px, 6vh, 64px));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 2.4s ease 0.8s,
    transform 2.4s ease 0.8s;
}

/* Quiet, film-title lockup: small tracked caps between two hairlines */
.title h1 {
  display: inline-flex;
  align-items: center;
  gap: 1.1em;
  margin: 0;
  font-weight: 800;
  font-size: clamp(0.95rem, 1.7vw, 1.3rem);
  line-height: 1;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 14px rgba(20, 32, 48, 0.28);
}

.title h1 span {
  margin-right: -0.42em; /* cancel trailing tracking so it centres */
}

.title h1::before,
.title h1::after {
  content: '';
  width: 2.6em;
  height: 1px;
  background: currentColor;
  opacity: 0.55;
}

@media (max-width: 480px) {
  .title h1 {
    gap: 0.8em;
    letter-spacing: 0.3em;
  }
  .title h1 span {
    margin-right: -0.3em;
  }
  .title h1::before,
  .title h1::after {
    width: 1.4em;
  }
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(env(safe-area-inset-bottom), clamp(20px, 5vh, 48px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 2.4s ease 1.6s;
}

/* Settings pill: hidden until the visitor moves the mouse or taps */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
  padding: 6px 8px 6px 16px;
  border-radius: 999px;
  background: rgba(20, 28, 36, 0.36);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 30px rgba(10, 20, 30, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
}

body.controls-visible .controls,
.controls:has(:focus-visible) {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-label {
  margin-right: 4px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.step,
.chip {
  appearance: none;
  border: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

.step {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.step:disabled {
  opacity: 0.3;
  cursor: default;
}

#disc-count {
  min-width: 2ch;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.chip {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-dim);
}

.step:hover:not(:disabled),
.chip:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--ink);
}

.chip[aria-pressed='true'] {
  background: rgba(255, 255, 255, 0.9);
  color: #1b2530;
}

.divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.2);
}

.controls button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .controls {
    gap: 10px;
    padding-left: 12px;
  }
  .control-label {
    letter-spacing: 0.1em;
  }
}

.counter {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-shadow: 0 1px 10px rgba(10, 20, 30, 0.5);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  transition: color 0.8s ease;
}

.counter #move {
  color: var(--ink);
  display: inline-block;
  min-width: 3ch;
  text-align: right;
}

.counter .sep {
  opacity: 0.5;
  margin: 0 0.2em;
}

.progress {
  width: min(220px, 50vw);
  height: 1px;
  background: rgba(244, 234, 217, 0.16);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd88f, var(--accent));
  box-shadow: 0 0 8px var(--accent);
  transition: width 0.4s ease;
}

.hud.solved .counter,
.hud.solved .counter #move {
  color: var(--accent);
}

.credit {
  margin-top: 6px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(244, 234, 217, 0.32);
  text-decoration: none;
  transition: color 0.3s ease;
}

.credit:hover {
  color: var(--ink-dim);
}

.curtain {
  position: fixed;
  inset: 0;
  background: var(--bg);
  pointer-events: none;
  transition: opacity 2.2s ease;
}

body.ready .curtain {
  opacity: 0;
}

body.ready .title {
  opacity: 1;
  transform: none;
}

body.ready .hud {
  opacity: 1;
}

/* No WebGL: still show a pleasant static page */
body.no-webgl {
  background: linear-gradient(#5d86c0, #d9cdb6 60%, #3c4a2c 61%, var(--bg));
}

body.no-webgl .curtain,
body.no-webgl .hud {
  display: none;
}

body.no-webgl .title {
  top: 40vh;
  opacity: 1;
  transform: none;
}

@media (max-height: 480px) {
  .credit {
    display: none;
  }
}
