@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000000;
  --panel: #0f0f0f;
  --panel-deep: #080808;
  --ink: #c2c2c2;
  --ink-hi: #e6e6e6;
  --dim: #7a7a7a;
  --line: #262626;
  --accent: #f4512b;
  --accent-soft: rgba(244, 81, 43, 0.14);
  --riddler: #e5484d;
  --betty: #ff7ab6;
  --system: #f4512b;
  --unknown: #b3b3b3;
  --kestrel: #7fd4e8;
  --elias: #d8b26a;
  --input: #7ee787;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -8%, #150b07 0%, rgba(0, 0, 0, 0) 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

a:hover,
a:focus-visible {
  border-bottom-color: currentColor;
}

::selection {
  background: var(--accent);
  color: #000;
}

.shell {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px) clamp(14px, 4vw, 28px) 64px;
}

.shell--narrow {
  width: min(100%, 620px);
}

.shell--story {
  width: min(100%, 980px);
}

/* Story pages */

.page-story {
  background:
    radial-gradient(1000px 560px at 50% -10%, #1a0c07 0%, rgba(0, 0, 0, 0) 62%),
    #050505;
}

.page-story::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: url('/images/scene.svg') center / cover no-repeat;
  opacity: 0.5;
}

.page-story .shell {
  position: relative;
  z-index: 1;
}

.story-shell {
  position: relative;
}

.story-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.story-top__menu {
  color: var(--dim);
}

.story-top__menu:hover,
.story-top__menu:focus-visible {
  color: var(--accent);
}

.story-top__level {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--accent);
}

.story-top__signal {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.story-top__signal i {
  display: block;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--input);
  box-shadow: 0 0 10px var(--input);
  animation: pulse 2.4s ease-in-out infinite;
}

.story-top__voice {
  margin: 0;
  padding: 0.32rem 0.6rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

.story-top__voice:hover,
.story-top__voice:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.story-top__voice[aria-pressed="false"] {
  opacity: 0.55;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.story {
  --tone: var(--system);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
  margin-top: 1.6rem;
}

.story[data-tone='system'] {
  --tone: var(--system);
}

.story[data-tone='riddler'] {
  --tone: var(--riddler);
}

.story[data-tone='betty'] {
  --tone: var(--betty);
}

.story[data-tone='unknown'] {
  --tone: var(--unknown);
}

.story[data-tone='kestrel'] {
  --tone: var(--kestrel);
}

.story[data-tone='elias'] {
  --tone: var(--elias);
}

.portrait {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.portrait__frame {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #0a0a0a;
  box-shadow:
    0 0 70px -24px var(--tone),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.portrait__frame img {
  display: block;
  width: 100%;
  height: auto;
}

.portrait__id {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 0.15rem;
}

.portrait__name {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--tone);
}

.portrait__role {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.story__main {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  min-width: 0;
}

.dialog {
  position: relative;
  min-height: 9em;
  padding: 1.5rem 1.5rem 2.6rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.94), rgba(7, 7, 7, 0.97));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 40px 90px -60px var(--tone);
  font-size: 1rem;
  line-height: 1.85;
  color: #dedede;
  cursor: pointer;
}

.dialog::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.5rem;
  width: 4.5rem;
  height: 2px;
  border-radius: 2px;
  background: var(--tone);
  box-shadow: 0 0 20px var(--tone);
}

.dialog:focus-visible {
  outline: 2px solid var(--tone);
  outline-offset: 3px;
}

.line {
  margin: 0 0 0.55em;
  overflow-wrap: anywhere;
}

.line:last-of-type {
  margin-bottom: 0;
}

.line.is-hidden {
  display: none;
}

.line.is-typing::after {
  content: '▌';
  margin-left: 2px;
  color: var(--tone);
  animation: blink 1s steps(2, start) infinite;
}

.dialog__hint {
  position: absolute;
  right: 1.15rem;
  bottom: 0.8rem;
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  opacity: 0;
  transition: opacity 180ms ease;
}

.dialog__hint::before {
  content: '>';
  margin-right: 0.45rem;
  color: var(--tone);
}

.dialog.is-ready .dialog__hint {
  opacity: 1;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.artifact {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 10, 10, 0.94);
  overflow: hidden;
}

.artifact__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}

.artifact__dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.artifact__body {
  padding: 1.1rem 1.15rem;
}

.clue {
  font-size: 0.92rem;
  line-height: 1.8;
  color: #cfcfcf;
}

.clue p {
  margin: 0 0 0.75em;
}

.clue p:last-child {
  margin-bottom: 0;
}

.asset {
  display: block;
  width: auto;
  max-width: min(100%, 640px);
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.asset--hidden {
  display: none;
}

.unlock {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(9, 9, 9, 0.95);
}

.unlock__prompt {
  margin: 0 0 0.85rem;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}

.unlock__prompt span {
  margin-right: 0.4rem;
  color: var(--accent);
}

.prompt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.prompt__line {
  flex: 1 1 14rem;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.prompt__line:focus-within {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

.prompt label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.prompt__sigil {
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
}

.prompt input[type='text'] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.15rem 0;
  border: 0;
  background: transparent;
  color: var(--input);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  caret-color: var(--accent);
}

.prompt input[type='text']:focus {
  outline: none;
}

.prompt button {
  padding: 0.45rem 0.85rem;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.prompt button:hover,
.prompt button:focus-visible {
  background: var(--accent);
  color: #000;
}

.prompt button:focus-visible {
  outline: 2px solid var(--ink-hi);
  outline-offset: 2px;
}

.error {
  margin: 0;
  font-size: 0.84rem;
  color: #ff8a8a;
}

.error.is-shaking {
  animation: shake 260ms ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.page-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
  color: var(--dim);
}

.page-foot__who {
  color: var(--ink-hi);
}

.page-foot__who::before {
  content: '> ';
  color: var(--accent);
}

.page-foot__nav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-left: auto;
}

.page-foot__nav a,
.page-foot__nav .link {
  color: var(--dim);
}

.page-foot__nav a:hover,
.page-foot__nav a:focus-visible,
.page-foot__nav .link:hover,
.page-foot__nav .link:focus-visible {
  color: var(--accent);
}

.page-foot__form {
  display: inline;
  margin: 0;
}

/* Subpage headings, auth, board, error */

.page-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.6rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.page-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink-hi);
}

.page-head__back {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.page-head__back:hover,
.page-head__back:focus-visible {
  color: var(--accent);
}

.auth__lead {
  margin: 0 0 1.3rem;
  font-size: 0.9rem;
  color: var(--dim);
}

.auth {
  display: grid;
  gap: 0.3rem;
  max-width: 380px;
  margin-top: 0.5rem;
}

.auth label {
  margin-top: 0.55rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.auth input {
  padding: 0.55rem 0.7rem;
  background: #050505;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: var(--ink-hi);
  font-family: inherit;
  font-size: 1rem;
}

.auth input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.auth button {
  justify-self: start;
  margin-top: 1rem;
  padding: 0.5rem 0.9rem;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.auth button:hover,
.auth button:focus-visible {
  background: var(--accent);
  color: #000;
}

.auth button:focus-visible {
  outline: 2px solid var(--ink-hi);
  outline-offset: 2px;
}

.board {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.board__row {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.65rem 0.15rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.board__rank {
  flex: 0 0 2rem;
  text-align: right;
  color: var(--dim);
  font-size: 0.7rem;
}

.board__name {
  flex: 1 1 auto;
  color: var(--ink-hi);
  overflow-wrap: anywhere;
}

.board__score {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.8rem;
}

.board__cleared {
  flex: 0 0 auto;
  color: var(--dim);
  font-size: 0.7rem;
}

.outro {
  margin: 1.4rem 0 0;
  font-size: 0.86rem;
  color: var(--dim);
}

.outro--panel {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 10, 10, 0.94);
  opacity: 0;
  transition: opacity 600ms ease;
}

.story__main:has(.dialog.is-done) .outro--panel {
  opacity: 1;
}

.error-card {
  padding: 1.6rem 1.5rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 14px;
  background: rgba(10, 10, 10, 0.95);
}

.error-card__label {
  margin: 0 0 0.7rem;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.error-card h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-hi);
}

.error-card p {
  margin: 0;
  color: var(--dim);
}

.error-card__link {
  display: inline-block;
  margin-top: 1.2rem;
  font-size: 0.8rem;
}

.link {
  padding: 0;
  background: none;
  border: 0;
  color: var(--dim);
  font-family: inherit;
  font-size: 0.7rem;
  text-decoration: underline;
  cursor: pointer;
}

/* Terminal start screen */

.terminal {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, #0d0d0d 0%, #060606 100%);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.02),
    0 0 90px rgba(244, 81, 43, 0.07);
  overflow: hidden;
}

.terminal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(620px 240px at 50% 0%, rgba(244, 81, 43, 0.09), transparent 70%);
  pointer-events: none;
}

.terminal__bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: #101010;
  font-size: 0.68rem;
  color: var(--dim);
}

.terminal__dots {
  display: inline-flex;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.terminal__dots i {
  display: block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #2b2b2b;
}

.terminal__dots i:first-child {
  background: rgba(244, 81, 43, 0.55);
}

.terminal__label {
  letter-spacing: 0.02em;
}

.terminal__screen {
  position: relative;
  padding: clamp(1.25rem, 4vw, 2.4rem);
}

.terminal__eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.66rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--dim);
}

.terminal__title {
  margin: 0;
  font-size: clamp(1.9rem, 7vw, 3rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--ink-hi);
  text-shadow: 0 0 26px rgba(244, 81, 43, 0.22);
}

.terminal__tagline {
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: var(--dim);
}

.term-output {
  margin-top: 1.6rem;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 0.35rem;
  font-size: 0.86rem;
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

.term-line {
  margin: 0 0 0.18em;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.term-line:last-child {
  margin-bottom: 0;
}

.term-line--muted {
  color: var(--dim);
}

.term-line--error {
  color: #ff8a8a;
}

.term-line--ok {
  color: var(--input);
}

.term-line--cmd {
  color: var(--ink-hi);
}

.term-prompt {
  margin-right: 0.35rem;
  color: var(--accent);
}

.term-input {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.term-input__prompt {
  flex: 0 0 auto;
  font-size: 0.86rem;
  color: var(--dim);
  white-space: nowrap;
}

.term-user {
  color: var(--accent);
}

.term-input input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-hi);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  caret-color: var(--accent);
}

.term-input input:focus {
  outline: none;
}

@media (max-width: 760px) {
  .story {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .portrait {
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
  }

  .portrait__frame {
    width: 78px;
    flex: 0 0 auto;
    border-radius: 10px;
  }

  .dialog {
    min-height: 9.5em;
    padding: 1.2rem 1.15rem 2.4rem;
    font-size: 0.95rem;
  }

  .story-top__signal {
    display: none;
  }
}

@media (max-width: 560px) {
  .prompt__line {
    flex-basis: 100%;
  }

  .prompt button {
    flex: 1 1 auto;
  }

  .board__cleared {
    display: none;
  }

  .terminal__screen {
    padding: 1.1rem 1rem 1.3rem;
  }

  .terminal__bar {
    padding: 0.5rem 0.7rem;
  }

  .terminal__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-foot__nav {
    margin-left: 0;
    gap: 0.7rem;
  }
}

/* Level 21: the shape is named only in the stylesheet, not in the page. */
body[data-level='21'] .shape::after {
  content: 'silhouette';
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.download a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.audio audio {
  width: 100%;
  margin-top: 0.4rem;
}

.heart {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--accent);
}

canvas#picture {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  border: 1px solid var(--line);
  background: #10100e;
}

@media print {
  body[data-level='44'] .print-clue::after {
    content: 'edition';
  }
}

body[data-level='45'] #room:target::after {
  content: 'anchor';
}

@keyframes pulse {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 1;
  }
}

body[data-level='46'] .heart {
  animation: pulse 1.2s ease-in-out infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
