:root {
  color-scheme: dark;
  --ink: #061216;
  --night: #09242d;
  --night-soft: rgba(9, 36, 45, 0.82);
  --cyan: #56e6e1;
  --acid: #d7f46a;
  --cream: #fff4db;
  --coral: #ff8066;
  --red: #ff4f65;
  --violet: #8269c8;
  --muted: #8ba4a2;
  --safe-top: max(0.8rem, env(safe-area-inset-top));
  --safe-right: max(0.8rem, env(safe-area-inset-right));
  --safe-bottom: max(0.8rem, env(safe-area-inset-bottom));
  --safe-left: max(0.8rem, env(safe-area-inset-left));
  font-family: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body,
#app {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

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

body {
  min-height: 100svh;
  overflow: hidden;
  overflow: clip;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

#app {
  position: relative;
  height: 100svh;
  isolation: isolate;
  overflow: hidden;
  background: #061319;
}

#game-canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.vignette,
.scanlines {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.vignette {
  background: radial-gradient(circle at 50% 44%, transparent 45%, rgba(0, 5, 8, 0.62) 115%);
  transition: background 500ms ease;
}

#app[data-game-state="escape"] .vignette {
  background: radial-gradient(circle at 50% 44%, transparent 36%, rgba(104, 0, 28, 0.38) 100%);
  animation: alarm-pulse 850ms ease-in-out infinite alternate;
}

.scanlines {
  opacity: 0.06;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.14) 4px);
  mix-blend-mode: soft-light;
}

.panel-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  transition: opacity 420ms ease, visibility 420ms;
}

.title-screen {
  display: flex;
  align-items: center;
  padding: max(2.6rem, var(--safe-top)) max(4vw, var(--safe-right)) max(2rem, var(--safe-bottom)) max(6vw, var(--safe-left));
  background:
    linear-gradient(90deg, rgba(4, 15, 19, 0.95) 0%, rgba(4, 15, 19, 0.76) 44%, rgba(4, 15, 19, 0.1) 75%, rgba(4, 15, 19, 0.28) 100%),
    radial-gradient(circle at 74% 30%, rgba(86, 230, 225, 0.12), transparent 32rem);
}

#app:not([data-game-state="title"]) .title-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.title-atmosphere { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.moon {
  position: absolute;
  top: 9%;
  right: 10%;
  width: clamp(4.5rem, 10vw, 8rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 3.5rem rgba(255, 244, 219, 0.26);
  opacity: 0.88;
}

.moon::after {
  position: absolute;
  inset: 12% -8% -8% 22%;
  border-radius: inherit;
  background: #0a232c;
  content: "";
}

.star {
  position: absolute;
  width: 0.25rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 1rem var(--cyan);
  animation: blink 2.8s ease-in-out infinite alternate;
}

.star-1 { top: 18%; left: 58%; }
.star-2 { top: 9%; left: 42%; animation-delay: -1s; }
.star-3 { top: 32%; right: 31%; animation-delay: -2s; }
.star-4 { top: 26%; left: 75%; animation-delay: -0.4s; }

.title-card {
  position: relative;
  z-index: 3;
  display: flex;
  width: min(92vw, 50rem);
  align-items: flex-start;
  flex-direction: column;
  animation: rise-in 850ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.eyebrow,
.build-label,
.controls-hint,
.micro-label {
  font-family: "DM Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
  color: var(--cyan);
  font-size: clamp(0.63rem, 1.5vw, 0.78rem);
  font-weight: 500;
}

.status-light {
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0.8rem var(--coral);
  animation: blink 700ms steps(2) infinite alternate;
}

.mask-mark {
  position: relative;
  width: 5.3rem;
  height: 4rem;
  margin: 0 0 -0.35rem 0.4rem;
  border-radius: 52% 52% 42% 42%;
  background: #90a2a1;
  transform: rotate(-4deg);
  box-shadow: inset 0 -0.65rem 0 #617676, 0 0.55rem 0 rgba(0, 0, 0, 0.25);
}

.ear {
  position: absolute;
  z-index: -1;
  top: -0.5rem;
  width: 1.85rem;
  aspect-ratio: 1;
  border-radius: 50% 50% 42% 42%;
  background: #667a7b;
}

.ear.left { left: -0.3rem; transform: rotate(-30deg); }
.ear.right { right: -0.3rem; transform: rotate(30deg); }

.mask-eye {
  position: absolute;
  top: 1.12rem;
  width: 2rem;
  height: 1.32rem;
  border-radius: 65% 45%;
  background: #142126;
}

.mask-eye::after {
  position: absolute;
  top: 0.31rem;
  right: 0.32rem;
  width: 0.52rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0.8rem rgba(215, 244, 106, 0.75);
  content: "";
}

.mask-eye.left { left: 0.5rem; transform: rotate(8deg); }
.mask-eye.right { right: 0.5rem; transform: scaleX(-1) rotate(8deg); }

.nose {
  position: absolute;
  right: 2.1rem;
  bottom: 0.4rem;
  width: 1rem;
  height: 0.68rem;
  border-radius: 55% 55% 70% 70%;
  background: #111c20;
}

h1 {
  display: flex;
  max-width: 45rem;
  margin: 0;
  align-items: center;
  flex-wrap: wrap;
  color: var(--cream);
  filter: drop-shadow(0 0.6rem 0 rgba(0, 0, 0, 0.35));
  font-family: "Fugaz One", Impact, sans-serif;
  font-size: clamp(3.5rem, 9vw, 7.9rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.77;
  text-transform: uppercase;
}

h1 span:first-child { width: 100%; color: var(--cream); }
h1 span:last-child { color: var(--acid); }
h1 em {
  margin: 0 0.04em;
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 0.72em;
  font-style: italic;
  transform: rotate(-9deg);
}

.tagline {
  margin: clamp(1.15rem, 2.5vh, 1.8rem) 0 1.25rem;
  color: #b7c7c4;
  font-size: clamp(0.95rem, 2.1vw, 1.2rem);
  font-weight: 800;
}

.start-button,
.primary-button {
  position: relative;
  border: 0;
  border-radius: 0.55rem;
  background: var(--coral);
  box-shadow: 0 0.5rem 0 #a7413e, 0 1.2rem 2.2rem rgba(0, 0, 0, 0.35);
  color: #171718;
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.start-button {
  display: flex;
  min-width: min(20rem, 84vw);
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 1.1rem 1rem 1.35rem;
  font-size: 1rem;
  text-align: left;
}

.start-button:disabled { filter: saturate(0.45); cursor: wait; opacity: 0.7; }
.start-button:not(:disabled):hover,
.start-button:not(:disabled):focus-visible,
.primary-button:hover,
.primary-button:focus-visible {
  outline: none;
  background: #ff967d;
  transform: translateY(-0.15rem) rotate(-0.5deg);
  box-shadow: 0 0.65rem 0 #a7413e, 0 1.4rem 2.5rem rgba(0, 0, 0, 0.42);
}

.start-button:not(:disabled):active,
.primary-button:active { transform: translateY(0.35rem); box-shadow: 0 0.15rem 0 #a7413e; }

kbd,
.key-hint {
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 0.28rem;
  padding: 0.28rem 0.45rem;
  background: rgba(255, 255, 255, 0.25);
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
}

.mission-peek {
  display: flex;
  margin-top: 1.4rem;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.mission-peek span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(86, 230, 225, 0.17);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  background: rgba(5, 23, 28, 0.54);
  color: #9db2b0;
  font-size: 0.7rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.mission-peek b { color: var(--cyan); font-family: "DM Mono", monospace; font-size: 0.58rem; }

.controls-hint {
  margin: 1.2rem 0 0;
  color: #75918e;
  font-size: 0.62rem;
  line-height: 1.6;
}

.touch-only { display: none; }

.tape {
  position: absolute;
  z-index: 5;
  width: 120%;
  padding: 0.38rem;
  overflow: hidden;
  background: var(--acid);
  color: #182015;
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-align: center;
  white-space: nowrap;
}

.tape-top { top: 1.2rem; left: -10%; transform: rotate(-1.5deg); }

.build-label {
  position: absolute;
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  z-index: 7;
  color: #69817e;
  font-size: 0.55rem;
}

.build-label span { color: var(--cyan); }

/* HUD */
.hud {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(14rem, 24rem) minmax(12rem, 1fr);
  align-items: start;
  gap: 1rem;
  padding: calc(var(--safe-top) + 0.25rem) calc(var(--safe-right) + 3.8rem) 0 var(--safe-left);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-0.75rem);
  transition: opacity 300ms ease, transform 300ms ease, visibility 300ms;
}

#app[data-game-state="playing"] .hud,
#app[data-game-state="escape"] .hud,
#app[data-game-state="stacking"] .hud,
#app[data-game-state="paused"] .hud {
  visibility: visible;
  opacity: 1;
  transform: none;
}

.hud-card {
  border: 1px solid rgba(86, 230, 225, 0.18);
  border-radius: 0.65rem;
  padding: 0.7rem 0.85rem;
  background: rgba(5, 22, 27, 0.79);
  box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
}

.mission-chip { justify-self: start; min-width: 13rem; }
.micro-label { display: block; color: var(--muted); font-size: 0.52rem; margin-bottom: 0.16rem; }
.mission-chip strong { color: var(--cream); font-size: 0.87rem; }

.alert-card { align-self: start; padding: 0.58rem 0.75rem 0.7rem; }
.alert-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.37rem; }
.alert-heading span { color: var(--muted); font-family: "DM Mono", monospace; font-size: 0.52rem; text-transform: uppercase; letter-spacing: 0.1em; }
.alert-heading strong { color: var(--cyan); font-size: 0.67rem; text-transform: uppercase; }
.alert-track { position: relative; height: 0.48rem; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.alert-track span { position: absolute; inset: 0; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--acid) 48%, var(--coral) 72%, var(--red)); box-shadow: 0 0 0.8rem currentColor; transition: width 100ms linear; }
.alert-track i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(5, 22, 27, 0.7); }
.alert-track i:nth-of-type(1) { left: 25%; }
.alert-track i:nth-of-type(2) { left: 50%; }
.alert-track i:nth-of-type(3) { left: 75%; }

.stats-card { display: flex; justify-self: end; gap: 1rem; }
.stats-card > div { min-width: 3rem; }
.stats-card strong { color: var(--acid); font-family: "DM Mono", monospace; font-size: 0.86rem; }
#timer-stat { display: none; }
#app[data-game-state="escape"] #timer-stat { display: block; }
#app[data-game-state="escape"] #timer { color: var(--coral); }

.utility-buttons {
  position: absolute;
  top: calc(var(--safe-top) + 0.25rem);
  right: var(--safe-right);
  display: flex;
  gap: 0.45rem;
  pointer-events: auto;
}

.icon-button {
  display: grid;
  width: 2.85rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(86, 230, 225, 0.18);
  border-radius: 0.65rem;
  background: rgba(5, 22, 27, 0.79);
  color: var(--cream);
  cursor: pointer;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.icon-button:hover,
.icon-button:focus-visible { border-color: var(--cyan); outline: none; color: var(--cyan); }

.interaction-prompt {
  position: absolute;
  z-index: 13;
  bottom: max(1.2rem, calc(var(--safe-bottom) + 0.4rem));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid rgba(255, 244, 219, 0.18);
  border-radius: 999px;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  background: rgba(5, 22, 27, 0.9);
  box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.34);
  opacity: 0;
  transform: translate(-50%, 1rem) scale(0.94);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.interaction-prompt.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.interaction-prompt strong { font-size: 0.72rem; text-transform: uppercase; }
.interaction-prompt .key-hint { color: var(--acid); border-color: rgba(215, 244, 106, 0.28); background: rgba(215, 244, 106, 0.1); }

.toast-stack {
  position: absolute;
  z-index: 14;
  top: 22%;
  left: 50%;
  display: flex;
  width: min(90vw, 28rem);
  align-items: center;
  flex-direction: column;
  gap: 0.55rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  border: 1px solid rgba(86, 230, 225, 0.25);
  border-radius: 0.6rem;
  padding: 0.62rem 0.9rem;
  background: rgba(5, 22, 27, 0.92);
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.36);
  color: var(--cream);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  animation: toast-in 240ms ease both;
}

.toast strong { color: var(--acid); }
.toast.danger { border-color: rgba(255, 79, 101, 0.5); color: #ffd9dd; }
.toast.big { padding: 0.8rem 1.15rem; font-family: "Fugaz One", sans-serif; font-size: clamp(1rem, 4vw, 1.5rem); text-transform: uppercase; }
.toast.is-leaving { animation: toast-out 220ms ease both; }

/* Touch controls */
.mobile-controls {
  position: absolute;
  z-index: 12;
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  left: var(--safe-left);
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.joystick {
  position: relative;
  display: grid;
  width: 7.4rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(86, 230, 225, 0.2);
  border-radius: 50%;
  background: rgba(5, 22, 27, 0.42);
  box-shadow: inset 0 0 2.4rem rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  touch-action: none;
}

.joystick::before,
.joystick::after { position: absolute; background: rgba(86, 230, 225, 0.12); content: ""; }
.joystick::before { width: 70%; height: 1px; }
.joystick::after { width: 1px; height: 70%; }
.joystick-arrows { position: absolute; top: 0.34rem; color: rgba(86, 230, 225, 0.34); font-size: 0.8rem; }

.joystick-knob {
  position: relative;
  z-index: 2;
  width: 3.55rem;
  aspect-ratio: 1;
  border: 2px solid rgba(215, 244, 106, 0.55);
  border-radius: 50%;
  background: rgba(17, 45, 51, 0.92);
  box-shadow: 0 0.5rem 1.1rem rgba(0, 0, 0, 0.4), inset 0 0 1rem rgba(215, 244, 106, 0.08);
  transform: translate3d(0, 0, 0);
}

.action-cluster { display: flex; align-items: end; gap: 0.7rem; pointer-events: auto; }

.control-button {
  display: flex;
  width: 4.3rem;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid rgba(255, 244, 219, 0.22);
  border-radius: 50%;
  background: rgba(5, 22, 27, 0.78);
  box-shadow: 0 0.45rem 1.2rem rgba(0, 0, 0, 0.35);
  color: var(--cream);
  touch-action: none;
}

.control-button span { font-size: 1.2rem; line-height: 1; }
.control-button small { margin-top: 0.18rem; color: var(--muted); font-family: "DM Mono", monospace; font-size: 0.45rem; text-transform: uppercase; }
.control-button.is-pressed { transform: translateY(0.2rem) scale(0.94); filter: brightness(1.3); }
.action-button { width: 5.2rem; border-color: rgba(255, 128, 102, 0.55); background: rgba(106, 44, 38, 0.82); }
.dash-button { margin-bottom: 2.5rem; border-color: rgba(215, 244, 106, 0.45); }

/* Modal screens */
.compact-screen {
  display: grid;
  place-items: center;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  visibility: hidden;
  background: rgba(2, 10, 13, 0.68);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(9px);
}

#app[data-game-state="paused"] .pause-screen,
#app[data-game-state="won"] .end-screen,
#app[data-game-state="lost"] .end-screen {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: min(92vw, 30rem);
  border: 1px solid rgba(86, 230, 225, 0.23);
  border-radius: 1rem;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  overflow: hidden;
  background: linear-gradient(155deg, rgba(13, 43, 50, 0.98), rgba(5, 19, 24, 0.98));
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.58), inset 0 1px rgba(255, 255, 255, 0.07);
  text-align: center;
  transform: translateY(1rem) scale(0.96);
  transition: transform 330ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#app[data-game-state="paused"] .pause-card,
#app[data-game-state="won"] .end-card,
#app[data-game-state="lost"] .end-card { transform: none; }

.modal-card h2 { margin: 0.35rem 0 0.55rem; color: var(--acid); font-family: "Fugaz One", sans-serif; font-size: clamp(1.8rem, 7vw, 2.8rem); font-weight: 400; line-height: 1; text-transform: uppercase; }
.modal-card p { margin: 0 auto 1.4rem; color: #9eb2af; font-size: 0.9rem; line-height: 1.55; }
.primary-button { width: 100%; min-height: 3.2rem; margin-top: 0.5rem; padding: 0.8rem 1rem; }
.text-button { min-height: 2.8rem; border: 0; background: transparent; color: #8ba4a2; cursor: pointer; font-size: 0.72rem; font-weight: 900; text-decoration: underline; text-decoration-color: rgba(139, 164, 162, 0.35); text-underline-offset: 0.25rem; text-transform: uppercase; }
.text-button:hover,
.text-button:focus-visible { outline: none; color: var(--cream); }

.stamp {
  display: inline-block;
  border: 2px solid var(--coral);
  border-radius: 0.25rem;
  padding: 0.28rem 0.48rem;
  color: var(--coral);
  font-family: "DM Mono", monospace;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  transform: rotate(-3deg);
}

.end-rank { display: flex; align-items: center; justify-content: center; gap: 0.65rem; margin: 0.65rem 0 -0.2rem; }
.end-rank small { color: var(--muted); font-family: "DM Mono", monospace; font-size: 0.55rem; text-transform: uppercase; }
.end-rank strong { color: var(--acid); font-family: "Fugaz One", sans-serif; font-size: 3rem; line-height: 1; text-shadow: 0 0 1.4rem rgba(215, 244, 106, 0.35); }
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; margin: 0.8rem 0 1.2rem; }
.score-grid div { border: 1px solid rgba(86, 230, 225, 0.13); border-radius: 0.55rem; padding: 0.65rem 0.3rem; background: rgba(0, 0, 0, 0.15); }
.score-grid span { display: block; margin-bottom: 0.2rem; color: var(--muted); font-family: "DM Mono", monospace; font-size: 0.48rem; text-transform: uppercase; }
.score-grid strong { color: var(--cream); font-size: 0.9rem; }

.rotate-nudge { display: none; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(1.8rem) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes blink {
  0%, 30% { opacity: 0.3; }
  100% { opacity: 1; }
}

@keyframes alarm-pulse {
  from { opacity: 0.66; }
  to { opacity: 1; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-0.7rem) scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-0.5rem) scale(0.96); }
}

@media (hover: none), (pointer: coarse) {
  .desktop-only { display: none; }
  .touch-only { display: inline; }
  kbd { display: none; }
  #app[data-game-state="playing"] .mobile-controls,
  #app[data-game-state="escape"] .mobile-controls { display: flex; }
  .interaction-prompt { bottom: calc(var(--safe-bottom) + 7.7rem); }
}

@media (max-width: 760px) {
  .desktop-only { display: none; }
  .touch-only { display: inline; }
  kbd { display: none; }
  #app[data-game-state="playing"] .mobile-controls,
  #app[data-game-state="escape"] .mobile-controls { display: flex; }
  .interaction-prompt { bottom: calc(var(--safe-bottom) + 7.7rem); }
  .title-screen {
    align-items: center;
    justify-content: center;
    padding: max(2.8rem, var(--safe-top)) var(--safe-right) max(1.5rem, var(--safe-bottom)) var(--safe-left);
    background: linear-gradient(180deg, rgba(4, 15, 19, 0.48), rgba(4, 15, 19, 0.87));
  }
  .title-card { width: 100%; align-items: center; text-align: center; }
  .mask-mark { margin-left: 0; transform: scale(0.86) rotate(-3deg); }
  h1 { max-width: 23rem; justify-content: center; font-size: clamp(3.4rem, 16vw, 6rem); }
  .tagline { max-width: 21rem; }
  .mission-peek { justify-content: center; gap: 0.35rem; }
  .mission-peek span { padding: 0.3rem 0.5rem; font-size: 0.6rem; }
  .moon { right: 8%; opacity: 0.5; }

  .hud {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 0.45rem;
    padding: calc(var(--safe-top) + 0.15rem) calc(var(--safe-right) + 3.2rem) 0 var(--safe-left);
  }
  .mission-chip { grid-column: 1; min-width: 0; max-width: 15rem; padding: 0.55rem 0.65rem; }
  .mission-chip strong { display: block; overflow: hidden; font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
  .alert-card { grid-row: 2; grid-column: 1 / -1; width: min(80vw, 22rem); justify-self: center; }
  .stats-card { grid-column: 2; gap: 0.5rem; padding: 0.52rem 0.62rem; }
  .stats-card > div { min-width: 2.2rem; }
  .stats-card .micro-label { font-size: 0.42rem; }
  .stats-card strong { font-size: 0.72rem; }
  .utility-buttons { top: calc(var(--safe-top) + 0.15rem); gap: 0.3rem; }
  .icon-button { width: 2.7rem; }
  #mute-button { display: none; }
  .toast-stack { top: 19%; }
}

@media (max-width: 380px) {
  .mission-chip { max-width: 11.5rem; }
  .stats-card > div:nth-child(2) { display: none; }
  .mission-peek span { font-size: 0.54rem; }
  .joystick { width: 6.6rem; }
  .action-button { width: 4.8rem; }
  .dash-button { width: 4rem; }
}

@media (max-height: 660px) and (orientation: landscape) {
  .title-screen { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
  .title-card { transform: scale(0.76); transform-origin: left center; }
  .mask-mark { display: none; }
  .tagline { margin: 0.8rem 0; }
  .mission-peek { margin-top: 1rem; }
  .tape-top { top: 0.35rem; }
  .joystick { width: 6.2rem; }
  .action-button { width: 4.6rem; }
  .dash-button { width: 3.8rem; margin-bottom: 1.5rem; }
  .interaction-prompt { bottom: calc(var(--safe-bottom) + 1.4rem); }
}

@media (max-width: 900px) and (max-height: 600px) {
  .desktop-only { display: none; }
  .touch-only { display: inline; }
  kbd { display: none; }
  #app[data-game-state="playing"] .mobile-controls,
  #app[data-game-state="escape"] .mobile-controls { display: flex; }
}

@media (orientation: portrait) and (max-width: 520px) and (hover: none) {
  .rotate-nudge {
    position: absolute;
    z-index: 9;
    right: var(--safe-right);
    bottom: calc(var(--safe-bottom) + 0.1rem);
    left: var(--safe-left);
    display: block;
    color: rgba(139, 164, 162, 0.5);
    font-family: "DM Mono", monospace;
    font-size: 0.45rem;
    text-align: center;
    pointer-events: none;
  }
  #app[data-game-state="playing"] .rotate-nudge,
  #app[data-game-state="escape"] .rotate-nudge { animation: fade-nudge 5s both; }
}

@keyframes fade-nudge {
  0%, 62% { opacity: 1; }
  100% { opacity: 0; }
}

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