:root {
  color-scheme: dark;
  --bg: #070707;
  --ink: #ece6dc;
  --mute: #8d877c;
  --line: rgba(236, 230, 220, 0.16);
  --rust: #8a2a24;
  --plaque: #cfc6b4;
  --serif: "Cinzel", "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "Share Tech Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #050505;
  color: var(--ink);
  font-family: var(--sans);
}

button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.grain,
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.grain {
  opacity: 0.18;
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 0.6px, transparent 0.7px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

.vignette {
  background: radial-gradient(circle at 50% 42%, transparent 38%, rgba(0, 0, 0, 0.72) 100%);
}

.gate {
  position: relative;
  z-index: 12;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 32px 20px 48px;
  text-align: center;
  background: #000;
}

.gate-lens {
  width: min(58vw, 280px);
  aspect-ratio: 1;
  overflow: hidden;
  margin-bottom: 18px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(236, 230, 220, 0.28), 0 30px 80px rgba(0, 0, 0, 0.8);
}

.gate-lens img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.08);
  animation: drift 18s ease-in-out infinite alternate;
}

.gate-kicker,
.path-kicker,
.plaque-km,
.bearing,
.clock,
.time-mark {
  margin: 0;
  color: var(--mute);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.gate h1,
.mark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.28em;
}

.gate h1 {
  font-size: clamp(2.4rem, 8vw, 4.2rem);
}

.gate-plaque {
  margin: 0 0 18px;
  color: var(--plaque);
  font-family: var(--serif);
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.gate-next {
  display: grid;
  gap: 4px;
  margin: 0 0 22px;
}

.gate-next span {
  color: var(--mute);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.gate-next strong {
  color: #e7d8c8;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  animation: nextPulse 1.6s ease-in-out infinite;
}

.enter,
.transport button {
  min-height: 46px;
  border: 1px solid var(--line);
  padding: 0 22px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.enter {
  background: rgba(12, 12, 12, 0.7);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.enter:hover,
.transport button:hover {
  border-color: var(--plaque);
  color: #fff;
}

.gate.leave {
  animation: fadeOut 0.7s ease forwards;
}

.stage[hidden] {
  display: none !important;
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(280px, 1.05fr) minmax(280px, 0.95fr);
  gap: 8vw;
  padding: 28px 48px 36px;
  background:
    linear-gradient(90deg, #050505 42%, #0b0b0b 100%);
}

.topbar {
  position: absolute;
  top: 22px;
  right: 48px;
  left: 48px;
  z-index: 4;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.mark {
  font-size: 0.9rem;
}

.lens-col,
.path-col {
  display: grid;
  align-content: center;
  min-width: 0;
}

.lens-col {
  justify-items: center;
  padding-top: 36px;
}

.lens {
  position: relative;
  width: min(72vw, 430px);
  aspect-ratio: 1;
}

.ring {
  position: absolute;
  inset: -14px;
  width: calc(100% + 28px);
  height: calc(100% + 28px);
  transform: rotate(-90deg);
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 0.7;
}

.ring-track {
  stroke: rgba(236, 230, 220, 0.16);
}

.ring-progress {
  stroke: var(--plaque);
  stroke-linecap: round;
  stroke-dasharray: 296.6;
  stroke-dashoffset: 296.6;
  transition: stroke 0.4s ease;
}

.lens.rust .ring-progress {
  stroke: #c45a4c;
}

.lens-hit {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(236, 230, 220, 0.22), 0 28px 70px rgba(0, 0, 0, 0.55);
  animation: redHalo 1.05s ease-in-out infinite;
}

.lens-hit::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 70, 55, 0.18), rgba(150, 6, 6, 0.82));
  mix-blend-mode: color;
  animation: redBlink 1.05s ease-in-out infinite;
}

.lens-hit img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 0.5s ease, transform 8s ease;
}

.lens.playing .lens-hit img {
  transform: scale(1.04);
  filter: grayscale(0.35) contrast(1.08);
}

.lens.rust.playing .lens-hit img {
  filter: grayscale(0.15) sepia(0.28) contrast(1.1);
}

.lens-play {
  position: absolute;
  z-index: 2;
  right: 18%;
  bottom: 16%;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 15px solid #f3eee4;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.7));
  opacity: 0.9;
}

.lens.playing .lens-play {
  width: 13px;
  height: 16px;
  border: 0;
  background: linear-gradient(#f3eee4, #f3eee4) left / 4px 100% no-repeat,
    linear-gradient(#f3eee4, #f3eee4) right / 4px 100% no-repeat;
}

.plaque {
  width: min(100%, 430px);
  margin-top: 22px;
  padding: 16px 4px 0;
  border-top: 1px solid var(--line);
  text-align: center;
}

.plaque strong {
  display: block;
  margin: 8px 0 8px;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.plaque p {
  margin: 0;
  color: var(--mute);
  line-height: 1.55;
}

.transport {
  display: flex;
  width: min(100%, 430px);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: var(--mute);
}

.transport button {
  min-width: 48px;
  padding: 0 12px;
}

.path-col {
  padding: 72px 0 20px;
}

.path-col h2 {
  margin: 8px 0 28px;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.04em;
}

.road {
  position: relative;
  display: grid;
  gap: 0;
  padding-left: 28px;
}

.road::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 7px;
  width: 1px;
  background: linear-gradient(#8d877c, rgba(141, 135, 124, 0.12));
}

.borne {
  position: relative;
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 18px 0 18px 8px;
  text-align: left;
}

.borne::before {
  content: "";
  position: absolute;
  top: 26px;
  left: -25px;
  width: 13px;
  height: 13px;
  border: 1px solid var(--plaque);
  border-radius: 50%;
  background: #0a0a0a;
}

.borne.active::before {
  background: var(--plaque);
  box-shadow: 0 0 16px rgba(207, 198, 180, 0.55);
}

.borne.rust.active::before {
  background: #c45a4c;
  border-color: #c45a4c;
}

.borne span {
  color: var(--mute);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.borne strong {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.borne p {
  margin: 0;
  max-width: 28rem;
  color: #b7b1a6;
  line-height: 1.5;
}

.borne.active strong {
  color: #fff;
}

.toast {
  position: fixed;
  right: 0;
  bottom: 22px;
  left: 0;
  z-index: 20;
  width: min(420px, calc(100% - 32px));
  margin: auto;
  opacity: 0;
  color: var(--plaque);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-align: center;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes drift {
  from {
    transform: scale(1.04) translateY(0);
  }
  to {
    transform: scale(1.12) translateY(-4%);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes redBlink {
  0%,
  100% {
    opacity: 0.05;
  }

  50% {
    opacity: 1;
  }
}

@keyframes redHalo {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(236, 230, 220, 0.22), 0 28px 70px rgba(0, 0, 0, 0.55);
  }

  50% {
    box-shadow:
      0 0 0 2px rgba(255, 52, 40, 0.95),
      0 0 34px rgba(220, 18, 18, 0.78),
      0 0 78px rgba(130, 0, 0, 0.5);
  }
}

@keyframes nextPulse {
  0%,
  100% {
    color: #e7d8c8;
    text-shadow: none;
  }

  50% {
    color: #ff3a32;
    text-shadow: 0 0 18px rgba(220, 20, 20, 0.7);
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .stage {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 64px 18px 48px;
  }

  .topbar {
    right: 18px;
    left: 18px;
    top: 14px;
  }

  .bearing,
  .clock {
    display: none;
  }

  .lens-col {
    padding-top: 8px;
  }

  .lens {
    width: min(68vw, 260px);
  }

  .path-col {
    padding-top: 8px;
  }

  .path-col h2 {
    margin-bottom: 18px;
    font-size: 1.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-lens img,
  .lens-hit,
  .lens-hit img,
  .lens-hit::after,
  .gate-next strong,
  .gate {
    animation: none;
  }

  .lens-hit::after {
    opacity: 0.28;
  }
}
