:root {
  color-scheme: dark;
  --ink: #f5efe4;
  --muted: #bdb2a0;
  --night: #12100f;
  --night-soft: #1c1917;
  --paper: #eadfc9;
  --paper-ink: #211c18;
  --left: #8ea8e6;
  --left-deep: #23345f;
  --right: #e6a37f;
  --right-deep: #6b2f2a;
  --brass: #d7b979;
  --line: rgba(234, 223, 201, 0.22);
  --focus: #fff3b0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 300px;
  background: var(--night);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -12%, rgba(215, 185, 121, 0.12), transparent 36rem),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 7px),
    var(--night);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(35, 52, 95, 0.13), transparent 34%, transparent 66%, rgba(107, 47, 42, 0.14));
  content: "";
  pointer-events: none;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 30;
  padding: 0.65rem 0.9rem;
  color: var(--paper-ink);
  background: var(--paper);
  border-radius: 0.25rem;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.masthead,
main {
  width: min(1180px, calc(100% - 2rem));
  margin-inline: auto;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(20rem, 1.2fr);
  gap: 2rem;
  align-items: end;
  padding: clamp(1.6rem, 4vw, 3.4rem) 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.masthead h1,
.studio-heading h1 {
  margin: 0.1rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 6vw, 5.2rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.94;
}

.eyebrow,
.door-name,
.stream-label {
  margin: 0;
  color: var(--brass);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.18em;
  line-height: 1.4;
  text-transform: uppercase;
}

.rule {
  max-width: 39rem;
  margin: 0 0 0.25rem auto;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2vw, 1.32rem);
  line-height: 1.5;
}

.rule strong:nth-of-type(1) {
  color: var(--left);
}

.rule strong:nth-of-type(2) {
  color: var(--right);
}

.rule strong:nth-of-type(3) {
  color: var(--brass);
}

.thresholds {
  display: flex;
  gap: 1.3rem;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 0;
}

.level-nav {
  display: flex;
  gap: 0.4rem;
}

.threshold-button {
  width: 2.7rem;
  min-height: 2.7rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50% 50% 0.2rem 0.2rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease;
}

.threshold-button:hover:not(:disabled) {
  border-color: var(--brass);
  transform: translateY(-2px);
}

.threshold-button[data-current="true"] {
  border-color: var(--brass);
  color: var(--night);
  background: var(--brass);
}

.threshold-button[data-solved="true"]:not([data-current="true"]) {
  border-color: rgba(215, 185, 121, 0.72);
  color: var(--brass);
  box-shadow: inset 0 0 0 3px rgba(215, 185, 121, 0.08);
}

.threshold-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.level-note {
  max-width: 43rem;
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
  font-style: italic;
  line-height: 1.45;
  text-align: right;
}

.door-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2.4rem);
  padding: clamp(0.5rem, 2vw, 1.5rem) clamp(0rem, 3vw, 2.5rem) 1rem;
  perspective: 1400px;
}

.door {
  position: relative;
  min-height: 25rem;
  border: 1px solid rgba(215, 185, 121, 0.58);
  border-top-left-radius: 48% 11%;
  border-top-right-radius: 48% 11%;
  background: #090807;
  box-shadow:
    0 1.5rem 3.5rem rgba(0, 0, 0, 0.34),
    inset 0 0 0 0.45rem #191411,
    inset 0 0 0 0.55rem rgba(215, 185, 121, 0.22);
  overflow: hidden;
  transform-style: preserve-3d;
}

.door::after {
  position: absolute;
  right: 14%;
  bottom: 0.85rem;
  left: 14%;
  height: 0.5rem;
  border-radius: 50%;
  background: rgba(215, 185, 121, 0.2);
  filter: blur(6px);
  content: "";
}

.door-echo {
  position: absolute;
  inset: 0.75rem;
  display: grid;
  z-index: 0;
  place-items: center;
  padding: 2.5rem;
  border-top-left-radius: 48% 11%;
  border-top-right-radius: 48% 11%;
  overflow: hidden;
}

.door-left .door-echo {
  background:
    radial-gradient(circle at 55% 48%, rgba(194, 211, 255, 0.34), transparent 36%),
    linear-gradient(160deg, #171d31, #07090f 70%);
}

.door-right .door-echo {
  background:
    radial-gradient(circle at 45% 48%, rgba(255, 194, 156, 0.32), transparent 36%),
    linear-gradient(200deg, #321b18, #0d0706 70%);
}

.door-echo::before {
  position: absolute;
  inset: 14% 20%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  content: "";
  filter: blur(0.2px);
  transform: scale(0.7);
  opacity: 0;
  transition: opacity 600ms ease, transform 1.1s cubic-bezier(0.18, 0.7, 0.2, 1);
}

.door[data-open="true"] .door-echo::before {
  opacity: 1;
  transform: scale(1.6);
}

.door-echo p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2.3rem);
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.door-leaf {
  position: absolute;
  inset: 0.75rem;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto 1.7rem;
  gap: 1rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid rgba(215, 185, 121, 0.42);
  border-top-left-radius: 48% 11%;
  border-top-right-radius: 48% 11%;
  box-shadow: inset 0 0 0 0.35rem rgba(0, 0, 0, 0.15);
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.18, 0.7, 0.2, 1), filter 600ms ease;
  backface-visibility: hidden;
}

.door-left .door-leaf {
  background:
    linear-gradient(105deg, rgba(255, 255, 255, 0.06), transparent 18% 82%, rgba(0, 0, 0, 0.14)),
    repeating-linear-gradient(87deg, transparent 0 17px, rgba(255, 255, 255, 0.018) 17px 19px),
    var(--left-deep);
  transform-origin: left center;
}

.door-right .door-leaf {
  background:
    linear-gradient(255deg, rgba(255, 255, 255, 0.055), transparent 18% 82%, rgba(0, 0, 0, 0.15)),
    repeating-linear-gradient(93deg, transparent 0 19px, rgba(255, 255, 255, 0.018) 19px 21px),
    var(--right-deep);
  transform-origin: right center;
}

.door-left[data-open="true"] .door-leaf {
  transform: rotateY(-102deg);
  filter: brightness(0.72);
}

.door-right[data-open="true"] .door-leaf {
  transform: rotateY(102deg);
  filter: brightness(0.72);
}

.door-leaf header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  min-height: 5.2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(234, 223, 201, 0.18);
}

.door-letter {
  display: grid;
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  place-items: center;
  border: 1px solid var(--brass);
  border-radius: 50%;
  color: var(--brass);
  font-family: Georgia, "Times New Roman", serif;
}

.door-leaf h2 {
  margin: 0.25rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  font-weight: 400;
  line-height: 1.25;
}

.door-voice {
  align-self: center;
}

.reading {
  min-height: 3.4em;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2.15rem);
  line-height: 1.35;
  text-wrap: balance;
}

.door[data-complete="true"] .reading {
  color: #fff5cc;
  text-shadow: 0 0 1.2rem rgba(255, 239, 167, 0.32);
}

.empty-reading {
  color: rgba(234, 223, 201, 0.45);
  font-size: 0.78em;
  font-style: italic;
}

.slots {
  display: flex;
  gap: 0.35rem;
  margin-top: 1rem;
}

.slot {
  width: 1.2rem;
  max-width: 10%;
  height: 0.2rem;
  border-radius: 1rem;
  background: rgba(234, 223, 201, 0.2);
}

.slot[data-state="true"] {
  background: var(--brass);
  box-shadow: 0 0 0.6rem rgba(215, 185, 121, 0.35);
}

.slot[data-state="caught"] {
  background: #ff8e78;
}

.door-status {
  min-height: 1.4em;
  margin: 0.55rem 0 0;
  color: rgba(245, 239, 228, 0.7);
  font-size: 0.78rem;
  line-height: 1.4;
}

.listen,
.quiet-button {
  justify-self: start;
  padding: 0.55rem 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: rgba(245, 239, 228, 0.78);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.listen:hover,
.quiet-button:hover {
  color: var(--brass);
}

.whisper {
  min-height: 1.3rem;
  margin: -0.6rem 0 0;
  color: var(--brass);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.84rem;
  font-style: italic;
}

.handle {
  position: absolute;
  top: 54%;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid #5b461f;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 0.35rem rgba(0, 0, 0, 0.2);
}

.door-left .handle {
  right: 1.2rem;
}

.door-right .handle {
  left: 1.2rem;
}

.word-field {
  position: relative;
  margin: 1.4rem 0 clamp(2rem, 5vw, 4rem);
  padding: clamp(1.1rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background:
    linear-gradient(90deg, rgba(142, 168, 230, 0.055), transparent 28% 72%, rgba(230, 163, 127, 0.055)),
    rgba(28, 25, 23, 0.82);
  box-shadow: 0 1.2rem 3rem rgba(0, 0, 0, 0.2);
}

.field-heading {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  padding-bottom: 1rem;
}

.field-heading h2 {
  margin: 0.18rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 400;
}

.route-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.72rem;
}

.route-key span {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 99rem;
}

.route-key .key-left {
  color: var(--left);
}

.route-key .key-right {
  color: var(--right);
}

.route-key .key-both {
  color: var(--brass);
}

.word-stream {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  min-height: 5.8rem;
  padding: 1rem 0.2rem;
}

.word {
  position: relative;
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  min-height: 3.25rem;
  padding: 0.7rem 0.75rem 0.7rem 1rem;
  border: 1px solid rgba(234, 223, 201, 0.26);
  border-radius: 0.35rem;
  color: var(--paper-ink);
  background: var(--paper);
  box-shadow: 0 0.45rem 0 rgba(0, 0, 0, 0.16);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 150ms ease, border-color 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.word:hover {
  border-color: var(--brass);
  transform: translateY(-2px);
  box-shadow: 0 0.55rem 0 rgba(0, 0, 0, 0.2);
}

.word-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
}

.route-mark {
  display: grid;
  min-width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 800;
}

.word[data-route="silence"] {
  opacity: 0.62;
  filter: saturate(0.4);
}

.word[data-route="silence"] .route-mark {
  color: #81786d;
  background: rgba(33, 28, 24, 0.08);
}

.word[data-route="left"] {
  border-color: var(--left);
  box-shadow: -0.35rem 0 0 var(--left-deep), 0 0.45rem 0 rgba(0, 0, 0, 0.16);
  transform: translateY(-0.3rem);
}

.word[data-route="left"] .route-mark {
  color: #eef2ff;
  background: var(--left-deep);
}

.word[data-route="right"] {
  border-color: var(--right);
  box-shadow: 0.35rem 0 0 var(--right-deep), 0 0.45rem 0 rgba(0, 0, 0, 0.16);
  transform: translateY(0.3rem);
}

.word[data-route="right"] .route-mark {
  color: #fff1e8;
  background: var(--right-deep);
}

.word[data-route="both"] {
  border-color: var(--brass);
  background: linear-gradient(110deg, #dce5fb 0 46%, #f7d6c3 54% 100%);
  box-shadow: 0 0 0 0.2rem rgba(215, 185, 121, 0.16), 0 0.45rem 0 rgba(0, 0, 0, 0.16);
}

.word[data-route="both"] .route-mark {
  color: #332514;
  background: var(--brass);
}

.keyboard-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.solved-passage,
.finale {
  width: min(55rem, 100%);
  margin: 1rem auto clamp(3rem, 8vw, 7rem);
  padding: clamp(1.5rem, 5vw, 3.8rem);
  border-top: 1px solid var(--brass);
  border-bottom: 1px solid var(--brass);
  text-align: center;
}

.solved-passage h2,
.finale h2 {
  margin: 0.35rem 0 0.9rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 3.6rem);
  font-weight: 400;
  line-height: 1.05;
}

.solved-passage > p:not(.eyebrow),
.finale > p:not(.eyebrow) {
  max-width: 42rem;
  margin: 0.5rem auto 1.5rem;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.55;
}

.walk-through {
  min-height: 3rem;
  padding: 0.7rem 1.2rem;
  border: 1px solid var(--brass);
  border-radius: 99rem;
  color: var(--night);
  background: var(--brass);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.025em;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.walk-through:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.65rem 1.5rem rgba(215, 185, 121, 0.18);
}

.finale {
  width: min(66rem, 100%);
  background: radial-gradient(circle at 50% 0, rgba(215, 185, 121, 0.11), transparent 52%);
}

.corridor {
  display: grid;
  gap: 0.55rem;
  margin: 2rem 0 2.5rem;
}

.corridor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.9rem;
  align-items: center;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
  font-family: Georgia, "Times New Roman", serif;
}

.corridor-row p {
  margin: 0;
  font-size: clamp(0.92rem, 2vw, 1.18rem);
  line-height: 1.35;
}

.corridor-row p:first-child {
  color: #cbd8ff;
  text-align: right;
}

.corridor-row p:last-child {
  color: #ffd4bf;
  text-align: left;
}

.corridor-row span {
  color: var(--brass);
}

.studio {
  padding: clamp(2rem, 7vw, 6rem) 0;
}

.studio-heading {
  display: flex;
  gap: 2rem;
  justify-content: space-between;
  align-items: start;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}

.studio-heading h1 {
  max-width: 49rem;
  font-size: clamp(2.2rem, 7vw, 5.5rem);
}

.studio-intro {
  max-width: 49rem;
  margin: 2rem 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.55;
}

.stream-label {
  display: block;
  margin-bottom: 0.55rem;
}

#custom-text {
  width: 100%;
  min-height: 7rem;
  resize: vertical;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  color: var(--paper-ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 3vw, 1.65rem);
  line-height: 1.4;
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0 2rem;
}

.custom-readings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0 1rem;
}

.custom-readings section {
  min-height: 10rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-top: 0.3rem solid var(--left);
  background: rgba(35, 52, 95, 0.2);
}

.custom-readings section:last-child {
  border-top-color: var(--right);
  background: rgba(107, 47, 42, 0.2);
}

.custom-readings .reading {
  margin-top: 0.7rem;
}

.studio-status {
  min-height: 1.5rem;
  color: var(--brass);
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.load-failed::after {
  display: block;
  max-width: 40rem;
  margin: 3rem auto;
  padding: 1rem;
  border: 1px solid #ff8e78;
  content: "Two Doors could not load its local word engine.";
}

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

  .rule {
    margin-left: 0;
  }

  .thresholds,
  .field-heading,
  .studio-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .thresholds,
  .field-heading {
    display: flex;
  }

  .level-note {
    text-align: left;
  }

  .door-pair {
    grid-template-columns: 1fr;
    width: min(34rem, 100%);
    margin-inline: auto;
  }

  .door {
    min-height: 23rem;
  }

  .route-key {
    justify-content: flex-start;
  }

  .word-stream {
    gap: 0.55rem;
  }

  .word {
    min-height: 3.15rem;
  }

  .custom-readings {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .masthead,
  main {
    width: min(100% - 1rem, 1180px);
  }

  .masthead h1 {
    font-size: 2.45rem;
  }

  .threshold-button {
    width: 2.4rem;
    min-height: 2.5rem;
  }

  .door-pair {
    padding-inline: 0;
  }

  .door-leaf {
    padding: 1.15rem;
  }

  .door-letter {
    width: 2rem;
    height: 2rem;
  }

  .word-field {
    padding: 1rem 0.75rem;
  }

  .word {
    gap: 0.45rem;
    padding-inline: 0.72rem 0.58rem;
  }

  .word-text {
    font-size: 1rem;
  }

  .corridor-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .corridor-row p:first-child,
  .corridor-row p:last-child {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }

  .door-left[data-open="true"] .door-leaf,
  .door-right[data-open="true"] .door-leaf {
    visibility: hidden;
    transform: none;
  }
}

@media (forced-colors: active) {
  .word,
  .door,
  .door-leaf,
  .custom-readings section {
    border: 2px solid CanvasText;
  }

  .word[data-route="left"] {
    border-left-width: 0.55rem;
  }

  .word[data-route="right"] {
    border-right-width: 0.55rem;
  }

  .word[data-route="both"] {
    border-block-width: 0.35rem;
  }
}
