:root {
  --ink: #f3efe6;
  --dim: rgba(243, 239, 230, 0.55);
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0a09;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}

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

/* HUD: museum wall-label, fades when the cursor rests */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: difference;
  transition: opacity 1.2s ease;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.hud.idle { opacity: 0; }

.mark {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  font: 400 22px/1 var(--serif);
  letter-spacing: 0.01em;
}
.mark span { font-style: italic; }

.label {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  margin: 0;
  display: grid;
  gap: 4px;
  max-width: min(70vw, 420px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.label.swap { opacity: 0; transform: translateY(6px); }
.label .title { font: italic 400 26px/1.05 var(--serif); }
.label .medium { font: 400 11px/1.4 var(--mono); color: var(--dim); }

.index {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: 8px;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.2em;
  color: var(--dim);
}
.bar { width: 88px; height: 1px; background: rgba(243, 239, 230, 0.25); }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); }

@media (max-width: 520px) {
  .label .title { font-size: 21px; }
  .bar { width: 56px; }
}

/* corner controls: about + sound */
.ctls {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  gap: 4px;
}
.ctl {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(243, 239, 230, 0.35);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font: italic 400 19px/1 var(--serif);
  cursor: pointer;
  transition: border-color 0.3s ease, transform 0.3s ease;
}
.ctl:hover { border-color: var(--ink); transform: scale(1.06); }
.ctl:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.ctl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.ctl .spk { fill: currentColor; stroke: none; }
.ctl .x { display: none; }
#sound[aria-pressed='false'] .wave { display: none; }
#sound[aria-pressed='false'] .x { display: inline; }

/* about */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  background: #f1eee7;
  color: #151312;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
dialog::backdrop { background: rgba(8, 7, 6, 0.55); backdrop-filter: blur(6px); }
dialog[open] { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.about-inner { padding: 32px 32px 28px; }
.about-no { margin: 0 0 6px; font: 400 11px/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; color: #8a847a; }
dialog h1 { margin: 0 0 18px; font: 400 48px/1 var(--serif); }
dialog h1 em { color: #b3261e; }
dialog p { margin: 0 0 14px; font: 400 19px/1.4 var(--serif); }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 20px 0 24px; font: 400 12px/1.5 var(--mono); }
dialog dt { color: #8a847a; }
dialog dd { margin: 0; }
.close {
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.08em;
  padding: 12px 16px;
  border: 1px solid #151312;
  background: transparent;
  color: #151312;
  cursor: pointer;
}
.close:hover { background: #151312; color: #f1eee7; }

/* the object in your hand */
.own-cursor, .own-cursor * { cursor: none !important; }
.own-cursor .ctl, .own-cursor dialog, .own-cursor dialog * { cursor: pointer !important; }
.cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 5;
  color: #f3efe6;
  mix-blend-mode: difference;
  transition: opacity 0.4s ease;
  will-change: transform;
}
.cursor[data-shape='lamp'], .cursor[data-shape='bead'], .cursor[data-shape='drop'], .cursor[data-shape='lens'] { mix-blend-mode: normal; }
.cursor svg { display: block; overflow: visible; }
.cursor .verb {
  position: absolute;
  left: 34px;
  top: 30px;
  white-space: nowrap;
  font: italic 400 15px/1 var(--serif);
  color: #f3efe6;
  mix-blend-mode: difference;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.cursor .verb.show, .touch-hint.show { opacity: 0.85; transform: none; }
.touch-hint {
  position: fixed;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  translate: -50% 0;
  font: italic 400 16px/1 var(--serif);
  color: #f3efe6;
  mix-blend-mode: difference;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1s ease, transform 1s ease;
}
.own-cursor .touch-hint { display: none; }
dialog[open] ~ .cursor { opacity: 0 !important; }

#tilt[aria-pressed='false'] .wave { opacity: 0.35; }
#tilt[aria-pressed='true'] { border-color: var(--ink); }

/* an invitation to sound, gone after a few seconds */
.sound-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  padding: 10px 18px;
  border: 1px solid rgba(243, 239, 230, 0.35);
  border-radius: 999px;
  font: italic 400 17px/1 var(--serif);
  color: #f3efe6;
  background: rgba(10, 9, 8, 0.35);
  backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 1.2s ease, transform 1.2s ease;
  z-index: 4;
}
.sound-hint.show { opacity: 1; transform: none; }

