:root {
  --bg: #050408;
  --ink: #f5f1e7;
  --muted: rgba(245, 241, 231, 0.68);
  --faint: rgba(245, 241, 231, 0.18);
  --cyan: #54fff1;
  --red: #ff4d5b;
  --gold: #ffd45e;
  --green: #8bff9c;
  --panel: rgba(6, 7, 10, 0.64);
  --panel-strong: rgba(6, 7, 10, 0.84);
  --line: rgba(245, 241, 231, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

#journey-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(circle at 50% 45%, rgba(84, 255, 241, 0.14), transparent 34%),
    radial-gradient(circle at 80% 20%, rgba(255, 77, 91, 0.12), transparent 32%),
    #050408;
}

.journey-noise,
.journey-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.journey-noise {
  opacity: 0.12;
  mix-blend-mode: screen;
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 41px 41px, 53px 53px;
}

.journey-vignette {
  background:
    radial-gradient(circle at center, transparent 32%, rgba(0, 0, 0, 0.32) 68%, rgba(0, 0, 0, 0.82) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.74), transparent 32%, transparent 62%, rgba(0, 0, 0, 0.68));
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  background: #050408;
  pointer-events: none;
  animation: portalBoot 900ms ease 700ms forwards;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.loading-screen span {
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.loading-screen strong {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(36px, 7vw, 86px);
  font-weight: 400;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
}

@keyframes portalBoot {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.journey-header {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand-link,
.journey-links a,
.portal-actions button {
  border: 1px solid var(--line);
  background: rgba(4, 5, 7, 0.72);
  color: var(--ink);
  text-decoration: none;
  backdrop-filter: blur(14px);
}

.brand-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  pointer-events: auto;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(84, 255, 241, 0.44);
  color: var(--cyan);
}

.journey-links {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.journey-links a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.journey-links a:hover {
  border-color: rgba(84, 255, 241, 0.42);
  color: var(--ink);
}

.journey-ui {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.realm-panel {
  position: absolute;
  left: clamp(18px, 5vw, 72px);
  top: 50%;
  width: min(520px, calc(100vw - 36px));
  transform: translateY(-50%);
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(84, 255, 241, 0.08), transparent 42%),
    var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.realm-kicker,
.truth-box span,
.portal-hint {
  margin: 0;
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.realm-panel h1 {
  margin: 12px 0 16px;
  max-width: 10ch;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(48px, 7vw, 94px);
  font-weight: 400;
  line-height: 0.88;
  letter-spacing: 0;
}

.realm-dictum {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  line-height: 1.2;
}

.realm-body {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.truth-box {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid rgba(255, 212, 94, 0.28);
  background: rgba(255, 212, 94, 0.07);
}

.truth-box p {
  margin: 9px 0 0;
  color: var(--ink);
  line-height: 1.45;
}

.portal-console {
  position: absolute;
  right: clamp(18px, 4vw, 58px);
  bottom: clamp(92px, 12vh, 140px);
  width: min(300px, calc(100vw - 36px));
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.portal-counter {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 900;
}

.portal-counter i {
  height: 1px;
  background: var(--line);
}

.portal-counter span:first-child {
  color: var(--cyan);
}

.portal-meter {
  height: 8px;
  margin: 14px 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(245, 241, 231, 0.08);
}

.portal-meter span {
  display: block;
  width: 7.14%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--gold));
  transition: width 260ms ease;
}

.portal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.portal-actions button {
  min-height: 42px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 900;
}

.portal-actions button:hover {
  border-color: rgba(84, 255, 241, 0.42);
}

.portal-hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.portal-rail {
  position: absolute;
  left: 50%;
  bottom: 22px;
  width: min(1060px, calc(100vw - 36px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
  pointer-events: auto;
}

.portal-rail button {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(4, 5, 7, 0.7);
  color: var(--muted);
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 900;
  backdrop-filter: blur(12px);
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.portal-rail button:hover,
.portal-rail button.is-active {
  border-color: rgba(84, 255, 241, 0.62);
  background: rgba(84, 255, 241, 0.12);
  color: var(--ink);
  transform: translateY(-3px);
}

@media (max-width: 980px) {
  body {
    overflow-y: auto;
  }

  #journey-canvas,
  .journey-noise,
  .journey-vignette,
  .journey-ui,
  .journey-header {
    position: fixed;
  }

  .realm-panel {
    top: auto;
    bottom: 246px;
    left: 14px;
    right: 14px;
    width: auto;
    transform: none;
  }

  .realm-panel h1 {
    max-width: 12ch;
    font-size: 42px;
  }

  .realm-dictum {
    font-size: 17px;
    line-height: 1.16;
  }

  .realm-body,
  .truth-box {
    display: none;
  }

  .portal-console {
    left: 14px;
    right: 14px;
    bottom: 78px;
    width: auto;
    padding: 12px;
  }

  .portal-hint {
    display: none;
  }

  .portal-rail {
    grid-template-columns: repeat(7, 1fr);
    bottom: 10px;
    gap: 4px;
  }

  .portal-rail button {
    height: 28px;
    font-size: 10px;
  }
}

@media (max-width: 640px) {
  .journey-header {
    top: 12px;
    left: 10px;
    right: 10px;
  }

  .journey-links a {
    padding: 7px 9px;
    font-size: 11px;
  }

  .journey-links a:nth-child(2) {
    display: none;
  }

  .brand-link span:last-child {
    display: none;
  }

  .realm-panel {
    bottom: 232px;
    padding: 16px;
  }

  .realm-panel h1 {
    font-size: 34px;
  }

  .realm-dictum {
    margin-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-rail button,
  .portal-meter span,
  .loading-screen {
    transition: none;
  }
}
