@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;500;600;700;900&family=Share+Tech+Mono&display=swap');

:root {
  --void: #060812;
  --ink: #0d1020;
  --panel: rgba(14, 20, 39, 0.88);
  --panel-solid: #12182b;
  --cyan: #00ffff;
  --cyan-soft: #82ffff;
  --pink: #ff007f;
  --pink-soft: #ff75b8;
  --violet: #806bff;
  --rust: #b65d32;
  --rust-dark: #542a20;
  --paper: #eefcff;
  --muted: #98acbc;
  --danger: #ff3b62;
  --success: #6effa6;
  --line: rgba(125, 233, 255, 0.26);
  --serif: 'Noto Serif TC', 'BIZ UDMincho', 'MS Mincho', 'PMingLiU', serif;
  --mono: 'Share Tech Mono', 'Cascadia Mono', 'Consolas', monospace;
  --safe-x: clamp(16px, 3vw, 42px);
  --safe-y: clamp(16px, 3vw, 36px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
}

body {
  color: var(--paper);
  font-family: var(--serif);
  cursor: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
[role='button'] {
  font: inherit;
  cursor: none;
}

button {
  border: 0;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--pink-soft);
  outline-offset: 4px;
}

::selection {
  background: var(--pink);
  color: var(--void);
}

#game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 53% 43%, rgba(0, 255, 255, 0.11), transparent 24%),
    radial-gradient(circle at 12% 85%, rgba(255, 0, 127, 0.12), transparent 29%),
    linear-gradient(135deg, #03050d 0%, #121326 48%, #090b15 100%);
}

#game-shell::before,
#game-shell::after {
  position: absolute;
  inset: 0;
  z-index: 20;
  content: '';
  pointer-events: none;
}

#game-shell::before {
  opacity: 0.21;
  background: repeating-linear-gradient(
    to bottom,
    rgba(170, 255, 255, 0.15) 0,
    rgba(170, 255, 255, 0.15) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: screen;
}

#game-shell::after {
  z-index: 21;
  opacity: 0.16;
  background-image:
    radial-gradient(rgba(228, 255, 255, 0.72) 0.5px, transparent 0.8px),
    radial-gradient(rgba(255, 84, 159, 0.56) 0.5px, transparent 0.8px);
  background-position: 0 0, 11px 9px;
  background-size: 4px 5px, 7px 7px;
  mix-blend-mode: soft-light;
  animation: noiseShift 220ms steps(2, end) infinite;
}

#viewport {
  position: relative;
  z-index: 6;
  width: min(100vw, calc(100dvh * 1.7777778));
  height: min(100dvh, calc(100vw / 1.7777778));
  min-height: min(100dvh, 320px);
  overflow: hidden;
  border: 1px solid rgba(122, 239, 255, 0.35);
  border-radius: clamp(0px, 1vw, 16px);
  background: rgba(11, 14, 27, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 0, 127, 0.08),
    0 0 42px rgba(0, 255, 255, 0.18),
    0 0 110px rgba(255, 0, 127, 0.13),
    inset 0 0 75px rgba(0, 0, 0, 0.65);
}

#viewport::before {
  position: absolute;
  z-index: 10;
  inset: 0;
  content: '';
  pointer-events: none;
  border: 10px solid transparent;
  border-image: linear-gradient(135deg, rgba(0, 255, 255, 0.4), transparent 22%, transparent 78%, rgba(255, 0, 127, 0.38)) 1;
  box-shadow: inset 0 0 55px rgba(0, 0, 0, 0.6);
}

#viewport::after {
  position: absolute;
  z-index: 11;
  inset: 0;
  content: '';
  pointer-events: none;
  opacity: 0.25;
  background: linear-gradient(90deg, rgba(255, 0, 127, 0.05), transparent 3%, transparent 97%, rgba(0, 255, 255, 0.06));
}

#world-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

#hud {
  position: absolute;
  z-index: 12;
  top: 0;
  left: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1.15fr) minmax(120px, 0.7fr) auto auto;
  align-items: center;
  gap: clamp(10px, 2vw, 25px);
  padding: clamp(15px, 2.4vw, 30px) var(--safe-x);
  pointer-events: none;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.55);
}

#hud > * {
  min-width: 0;
}

.hud-kicker,
.micro-label,
#chapter-label,
.terminal-index,
.system-line,
.ending-kicker {
  margin: 0;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: clamp(0.56rem, 1vw, 0.78rem);
  letter-spacing: 0.16em;
  line-height: 1.4;
  text-transform: uppercase;
}

#chapter-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--paper);
  font-size: clamp(0.66rem, 1.2vw, 0.92rem);
  font-weight: 700;
}

#chapter-label::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  content: '';
  border: 1px solid var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  transform: rotate(45deg);
}

.progress-cluster {
  display: grid;
  gap: 7px;
}

#progress-rail {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 255, 255, 0.55);
  border-radius: 1px;
  background: rgba(1, 8, 15, 0.74);
  box-shadow: inset 0 0 9px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 255, 255, 0.16);
}

#progress-rail::after {
  position: absolute;
  inset: 1px;
  content: '';
  opacity: 0.5;
  background: repeating-linear-gradient(90deg, transparent 0 13px, rgba(237, 255, 255, 0.35) 13px 14px);
}

#progress-fill {
  position: relative;
  z-index: 1;
  width: 0%;
  height: 100%;
  border-right: 2px solid #fff;
  background: linear-gradient(90deg, var(--cyan), #8cffff 62%, var(--pink));
  box-shadow: 0 0 12px var(--cyan), 0 0 19px var(--pink);
  transition: width 550ms cubic-bezier(0.16, 1, 0.3, 1);
}

#signal-meter {
  justify-self: end;
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  column-gap: 8px;
  row-gap: 3px;
  min-height: 30px;
  padding: 4px 5px;
  border: 1px solid rgba(255, 0, 127, 0.37);
  background: rgba(15, 9, 27, 0.6);
}

#signal-meter .micro-label {
  grid-column: 1 / -1;
  font-size: 0.48rem;
  color: var(--pink-soft);
}

#signal-value {
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.signal-bars {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 18px;
}

.signal-bars i {
  display: block;
  width: 3px;
  border: 1px solid rgba(255, 0, 127, 0.7);
  background: var(--pink);
  box-shadow: 0 0 7px var(--pink);
  animation: signalPulse 950ms ease-in-out infinite alternate;
}

.signal-bars i:nth-child(1) { height: 6px; animation-delay: 70ms; }
.signal-bars i:nth-child(2) { height: 10px; animation-delay: 170ms; }
.signal-bars i:nth-child(3) { height: 14px; animation-delay: 10ms; }
.signal-bars i:nth-child(4) { height: 18px; animation-delay: 220ms; }

.screen {
  position: absolute;
  z-index: 13;
  inset: 0;
  display: none;
  place-items: center;
  padding: calc(var(--safe-y) + 34px) var(--safe-x) var(--safe-y);
  opacity: 0;
  pointer-events: none;
}

.screen.active {
  display: grid;
  opacity: 1;
  pointer-events: auto;
  animation: screenEnter 480ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.screen::before {
  position: absolute;
  inset: 0;
  content: '';
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 20%, rgba(3, 5, 13, 0.54) 100%);
}

.screen-card {
  position: relative;
  width: min(880px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(26px, 4.5vw, 62px);
  border: 1px solid rgba(0, 255, 255, 0.5);
  clip-path: polygon(0 17px, 17px 0, calc(100% - 45px) 0, 100% 45px, 100% calc(100% - 17px), calc(100% - 17px) 100%, 17px 100%, 0 calc(100% - 17px));
  background:
    linear-gradient(132deg, rgba(0, 255, 255, 0.09), transparent 25%),
    linear-gradient(315deg, rgba(255, 0, 127, 0.08), transparent 31%),
    rgba(8, 12, 27, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 35px rgba(0, 255, 255, 0.06),
    0 0 30px rgba(0, 255, 255, 0.16),
    14px 14px 0 rgba(255, 0, 127, 0.1);
  backdrop-filter: blur(10px);
}

.screen-card::before,
.screen-card::after {
  position: absolute;
  width: 25%;
  height: 1px;
  content: '';
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.screen-card::before {
  top: 11px;
  right: 28px;
}

.screen-card::after {
  bottom: 11px;
  left: 28px;
  background: var(--pink);
  box-shadow: 0 0 8px var(--pink);
}

#start-screen .screen-card {
  width: min(1000px, 100%);
  text-align: center;
}

.game-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 17px;
  border: 1px solid var(--cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 17px rgba(0, 255, 255, 0.5);
}

.game-mark svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.5;
  transform: rotate(-45deg);
}

.title-rubric {
  margin: 0 0 15px;
  color: var(--pink-soft);
  font-family: var(--mono);
  font-size: clamp(0.58rem, 1.1vw, 0.84rem);
  letter-spacing: 0.24em;
}

.game-title {
  max-width: 800px;
  margin: 0 auto;
  color: #f4ffff;
  font-size: clamp(2rem, 6.8vw, 5.9rem);
  font-weight: 900;
  letter-spacing: clamp(0.08em, 0.75vw, 0.22em);
  line-height: 1.08;
  text-shadow: 3px 0 rgba(255, 0, 127, 0.55), -2px 0 rgba(0, 255, 255, 0.56), 0 0 30px rgba(0, 255, 255, 0.25);
}

.title-subtitle {
  margin: 19px auto 0;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: clamp(0.77rem, 1.55vw, 1.08rem);
  letter-spacing: 0.18em;
}

.story-copy {
  max-width: 660px;
  margin: clamp(23px, 3vw, 35px) auto;
  color: #d8e7ea;
  font-size: clamp(0.84rem, 1.35vw, 1.04rem);
  font-weight: 500;
  line-height: 2;
  text-align: left;
}

.story-copy strong,
.dialogue strong {
  color: var(--pink-soft);
  font-weight: 700;
}

.action-button {
  position: relative;
  display: inline-flex;
  min-width: min(300px, 100%);
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 25px;
  overflow: hidden;
  color: #07121c;
  border: 1px solid var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 255, 255, 0.46), inset 0 -4px 0 rgba(0, 75, 90, 0.3);
  font-family: var(--serif);
  font-size: clamp(0.9rem, 1.4vw, 1.05rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-align: center;
  transition: color 180ms ease, transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  touch-action: manipulation;
}

.action-button::before,
.action-button::after {
  position: absolute;
  content: '';
  pointer-events: none;
}

.action-button::before {
  top: 0;
  left: -120%;
  width: 68%;
  height: 100%;
  transform: skewX(-24deg);
  background: rgba(255, 255, 255, 0.48);
  transition: left 350ms ease;
}

.action-button::after {
  right: 8px;
  bottom: 7px;
  width: 6px;
  height: 6px;
  border-right: 1px solid #07121c;
  border-bottom: 1px solid #07121c;
}

.action-button:hover,
.action-button:focus-visible {
  color: #fff;
  background: var(--pink);
  box-shadow: 0 0 22px rgba(255, 0, 127, 0.7), inset 0 -4px 0 rgba(77, 0, 39, 0.3);
  transform: translateY(-3px);
}

.action-button:hover::before,
.action-button:focus-visible::before {
  left: 150%;
}

.action-button:active {
  transform: translateY(1px) scale(0.98);
}

.action-button.secondary {
  color: var(--cyan-soft);
  border-color: rgba(0, 255, 255, 0.5);
  background: rgba(0, 255, 255, 0.07);
  box-shadow: inset 0 0 16px rgba(0, 255, 255, 0.08);
}

.action-button.secondary:hover,
.action-button.secondary:focus-visible {
  color: #fff;
  border-color: var(--pink);
  background: rgba(255, 0, 127, 0.35);
}

.button-glyph {
  width: 15px;
  height: 15px;
  border: 1px solid currentColor;
  transform: rotate(45deg);
}

#briefing-screen .screen-card {
  width: min(760px, 100%);
}

.briefing-grid {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 28px;
  align-items: start;
}

.signal-seal {
  position: relative;
  width: 100px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed var(--pink);
  border-radius: 50%;
  color: var(--pink);
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.21);
  animation: spinSlow 11s linear infinite;
}

.signal-seal::before,
.signal-seal::after {
  position: absolute;
  content: '';
  border-radius: 50%;
}

.signal-seal::before {
  inset: 14px;
  border: 1px solid var(--cyan);
}

.signal-seal::after {
  width: 23px;
  height: 23px;
  border: 1px solid var(--pink);
  box-shadow: 0 0 12px var(--pink);
}

.briefing-title,
.ending-title {
  margin: 7px 0 14px;
  color: var(--paper);
  font-size: clamp(1.45rem, 3.3vw, 2.65rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

.dialogue {
  margin: 0;
  color: #d2e4e8;
  font-size: clamp(0.84rem, 1.35vw, 1.02rem);
  line-height: 2;
}

.briefing-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.briefing-controls .action-button {
  min-width: 180px;
}

#terminal-panel {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: clamp(13px, 3.1vw, 42px);
  width: min(830px, calc(100% - var(--safe-x) * 2));
  max-height: min(72%, 670px);
  display: none;
  overflow: auto;
  padding: clamp(17px, 2.7vw, 32px);
  border: 1px solid rgba(0, 255, 255, 0.7);
  clip-path: polygon(0 13px, 13px 0, calc(100% - 30px) 0, 100% 30px, 100% 100%, 0 100%);
  background:
    linear-gradient(90deg, rgba(0, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(0, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 24px 24px,
    rgba(5, 12, 26, 0.91);
  box-shadow: 0 0 0 1px rgba(255, 0, 127, 0.15), 0 0 30px rgba(0, 255, 255, 0.25), inset 0 0 46px rgba(0, 0, 0, 0.67);
  transform: translateX(-50%) translateY(25px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease, transform 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

#terminal-panel.active {
  display: block;
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#terminal-panel::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  content: '';
  background: linear-gradient(90deg, var(--cyan), transparent 45%, var(--pink));
  box-shadow: 0 0 12px var(--cyan);
}

.terminal-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.terminal-title {
  margin: 4px 0 0;
  color: var(--paper);
  font-size: clamp(1.02rem, 2vw, 1.42rem);
  font-weight: 700;
  letter-spacing: 0.1em;
}

#timer-ring {
  position: relative;
  width: clamp(63px, 8vw, 79px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.06);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.32), inset 0 0 15px rgba(0, 255, 255, 0.15);
}

#timer-ring::before {
  position: absolute;
  inset: -5px;
  content: '';
  border: 1px dashed rgba(255, 0, 127, 0.7);
  border-radius: 50%;
  animation: spinSlow 5s linear infinite reverse;
}

#timer-ring.urgent {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 21px rgba(255, 59, 98, 0.72), inset 0 0 15px rgba(255, 59, 98, 0.2);
  animation: urgentPulse 700ms ease-in-out infinite;
}

#timer-value {
  position: relative;
  z-index: 1;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: clamp(1.1rem, 2.1vw, 1.45rem);
  letter-spacing: -0.05em;
}

#timer-ring.urgent #timer-value {
  color: var(--danger);
}

#memory-log {
  position: relative;
  margin: clamp(16px, 2vw, 24px) 0;
  padding: 15px 17px 15px 21px;
  border-left: 2px solid var(--pink);
  color: #d9ebed;
  background: linear-gradient(90deg, rgba(255, 0, 127, 0.1), transparent 80%);
  font-size: clamp(0.82rem, 1.4vw, 1rem);
  line-height: 1.85;
}

#memory-log::before {
  display: block;
  margin-bottom: 6px;
  color: var(--pink-soft);
  content: 'MEMORY_FRAGMENT // CORRUPTED';
  font-family: var(--mono);
  font-size: 0.72em;
  letter-spacing: 0.13em;
}

.decode-label {
  margin: 0 0 10px;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: clamp(0.65rem, 1.1vw, 0.83rem);
  letter-spacing: 0.12em;
}

#assembly-slots {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(7px, 1vw, 11px);
  min-height: clamp(53px, 6vw, 68px);
  align-items: center;
  margin: 0 0 clamp(17px, 2vw, 23px);
}

.slot {
  position: relative;
  width: clamp(37px, 5.5vw, 58px);
  height: clamp(48px, 6.5vw, 65px);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--paper);
  border: 1px solid rgba(0, 255, 255, 0.63);
  background: rgba(0, 255, 255, 0.05);
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.38);
  font-family: var(--mono);
  font-size: clamp(1.1rem, 3vw, 1.9rem);
  font-weight: 700;
  text-transform: uppercase;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.slot::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 4px;
  height: 4px;
  content: '';
  background: var(--pink);
  box-shadow: 0 0 5px var(--pink);
}

.slot.filled {
  color: var(--void);
  border-color: var(--cyan-soft);
  background: var(--cyan);
  box-shadow: 0 0 13px rgba(0, 255, 255, 0.45);
  animation: slotLock 260ms ease-out;
}

.slot.filled::after {
  background: #fff;
  box-shadow: none;
}

#letter-field {
  position: relative;
  min-height: clamp(90px, 15vw, 154px);
  overflow: hidden;
  border: 1px dashed rgba(255, 0, 127, 0.38);
  background: rgba(255, 0, 127, 0.025);
}

#letter-field::before,
#letter-field::after {
  position: absolute;
  content: '';
  pointer-events: none;
}

#letter-field::before {
  top: 50%;
  left: 0;
  width: 100%;
  border-top: 1px solid rgba(0, 255, 255, 0.16);
}

#letter-field::after {
  top: 0;
  left: 50%;
  height: 100%;
  border-left: 1px solid rgba(0, 255, 255, 0.12);
}

#word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 1.25vw, 14px);
  align-items: center;
  justify-content: center;
  min-height: clamp(94px, 15vw, 154px);
  padding: clamp(12px, 2vw, 22px);
}

.letter-chip {
  position: relative;
  width: clamp(42px, 5vw, 60px);
  height: clamp(47px, 5.7vw, 67px);
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--cyan-soft);
  border: 1px solid rgba(0, 255, 255, 0.72);
  border-radius: 2px;
  background: linear-gradient(145deg, rgba(0, 255, 255, 0.19), rgba(8, 17, 31, 0.8));
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.21), inset 0 0 12px rgba(0, 255, 255, 0.05);
  font-family: var(--mono);
  font-size: clamp(1.15rem, 3.1vw, 2rem);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  touch-action: manipulation;
  user-select: none;
  transition: transform 140ms ease, color 140ms ease, border-color 140ms ease, background 140ms ease, opacity 180ms ease;
}

.letter-chip::before {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 5px;
  height: 5px;
  content: '';
  border-top: 1px solid var(--pink);
  border-left: 1px solid var(--pink);
}

.letter-chip:nth-child(odd) {
  transform: rotate(-2.2deg) translateY(2px);
}

.letter-chip:nth-child(even) {
  transform: rotate(1.7deg) translateY(-2px);
}

.letter-chip:hover,
.letter-chip:focus-visible {
  color: #fff;
  border-color: var(--pink);
  background: linear-gradient(145deg, rgba(255, 0, 127, 0.42), rgba(37, 5, 29, 0.88));
  box-shadow: 0 0 17px rgba(255, 0, 127, 0.55);
}

.letter-chip:hover {
  transform: translateY(-8px) rotate(0deg);
}

.letter-chip.selected,
.letter-chip.used {
  opacity: 0.2;
  filter: saturate(0);
  pointer-events: none;
  transform: scale(0.82);
}

.terminal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

#hint-text {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.71rem, 1.1vw, 0.84rem);
  line-height: 1.5;
}

#hint-text[data-tone='alert'] {
  color: var(--pink-soft);
}

#hint-text[data-tone='success'] {
  color: var(--success);
}

.terminal-control {
  min-width: 100px;
  min-height: 39px;
  padding: 8px 13px;
  color: var(--pink-soft);
  border: 1px solid rgba(255, 0, 127, 0.65);
  background: rgba(255, 0, 127, 0.07);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.terminal-control:hover,
.terminal-control:focus-visible {
  color: #fff;
  background: rgba(255, 0, 127, 0.45);
  transform: translateY(-2px);
}

#translation-reveal {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 13px 15px;
  color: #d2f9df;
  border: 1px solid rgba(110, 255, 166, 0.47);
  background: rgba(110, 255, 166, 0.07);
  font-size: clamp(0.76rem, 1.2vw, 0.91rem);
  line-height: 1.6;
  opacity: 0;
  transform: translateY(7px);
  pointer-events: none;
  transition: opacity 320ms ease, transform 320ms ease;
}

#translation-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.translation-sigil {
  width: 21px;
  height: 21px;
  border: 1px solid var(--success);
  transform: rotate(45deg);
  box-shadow: 0 0 9px rgba(110, 255, 166, 0.56);
}

#ending-screen {
  background: radial-gradient(circle at 50% 28%, rgba(0, 255, 255, 0.13), transparent 42%);
}

#ending-screen .screen-card {
  width: min(820px, 100%);
  text-align: center;
  border-color: rgba(110, 255, 166, 0.64);
  background:
    linear-gradient(130deg, rgba(110, 255, 166, 0.11), transparent 34%),
    rgba(5, 14, 22, 0.88);
  box-shadow: 0 0 38px rgba(110, 255, 166, 0.2), 0 0 72px rgba(0, 255, 255, 0.14);
}

.ending-title {
  color: #eafff5;
  text-shadow: 0 0 18px rgba(110, 255, 166, 0.42);
}

.ending-summary {
  max-width: 640px;
  margin: 0 auto 25px;
  color: #d1e5de;
  font-size: clamp(0.84rem, 1.35vw, 1.02rem);
  line-height: 2;
  text-align: left;
}

.word-archive {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 20px 0 30px;
}

.archive-token {
  padding: 6px 9px;
  color: var(--cyan-soft);
  border: 1px solid rgba(0, 255, 255, 0.35);
  background: rgba(0, 255, 255, 0.06);
  font-family: var(--mono);
  font-size: 0.73rem;
  letter-spacing: 0.06em;
}

#pause-overlay {
  z-index: 18;
  background: rgba(2, 5, 12, 0.74);
  backdrop-filter: blur(9px) grayscale(0.6);
}

#pause-overlay .screen-card {
  width: min(480px, 100%);
  padding: clamp(27px, 4vw, 45px);
  text-align: center;
}

.pause-title {
  margin: 0 0 11px;
  color: var(--cyan-soft);
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  letter-spacing: 0.18em;
}

.pause-copy {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.8;
}

.storm {
  animation: electronicStorm 730ms steps(2, end) both;
}

.storm::after {
  opacity: 0.72 !important;
  background-image:
    linear-gradient(90deg, rgba(255, 0, 127, 0.9), transparent 7%, rgba(0, 255, 255, 0.87) 19%, transparent 30%, rgba(255, 255, 255, 0.6) 41%, transparent 55%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.4) 0 2px, transparent 2px 8px) !important;
  mix-blend-mode: screen !important;
}

.shake {
  animation: impactShake 430ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.glitching {
  animation: textGlitch 470ms steps(2, end) both;
}

.glitching::before,
.glitching::after {
  content: attr(data-glitch);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glitching::before {
  color: var(--cyan);
  transform: translate(-3px, 0);
  clip-path: inset(0 0 58% 0);
}

.glitching::after {
  color: var(--pink);
  transform: translate(3px, 0);
  clip-path: inset(63% 0 0 0);
}

/* Structural styling for the modular scene layout. */
.world-vignette,
.crt-noise,
.scanlines,
#storm-layer {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}

.world-vignette {
  background: radial-gradient(ellipse at center, transparent 34%, rgba(0, 0, 0, 0.18) 67%, rgba(0, 0, 0, 0.83) 100%);
}

.crt-noise {
  opacity: 0.09;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.92'/%3E%3C/svg%3E");
  mix-blend-mode: screen;
  animation: noiseShift 170ms steps(2, end) infinite;
}

.scanlines {
  opacity: 0.19;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(158, 255, 255, 0.22) 3px 4px);
  mix-blend-mode: screen;
}

#storm-layer {
  z-index: 30;
  overflow: hidden;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 120ms ease;
}

#storm-layer.active {
  opacity: 1;
  animation: stormFlash 650ms steps(2, end) both;
}

.storm-band {
  position: absolute;
  display: block;
  width: 130%;
  height: 15%;
  background: linear-gradient(90deg, transparent, var(--pink), rgba(255, 255, 255, 0.85), var(--cyan), transparent);
  filter: blur(2px);
}

.storm-band-a { top: 13%; left: -17%; transform: rotate(-5deg); }
.storm-band-b { top: 47%; left: -10%; transform: rotate(2deg); }
.storm-band-c { top: 80%; left: -18%; transform: rotate(-3deg); }

.hud-brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: var(--cyan);
  filter: drop-shadow(0 0 7px rgba(0, 255, 255, 0.55));
}

.hud-objective {
  min-width: 0;
  padding-left: clamp(0px, 1.6vw, 22px);
  border-left: 1px solid rgba(0, 255, 255, 0.3);
}

#objective-text {
  max-width: 27ch;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--paper);
  font-size: clamp(0.66rem, 1.1vw, 0.82rem);
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-progress {
  display: grid;
  gap: 5px;
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

#progress-text {
  color: var(--pink-soft);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.hud-controls {
  display: flex;
  grid-column: auto;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: auto;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--cyan-soft);
  border: 1px solid rgba(0, 255, 255, 0.36);
  background: rgba(5, 14, 27, 0.68);
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 1.6;
}

.icon-button .icon-sound-off {
  display: none;
}

.icon-button[aria-pressed='true'] .icon-sound-on {
  display: none;
}

.icon-button[aria-pressed='true'] .icon-sound-off {
  display: block;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: #fff;
  border-color: var(--pink);
  background: rgba(255, 0, 127, 0.33);
}

.start-screen {
  align-items: stretch;
  justify-items: stretch;
  padding: 0;
}

.start-grid {
  position: absolute;
  inset: 0;
  opacity: 0.46;
  background:
    linear-gradient(rgba(0, 255, 255, 0.1) 1px, transparent 1px) 0 0 / 45px 45px,
    linear-gradient(90deg, rgba(0, 255, 255, 0.1) 1px, transparent 1px) 0 0 / 45px 45px;
  mask-image: linear-gradient(to bottom, transparent, #000 30%, transparent 93%);
  transform: perspective(400px) rotateX(57deg) scale(1.9) translateY(30%);
  transform-origin: center bottom;
}

.title-lockup {
  position: relative;
  z-index: 1;
  width: min(820px, 78%);
  align-self: center;
  padding: 58px 18px 44px clamp(34px, 7vw, 95px);
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  margin: 0 0 14px;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: clamp(0.56rem, 1vw, 0.75rem);
  letter-spacing: 0.15em;
  line-height: 1.4;
}

.eyebrow span + span {
  color: var(--pink-soft);
}

#game-title {
  position: relative;
  width: fit-content;
  margin: 0;
  color: #f5ffff;
  font-family: var(--serif);
  font-size: clamp(3.2rem, 10vw, 8.8rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 0.78;
  text-shadow: 4px 0 var(--pink), -3px 0 rgba(0, 255, 255, 0.9), 0 0 28px rgba(0, 255, 255, 0.35);
}

#game-title span {
  margin-left: clamp(17px, 5vw, 72px);
  color: var(--cyan-soft);
}

#game-title::after {
  position: absolute;
  right: -18%;
  bottom: -16px;
  width: 46%;
  height: 2px;
  content: '';
  background: var(--pink);
  box-shadow: 0 0 11px var(--pink);
}

.title-zh {
  margin: 31px 0 10px;
  color: var(--pink-soft);
  font-size: clamp(1rem, 2.1vw, 1.55rem);
  font-weight: 900;
  letter-spacing: 0.19em;
}

.lead {
  max-width: 57ch;
  margin: 0;
  color: #c7dce0;
  font-size: clamp(0.77rem, 1.25vw, 0.98rem);
  line-height: 1.9;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.start-actions .action-button {
  min-width: 190px;
}

.action-button svg {
  width: 29px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-width: 1.5;
}

.button-index {
  align-self: stretch;
  display: grid;
  place-items: center;
  padding-right: 10px;
  border-right: 1px solid currentColor;
  font-family: var(--mono);
  font-size: 0.66rem;
}

.button-label {
  position: relative;
  z-index: 1;
}

.action-button.compact {
  min-width: 165px;
  min-height: 46px;
  padding: 11px 16px;
  font-size: 0.8rem;
}

.control-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 17px;
  margin-top: 20px;
  color: rgba(152, 172, 188, 0.88);
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.04em;
}

.start-transmission {
  position: absolute;
  right: clamp(22px, 5vw, 75px);
  bottom: clamp(23px, 6vh, 57px);
  width: min(240px, 25vw);
  padding: 14px 15px;
  color: var(--muted);
  border: 1px solid rgba(255, 0, 127, 0.38);
  background: rgba(16, 8, 25, 0.54);
  box-shadow: 0 0 21px rgba(255, 0, 127, 0.1);
  font-family: var(--mono);
  font-size: clamp(0.54rem, 0.85vw, 0.67rem);
  line-height: 1.55;
}

.start-transmission::before {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 28%;
  border-top: 2px solid var(--pink);
  content: '';
}

.start-transmission p {
  margin: 4px 0;
}

.transmission-status {
  color: var(--pink-soft);
  letter-spacing: 0.11em;
}

.waveform {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 10px 0 7px;
}

.waveform i {
  width: 2px;
  height: 28%;
  display: block;
  background: var(--cyan);
  box-shadow: 0 0 4px var(--cyan);
  animation: wavePulse 800ms ease-in-out infinite alternate;
}

.waveform i:nth-child(2n) { height: 77%; animation-delay: 230ms; }
.waveform i:nth-child(3n) { height: 100%; animation-delay: 90ms; }
.waveform i:nth-child(5n) { height: 50%; animation-delay: 320ms; }

.terminal-glass {
  border: 1px solid rgba(0, 255, 255, 0.49);
  background: rgba(7, 14, 28, 0.9);
  box-shadow: 0 0 28px rgba(0, 255, 255, 0.18), inset 0 0 32px rgba(0, 255, 255, 0.04);
  backdrop-filter: blur(10px);
}

.briefing-card,
.ending-card,
.pause-card {
  position: relative;
  width: min(770px, 100%);
  padding: clamp(25px, 4vw, 50px);
  clip-path: polygon(0 18px, 18px 0, calc(100% - 39px) 0, 100% 39px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px));
}

.panel-corners i {
  position: absolute;
  width: 15px;
  height: 15px;
  border-color: var(--pink);
}

.panel-corners i:nth-child(1) { top: 10px; left: 10px; border-top: 1px solid; border-left: 1px solid; }
.panel-corners i:nth-child(2) { top: 10px; right: 10px; border-top: 1px solid; border-right: 1px solid; }
.panel-corners i:nth-child(3) { bottom: 10px; left: 10px; border-bottom: 1px solid; border-left: 1px solid; }
.panel-corners i:nth-child(4) { right: 10px; bottom: 10px; border-right: 1px solid; border-bottom: 1px solid; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header .eyebrow {
  margin: 0;
}

.panel-status,
.briefing-meta {
  color: var(--pink-soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

#briefing-title,
#ending-title,
#pause-title {
  margin: 23px 0 14px;
  color: var(--paper);
  font-size: clamp(1.65rem, 3.6vw, 3rem);
  letter-spacing: 0.11em;
  line-height: 1.35;
}

.briefing-meta {
  margin: 0 0 23px;
  color: var(--cyan-soft);
}

#terminal-panel.terminal-screen {
  inset: 0;
  left: auto;
  bottom: auto;
  width: 100%;
  max-height: none;
  align-items: end;
  padding: 84px var(--safe-x) clamp(12px, 2vw, 28px);
  overflow: hidden;
  border: 0;
  clip-path: none;
  background: transparent;
  box-shadow: none;
  transform: none;
  opacity: 0;
  pointer-events: none;
}

#terminal-panel.terminal-screen.active {
  display: grid;
  opacity: 1;
  pointer-events: auto;
}

#terminal-panel.terminal-screen::before {
  display: none;
}

.terminal-frame {
  position: relative;
  width: min(1120px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(17px, 2.5vw, 31px);
  clip-path: polygon(0 14px, 14px 0, calc(100% - 35px) 0, 100% 35px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px));
}

.terminal-frame::before {
  position: absolute;
  inset: 0;
  content: '';
  opacity: 0.19;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 255, 255, 0.16) 1px, transparent 1px) 0 0 / 26px 26px, linear-gradient(rgba(0, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 26px 26px;
}

.terminal-topline,
.terminal-grid,
.translation-reveal {
  position: relative;
  z-index: 1;
}

.terminal-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.terminal-topline .eyebrow {
  margin-bottom: 4px;
}

#puzzle-title {
  margin: 0;
  color: var(--paper);
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  letter-spacing: 0.09em;
}

.timer-ring {
  flex: 0 0 auto;
}

#timer-ring svg {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  transform: rotate(-90deg);
}

.timer-track,
.timer-progress {
  fill: none;
  stroke-width: 4;
}

.timer-track { stroke: rgba(0, 255, 255, 0.16); }
.timer-progress { stroke: var(--pink); stroke-linecap: square; filter: drop-shadow(0 0 3px var(--pink)); }

#timer-ring > span {
  display: grid;
  place-items: center;
  line-height: 1;
}

#timer-ring small {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.45rem;
  letter-spacing: 0.12em;
}

.terminal-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.73fr) minmax(330px, 1.27fr);
  gap: clamp(17px, 3vw, 38px);
  margin-top: 19px;
}

.memory-column,
.decoder-column {
  min-width: 0;
}

.memory-column {
  padding-right: clamp(0px, 2vw, 26px);
  border-right: 1px solid rgba(0, 255, 255, 0.19);
}

.module-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.module-heading > span {
  width: 29px;
  height: 29px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--void);
  background: var(--cyan);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.module-heading p,
.module-heading h3 {
  margin: 0;
}

.module-heading p {
  color: var(--pink-soft);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}

.module-heading h3 {
  color: var(--paper);
  font-size: 0.87rem;
  letter-spacing: 0.08em;
}

#memory-log.memory-log {
  min-height: 190px;
  margin: 0;
  padding: 15px;
  overflow: auto;
  color: #d9edf0;
  border: 1px solid rgba(0, 255, 255, 0.23);
  border-left: 2px solid var(--pink);
  background: rgba(0, 0, 0, 0.27);
  font-family: var(--mono);
  font-size: clamp(0.66rem, 1.06vw, 0.78rem);
  line-height: 1.75;
  white-space: pre-wrap;
}

#memory-log.memory-log::before {
  display: none;
}

.clue-console {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 0, 127, 0.24);
  background: rgba(255, 0, 127, 0.045);
}

.clue-label {
  color: var(--pink-soft);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.12em;
}

.clue-console #hint-text {
  margin-top: 6px;
}

.assembly-module {
  position: relative;
  margin-top: 13px;
  padding: 12px;
  border: 1px solid rgba(0, 255, 255, 0.25);
  background: rgba(0, 255, 255, 0.025);
}

.assembly-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

#slot-count {
  color: var(--pink-soft);
}

.decoder-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
}

.text-button {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  font-family: var(--serif);
  font-size: 0.75rem;
  transition: color 150ms ease, background 150ms ease;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--cyan-soft);
  background: rgba(0, 255, 255, 0.08);
}

kbd {
  padding: 2px 4px;
  color: var(--pink-soft);
  border: 1px solid rgba(255, 0, 127, 0.4);
  font-family: var(--mono);
  font-size: 0.7rem;
}

#translation-reveal.translation-reveal {
  grid-template-columns: auto minmax(115px, 0.7fr) minmax(150px, 1fr) auto;
  gap: clamp(11px, 2vw, 21px);
  align-items: center;
  margin-top: 17px;
  padding: 14px;
  border-color: rgba(110, 255, 166, 0.48);
  background: rgba(110, 255, 166, 0.06);
}

#translation-reveal.translation-reveal[hidden] {
  display: none;
}

.decode-stamp {
  padding: 7px 5px;
  color: var(--success);
  border: 1px solid var(--success);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.11em;
  transform: rotate(-7deg);
}

.reveal-word-block h3,
.reveal-word-block p,
.reveal-meaning-block p,
.story-after {
  margin: 3px 0 0;
}

.reveal-word-block h3 {
  color: #efffff;
  font-family: var(--mono);
  font-size: clamp(1rem, 2vw, 1.4rem);
  letter-spacing: 0.07em;
}

.reveal-word-block p,
.reveal-meaning-block p,
.story-after {
  color: #cbdfd8;
  font-size: 0.75rem;
  line-height: 1.5;
}

#reveal-pos {
  color: var(--pink-soft);
  font-family: var(--mono);
}

#reveal-pronunciation {
  margin-left: 7px;
  color: var(--muted);
  font-family: var(--mono);
}

.context-sentence {
  color: var(--cyan-soft) !important;
  font-family: var(--mono);
}

.story-after {
  grid-column: 2 / 4;
}

.system-footer {
  position: absolute;
  z-index: 15;
  right: var(--safe-x);
  bottom: 11px;
  left: var(--safe-x);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(135, 163, 174, 0.7);
  font-family: var(--mono);
  font-size: clamp(0.48rem, 0.72vw, 0.61rem);
  letter-spacing: 0.08em;
  pointer-events: none;
}

.footer-pulse {
  color: var(--cyan-soft);
}

.footer-pulse i {
  width: 5px;
  height: 5px;
  display: inline-block;
  margin-right: 4px;
  background: var(--cyan);
  box-shadow: 0 0 7px var(--cyan);
  animation: signalPulse 900ms ease-in-out infinite alternate;
}

.ending-card {
  width: min(790px, 100%);
  text-align: center;
  border-color: rgba(110, 255, 166, 0.52);
}

.ending-card .story-copy {
  text-align: left;
}

.sunrise-mark {
  position: relative;
  width: 92px;
  height: 54px;
  margin: 13px auto 8px;
  overflow: hidden;
  border-bottom: 1px solid var(--cyan);
}

.sunrise-mark span {
  position: absolute;
  bottom: -30px;
  left: 50%;
  width: 66px;
  height: 66px;
  border: 1px solid var(--success);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(110, 255, 166, 0.48);
  transform: translateX(-50%);
}

.sunrise-mark i {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 1px;
  height: 24px;
  background: var(--pink);
  box-shadow: 0 0 8px var(--pink);
  transform-origin: 50% 45px;
}

.sunrise-mark i:nth-of-type(1) { transform: rotate(-60deg); }
.sunrise-mark i:nth-of-type(2) { transform: rotate(-30deg); }
.sunrise-mark i:nth-of-type(3) { transform: rotate(0deg); }
.sunrise-mark i:nth-of-type(4) { transform: rotate(30deg); }
.sunrise-mark i:nth-of-type(5) { transform: rotate(60deg); }

.ending-stats {
  margin: 22px 0 26px;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: 0.77rem;
  letter-spacing: 0.08em;
}

#pause-overlay.pause-overlay {
  position: absolute;
  z-index: 40;
  inset: 0;
  display: none;
  place-items: center;
  padding: var(--safe-y) var(--safe-x);
  background: rgba(1, 4, 10, 0.78);
  backdrop-filter: blur(9px);
}

#pause-overlay.pause-overlay.active,
#pause-overlay.pause-overlay:not([hidden]) {
  display: grid;
}

.pause-card {
  width: min(440px, 100%);
  text-align: center;
}

.pause-card p:not(.eyebrow) {
  margin: 0 0 23px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.85;
}

@keyframes wavePulse {
  from { transform: scaleY(0.45); opacity: 0.4; }
  to { transform: scaleY(1); opacity: 1; }
}

@keyframes stormFlash {
  0% { opacity: 0; }
  13% { opacity: 0.92; transform: translateX(-2%); }
  26% { opacity: 0.13; transform: translateX(2%); }
  44% { opacity: 0.83; transform: translateX(-1%); }
  69% { opacity: 0.21; transform: translateX(2%); }
  100% { opacity: 0; transform: translateX(0); }
}

/* Runtime state aliases used by the interaction engine. */
.scrambled-letter {
  position: absolute;
  z-index: 2;
  touch-action: none;
  animation: letterDrift 4.7s ease-in-out var(--drift-delay, 0s) infinite alternate;
}

.scrambled-letter.is-dragging {
  z-index: 8;
  color: #fff;
  border-color: var(--pink-soft);
  background: rgba(255, 0, 127, 0.52);
  box-shadow: 0 0 24px var(--pink), 0 13px 23px rgba(0, 0, 0, 0.42);
  cursor: none;
  animation-play-state: paused;
  transform: scale(1.13) rotate(0deg) !important;
}

.scrambled-letter.is-used {
  opacity: 0;
  pointer-events: none;
  animation: none;
}

.assembly-slot.is-filled {
  color: var(--void);
  border-color: var(--cyan-soft);
  background: var(--cyan);
  box-shadow: 0 0 13px rgba(0, 255, 255, 0.45);
  animation: slotLock 260ms ease-out;
}

.assembly-slot:not(.is-filled) {
  color: transparent;
}

.assembly-slot:not(.is-filled):disabled {
  opacity: 1;
}

#game-shell.electronic-storm {
  animation: electronicStorm 730ms steps(2, end) both;
}

#game-shell.electronic-storm #world-canvas {
  filter: saturate(2.4) contrast(1.32) hue-rotate(-13deg);
}

#game-shell.electronic-storm .scanlines {
  opacity: 0.72;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.64) 0 2px, transparent 2px 7px);
}

#signal-meter.is-critical {
  border-color: var(--danger);
  box-shadow: 0 0 15px rgba(255, 59, 98, 0.38);
  animation: urgentPulse 800ms ease-in-out infinite;
}

#signal-meter.is-critical #signal-value {
  color: var(--danger);
}

#signal-meter.is-critical .signal-bars i {
  border-color: var(--danger);
  background: var(--danger);
  box-shadow: 0 0 7px var(--danger);
}

#timer-ring.is-critical {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 21px rgba(255, 59, 98, 0.72), inset 0 0 15px rgba(255, 59, 98, 0.2);
  animation: urgentPulse 700ms ease-in-out infinite;
}

#timer-ring.is-critical #timer-value,
#timer-ring.is-critical small {
  color: var(--danger);
}

#timer-ring.is-critical .timer-progress {
  stroke: var(--danger);
  filter: drop-shadow(0 0 4px var(--danger));
}

#word-bank.assembly-module {
  display: block;
  min-height: 0;
  overflow: visible;
  border: 1px solid rgba(0, 255, 255, 0.25);
  background: rgba(0, 255, 255, 0.025);
}

#cat-cursor:not(.is-visible) {
  opacity: 0;
}

#cat-cursor.is-visible {
  opacity: 1;
}

#cat-cursor.is-pressed {
  width: 29px;
  gap: 4px;
  filter: drop-shadow(0 0 12px rgba(255, 0, 127, 0.95));
}

#cat-cursor.is-pressed .cursor-eye {
  transform: scaleY(0.38) !important;
}

@keyframes letterDrift {
  from { margin-top: 0; }
  to { margin-top: -5px; }
}

#cat-cursor {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 38px;
  height: 23px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  pointer-events: none;
  transform: translate3d(-100px, -100px, 0);
  filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.85));
  transition: width 160ms ease, gap 160ms ease, filter 160ms ease;
  will-change: transform;
}

.cursor-eye {
  position: relative;
  width: 13px;
  height: 17px;
  display: block;
  overflow: hidden;
  border: 1px solid var(--cyan-soft);
  border-radius: 72% 28% 68% 32% / 59% 42% 58% 41%;
  background: linear-gradient(130deg, #f3ffff, var(--cyan) 47%, #007d95 100%);
  box-shadow: 0 0 7px var(--cyan), inset 0 0 3px #fff;
}

.cursor-eye.left {
  transform: rotate(-11deg);
}

.cursor-eye.right {
  transform: scaleX(-1) rotate(-11deg);
}

.cursor-eye::after {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 50%;
  width: 2px;
  content: '';
  border-radius: 99px;
  background: #07111c;
  box-shadow: 0 0 1px #000;
  transform: translateX(-50%);
}

#cat-cursor.is-active {
  width: 46px;
  gap: 10px;
  filter: drop-shadow(0 0 10px rgba(255, 0, 127, 0.9));
}

#cat-cursor.is-active .cursor-eye {
  border-color: var(--pink-soft);
  background: linear-gradient(130deg, #fff2fa, var(--pink) 47%, #9f004e 100%);
  box-shadow: 0 0 9px var(--pink), inset 0 0 3px #fff;
}

body.cursor-hidden #cat-cursor {
  opacity: 0;
}

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

@keyframes noiseShift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-2%, 1%, 0); }
  50% { transform: translate3d(1%, -2%, 0); }
  75% { transform: translate3d(2%, 2%, 0); }
  100% { transform: translate3d(-1%, 0, 0); }
}

@keyframes screenEnter {
  from { opacity: 0; transform: scale(1.02); filter: brightness(2.4); }
  to { opacity: 1; transform: scale(1); filter: brightness(1); }
}

@keyframes signalPulse {
  from { opacity: 0.35; transform: scaleY(0.55); }
  to { opacity: 1; transform: scaleY(1); }
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

@keyframes urgentPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes slotLock {
  0% { transform: scale(0.78) rotate(-5deg); filter: brightness(2.5); }
  60% { transform: scale(1.12) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); filter: brightness(1); }
}

@keyframes electronicStorm {
  0% { filter: brightness(1) saturate(1); }
  10% { filter: brightness(4) saturate(3) hue-rotate(30deg); }
  26% { filter: brightness(0.35) saturate(0.3); }
  42% { filter: brightness(3) saturate(4) hue-rotate(-40deg); }
  58% { filter: brightness(0.6) saturate(2); }
  74% { filter: brightness(2.2) contrast(1.5); }
  100% { filter: brightness(1) saturate(1); }
}

@keyframes impactShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 1px, 0); }
  40%, 60% { transform: translate3d(6px, -1px, 0); }
}

@keyframes textGlitch {
  0% { transform: translate(0); filter: none; }
  18% { transform: translate(-4px, 1px); filter: hue-rotate(80deg); }
  38% { transform: translate(4px, -1px); filter: contrast(1.7); }
  56% { transform: translate(-2px, 0); filter: hue-rotate(-40deg); }
  100% { transform: translate(0); filter: none; }
}

@media (max-width: 760px) {
  #viewport {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  #hud {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px 16px;
  }

  .progress-cluster {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #signal-meter {
    grid-column: 2;
    grid-row: 1;
  }

  .screen {
    padding: 78px 15px 15px;
  }

  .screen-card {
    padding: 25px 22px 28px;
    clip-path: polygon(0 12px, 12px 0, calc(100% - 26px) 0, 100% 26px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px));
  }

  .story-copy {
    margin: 20px auto 24px;
    line-height: 1.83;
  }

  .briefing-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .signal-seal {
    width: 66px;
  }

  .briefing-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .briefing-controls .action-button,
  .action-button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
  }

  #terminal-panel {
    bottom: 0;
    width: 100%;
    max-height: calc(100% - 76px);
    padding: 18px 15px 16px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    clip-path: none;
  }

  .terminal-header {
    gap: 7px;
  }

  #memory-log {
    margin: 13px 0;
    padding: 11px 12px 11px 14px;
    line-height: 1.7;
  }

  #assembly-slots {
    gap: 6px;
    margin-bottom: 13px;
  }

  .slot {
    width: 35px;
    height: 45px;
  }

  #word-bank {
    gap: 7px;
    padding: 11px 6px;
  }

  .letter-chip {
    width: 42px;
    height: 48px;
  }

  .terminal-footer {
    align-items: flex-start;
  }

  .terminal-control {
    min-width: 84px;
    min-height: 43px;
  }

  #cat-cursor {
    display: none;
  }

  body,
  button,
  input,
  [role='button'] {
    cursor: auto;
  }
}

@media (max-width: 420px) {
  .title-rubric {
    letter-spacing: 0.13em;
  }

  .game-title {
    font-size: 1.85rem;
  }

  .title-subtitle {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
  }

  .terminal-title {
    font-size: 0.91rem;
  }

  #timer-ring {
    width: 56px;
  }

  #translation-reveal {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (hover: none), (pointer: coarse) {
  .letter-chip:hover {
    transform: none;
  }

  .action-button:hover,
  .terminal-control:hover {
    transform: none;
  }
}

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

  #game-shell::after {
    animation: none;
  }
}

/* Narrow-screen layout mapped to the current modular DOM. */
@media (max-width: 760px) {
  #hud {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 13px;
    background: linear-gradient(to bottom, rgba(3, 7, 17, 0.88), rgba(3, 7, 17, 0.16));
  }

  .hud-brand {
    grid-column: 1;
    grid-row: 1;
  }

  #signal-meter {
    grid-column: 2;
    grid-row: 1;
  }

  .hud-objective {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 0;
    border-left: 0;
  }

  #objective-text {
    max-width: none;
  }

  .hud-progress {
    grid-column: 1;
    grid-row: 3;
  }

  .hud-controls {
    grid-column: 2;
    grid-row: 3;
  }

  .start-screen {
    overflow-y: auto;
  }

  .title-lockup {
    width: 100%;
    max-height: 100%;
    align-self: start;
    padding: 116px 18px 38px;
    overflow-y: auto;
  }

  #game-title {
    font-size: clamp(3rem, 18vw, 5.7rem);
  }

  .start-transmission,
  .system-footer {
    display: none;
  }

  .briefing-screen,
  .ending-screen {
    padding: 122px 13px 16px;
  }

  .briefing-card,
  .ending-card {
    max-height: 100%;
    padding: 24px 20px 28px;
    overflow-y: auto;
  }

  #terminal-panel.terminal-screen {
    width: 100%;
    max-height: none;
    align-items: stretch;
    padding: 126px 9px 12px;
    overflow: hidden;
  }

  .terminal-frame {
    width: 100%;
    max-height: 100%;
    padding: 14px;
    overflow-y: auto;
  }

  .terminal-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 15px;
  }

  .memory-column {
    padding-right: 0;
    padding-bottom: 14px;
    border-right: 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.19);
  }

  #memory-log.memory-log {
    min-height: 108px;
    max-height: 150px;
  }

  #letter-field {
    min-height: 140px;
  }

  #word-bank.assembly-module {
    padding: 10px;
  }

  .decoder-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .decoder-actions .action-button {
    grid-column: 1 / -1;
  }

  #translation-reveal.translation-reveal {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  #translation-reveal .story-after {
    grid-column: auto;
  }

  #translation-reveal .action-button {
    width: 100%;
  }

  .decode-stamp {
    justify-self: start;
  }
}

@media (max-width: 460px) {
  #hud {
    grid-template-rows: auto auto;
  }

  .hud-objective {
    display: none;
  }

  .hud-progress {
    grid-row: 2;
  }

  .hud-controls {
    grid-row: 2;
  }

  .briefing-screen,
  .ending-screen {
    padding-top: 86px;
  }

  #terminal-panel.terminal-screen {
    padding-top: 88px;
  }

  .title-lockup {
    padding-top: 90px;
  }

  #game-title {
    font-size: clamp(2.75rem, 19vw, 4.4rem);
  }

  .title-zh {
    letter-spacing: 0.11em;
  }

  .control-legend {
    display: grid;
    gap: 4px;
  }

  .terminal-topline {
    gap: 10px;
  }

  #puzzle-title {
    font-size: 1rem;
  }

  #timer-ring {
    width: 54px;
  }
}

@media (max-height: 620px) and (min-width: 761px) {
  #hud {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .title-lockup {
    padding-top: 72px;
    padding-bottom: 28px;
  }

  #game-title {
    font-size: clamp(3rem, 9vw, 5.2rem);
  }

  .start-transmission {
    display: none;
  }

  #terminal-panel.terminal-screen {
    padding-top: 64px;
    padding-bottom: 10px;
  }

  #memory-log.memory-log {
    min-height: 115px;
  }

  #letter-field {
    min-height: 120px;
  }
}

/* Readability, fit and performance pass. */
html {
  font-size: clamp(16px, 0.95vw, 18px);
}

#viewport {
  width: calc(100vw - 20px);
  height: calc(100dvh - 20px);
  min-height: 0;
}

#game-shell::after,
.crt-noise {
  animation: none;
}

#game-shell::after {
  opacity: 0.08;
}

.crt-noise {
  opacity: 0.035;
}

.scanlines {
  opacity: 0.11;
}

.micro-label,
.eyebrow,
.panel-status,
.briefing-meta,
.clue-label,
.assembly-label,
.transmission-status {
  font-size: max(0.74rem, 12px);
}

#chapter-label {
  font-size: max(0.84rem, 14px);
}

#objective-text,
.lead,
.story-copy,
.dialogue {
  font-size: max(0.94rem, 15px);
}

.story-copy {
  line-height: 1.72;
}

#signal-value {
  font-size: 1rem;
}

#signal-meter .micro-label {
  font-size: max(0.67rem, 11px);
}

.action-button,
.text-button,
.terminal-control {
  font-size: max(0.9rem, 15px);
}

.control-legend,
.start-transmission,
.system-footer {
  font-size: max(0.75rem, 12px);
}

.module-heading p {
  font-size: max(0.7rem, 12px);
}

.module-heading h3 {
  font-size: max(0.94rem, 15px);
}

#memory-log.memory-log,
#hint-text,
.reveal-word-block p,
.reveal-meaning-block p,
.story-after,
.ending-stats {
  font-size: max(0.88rem, 14px);
}

#memory-log.memory-log {
  line-height: 1.62;
}

#timer-ring small {
  font-size: max(0.62rem, 10px);
}

.decode-stamp {
  font-size: max(0.68rem, 11px);
}

.terminal-screen,
.start-screen,
.briefing-screen,
.ending-screen,
.terminal-frame,
.briefing-card,
.ending-card,
.title-lockup {
  scrollbar-width: none;
}

.terminal-screen::-webkit-scrollbar,
.start-screen::-webkit-scrollbar,
.briefing-screen::-webkit-scrollbar,
.ending-screen::-webkit-scrollbar,
.terminal-frame::-webkit-scrollbar,
.briefing-card::-webkit-scrollbar,
.ending-card::-webkit-scrollbar,
.title-lockup::-webkit-scrollbar {
  display: none;
}

#terminal-panel.terminal-screen {
  align-items: stretch;
  padding: 68px 16px 18px;
  overflow: hidden;
}

.terminal-frame {
  height: 100%;
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(13px, 1.6vw, 22px);
  overflow: hidden;
}

.terminal-grid {
  min-height: 0;
  align-items: stretch;
  gap: clamp(14px, 2vw, 26px);
  margin-top: 12px;
}

.memory-column,
.decoder-column {
  min-height: 0;
}

.module-heading {
  margin-bottom: 8px;
}

#memory-log.memory-log {
  height: clamp(108px, 22dvh, 176px);
  min-height: 0;
  overflow: hidden;
}

.clue-console {
  margin-top: 8px;
  padding: 9px 11px;
}

#letter-field {
  height: clamp(126px, 23dvh, 184px);
  min-height: 0;
}

#word-bank.assembly-module {
  margin-top: 9px;
  padding: 9px 11px;
}

#assembly-slots {
  min-height: 50px;
  margin-bottom: 0;
}

.decoder-actions {
  margin-top: 9px;
}

.letter-chip,
.scrambled-letter {
  width: clamp(48px, 4.3vw, 62px);
  height: clamp(52px, 4.8vw, 66px);
  font-size: clamp(1.4rem, 2.3vw, 2rem);
  animation: none;
  transform: rotate(var(--card-angle, 0deg));
}

.letter-chip:nth-child(odd),
.letter-chip:nth-child(even) {
  transform: rotate(var(--card-angle, 0deg));
}

.letter-chip:hover,
.letter-chip:focus-visible {
  transform: translateY(-4px) rotate(0deg);
}

#translation-reveal.visible:not([hidden]) {
  display: grid;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#next-button {
  position: relative;
  z-index: 4;
  pointer-events: auto;
}

#game-shell[data-phase='resolved'] #terminal-panel.terminal-screen {
  align-items: center;
}

#game-shell[data-phase='resolved'] .terminal-frame {
  width: min(960px, 100%);
  height: auto;
  min-height: min(430px, calc(100dvh - 110px));
  grid-template-rows: auto 1fr;
}

#game-shell[data-phase='resolved'] .terminal-grid,
#game-shell[data-phase='resolved'] #timer-ring {
  display: none;
}

#game-shell[data-phase='resolved'] #translation-reveal.translation-reveal {
  grid-row: 2;
  align-self: center;
  margin-top: 14px;
  padding: clamp(18px, 2.5vw, 30px);
}

#game-shell.electronic-storm {
  animation: impactShake 260ms ease-out both;
}

#game-shell.electronic-storm #world-canvas {
  filter: none;
}

#game-shell.electronic-storm .scanlines {
  opacity: 0.24;
}

#storm-layer.active {
  animation: stormFlash 400ms steps(2, end) both;
}

.storm-band {
  filter: none;
}

.learning-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 15px;
}

.learning-link,
.utility-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--cyan-soft);
  border: 1px solid rgba(0, 255, 255, 0.34);
  background: rgba(5, 14, 27, 0.66);
  font-family: var(--serif);
  font-size: max(0.85rem, 14px);
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.learning-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.learning-link:hover,
.learning-link:focus-visible,
.utility-button:hover,
.utility-button:focus-visible {
  color: #fff;
  border-color: var(--pink);
  background: rgba(255, 0, 127, 0.28);
}

.utility-button {
  min-height: 34px;
  padding: 5px 9px;
  font-family: var(--mono);
  font-size: max(0.72rem, 12px);
}

.learning-overlay {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: none;
  place-items: center;
  padding: clamp(14px, 4vw, 52px);
  background: rgba(1, 4, 11, 0.88);
  backdrop-filter: blur(8px);
}

.learning-overlay.active:not([hidden]) {
  display: grid;
}

.learning-panel {
  width: min(1040px, 100%);
  max-height: min(88dvh, 760px);
  padding: clamp(20px, 3vw, 38px);
  overflow: hidden;
  clip-path: polygon(0 16px, 16px 0, calc(100% - 38px) 0, 100% 38px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px));
}

.learning-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.learning-header .eyebrow {
  margin-bottom: 4px;
}

.learning-header h2 {
  margin: 0;
  color: var(--paper);
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  letter-spacing: 0.1em;
}

.close-button {
  width: 45px;
  height: 45px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--pink-soft);
  border: 1px solid rgba(255, 0, 127, 0.55);
  background: rgba(255, 0, 127, 0.08);
}

.close-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.manual-content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 22px);
  margin-top: 18px;
}

.manual-section {
  padding: 17px;
  border: 1px solid rgba(0, 255, 255, 0.22);
  background: rgba(0, 255, 255, 0.035);
}

.manual-section h3 {
  margin: 0 0 11px;
  color: var(--cyan-soft);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

.manual-section ol {
  margin: 0;
  padding-left: 1.55em;
}

.manual-section li {
  margin: 0 0 9px;
  color: #d2e5e8;
  font-size: max(0.88rem, 14px);
  line-height: 1.55;
}

.cards-panel {
  width: min(780px, 100%);
}

.cards-instruction {
  margin: 13px 0;
  color: var(--muted);
  font-size: max(0.9rem, 15px);
  text-align: center;
}

.flashcard {
  width: min(570px, 100%);
  height: clamp(265px, 39dvh, 340px);
  margin: 0 auto;
  perspective: 1000px;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.flashcard.is-flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: clamp(22px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid rgba(0, 255, 255, 0.55);
  background: linear-gradient(140deg, rgba(0, 255, 255, 0.12), rgba(5, 11, 24, 0.97) 48%, rgba(255, 0, 127, 0.1));
  box-shadow: inset 0 0 36px rgba(0, 255, 255, 0.06), 0 0 25px rgba(0, 255, 255, 0.13);
  backface-visibility: hidden;
  text-align: center;
}

.flashcard-back {
  transform: rotateY(180deg);
  border-color: rgba(255, 0, 127, 0.55);
}

.card-counter {
  position: absolute;
  top: 15px;
  right: 17px;
  color: var(--pink-soft);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.flashcard-face h3 {
  margin: 10px 0;
  color: #efffff;
  font-size: clamp(2rem, 6vw, 4rem);
  letter-spacing: 0.1em;
  text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan);
}

.flashcard-back h3 {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  letter-spacing: 0.04em;
  text-shadow: none;
}

#card-pos,
#card-pronunciation {
  margin: 0 6px;
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: 1rem;
}

.card-example,
.card-tip {
  max-width: 46ch;
  margin: 8px 0;
  color: #d6e9eb;
  font-size: max(0.95rem, 15px);
  line-height: 1.6;
}

.card-tip {
  color: var(--pink-soft);
}

.flip-prompt {
  position: absolute;
  bottom: 15px;
  color: var(--muted);
  font-size: max(0.76rem, 12px);
}

.card-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
}

.card-nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.card-nav-button:last-child {
  justify-self: end;
}

.card-nav-button svg {
  width: 28px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

@media (max-width: 760px) {
  #viewport {
    width: 100vw;
    height: 100dvh;
  }

  #terminal-panel.terminal-screen {
    padding: 84px 9px 9px;
  }

  .terminal-frame {
    padding: 11px;
  }

  .terminal-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }

  .memory-column {
    padding-bottom: 7px;
  }

  #memory-log.memory-log {
    height: clamp(88px, 16dvh, 120px);
  }

  #letter-field {
    height: clamp(132px, 20dvh, 150px);
  }

  .module-heading {
    margin-bottom: 5px;
  }

  .clue-console {
    margin-top: 5px;
    padding: 6px 9px;
  }

  .letter-chip,
  .scrambled-letter {
    width: 42px;
    height: 46px;
  }

  .briefing-screen,
  .ending-screen {
    padding: 86px 10px 10px;
  }

  .briefing-card,
  .ending-card,
  .title-lockup {
    overflow: hidden;
  }

  .manual-content {
    grid-template-columns: minmax(0, 1fr);
    max-height: calc(84dvh - 90px);
    overflow-y: auto;
    scrollbar-width: none;
  }

  .manual-content::-webkit-scrollbar {
    display: none;
  }

  .learning-panel {
    max-height: 94dvh;
  }

  .flashcard {
    height: clamp(250px, 43dvh, 310px);
  }

  .card-navigation {
    grid-template-columns: 1fr 1fr;
  }

  #flashcard-flip {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .card-nav-button {
    grid-row: 2;
  }
}

@media (max-height: 700px) {
  #terminal-panel.terminal-screen {
    padding-top: 62px;
  }

  #memory-log.memory-log {
    height: 92px;
  }

  #letter-field {
    height: 146px;
  }

  .terminal-topline {
    padding-bottom: 8px;
  }

  .title-lockup {
    padding-top: 66px;
    padding-bottom: 18px;
  }

  .control-legend {
    display: none;
  }

  .learning-panel {
    max-height: 96dvh;
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .flashcard {
    height: 260px;
  }
}

@media (max-width: 760px) and (max-height: 700px) {
  #terminal-panel.terminal-screen {
    padding: 57px 6px 6px;
  }

  .terminal-frame {
    padding: 8px;
  }

  .terminal-topline {
    padding-bottom: 4px;
  }

  #timer-ring {
    width: 49px;
  }

  .terminal-grid {
    gap: 4px;
    margin-top: 5px;
  }

  .memory-column {
    padding-bottom: 4px;
  }

  .module-heading {
    margin-bottom: 3px;
  }

  .module-heading > span {
    width: 25px;
    height: 25px;
  }

  .module-heading p {
    display: none;
  }

  #memory-log.memory-log {
    height: 66px;
    padding: 7px 9px;
    line-height: 1.45;
  }

  .clue-console {
    padding: 4px 7px;
  }

  .clue-label {
    display: none;
  }

  #hint-text {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #letter-field {
    height: 124px;
  }

  #word-bank.assembly-module {
    margin-top: 4px;
    padding: 5px 7px;
  }

  #assembly-slots {
    min-height: 43px;
  }

  .decoder-actions {
    grid-template-columns: auto auto minmax(112px, 1fr);
    gap: 5px;
    margin-top: 5px;
  }

  .decoder-actions .action-button {
    grid-column: auto;
    min-width: 0;
    min-height: 42px;
  }

  .text-button {
    min-height: 42px;
    padding: 5px 7px;
  }
}

/* Cat-paw cursor, adaptive story frames, and resolved-action placement. */
@media (pointer: fine) {
  .scrambled-letter,
  .scrambled-letter:hover,
  .scrambled-letter:active,
  .scrambled-letter.is-dragging {
    cursor: none !important;
  }
}

#cat-cursor.is-paw {
  width: 32px;
  height: 32px;
  display: block;
  margin-top: -4px;
  margin-left: -5px;
  background-image: url('assets/cat-paw-cursor-v2-web.png');
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 200% 100%;
  filter: drop-shadow(0 0 5px rgba(0, 255, 255, 0.72));
  transition: width 100ms ease, height 100ms ease, filter 100ms ease;
}

#cat-cursor.is-paw .cursor-eye {
  display: none !important;
}

#cat-cursor.is-paw.is-grabbing {
  width: 30px;
  height: 30px;
  margin-top: -2px;
  margin-left: -3px;
  background-position: right center;
  filter: drop-shadow(0 0 6px rgba(255, 0, 127, 0.82));
}

#briefing-screen .briefing-card,
#ending-screen .ending-card {
  box-sizing: border-box;
  height: auto;
  max-height: calc(100dvh - 116px);
  overflow: hidden;
  padding: clamp(24px, 3.4vw, 42px);
}

#briefing-screen .briefing-card {
  width: min(850px, calc(100vw - 64px));
}

#ending-screen .ending-card {
  width: min(900px, calc(100vw - 64px));
}

#game-shell[data-phase='resolved'] #translation-reveal.translation-reveal {
  position: relative;
  min-height: clamp(300px, 52dvh, 420px);
  align-content: start;
  padding-bottom: clamp(86px, 12dvh, 108px);
}

#game-shell[data-phase='resolved'] #next-button {
  position: absolute;
  z-index: 5;
  right: clamp(16px, 2.2vw, 28px);
  bottom: clamp(14px, 2.2vw, 24px);
  width: auto;
  min-width: min(260px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  justify-self: end;
}

@media (max-width: 760px) {
  #briefing-screen .briefing-card,
  #ending-screen .ending-card {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 96px);
    padding: 20px 18px 23px;
  }

  #game-shell[data-phase='resolved'] #translation-reveal.translation-reveal {
    min-height: calc(100dvh - 190px);
    padding-bottom: 82px;
  }

  #game-shell[data-phase='resolved'] #next-button {
    right: 13px;
    bottom: 13px;
    width: auto;
    min-width: min(230px, calc(100% - 26px));
    max-width: calc(100% - 26px);
  }

  #briefing-story.story-copy,
  #ending-story.story-copy {
    margin: 12px auto 14px;
    line-height: 1.55;
    white-space: normal !important;
  }

  #briefing-title,
  #ending-title {
    margin: 12px 0 9px;
  }

  #briefing-wordmeta.briefing-meta {
    margin-bottom: 13px;
  }
}

@media (max-height: 700px) {
  #briefing-screen .briefing-card,
  #ending-screen .ending-card {
    padding-top: 17px;
    padding-bottom: 18px;
  }

  #briefing-story.story-copy,
  #ending-story.story-copy {
    margin: 9px auto 11px;
    line-height: 1.52;
    white-space: normal !important;
  }

  #briefing-title,
  #ending-title {
    margin: 9px 0 7px;
    font-size: clamp(1.48rem, 3.2vw, 2.2rem);
  }

  #briefing-wordmeta.briefing-meta {
    margin-bottom: 10px;
  }

  .ending-card .sunrise-mark {
    height: 42px;
    margin-top: 5px;
    margin-bottom: 4px;
  }
}

/* Keep narrative actions inside their frames at 100% browser zoom. */
#briefing-screen .briefing-card,
#ending-screen .ending-card {
  display: grid;
  box-sizing: border-box;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  padding-block: clamp(17px, 2.5dvh, 28px);
  padding-inline: clamp(18px, 3.4vw, 42px);
}

#briefing-screen .briefing-card {
  width: min(850px, calc(100vw - 64px));
  height: min(610px, 100%);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

#ending-screen .ending-card {
  width: min(900px, calc(100vw - 64px));
  height: min(640px, 100%);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
}

#briefing-story.story-copy,
#ending-story.story-copy {
  width: 100%;
  min-height: 0;
  margin: clamp(9px, 1.8dvh, 18px) auto;
  padding-right: 5px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  line-height: 1.62;
  scrollbar-width: none;
  white-space: pre-line !important;
}

#briefing-story.story-copy::-webkit-scrollbar,
#ending-story.story-copy::-webkit-scrollbar {
  display: none;
}

#briefing-screen .panel-header,
#briefing-title,
#briefing-wordmeta,
#enter-terminal-button,
#ending-screen > .ending-card > .eyebrow,
#ending-screen .sunrise-mark,
#ending-title,
#ending-stats,
.ending-actions {
  min-height: 0;
}

#briefing-title,
#ending-title {
  margin: clamp(8px, 1.6dvh, 15px) 0 clamp(5px, 1dvh, 9px);
}

#briefing-wordmeta.briefing-meta {
  margin: 0 0 clamp(8px, 1.5dvh, 13px);
}

#enter-terminal-button {
  max-width: 100%;
  justify-self: center;
}

#ending-stats.ending-stats {
  margin: clamp(7px, 1.4dvh, 12px) 0;
}

.ending-actions {
  width: min(690px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  justify-self: center;
}

.ending-actions .action-button {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding-inline: clamp(12px, 2vw, 22px);
}

@media (max-width: 760px) {
  #briefing-screen .briefing-card,
  #ending-screen .ending-card {
    width: calc(100vw - 24px);
    height: 100%;
    padding-inline: 17px;
  }

  .ending-actions {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .ending-actions .action-button {
    min-height: 48px;
    padding-block: 10px;
  }
}

@media (max-height: 700px) {
  #briefing-story.story-copy,
  #ending-story.story-copy {
    margin-block: 6px;
    line-height: 1.52;
  }

  #briefing-screen .panel-header {
    padding-bottom: 7px;
  }

  .ending-card .sunrise-mark {
    height: 38px;
    margin-block: 3px;
  }

  #ending-stats.ending-stats {
    margin-block: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #cat-cursor.is-paw {
    transition: none;
  }
}
