:root {
  --ink: #f4efe4;
  --ink-dim: rgba(244, 239, 228, 0.62);
  --ink-faint: rgba(244, 239, 228, 0.34);
  --plate: rgba(9, 9, 16, 0.5);
  --accent: #ffd23a;
  --face: Bahnschrift, "DIN Alternate", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #000;
  color: var(--ink);
  font-family: var(--face);
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#stage.dragging { cursor: grabbing; }
#stage.hot { cursor: pointer; }

/* Black cover used while one background is swapped for another. */
#veil {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}
#veil.on { opacity: 1; }

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 600ms ease;
}
#ui.idle, #ui.off { opacity: 0; }
#ui.off * { pointer-events: none !important; }

.caption {
  position: absolute;
  left: clamp(18px, 3.2vw, 48px);
  bottom: clamp(18px, 3.2vw, 44px);
  max-width: min(34rem, 60vw);
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.75);
}
.caption h1 {
  margin: 0;
  font-weight: 300;
  font-stretch: 75%;
  font-size: clamp(2.4rem, 6vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: -0.01em;
}
.caption p { margin: 0; }
#hint {
  margin-top: 0.7rem;
  font-size: 1rem;
  color: var(--ink-dim);
}

.shelf {
  position: absolute;
  right: clamp(14px, 2.6vw, 40px);
  bottom: clamp(18px, 3.2vw, 44px);
  pointer-events: auto;
}
.shelf ul {
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--plate);
  backdrop-filter: blur(10px);
  border-radius: 4px;
}
.shelf button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 14px 6px 6px;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
.shelf button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.shelf button[aria-current="true"] { color: var(--ink); }
.shelf button[aria-current="true"] .chip { outline: 1px solid var(--ink); outline-offset: 2px; }

/* Three diagonal bands in the background's own colours. */
.chip {
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 1px;
  background: linear-gradient(
    115deg,
    var(--c1) 0 36%,
    var(--c2) 36% 68%,
    var(--c3) 68% 100%
  );
}

.tools {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: 4px;
}
.tools button {
  padding: 7px 11px;
  border: 0;
  border-radius: 2px;
  background: var(--plate);
  backdrop-filter: blur(10px);
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.tools button:hover { color: var(--ink); }

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

#fail {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 2rem;
  text-align: center;
  font-size: 1.1rem;
  color: var(--ink);
  background: #0b0a14;
}
#fail[hidden] { display: none; }

@media (max-width: 640px) {
  .caption { max-width: none; right: 18px; bottom: auto; top: 16px; }
  .caption h1 { font-size: 2.3rem; }
  .tools #btn-full, .tools #btn-hide { display: none; }
  .shelf { left: 14px; right: 14px; }
  .shelf ul { display: grid; grid-template-columns: 1fr 1fr; }
}

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