body[data-broken] {
  --page: color-mix(in srgb, #180b0a, #090302 var(--timeline-depth));
  --panel: color-mix(in srgb, #231313, #190b0a var(--timeline-depth));
  --inset: color-mix(in srgb, #382020, #2b1210 var(--timeline-depth));
  --stroke: color-mix(in srgb, #55312d, #55221e var(--timeline-depth));
  --accent: color-mix(in srgb, #ff9d94, #ff766e var(--timeline-depth));
  --frame: color-mix(in srgb, #492523, #361615 var(--timeline-depth));
  --text: #fff1ee;
  --muted: #d7b9b4;
  background:
    radial-gradient(ellipse at 32% 12%, color-mix(in srgb, #c12620, transparent 88%), transparent 56%),
    radial-gradient(ellipse at 98% 65%, color-mix(in srgb, #992713, transparent 93%), transparent 48%),
    var(--page);
}

body[data-stage="1000"] {
  --page: #060101;
  --panel: #160808;
  --inset: #290e0d;
  --stroke: #5b211b;
  --accent: #ff6b60;
  --frame: #331010;
}

#title {
  position: relative;
  isolation: isolate;
  width: fit-content;
  max-width: 100%;
}

.title-distortion {
  display: none;
  position: absolute;
  inset: 0;
  z-index: -1;
  clip-path: inset(-8px -12px -15px);
  pointer-events: none;
  user-select: none;
}

body[data-title-decay] .title-distortion {
  --echo-x: calc(-1px - 5px * var(--ui-decay-depth));
  --slice-x: calc(1px + 9px * var(--ui-decay-depth));
  display: block;
}

.title-echo, .title-slices {
  position: absolute;
  inset: 0;
}
.title-distortion em { color: inherit; }
.title-echo {
  color: #bf2522;
  text-shadow: -.06em .025em .06em #7c0c08;
  opacity: calc(.11 + .47 * var(--ui-decay-depth));
  transform: translate(var(--echo-x), calc(var(--ui-decay-depth) * 3px));
}
.title-slices {
  color: #f75b4c;
  opacity: clamp(0, calc((var(--ui-decay-depth) - .13) * .86), .74);
  clip-path: polygon(0 13%, 100% 18%, 100% 27%, 0 23%, 0 39%, 100% 36%, 100% 54%, 0 50%, 0 68%, 100% 64%, 100% 78%, 0 82%);
  transform: translateX(var(--slice-x));
}

.title-distortion::before {
  content: "";
  position: absolute;
  inset: 81% 0 auto;
  height: calc(4px + 18px * var(--ui-decay-depth));
  opacity: clamp(0, calc((var(--ui-decay-depth) - .22) * 1.15), .87);
  background:
    radial-gradient(ellipse at top, #ad211a 25%, #9c1511 51%, transparent 69%) 9% 0 / 3px 74%,
    radial-gradient(ellipse at top, #e83c2d 17%, #991813 50%, transparent 72%) 26% 0 / 2px 55%,
    radial-gradient(ellipse at top, #ce2a1e 22%, #881312 50%, transparent 72%) 37% 0 / 5px 100%,
    radial-gradient(ellipse at top, #d83727 20%, #850f0e 48%, transparent 68%) 64% 0 / 2px 88%,
    radial-gradient(ellipse at top, #d63224 25%, #ac1f19 50%, transparent 72%) 83% 0 / 5px 77%,
    radial-gradient(ellipse at top, #e74936 17%, #9b1a14 52%, transparent 72%) 95% 0 / 3px 64%;
  background-repeat: no-repeat;
}

.title-distortion::after {
  content: "";
  position: absolute;
  inset: 5% -.09em 3%;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #d94c331e 3px 4px);
  mask-image: linear-gradient(90deg, transparent, #000 22% 77%, transparent);
  opacity: clamp(0, calc((var(--ui-decay-depth) - .3) * 1.5), 1);
}

.title-scan {
  position: absolute;
  inset: 0 0 auto;
  height: .16em;
  background: linear-gradient(180deg, transparent, #fd6d52 52%, transparent);
  mask-image: linear-gradient(90deg, transparent 3%, #000 19% 72%, transparent 96%);
  opacity: 0;
}

body[data-timeline-bands] :is(.intro p, #checkpoint-description, #history-empty) {
  text-shadow: calc(.3px + .55px * var(--ui-decay-depth)) 0 1px #e244376b;
}

.panel-cracks { display: none; pointer-events: none; }
body[data-panel-cracks] .sidebar > .panel {
  position: relative;
  isolation: isolate;
}
body[data-panel-cracks] .panel-cracks {
  display: block;
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  opacity: calc(.08 + .84 * var(--ui-decay-depth));
}

@media (prefers-reduced-motion: no-preference) {
  body[data-title-scan] .title-scan { animation: title-scan 18s ease-in-out infinite; }
  body[data-rewinding][data-title-decay] .title-slices { animation: title-split 1s ease-out both; }
}

@keyframes title-scan {
  0%, 84% { transform: translateY(0); opacity: 0; }
  88% { opacity: .19; }
  96% { opacity: .19; }
  100% { transform: translateY(.8em); opacity: 0; }
}

@keyframes title-split {
  0%, 100% { transform: translateX(var(--slice-x)); }
  37% { transform: translate(calc(var(--slice-x) + var(--ui-decay-depth) * 10px), -2px) skewX(-8deg); }
  69% { transform: translate(calc(var(--slice-x) - var(--ui-decay-depth) * 6px), 1px) skewX(3deg); }
}

/* At rest the scanlines stay in the frame, outside the squares. */
body[data-broken] .board-shell::after {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: 2;
  border: 7px solid transparent;
  border-radius: inherit;
  background: repeating-linear-gradient(0deg, #ff8f7f 0 1px, transparent 1px 4px) border-box;
  mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: var(--timeline-scan);
  pointer-events: none;
}

.timeline-rifts, .timeline-echoes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.timeline-milestone {
  position: relative;
  width: fit-content;
  padding: 5px 8px;
  color: #ffece5;
  background: #290b09d9;
  border: 1px solid #f39a8f7d;
  border-radius: 4px;
  font: clamp(9px, 1.5vw, 12px) var(--mono);
  letter-spacing: .12em;
}

.timeline-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.decay-surface { display: none; pointer-events: none; }
body[data-broken] .decay-surface {
  display: block;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: min(1, calc(.07 + var(--satella-depth) * .93));
}
#decay-room { position: fixed; z-index: 0; }
#decay-board {
  position: absolute;
  z-index: 3;
  mask-image: radial-gradient(ellipse at 50% 49%, transparent 46%, #0002 61%, #000 95%);
}

body[data-broken] .rewind-effect {
  background:
    repeating-linear-gradient(0deg, #f4817028 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 45% 43%, #601b16e8, #190a0aeb 63%, #0c0403f5 100%);
}
body[data-broken] .rewind-effect > .icon,
body[data-broken] #rewind-label { position: relative; }
body[data-timeline-split] #rewind-label {
  text-shadow: -2px 0 #cf241f, 2px 0 #ff8568;
}
body[data-timeline-split] .rewind-effect.active .timeline-rifts::before,
body[data-timeline-split] .rewind-effect.active .timeline-rifts::after {
  content: "";
  position: absolute;
  inset: 7% 5%;
  border: 2px solid #ff3b39;
  box-shadow: inset 14px 0 18px -18px #ff6056, 0 0 14px #ff453c70;
  animation: timeline-rift 1s both;
}
body[data-timeline-split] .rewind-effect.active .timeline-rifts::after {
  border-color: #ff8568;
  box-shadow: inset -14px 0 18px -18px #ff8e74, 0 0 14px #ff8b6d80;
  --rift-direction: -1;
}
body[data-timeline-bands] .rewind-effect.active .timeline-rifts::before,
body[data-timeline-bands] .rewind-effect.active .timeline-rifts::after {
  inset: 0 2%;
  background: linear-gradient(100deg, #ff3d316f, transparent 42%, #b7372066 100%);
  mask-image: linear-gradient(0deg, #000 0 2%, transparent 2% 18%, #000 18% 23%, transparent 23% 45%, #000 45% 48%, transparent 48% 68%, #000 68% 74%, transparent 74% 87%, #000 87% 91%, transparent 91% 98%, #000 98%);
}

.timeline-echo {
  position: absolute;
  inset: 7% 6%;
  width: 88%;
  height: 86%;
  animation: timeline-echo 1s both;
  mix-blend-mode: screen;
}
.timeline-echo:nth-child(2) {
  inset: 13% 2%;
  width: 96%;
  height: 74%;
  --echo-direction: -1;
  --echo-alpha: .25;
  mask-image: repeating-linear-gradient(0deg, #000 0 10%, transparent 10% 18%);
}
.timeline-echo:nth-child(3) {
  inset: 4% 10%;
  width: 80%;
  height: 92%;
  --echo-alpha: .16;
  mask-image: repeating-linear-gradient(0deg, transparent 0 16%, #000 16% 24%);
}

.history-panel { position: relative; overflow: hidden; }
.timeline-history {
  position: absolute;
  inset: auto 8px 10px;
  display: grid;
  gap: 4px;
  padding: 5px 12px;
  color: #ffad9b;
  text-shadow: 2px 0 #e95f42, -2px 0 #c9241e;
  font: 12px/1.5 var(--mono);
  pointer-events: none;
}
.timeline-history:empty { display: none; }
.history-panel:has(.history-controls:not([hidden])) .timeline-history { bottom: 48px; }
body[data-timeline-rewinding] .timeline-history { animation: timeline-history-back 1s both; }
body[data-stage="1000"] .rewind-effect.active .timeline-echo,
body[data-stage="1000"] .rewind-effect.active .timeline-rifts::before,
body[data-stage="1000"] .rewind-effect.active .timeline-rifts::after {
  animation-name: timeline-realign;
}

@keyframes timeline-rift {
  0%, 100% { opacity: 0; transform: none; }
  27% { opacity: .58; transform: translateX(calc(var(--timeline-offset) * var(--rift-direction, 1))) skewX(-3deg); }
  63% { opacity: .42; transform: translateX(calc(var(--timeline-offset) * var(--rift-direction, 1) * -.65)); }
}
@keyframes timeline-echo {
  0%, 100% { opacity: 0; transform: none; }
  32% { opacity: var(--echo-alpha, .34); transform: translateX(calc(var(--timeline-offset) * var(--echo-direction, 1))) skewX(-5deg); }
  68% { opacity: .14; transform: translate(-2%, 1%); }
}
@keyframes timeline-history-back {
  0%, 100% { opacity: 0; transform: none; }
  28% { opacity: .55; transform: translate(11px, 7px); }
  70% { opacity: .26; transform: translate(-6px, -16px); }
}
@keyframes timeline-realign {
  0%, 100% { opacity: 0; transform: none; }
  33% { opacity: var(--echo-alpha, .42); transform: translateX(calc(var(--timeline-offset) * var(--rift-direction, 1) * var(--echo-direction, 1))) skewX(-8deg) scale(1.04); }
  61% { opacity: .23; transform: translateX(-5px) skewX(2deg); }
  74% { opacity: .14; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .timeline-rifts, .timeline-echoes, .timeline-history { display: none; }
  .rewind-effect.active { animation: rewind-overlay .55s both; }
}
