:root {
  --paper: #d5d5d0;
  --ink: #11110f;
  --muted: rgba(17, 17, 15, 0.54);
  --hairline: rgba(17, 17, 15, 0.22);
  --safe-x: clamp(18px, 3.1vw, 54px);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
html { overscroll-behavior: none; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  cursor: none;
}
button, a { color: inherit; }
a { text-decoration: none; }

.ambient,
.ambient::before,
.ambient::after {
  position: fixed;
  inset: -12%;
  pointer-events: none;
}
.ambient {
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 24%, rgba(255,255,255,.76), transparent 34%),
    radial-gradient(circle at 84% 68%, rgba(45,45,41,.15), transparent 40%),
    radial-gradient(circle at 52% 42%, rgba(255,255,255,.22), transparent 48%),
    linear-gradient(118deg, #e7e7e2 0%, #c9c9c3 47%, #deded9 100%);
}
.ambient::before {
  content: '';
  background:
    radial-gradient(ellipse at 36% 60%, rgba(0,0,0,.11), transparent 42%),
    radial-gradient(ellipse at 68% 36%, rgba(255,255,255,.48), transparent 42%);
  filter: blur(44px);
  animation: ambientDrift 17s ease-in-out infinite alternate;
}
.ambient::after {
  content: '';
  opacity: .16;
  background: repeating-linear-gradient(110deg, transparent 0 90px, rgba(0,0,0,.025) 91px 92px);
  animation: ambientSlide 22s linear infinite;
}

#webgl,
#grain {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
#webgl { z-index: 2; touch-action: none; isolation: isolate; }
#grain {
  z-index: 6;
  pointer-events: none;
  opacity: .16;
  image-rendering: pixelated;
  mix-blend-mode: soft-light;
}

.topbar {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  width: 100%;
  padding: 24px var(--safe-x);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}
.brand {
  pointer-events: auto;
  display: grid;
  gap: 5px;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 700;
}
.brand small,
.instructions {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .14em;
}
.topbar-tools {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}
.instructions { padding-top: 2px; }
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 9px/1 Arial, Helvetica, sans-serif;
  letter-spacing: .14em;
  cursor: none;
  transition: color .2s ease, opacity .2s ease;
}
.sound-toggle:hover { color: var(--ink); }
.sound-toggle i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 rgba(17,17,15,.22);
  animation: soundPulse 2.8s ease-out infinite;
}
.sound-toggle.is-muted { opacity: .5; }
.sound-toggle.is-muted i {
  background: transparent;
  border: 1px solid currentColor;
  animation: none;
}
kbd {
  border: 0;
  font: inherit;
  color: var(--ink);
}

.interface { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
.caption {
  position: absolute;
  left: 50%;
  bottom: clamp(48px, 7vh, 82px);
  width: min(680px, calc(100vw - 150px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.counter {
  padding-top: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .12em;
}
.counter i { height: 1px; background: var(--hairline); }
.caption-copy {
  transition: opacity .2s ease, transform .28s cubic-bezier(.2,.75,.2,1);
}
.caption-copy.is-changing { opacity: 0; transform: translateY(8px); }
.meta-line {
  min-height: 14px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .15em;
}
h1 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  font-size: clamp(28px, 3vw, 48px);
  line-height: .98;
  letter-spacing: -.035em;
}
#description {
  max-width: 530px;
  margin: 13px 0 0;
  color: rgba(17,17,15,.68);
  font-size: 11px;
  line-height: 1.55;
  letter-spacing: .015em;
}
.controls {
  position: absolute;
  right: var(--safe-x);
  bottom: clamp(48px, 7vh, 82px);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.controls button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  font-size: 17px;
  cursor: none;
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
}
.controls button:hover { background: rgba(255,255,255,.55); border-color: rgba(17,17,15,.48); transform: scale(1.04); }
.controls button:disabled { opacity: .24; transform: none; }
.progress {
  position: absolute;
  left: var(--safe-x);
  right: var(--safe-x);
  bottom: 22px;
  height: 1px;
  background: rgba(17,17,15,.13);
  overflow: hidden;
}
.progress span {
  display: block;
  width: 10%;
  height: 100%;
  background: var(--ink);
  transform-origin: left center;
  transition: width .5s cubic-bezier(.2,.75,.2,1);
}

.cursor {
  position: fixed;
  z-index: 30;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(17,17,15,.5);
  border-radius: 50%;
  transform: translate(-100px,-100px);
  pointer-events: none;
  display: grid;
  place-items: center;
  transition: width .2s ease, height .2s ease, background .2s ease, border-color .2s ease;
}
.cursor::after {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
}
.cursor span {
  display: none;
  font-size: 8px;
  letter-spacing: .12em;
}
.cursor.is-open {
  width: 72px;
  height: 72px;
  background: rgba(229,229,224,.72);
  border-color: transparent;
  backdrop-filter: blur(4px);
}
.cursor.is-open::after { display: none; }
.cursor.is-open span { display: block; }
.cursor.is-down { transform-origin: center; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #d5d5d0;
  display: grid;
  place-content: center;
  gap: 16px;
  text-align: center;
  transition: opacity .7s ease, visibility .7s ease;
}
.loading span { font-size: 9px; letter-spacing: .18em; }
.loading i { width: 150px; height: 1px; background: rgba(0,0,0,.15); overflow: hidden; }
.loading i::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: #111;
  animation: loader 1.2s ease-in-out infinite;
}
.loading.is-hidden { opacity: 0; visibility: hidden; }
.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -40%);
  padding: 12px 16px;
  background: rgba(17,17,15,.9);
  color: #eee;
  font-size: 10px;
  letter-spacing: .08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, -50%); }

@keyframes ambientDrift {
  from { transform: translate3d(-2%, -2%, 0) scale(1); }
  to { transform: translate3d(4%, 3%, 0) scale(1.08); }
}
@keyframes ambientSlide { to { transform: translate3d(110px, -60px, 0); } }
@keyframes soundPulse {
  0%, 72% { box-shadow: 0 0 0 0 rgba(17,17,15,.18); }
  100% { box-shadow: 0 0 0 7px rgba(17,17,15,0); }
}
@keyframes loader {
  0% { transform: translateX(-110%); }
  50% { transform: translateX(90%); }
  100% { transform: translateX(280%); }
}

@media (max-width: 760px) {
  :root { --safe-x: 18px; }
  body { cursor: auto; }
  .cursor { display: none; }
  .topbar { padding-top: 18px; }
  .instructions { display: none; }
  .topbar-tools { gap: 0; }
  .sound-toggle { font-size: 8px; }
  .caption {
    left: var(--safe-x);
    right: var(--safe-x);
    bottom: 54px;
    width: auto;
    transform: none;
    grid-template-columns: 48px minmax(0,1fr);
    gap: 14px;
  }
  h1 { font-size: clamp(28px, 9vw, 42px); }
  #description { font-size: 10px; line-height: 1.45; margin-top: 9px; }
  .controls { right: var(--safe-x); bottom: 16px; }
  .controls button { width: 34px; height: 34px; }
  .progress { left: var(--safe-x); right: 110px; bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .ambient::before, .ambient::after, .loading i::after,
  .sound-toggle i { animation: none !important; }
  #grain { display: none; }
  * { scroll-behavior: auto !important; }
}
