* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: #000; }
html, body { height: 100%; }
body {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--text, #d6cbb2);
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

:root {
  --gap: 0px;
}

.stage {
  position: relative;
  width: min(calc(100vw - 2 * var(--gap)), calc((100dvh - 2 * var(--gap)) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg, #050607);
}

.world { position: absolute; inset: 0; transform-origin: 50% 60%; animation: arrive 2.4s ease-out; }
@keyframes arrive { from { opacity: 0; } }

.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }

.glow {
  position: absolute;
  width: var(--size, 14%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--glow, #ffb45a) 60%, transparent) 0%, transparent 62%);
  mix-blend-mode: screen;
  pointer-events: none;
  transition: opacity .14s linear, transform .14s linear;
}

.glow.core {
  background: radial-gradient(circle, rgba(255, 238, 196, .9) 0%, rgba(255, 205, 125, .38) 34%, transparent 66%);
}

.fog {
  position: absolute;
  left: 0; right: 0;
  height: 55%;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1200' height='400'><filter id='f' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='0.004 0.012' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.75  0 0 0 0 0.82  0 0 0 0 0.85  0 0 0 1.6 -0.55'/></filter><rect width='1200' height='400' filter='url(%23f)'/></svg>");
  background-size: 1200px 100%;
  background-repeat: repeat-x;
  opacity: var(--haze, .3);
  mix-blend-mode: screen;
  -webkit-mask-image: linear-gradient(transparent, #000 40%, #000 60%, transparent);
  mask-image: linear-gradient(transparent, #000 40%, #000 60%, transparent);
}
.fog.low  { bottom: 0;   animation: drift 140s linear infinite; }
.fog.high { bottom: 14%; animation: drift 220s linear infinite reverse; opacity: calc(var(--haze, .3) * .6); }
@keyframes drift { to { background-position-x: -1200px; } }

.speck {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--glow, #ffb45a);
  opacity: 0;
  pointer-events: none;
  animation: float var(--t, 18s) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes float {
  0%   { opacity: 0;  transform: translate(0, 0); }
  30%  { opacity: calc(var(--haze, .3) * 1.4); }
  100% { opacity: 0;  transform: translate(var(--x, 30px), -90px); }
}

.veil { position: absolute; inset: 0; pointer-events: none; }
.vignette { background: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(0,0,0,var(--vignette, .55)) 100%); }
.grain {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
  opacity: var(--grain, .14);
}
.blackout { background: #000; opacity: 0; transition: opacity 1.1s ease-in; }

.threshold {
  display: none;
  max-width: 24ch;
  padding: 2rem;
  text-align: center;
  line-height: 1.6;
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text, #d6cbb2);
}
@media (orientation: portrait) and (max-width: 800px) {
  .stage { display: none; }
  .threshold { display: block; }
}

.slot {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  padding: 4%;
  background: linear-gradient(#0a0b0d, #101215);
  border: 1px solid color-mix(in srgb, var(--accent, #b08d4a) 45%, transparent);
  color: color-mix(in srgb, var(--text, #d6cbb2) 70%, transparent);
  line-height: 1.7;
}
.slot b { display: block; font-weight: normal; font-size: 1.5em; color: var(--text, #d6cbb2); margin-bottom: .4em; }

@media (prefers-reduced-motion: reduce) {
  .world, .fog, .speck { animation: none; }
  .blackout { transition-duration: .3s; }
}
[hidden] { display: none !important; }

.sound-toggle {
  position: absolute;
  right: 2.2%; bottom: 4%;
  width: clamp(34px, 3.2vw, 46px);
  aspect-ratio: 1;
  display: grid; place-items: center;
  background: transparent;
  border: 0;
  color: var(--accent, #b08d4a);
  opacity: .55;
  cursor: pointer;
  transition: opacity .4s;
}
.sound-toggle:hover, .sound-toggle:focus-visible { opacity: 1; }
.sound-toggle:focus-visible { outline: 1px solid var(--accent, #b08d4a); outline-offset: 2px; }
.sound-toggle svg { width: 62%; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .w { display: none; }
.sound-toggle.on .w { display: inline; }
.sound-toggle.on .x { display: none; }
.stage.opening .sound-toggle, .stage.leaving .sound-toggle { opacity: 0; pointer-events: none; }

:root {
  --spot-warm: 1;
  --spot-warm-color: #ffaa50;
  --spot-lift: 0;
  --spot-edge: .75;
  --spot-cool: 0;
  --spot-edge-color: #e8dcc0;
  --spot-cool-color: #9db6e6;
  --spot-draw-start: 0;
}

.hot { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hot .spot { outline: none; }
.hot .hit { fill: transparent; pointer-events: all; cursor: pointer; }
.hot .warm, .hot .lift, .hot .edge, .hot .cool { pointer-events: none; opacity: 0; }
.hot .warm {
  fill: color-mix(in srgb, var(--spot-warm-color) 14%, transparent);
  stroke: color-mix(in srgb, var(--spot-warm-color) 55%, transparent);
  stroke-width: 10; filter: blur(5px); transition: opacity .5s ease;
}
.hot .lift { fill: #fff; mix-blend-mode: soft-light; transition: opacity .6s ease; }
.hot .edge {
  fill: none; stroke: var(--spot-edge-color); stroke-width: 3; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: var(--spot-draw-start);
  transition: opacity .5s ease, stroke-dashoffset .8s ease;
}
.hot .cool { fill: none; stroke: var(--spot-cool-color); stroke-width: 20; filter: blur(9px); transition: opacity .6s ease; }
.hot .spot:hover .warm, .hot .spot:focus-visible .warm { opacity: var(--spot-warm); }
.hot .spot:hover .lift, .hot .spot:focus-visible .lift { opacity: var(--spot-lift); }
.hot .spot:hover .edge, .hot .spot:focus-visible .edge { opacity: var(--spot-edge); stroke-dashoffset: 0; }
.hot .spot:hover .cool, .hot .spot:focus-visible .cool { opacity: var(--spot-cool); }
