:root {
  color-scheme: dark;
  font-family: "Courier New", "Yu Gothic", monospace;
  color: #f2f6f3;
  background: #090c0d;
  font-synthesis: none;
  --decay: 0;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #090c0d; }
button { font: inherit; }

.stage { position: relative; width: 100%; height: 100%; min-height: 500px; overflow: hidden; isolation: isolate; background: #111; }
.fallback, .fallback img, #glitch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fallback img { object-fit: cover; }
#glitch-canvas { z-index: 1; display: block; cursor: crosshair; }
.surface-noise { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .18; background: radial-gradient(circle at 65% 38%, transparent 0 20%, rgba(4,8,9,.16) 73%, rgba(3,5,6,.54) 100%); mix-blend-mode: soft-light; }
.surface-noise::after { content: ""; position: absolute; inset: -20%; opacity: .16; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E"); animation: grain .16s steps(2) infinite; }

.topbar, .status, .coordinates, .interaction-note, .world-dots, .world-arrow, .memory-link { position: absolute; z-index: 3; text-shadow: 0 1px 8px rgba(0,0,0,.32); }
.topbar { top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; padding: 24px 28px; border-bottom: 1px solid rgba(255,255,255,.35); font-size: 12px; line-height: 1.04; letter-spacing: .16em; }
.brand { font-weight: 700; }
.mode { padding-top: 2px; }
.clock { justify-self: end; display: flex; align-items: center; gap: 18px; }
.countdown { color: #e8ff1f; font: 700 25px/1 "Courier New", monospace; letter-spacing: .06em; text-shadow: 0 0 14px rgba(223,255,41,.62); }
.sound-toggle { margin-left: 18px; padding: 4px 7px; border: 1px solid currentColor; color: inherit; background: rgba(8,12,13,.18); font: inherit; font-size: 10px; letter-spacing: .12em; cursor: pointer; }
.sound-toggle:hover, .sound-toggle:focus-visible, .sound-toggle.active { color: #0a0d0d; background: #dfff29; border-color: #dfff29; outline: none; text-shadow: none; }

.status { left: 7vw; top: 42%; width: 62vw; transform: translateY(-50%); }
.eyebrow { margin: 0 0 12px; font-size: 12px; letter-spacing: .18em; }
.world-description { margin: 18px 0 0 3px; max-width: 520px; font-size: 11px; line-height: 1.55; letter-spacing: .115em; text-transform: uppercase; text-shadow: 0 1px 8px rgba(0,0,0,.58); }
.glitch-title { position: relative; display: inline-block; margin: 0; max-width: 100%; color: #f3f6f1; font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif; font-size: clamp(48px, 9.1vw, 156px); line-height: .78; letter-spacing: -.082em; font-weight: 900; white-space: nowrap; isolation: isolate; filter: blur(calc(var(--decay) * .7px)); opacity: calc(1 - var(--decay) * .12); }
.glitch-title::before, .glitch-title::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: calc(var(--decay) * .92); }
.glitch-title::before { color: #65e8f1; transform: translate3d(calc(var(--decay) * -22px), calc(var(--decay) * -5px), 0); clip-path: polygon(0 3%, 100% 3%, 100% 27%, 0 27%, 0 51%, 100% 51%, 100% 64%, 0 64%); mix-blend-mode: screen; }
.glitch-title::after { color: #ff4b72; transform: translate3d(calc(var(--decay) * 28px), calc(var(--decay) * 7px), 0); clip-path: polygon(0 31%, 100% 31%, 100% 48%, 0 48%, 0 69%, 100% 69%, 100% 92%, 0 92%); mix-blend-mode: screen; }
.status.break-1 .glitch-title { clip-path: polygon(0 0, 100% 0, 100% 29%, 96% 29%, 96% 36%, 100% 36%, 100% 100%, 0 100%); }
.status.break-2 .glitch-title { clip-path: polygon(0 0, 100% 0, 100% 22%, 86% 22%, 86% 34%, 100% 34%, 100% 57%, 91% 57%, 91% 71%, 100% 71%, 100% 100%, 0 100%); }
.status.break-3 .glitch-title { clip-path: polygon(0 0, 84% 0, 84% 16%, 100% 16%, 100% 33%, 76% 33%, 76% 43%, 100% 43%, 100% 64%, 89% 64%, 89% 78%, 100% 78%, 100% 100%, 0 100%); }
.stage.world-1 .glitch-title { font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif; font-weight: 900; letter-spacing: -.082em; color: #f3f6f1; }
.stage.world-2 .glitch-title { font-family: Didot, "Bodoni 72", "Times New Roman", serif; font-weight: 700; font-style: italic; letter-spacing: -.045em; color: #ffe7b3; text-shadow: 4px 0 0 rgba(255,36,126,.38), -3px 0 0 rgba(0,238,255,.26), 0 0 24px rgba(255,176,48,.42); }
.stage.world-3 .glitch-title { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -.035em; color: #e3e4da; text-shadow: 0 4px 0 rgba(53,30,12,.82), 0 0 22px rgba(255,108,27,.32); }
.stage.world-4 .glitch-title { padding: .04em .12em .08em .08em; font-family: Impact, "Arial Black", sans-serif; font-weight: 900; letter-spacing: .01em; color: #111; background: rgba(239,239,234,.88); text-shadow: none; }

.memory-link { --memory-hue: 0deg; --memory-tint: #89dbff; right: 9vw; top: 47%; width: clamp(92px, 9vw, 152px); color: inherit; text-decoration: none; transform: translateY(-50%) rotate(4deg); transition: transform .35s ease, filter .35s ease; isolation: isolate; }
.memory-link::before { content: ""; position: absolute; inset: 9% 13% 12%; z-index: -1; border-radius: 12px; background: var(--memory-tint); opacity: .42; filter: blur(13px); mix-blend-mode: screen; }
.memory-link img { display: block; width: 100%; opacity: .79; mix-blend-mode: screen; filter: hue-rotate(var(--memory-hue)) saturate(1.45) brightness(1.16) contrast(.9) drop-shadow(0 18px 22px rgba(0,0,0,.38)); }
.memory-link span { position: absolute; left: 33%; top: 51%; width: 47%; color: #26242b; font: 700 clamp(12px,1.25vw,20px)/1 "Courier New", monospace; text-align: center; text-shadow: none; }
.memory-coming { position: absolute; z-index: 2; left: 6%; top: 39%; width: 102%; padding: 7px 3px 6px; color: #111; background: #f5df21; box-shadow: 0 2px 5px rgba(0,0,0,.26); font: 700 clamp(10px,1.05vw,16px)/1 "Bradley Hand", "Comic Sans MS", cursive; letter-spacing: .015em; text-align: center; text-shadow: none; transform: rotate(-7deg); }
.memory-coming::before, .memory-coming::after { content: ""; position: absolute; inset: 0 auto 0 -4px; width: 7px; background: linear-gradient(135deg,transparent 0 28%,#f5df21 30% 70%,transparent 72%); }
.memory-coming::after { left: auto; right: -4px; transform: scaleX(-1); }
.memory-link small { position: absolute; left: 50%; top: calc(100% + 9px); transform: translateX(-50%); width: max-content; font-size: 10px; letter-spacing: .13em; opacity: .8; }
.memory-link:hover, .memory-link:focus-visible { transform: translateY(-50%) rotate(0) scale(1.12); filter: saturate(1.25) brightness(1.08); outline: none; }
.stage.is-switching .status { animation: title-switch .86s steps(8, end); }
.stage.is-switching .memory-link { animation: memory-switch .86s steps(7, end); }
.stage.is-switching .surface-noise { opacity: .42; }

.world-arrow { top: 50%; width: 52px; height: 86px; border: 0; color: #f6f8f4; background: transparent; font: 200 64px/1 Arial, sans-serif; cursor: pointer; transform: translateY(-50%); opacity: .72; transition: opacity .2s, transform .2s; }
.world-arrow:hover, .world-arrow:focus-visible { opacity: 1; color: #dfff29; outline: none; }
.world-arrow--prev { left: 14px; }
.world-arrow--next { right: 14px; }
.world-arrow--prev:hover { transform: translate(-4px,-50%); }
.world-arrow--next:hover { transform: translate(4px,-50%); }

.coordinates { left: 28px; bottom: 26px; display: flex; gap: 28px; font-size: 11px; letter-spacing: .12em; }
.interaction-note { right: 28px; bottom: 26px; font-size: 11px; letter-spacing: .12em; }
.world-dots { left: 50%; bottom: 26px; display: flex; gap: 9px; transform: translateX(-50%); }
.world-dots i { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.world-dots i.active { background: #dfff29; border-color: #dfff29; box-shadow: 0 0 8px #dfff29; }

.loading { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 18px; background: radial-gradient(circle at 50% 42%,#eff7f8 0,#dbe7ea 48%,#bdcbd0 100%); color: #13191a; font-size: 11px; letter-spacing: .18em; transition: opacity .55s, visibility .55s; }
.loading > span { font-weight: 700; }
.loading-memories { display: flex; align-items: center; justify-content: center; gap: clamp(8px,2vw,28px); min-height: 190px; padding: 12px 4vw; }
.loading-memories figure { position: relative; width: clamp(70px,8vw,124px); margin: 0; opacity: 0; transform: translateY(18px) scale(.86); animation: load-memory .35s steps(5,end) forwards; }
.loading-memories figure:nth-child(1) { animation-delay: .18s; }
.loading-memories figure:nth-child(2) { animation-delay: .82s; }
.loading-memories figure:nth-child(3) { animation-delay: 1.46s; }
.loading-memories figure:nth-child(4) { animation-delay: 2.1s; }
.loading-memories figure::before { content: ""; position: absolute; inset: 12% 10%; border-radius: 12px; background: var(--load-tint); opacity: .34; filter: blur(12px); }
.loading-memories img { display: block; width: 100%; opacity: .82; mix-blend-mode: multiply; filter: hue-rotate(var(--load-hue)) saturate(1.35) brightness(1.08) contrast(.92) drop-shadow(0 13px 11px rgba(25,35,39,.18)); }
.loading-memories b { position: absolute; left: 33%; top: 51%; width: 47%; color: #29282d; font: 700 clamp(10px,1.1vw,16px)/1 "Courier New", monospace; text-align: center; letter-spacing: 0; }
.loading-track { width: min(430px,68vw); height: 2px; overflow: hidden; background: rgba(0,0,0,.15); }
.loading-track::after { content: ""; display: block; width: 100%; height: 100%; background: #111; transform-origin: left; animation: load 2.8s linear forwards; }
.loading > small { font-size: 9px; opacity: .58; }
.loading.hidden { opacity: 0; visibility: hidden; }
.deconstruction { position: absolute; inset: 0; z-index: 8; visibility: hidden; display: grid; place-items: center; pointer-events: none; }
.deconstruction-noise { position: absolute; inset: 0; opacity: 0; background-color: #000; background-image: linear-gradient(90deg,transparent 0 12%,rgba(255,255,255,.05) 12% 12.4%,transparent 12.4% 47%,rgba(255,255,255,.035) 47% 48%,transparent 48%), url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='d'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78 .42' numOctaves='4' seed='17' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23d)' opacity='.62'/%3E%3C/svg%3E"); background-size: auto, 220px 220px; }
.deconstruction-noise::before, .deconstruction-noise::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg,#000 0 7px,transparent 7px 12px); opacity: .76; transform: translateX(-13%); }
.deconstruction-noise::after { background: repeating-linear-gradient(90deg,#000 0 19px,transparent 19px 31px); opacity: .52; transform: translateY(11%); }
.deconstruction-message { position: relative; z-index: 2; max-width: min(880px,88vw); opacity: 0; color: #f1f3ef; text-align: center; }
.deconstruction-message h2 { margin: 0 0 30px; font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif; font-size: clamp(30px,5.3vw,78px); line-height: .9; letter-spacing: -.055em; }
.deconstruction-message button { padding: 15px 22px; border: 1px solid #e8ff1f; color: #e8ff1f; background: rgba(0,0,0,.72); font: 700 12px/1 "Courier New", monospace; letter-spacing: .12em; cursor: pointer; }
.deconstruction-message button span { display: inline-block; margin-right: 7px; font-size: 18px; vertical-align: -2px; }
.deconstruction-message button:hover, .deconstruction-message button:focus-visible { color: #050606; background: #e8ff1f; outline: none; }
.deconstruction.active { visibility: visible; pointer-events: auto; }
.deconstruction.active .deconstruction-noise { animation: noise-takeover .92s steps(9,end) forwards, dead-signal .12s steps(2,end) .92s infinite; }
.deconstruction.active .deconstruction-message { animation: end-message .4s steps(5,end) 1.02s forwards; }

@keyframes grain { 0% { transform: translate3d(-3%,2%,0); } 25% { transform: translate3d(4%,-3%,0); } 50% { transform: translate3d(-2%,4%,0); } 75% { transform: translate3d(3%,2%,0); } 100% { transform: translate3d(-4%,-2%,0); } }
@keyframes load { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes load-memory { 0% { opacity: 0; transform: translateY(18px) scale(.86); filter: blur(5px); } 55% { opacity: .62; transform: translate(-5px,2px) scale(1.05,.94); filter: blur(1px); } 100% { opacity: 1; transform: none; filter: none; } }
@keyframes noise-takeover { 0% { opacity: 0; clip-path: inset(49% 0 49% 0); } 22% { opacity: .42; clip-path: inset(8% 0 63% 0); } 47% { opacity: .73; clip-path: inset(31% 0 9% 0); } 71% { opacity: .9; clip-path: inset(4% 0 15% 0); } 100% { opacity: 1; clip-path: inset(0); } }
@keyframes dead-signal { 0% { background-position: 0 0,0 0; filter: contrast(1.2); } 50% { background-position: 17px -9px,31px -18px; filter: contrast(1.7); } 100% { background-position: -13px 8px,-19px 23px; filter: contrast(1.35); } }
@keyframes end-message { from { opacity: 0; transform: translate(16px,-7px); filter: blur(7px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes title-switch {
  0% { transform: translateY(-50%); clip-path: inset(0); }
  14% { transform: translate(-18px,-53%); clip-path: inset(0 0 68% 0); }
  29% { transform: translate(24px,-47%); clip-path: inset(24% 0 31% 0); }
  43% { transform: translate(-34px,-51%); clip-path: inset(57% 0 8% 0); }
  58% { transform: translate(29px,-49%); clip-path: inset(10% 0 49% 0); }
  72% { transform: translate(-12px,-52%); clip-path: inset(43% 0 18% 0); }
  86% { transform: translate(7px,-48%); clip-path: inset(5% 0 5% 0); }
  100% { transform: translateY(-50%); clip-path: inset(0); }
}
@keyframes memory-switch {
  0%, 100% { transform: translateY(-50%) rotate(4deg); }
  18% { transform: translate(-19px,-56%) rotate(-12deg) scaleX(.73); }
  37% { transform: translate(14px,-43%) rotate(15deg) scaleY(.66); }
  58% { transform: translate(-8px,-52%) rotate(-7deg) scale(1.18,.84); }
  79% { transform: translate(11px,-48%) rotate(10deg) scale(.91,1.08); }
}

@media (max-width: 760px) {
  .stage { min-height: 420px; }
  .topbar { grid-template-columns: 1fr 1fr; padding: 16px 18px; }
  .mode { display: none; }
  .clock { display: flex; align-items: flex-start; gap: 7px; }
  .sound-toggle { margin-left: 0; }
  .status { left: 13vw; top: 35%; width: 76vw; }
  .glitch-title { font-size: clamp(40px, 13vw, 74px); white-space: normal; overflow-wrap: anywhere; }
  .memory-link { right: 50%; top: 68%; width: 82px; transform: translate(50%,-50%) rotate(4deg); }
  .memory-link:hover, .memory-link:focus-visible { transform: translate(50%,-50%) scale(1.08); }
  .world-arrow { width: 42px; font-size: 52px; }
  .coordinates { left: 18px; bottom: 18px; flex-direction: column; gap: 2px; font-size: 9px; }
  .interaction-note { display: none; }
  .world-dots { bottom: 18px; }
  .loading-memories { min-height: 130px; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .surface-noise::after { animation: none; }
}
