@font-face {
  font-family: "Galmuri14";
  src: url("/fonts/Galmuri14.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

:root {
  color-scheme: dark;
  --red: #ff0000;
  --text-size: clamp(24px, 4.9vw, 90px);
  font-family: "Galmuri14", monospace;
  font-synthesis: none;
  background: #000;
  color: var(--red);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: #000; }
body { overflow-x: hidden; }
::selection { background: var(--red); color: #000; }

.stage {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  padding: 48px clamp(24px, 6vw, 96px);
  isolation: isolate;
}

.narrative { width: 100%; font-size: var(--text-size); font-weight: 400; letter-spacing: .012em; line-height: 1.8; }
.ending { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.5svh, 26px); margin: 0; width: 100%; }
.medusa { display: block; width: min(82vw, 70svh, 740px); height: auto; max-height: 70svh; object-fit: contain; image-rendering: pixelated; }
.ending-caption { margin: 0; color: var(--red); font-size: clamp(24px, 3vw, 45px); letter-spacing: .012em; line-height: 1.45; text-align: center; white-space: nowrap; }
.line { margin: 0; min-height: 1.8em; white-space: nowrap; }
.line:empty { visibility: hidden; }
.word { display: inline-block; position: relative; }
.word.glitching { animation: tear .42s steps(1, end) both; }
.word.glitching::before, .word.glitching::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: #ff7277;
  opacity: .85;
}
.word.glitching::before { clip-path: inset(16% 0 58% 0); animation: slice-top .42s steps(1, end) both; }
.word.glitching::after { color: #b00000; clip-path: inset(58% 0 19% 0); animation: slice-bottom .42s steps(1, end) both; }
.line.appearing { animation: appear .3s ease-out both; }

.stage.screen-tearing { animation: screen-tear .56s steps(1, end) both; }
.screen-glitch {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  overflow: hidden;
  background: repeating-linear-gradient(0deg, transparent 0 5px, rgb(255 0 0 / .32) 5px 6px);
  animation: screen-noise .56s linear both;
}
.screen-glitch::before, .screen-glitch::after {
  content: '';
  position: absolute;
  inset: -24px;
  background: repeating-linear-gradient(0deg, transparent 0 29px, #ff0000 29px 34px, transparent 34px 91px, #600000 91px 110px, transparent 110px 139px);
  clip-path: inset(14% 0 64% 0);
  animation: screen-bands .56s steps(1, end) both;
}
.screen-glitch::after { transform: scaleY(-1); animation-direction: reverse; opacity: .7; }

@keyframes tear {
  0%, 100% { transform: none; opacity: 1; text-shadow: none; }
  8% { transform: translate(-6px, 0); text-shadow: 9px 0 #920000; }
  20% { transform: translate(7px, 2px) skewX(-5deg); }
  30% { transform: translate(-3px, 0); opacity: .5; }
  42% { transform: translate(6px, -2px); text-shadow: -8px 0 #ff7277; }
  55% { transform: translate(-7px, 0); }
  69% { transform: translate(4px, 0); opacity: .8; }
  82% { transform: translate(-2px, 0); }
}
@keyframes slice-top {
  0%, 100% { transform: none; opacity: 0; }
  8%, 30% { transform: translate(14px, -2px); opacity: 1; }
  20%, 55% { transform: translate(-11px, 0); opacity: .85; }
  42%, 69% { transform: translate(9px, 0); opacity: .95; }
  82% { transform: translate(-4px, 0); opacity: .5; }
}
@keyframes slice-bottom {
  0%, 100% { transform: none; opacity: 0; }
  8%, 42% { transform: translate(-13px, 2px); opacity: .95; }
  20%, 69% { transform: translate(11px, 0); opacity: .85; }
  30%, 55% { transform: translate(-8px, 2px); opacity: 1; }
  82% { transform: translate(4px, 0); opacity: .5; }
}
@keyframes screen-tear {
  0%, 100% { transform: none; filter: none; }
  8% { transform: translate(-14px, 3px) skewX(-1deg); filter: contrast(1.7); }
  24% { transform: translate(11px, -2px) skewX(1.4deg); }
  42% { transform: translate(-7px, 1px); filter: contrast(1.35); }
  66% { transform: translate(5px, 0); }
  84% { transform: translate(-2px, 0); }
}
@keyframes screen-noise { 0% { opacity: .85; } 45% { opacity: .65; } 80% { opacity: .3; } 100% { opacity: 0; } }
@keyframes screen-bands {
  0% { clip-path: inset(14% 0 64% 0); }
  18% { clip-path: inset(57% 0 22% 0); }
  38% { clip-path: inset(31% 0 48% 0); }
  64% { clip-path: inset(75% 0 8% 0); }
  82% { clip-path: inset(6% 0 78% 0); }
  100% { clip-path: inset(100% 0 0 0); }
}
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 1800px) { .stage { padding-left: max(96px, calc((100vw - 1600px) / 2)); padding-right: max(96px, calc((100vw - 1600px) / 2)); } }
@media (max-width: 600px) {
  .stage { padding: 32px 24px; }
  .narrative { line-height: 1.85; }
  .line { min-height: 1.85em; }
}
@media (max-height: 440px) and (orientation: landscape) {
  .stage { padding-top: 24px; padding-bottom: 24px; }
  .narrative { font-size: min(var(--text-size), 10vh); line-height: 1.5; }
  .line { min-height: 1.5em; }
}
@media (prefers-reduced-motion: reduce) {
  .word.glitching, .word.glitching::before, .word.glitching::after,
  .line.appearing { animation: none !important; }
  .word.glitching::before, .word.glitching::after { display: none; }
  .stage.screen-tearing { animation: none !important; }
  .screen-glitch { display: none !important; }
}
