:root {
  color-scheme: dark;
  font-family: "Courier New", Courier, monospace;
  color: #7ce18a;
  background: #050805;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }
html { overflow-x: clip; }

body { overflow-x: hidden; }

button { font: inherit; }

.track {
  position: relative;
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100svh;
  transition: transform 650ms ease-in-out;
}

.track.show-game { transform: translateX(-100%); }
.track.show-game-three .home, .track.show-game-three .game-three { transform: translateX(100%); }
.track.show-game-two .home, .track.show-game-two .game-two { transform: translateY(-100%); }

.screen {
  flex: 0 0 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-y: auto;
  padding: clamp(24px, 5vw, 60px);
}

.home {
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: transform 650ms ease-in-out;
}

.terminal {
  align-self: center;
  width: min(100%, 32ch);
  min-height: 9.5em;
  text-align: left;
  text-indent: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: clamp(16px, 3vw, 19px);
  text-shadow: 0 0 7px #55ce6b55;
  transition: transform 550ms ease;
}

.home.awaiting-intro .terminal { visibility: hidden; }
.home.opening .terminal { transform: translateY(calc(50svh - 50% - clamp(24px, 5vw, 60px))); }
.home.opening.settling .terminal { transform: none; }
.home.opening #center-stage,
.home.opening:not(.message-building) #message { display: none; }
.home.opening.message-building #message {
  display: block;
  visibility: visible;
  opacity: 1;
  margin-top: auto;
}

.cursor { animation: blink 1s steps(1) infinite; }

.concealed { visibility: hidden; opacity: 0; pointer-events: none; }

.revealed {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 700ms ease;
}

.center-stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 14px 0;
}

.countdown {
  color: #9cf7a9;
  font-size: clamp(48px, 13vw, 108px);
  line-height: 1;
  letter-spacing: -.065em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px #60db7770;
}

.terminal-button {
  min-height: 48px;
  padding: 9px 18px;
  border: 1px solid #61c774;
  background: transparent;
  color: #91eda0;
  cursor: pointer;
  letter-spacing: .08em;
  text-shadow: 0 0 7px #55ce6b55;
}

.terminal-button:hover,
.terminal-button:focus-visible {
  background: #14351b;
  outline: 1px solid #9cf7a9;
  outline-offset: 3px;
}

.terminal-button:active { background: #23632f; }

#start-button { visibility: hidden; opacity: 0; transition: opacity 350ms ease; }
#start-button.ready { visibility: visible; opacity: 1; }

.message {
  width: 100%;
  padding-bottom: 5px;
  color: #66c777;
  text-align: center;
  font-size: clamp(17px, 4vw, 22px);
  font-weight: 700;
  line-height: 1.8;
  letter-spacing: .04em;
  text-shadow: 0 0 7px #55ce6b55;
}

.message-line { display: flex; justify-content: center; flex-wrap: wrap; column-gap: 1em; }
.segment { display: inline-flex; max-width: 100%; flex-wrap: wrap; justify-content: center; column-gap: 1em; }
.word { display: inline-flex; gap: .14em; white-space: nowrap; }
.letter { display: inline-block; min-width: .6em; }

.home.final-clearing .terminal, .home.final-clearing .center-stage { opacity: 0; pointer-events: none; transition: opacity 650ms ease; }
.home.finalized .terminal, .home.finalized .center-stage { display: none; }
.final-stage[hidden] { display: none !important; }
.final-stage { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(22px, 5vh, 42px); padding: 24px; background: #050805; text-align: center; }
#final-phrase-slot { width: 100%; }
.final-stage .message { width: 100%; padding: 0; font-size: clamp(20px, 4.5vw, 29px); line-height: 1.6; text-shadow: 0 0 11px #71ca8188; transform-origin: center center; }
#final-note { max-width: 66ch; min-height: 5em; margin: 0; color: #9bdba5; font-size: clamp(14px, 2.7vw, 17px); line-height: 1.65; white-space: pre-line; }

.letter-finale { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; pointer-events: none; background: transparent; transition: background 500ms ease; }
.letter-finale.formed { background: #050805; }
.letter-finale-stage { width: min(100%, 900px); text-align: center; }
.letter-finale-words { display: flex; flex-wrap: wrap; justify-content: center; gap: .18em .7em; color: #c1f9c9; font-size: clamp(24px, 5vw, 46px); text-shadow: 0 0 10px #67e47d88; }
.letter-finale-word { display: inline-flex; white-space: nowrap; }
.letter-finale-letter { display: inline-block; min-width: .67em; visibility: hidden; }
.letter-finale.formed .letter-finale-letter { visibility: visible; }
.letter-finale-status { margin-top: 28px; font-size: clamp(13px, 2.5vw, 16px); line-height: 1.55; white-space: pre-wrap; }
.letter-finale .terminal-button { margin-top: 24px; pointer-events: auto; }
.flying-letter { position: fixed; z-index: 31; color: #c1f9c9; font-family: "Courier New", Courier, monospace; text-align: center; text-shadow: 0 0 10px #67e47d; pointer-events: none; transform-origin: top left; }
.game-content.gathering .music-workspace, .memory-content.gathering .memory-workspace, .memory-content.gathering .memory-final, .game-three.gathering .game-three-content { opacity: 0; transition: opacity 450ms ease; }

.game {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.5vh, 26px);
  padding-block: clamp(16px, 2.5vh, 28px);
}

.game [hidden] { display: none !important; }
.game.intro-active .game-timer { visibility: hidden; }
.game-timer { align-self: flex-end; color: #66c777; font-size: clamp(12px, 2.8vw, 15px); white-space: nowrap; }
.game-intro { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; padding-inline: clamp(24px, 5vw, 60px); line-height: 1.6; font-size: clamp(13px, 2.8vw, 16px); transition: opacity 300ms ease; }
.game.intro-active .game-intro { position: absolute; inset: 0; }
.game-intro.finishing { opacity: 0; }
.game-intro-block { width: min(100%, 40ch); white-space: pre-wrap; text-align: left; }
.game-content { width: min(100%, 1100px); margin: 0 auto; padding-bottom: 8px; }
.game-content.concealed:not(.revealed) { display: none; }
.game-content.revealed { flex: 1; display: flex; flex-direction: column; }
.game-content.all-songs.revealed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0fr); grid-template-rows: minmax(0, 1fr) auto; transition: grid-template-columns 700ms ease; }
.game-content.all-songs.final-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.game-content.all-songs.music-success { grid-template-columns: minmax(0, 1fr) minmax(0, 0fr); grid-template-rows: minmax(0, 1fr) auto auto; }
.all-songs .music-workspace { grid-column: 1; grid-row: 1; align-self: center; min-width: 0; }
.all-songs .music-next { grid-column: 2; grid-row: 1; align-self: center; min-width: 0; }
.music-success .music-workspace { transform: translateY(-2vh); transition: transform 700ms ease; }
.music-success .music-next { opacity: 0; pointer-events: none; transition: opacity 300ms ease; }
.music-workspace { flex: 1; display: grid; grid-template-columns: minmax(240px, 34%) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: center; }
.music-workspace.all-found { display: block; }
.music-workspace .music-left { transition: opacity 400ms ease; }
.music-workspace.closing .music-left { opacity: 0; }
.music-workspace.all-found .music-left { display: none; }
.music-left h1 { margin: 0 0 10px; font-size: clamp(16px, 2.5vw, 21px); font-weight: normal; line-height: 1.35; }
.transmission-list { display: flex; flex-direction: column; }
.transmission-item { min-height: 34px; padding: 5px 0; border: 0; border-bottom: 1px solid #24532d; background: transparent; color: #7ce18a; text-align: left; cursor: pointer; }
.transmission-item:hover, .transmission-item:focus-visible { color: #b1ffbd; background: #102817; outline: 1px solid #61c774; }
.transmission-item:disabled { color: #66c777; cursor: default; }
.investigation { margin: 0 0 6px; padding: 10px 0 12px 14px; border-left: 1px solid #61c774; }
.investigation h2 { margin: 0 0 8px; font-size: clamp(16px, 2.8vw, 20px); font-weight: normal; }
.investigation p { margin: 0 0 10px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.investigation form, .music-key-form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.investigation input, .music-key-form input { width: 100%; min-height: 42px; padding: 8px; border: 1px solid #61c774; border-radius: 0; background: #050805; color: #9cf7a9; font: inherit; outline-offset: 3px; }
.investigation input:focus, .music-key-form input:focus { outline: 1px solid #9cf7a9; }
.investigation .terminal-button { min-height: 40px; }
.music-feedback { margin: 10px 0; white-space: pre-wrap; }
.music-feedback:empty { display: none; }
.music-archive { width: min(100%, 650px); min-height: 25em; padding: 0; margin: 0 auto; list-style: none; }
.music-archive li { display: flex; align-items: center; justify-content: center; height: 2.8em; text-align: center; font-size: clamp(16px, 2.6vw, 21px); line-height: 1.25; overflow-wrap: anywhere; }
.final-layout .music-archive li { height: 2.35em; font-size: clamp(15px, 1.5vw, 18px); transition: height 700ms ease, font-size 700ms ease; }
.music-title { max-width: 100%; }
.music-success .music-archive { min-height: 0; }
.music-success .music-archive li { height: 2.1em; transition: height 700ms ease, font-size 700ms ease; }
.music-archive.decoded .music-title { color: #67b876; }
.music-archive.decoded .music-initial.lit { color: #d7ffdd; font-size: 1.24em; font-weight: bold; text-shadow: 0 0 8px #9cffac, 0 0 18px #67e47d; }
.flying-title { position: fixed; z-index: 10; color: #9cf7a9; text-align: center; white-space: nowrap; pointer-events: none; text-shadow: 0 0 9px #55ce6b; transition: transform 650ms ease, opacity 650ms ease; }
.music-next { margin: 30px auto 0; text-align: center; line-height: 1.7; }
.music-next > p { margin: 0 0 22px; }
.all-songs .music-next { width: 100%; margin: 0; padding-left: clamp(12px, 2vw, 32px); text-align: left; line-height: 1.5; }
.music-next.pattern-pending { visibility: hidden; }
.music-next #music-pattern-status { min-height: 3em; white-space: pre-line; margin-bottom: 14px; }
.music-next #fragment-button.arriving { animation: fragment-appear 250ms ease-out; }
.fragment { width: min(100%, 480px); margin: 18px auto; padding: 16px; border: 1px solid #61c774; text-align: left; }
.fragment p { margin: 0 0 18px; }
.music-key-form { width: min(100%, 420px); margin: 28px auto 0; text-align: left; }
.music-key-form input { letter-spacing: .12em; }
.all-songs .fragment { width: min(100%, 420px); margin: 12px 0; padding: 10px 12px; border-left: 1px solid #61c774; border-top: 0; border-right: 0; border-bottom: 0; }
.all-songs .fragment p { margin-bottom: 10px; }
.all-songs .music-key-form { margin: 16px 0 0; }
.all-songs .music-key-form input { border: 0; border-bottom: 1px solid #376b42; padding-inline: 0; background: transparent; }
.all-songs .music-key-form input::placeholder { color: #66c777; opacity: 1; }
.all-songs #music-key-feedback { margin: 6px 0; }
#music-key-feedback { min-height: 1.5em; white-space: pre-wrap; }
.music-success .music-result { grid-column: 1 / -1; grid-row: 2; min-height: 8.5em; text-align: center; white-space: pre-wrap; line-height: 1.35; font-size: clamp(13px, 1.1vw, 15px); overflow-wrap: anywhere; }

@keyframes fragment-appear { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 720px) {
  .game-content.all-songs.revealed { display: flex; flex-direction: column; }
  .all-songs .music-next { padding-left: 0; margin-top: 22px; }
  .music-success .music-workspace { flex: 0 0 auto; width: 100%; transform: none; }
  .music-success .music-result { min-height: 0; margin-top: 16px; }
  .music-workspace { grid-template-columns: 1fr; align-items: start; }
  .transmission-item { min-height: 44px; }
  .music-archive { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .game-content.all-songs.revealed, .final-layout .music-archive li, .music-success .music-archive li, .music-success .music-workspace, .music-success .music-next { transition: none; }
  .music-archive.decoded .music-initial.lit { text-shadow: none; }
  .music-next #fragment-button.arriving { animation: none; }
}

.game-three {
  position: fixed;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block: clamp(16px, 2vh, 24px);
  transition: transform 650ms ease-in-out;
}

.game-three [hidden] { display: none !important; }

.game-three-timer {
  align-self: flex-end;
  color: #66c777;
  font-size: clamp(12px, 2.8vw, 15px);
  white-space: nowrap;
}

.game-three-intro {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: clamp(24px, 5vw, 60px);
  background: #050805;
}

.game-three-intro-block {
  width: min(100%, 50ch);
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: clamp(14px, 2.8vw, 17px);
}

.game-three-content {
  width: min(100%, 1200px);
  margin: auto;
  padding-bottom: 24px;
}

.game-three-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 60px); align-items: center; }
.game-three-puzzle { width: min(100%, 580px); margin-inline: auto; }
.game-three-records { min-width: 0; }
.game-three-records .records-panel { max-height: calc(100svh - 155px); margin: 0; overflow-y: auto; }
.game-three-records .records-list { line-height: 1.45; }

.game-three-content h1 {
  margin: 0 0 20px;
  font-size: clamp(20px, 5vw, 30px);
  font-weight: normal;
  letter-spacing: .07em;
  text-shadow: 0 0 9px #55ce6b55;
}

.transmission {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vh, 24px);
  margin: 20px 0 26px;
  font-size: clamp(14px, 3.6vw, 19px);
  letter-spacing: .05em;
}

.coordinate-group { display: flex; flex-wrap: wrap; gap: 12px 18px; padding-bottom: 12px; border-bottom: 1px solid #24532d; transition: gap 700ms ease, border-color 700ms ease; }
.coordinate { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 4.5ch; white-space: nowrap; transition: min-width 700ms ease; }
.coordinate-label { max-height: 2em; overflow: hidden; transition: opacity 700ms ease, max-height 700ms ease; }
.coordinate input { width: 2.2em; height: 1.8em; padding: 0 2px; border: 0; border-bottom: 2px solid #61c774; border-radius: 0; background: transparent; color: #b9f4c1; font: inherit; font-size: max(16px, 1em); text-align: center; text-transform: uppercase; outline-offset: 2px; transition: width 700ms ease, border-color 700ms ease, text-shadow 700ms ease; }
.coordinate input:focus { outline: 1px dashed #9cf7a9; }
.coordinate input.lit { color: #d7ffdd; opacity: 1; text-shadow: 0 0 8px #9cffac, 0 0 18px #67e47d; }
.game-three.decoded .coordinate-group { gap: 0; border-color: transparent; }
.game-three.decoded .coordinate { min-width: 0; }
.game-three.decoded .coordinate-label { position: absolute; opacity: 0; max-height: 0; }
.game-three.decoded .coordinate input { width: 1.15em; border-color: transparent; color: #b9f4c1; text-shadow: 0 0 9px #71ca81; opacity: 1; }
#game-three-feedback, #game-three-hint { min-height: 1.5em; white-space: pre-wrap; }
#game-three-feedback { margin: 12px 0; }
#game-three-hint { margin: 12px 0 24px; }
.game-three-result { margin-top: 24px; white-space: pre-wrap; }
#game-three-result-text { font-size: clamp(18px, 4vw, 28px); line-height: 1.5; color: #b9f4c1; text-shadow: 0 0 9px #71ca81; }
#game-three-final-status { line-height: 1.6; }

.records-button { max-width: 100%; white-space: normal; text-align: left; }
.records-panel { margin: 28px 0 20px; line-height: 1.7; }
.records-panel[hidden], .records-list[hidden] { display: none; }
#records-status { white-space: pre-wrap; }
.records-list { padding: 0; margin: 16px 0 0; list-style: none; }
.records-list li:nth-child(11) { margin-top: 1.2em; }

@media (min-width: 721px) {
  .game-three-content h1 { margin-bottom: 12px; }
  .game-three .transmission { gap: 12px; margin: 12px 0 16px; font-size: 16px; }
  .game-three .coordinate-group { gap: 8px 10px; padding-bottom: 7px; }
  .game-three .coordinate input { height: 1.45em; }
  .game-three #game-three-feedback { margin: 6px 0; }
  .game-three .records-button { min-height: 40px; }
}

@media (max-width: 720px) {
  .game-three-layout { grid-template-columns: 1fr; }
  .game-three-records .records-panel { max-height: none; overflow: visible; }
  .coordinate-group { gap: 12px 14px; }
  .game-three-content { margin: 20px auto; }
}

.game-two {
  position: fixed;
  top: 100%;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block: clamp(16px, 2vh, 24px);
  transition: transform 650ms ease-in-out;
}

.game-two [hidden] { display: none !important; }
.game-two-timer { align-self: flex-end; color: #66c777; font-size: clamp(12px, 2.8vw, 15px); white-space: nowrap; }
.memory-intro { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; }
.memory-intro-block { width: min(100%, 43ch); white-space: pre-wrap; line-height: 1.65; font-size: clamp(14px, 2.8vw, 17px); }
.memory-intro-block .terminal-button { margin-top: 28px; }
.memory-content { display: flex; flex: 1; flex-direction: column; justify-content: center; width: min(100%, 1100px); margin: 0 auto; padding: 0; }
.memory-content h1 { margin: 0 0 8px; font-size: clamp(18px, 4vw, 28px); font-weight: normal; letter-spacing: .06em; }
.memory-workspace { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: clamp(24px, 4vw, 60px); align-items: center; transition: grid-template-columns 700ms ease, column-gap 700ms ease; }
#memory-register { min-width: 0; }
#memory-register > p { margin: 8px 0; }
#memory-integrity { color: #66c777; }
.memory-question { margin: 18px 0 26px; font-size: clamp(18px, 3.5vw, 24px); line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-question.verse { font-size: clamp(12px, 3.6vw, 24px); white-space: pre-line; }
#memory-answer-form, #memory-decode-form { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
#memory-answer, #memory-decode { width: min(100%, 480px); min-height: 40px; padding: 8px; border: 1px solid #61c774; border-radius: 0; background: #050805; color: #9cf7a9; font: inherit; outline-offset: 3px; }
#memory-answer:focus, #memory-decode:focus { outline: 1px solid #9cf7a9; }
#memory-answer-feedback, #memory-decode-feedback { min-height: 1.5em; white-space: pre-wrap; }
.memory-answers { grid-column: 2; width: 100%; padding: 0; margin: 0; list-style: none; font-size: clamp(13px, 1.45vw, 18px); line-height: 1; }
.memory-answers li { position: relative; width: 100%; height: 1.4em; }
.memory-answer-word { position: absolute; left: 50%; top: 50%; margin-top: -.5em; white-space: pre; letter-spacing: 0; }
.memory-target.lit { color: #b9f4c1; text-shadow: 0 0 6px #71ca81; }
.memory-flying-answer { position: fixed; z-index: 10; white-space: nowrap; color: #9cf7a9; pointer-events: none; text-shadow: 0 0 8px #55ce6b; transition: transform 680ms ease; }
.memory-content.final-composition .memory-workspace { flex: 0 0 auto; grid-template-columns: minmax(0, 0fr) minmax(0, 1fr); column-gap: 0; }
.memory-final { width: min(100%, 500px); margin: 8px auto 0; }
.memory-final.awaiting-prompt { visibility: hidden; }
#memory-final-status { min-height: 2.8em; margin: 0 0 6px; text-align: center; white-space: pre-wrap; line-height: 1.4; font-size: clamp(13px, 1.25vw, 16px); }
#memory-decode-form { align-items: center; gap: 8px; }
#memory-decode-form .terminal-button { min-height: 40px; }
#memory-decode-feedback { text-align: center; }
.memory-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
#memory-register.glitch-out { animation: memory-glitch-out 260ms steps(2, end) both; }
@keyframes memory-glitch-out { 25% { opacity: .65; transform: translateX(3px); } 55% { opacity: .85; transform: translateX(-3px); } 100% { opacity: 0; transform: none; } }

@media (max-width: 720px) {
  .memory-content { justify-content: flex-start; }
  .memory-workspace { display: flex; flex-direction: column; align-items: stretch; gap: 18px; }
  .memory-content.final-composition .memory-workspace { flex: 0 0 auto; }
  .memory-answers { font-size: clamp(13px, 3.6vw, 16px); }
  .memory-answer-word { white-space: pre; }
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .track, .home, .game-two, .game-three, .revealed, .terminal, #start-button, .flying-title, .music-workspace .music-left, .game-intro { transition: none; }
  .letter-finale, .game-content.gathering .music-workspace, .memory-content.gathering .memory-workspace, .memory-content.gathering .memory-final, .game-three.gathering .game-three-content { transition: none; }
  .cursor { animation: none; }
  .investigation { animation: none; }
  .memory-workspace, .memory-flying-answer { transition: none; }
  .coordinate-group, .coordinate, .coordinate-label, .coordinate input { transition: none; }
  #memory-register.glitch-out { animation: none; }
}

.home.intro-restored .terminal,
.home.intro-restored .revealed,
.home.intro-restored #start-button { transition: none; }
