:root {
  color-scheme: dark;
  --ink: #eef1dc;
  --muted: #9ca998;
  --night: #07110f;
  --panel: rgba(5, 12, 10, 0.87);
  --yellow: #ffc62e;
  --yellow-soft: #ffe79a;
  --danger: #ec5d3f;
  --line: rgba(234, 239, 205, 0.22);
}

* { box-sizing: border-box; }

html,
body {
  width: 100vw;
  min-width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #030706;
  color: var(--ink);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
}

button,
a { font: inherit; }

button { color: inherit; }

#game-shell,
#viewport,
#viewport canvas {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  min-width: 100vw;
  height: 100dvh !important;
  min-height: 100dvh;
  background: #030706;
}

#viewport canvas {
  display: block;
  image-rendering: auto;
}

.hidden { display: none !important; }
.mobile-only { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(2, 6, 5, 0.97), rgba(2, 6, 5, 0.58) 54%, rgba(2, 6, 5, 0.82)),
    radial-gradient(circle at 68% 45%, rgba(66, 92, 75, 0.15), transparent 36%);
  backdrop-filter: blur(3px);
}

.screen.active { display: flex; }

#title-screen {
  justify-content: flex-start;
  background:
    linear-gradient(90deg, rgba(3, 8, 7, 0.99) 0 36%, rgba(3, 8, 7, 0.68) 58%, rgba(3, 8, 7, 0.18)),
    radial-gradient(circle at 76% 42%, rgba(255, 198, 46, 0.11), transparent 23%);
}

.title-content {
  width: min(560px, 92vw);
  margin-left: clamp(0px, 5vw, 90px);
  padding: 34px 0;
}

.signal-mark {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 34px;
  margin-bottom: 16px;
}

.signal-mark i {
  width: 7px;
  background: var(--yellow);
  box-shadow: 0 0 18px rgba(255, 198, 46, 0.65);
  animation: signal 1.4s steps(3) infinite;
}

.signal-mark i:nth-child(1) { height: 8px; animation-delay: -.3s; }
.signal-mark i:nth-child(2) { height: 17px; animation-delay: -.6s; }
.signal-mark i:nth-child(3) { height: 30px; animation-delay: -.9s; }
.signal-mark i:nth-child(4) { height: 20px; animation-delay: -1.2s; }
.signal-mark i:nth-child(5) { height: 11px; animation-delay: -1.5s; }

@keyframes signal { 0%, 70%, 100% { opacity: .34; } 35% { opacity: 1; } }

.eyebrow,
.label {
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1,
h2,
p { margin-top: 0; }

.title-content h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(72px, 10vw, 138px);
  line-height: .76;
  letter-spacing: -.025em;
  color: #f0f0dc;
  text-shadow: 8px 9px 0 rgba(0, 0, 0, .55), 0 0 60px rgba(225, 237, 204, .11);
}

.title-content h2 {
  margin: 14px 0 28px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(38px, 5vw, 68px);
  line-height: 1;
  letter-spacing: .11em;
  color: var(--yellow);
  text-shadow: 0 0 36px rgba(255, 198, 46, .22);
}

.tagline {
  max-width: 480px;
  margin-bottom: 25px;
  color: #cfd6c0;
  font-size: clamp(13px, 1.3vw, 17px);
  line-height: 1.65;
}

button {
  position: relative;
  border: 0;
  padding: 14px 20px;
  cursor: pointer;
  letter-spacing: .09em;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  transition: transform .15s ease, filter .15s ease, background .15s ease;
}

button:hover { transform: translateY(-2px); filter: brightness(1.1); }
button:focus-visible { outline: 2px solid white; outline-offset: 4px; }

.primary {
  min-width: 240px;
  background: var(--yellow);
  color: #161608;
  box-shadow: 7px 7px 0 rgba(0, 0, 0, .48), 0 0 34px rgba(255, 198, 46, .13);
}

.secondary {
  border: 1px solid rgba(239, 242, 218, .35);
  background: rgba(10, 18, 15, .7);
  color: #edf1dc;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  max-width: 460px;
  margin-top: 36px;
}

.control-grid span {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

kbd {
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
}

.control-grid small,
.meta {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .1em;
}

.meta { margin: 22px 0 0; }

.title-buttons { justify-content: flex-start; }
.title-buttons .secondary { min-width: 148px; }

.creator-credit {
  display: inline-block;
  color: var(--yellow);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-decoration: none;
}

.title-credit {
  margin-top: 19px;
  padding: 12px 15px 11px;
  border: 1px solid rgba(255, 198, 46, .26);
  border-left: 4px solid var(--yellow);
  background: linear-gradient(90deg, rgba(255, 198, 46, .12), rgba(3, 8, 7, .18));
  box-shadow: 0 10px 30px rgba(0, 0, 0, .24), inset 0 0 28px rgba(255, 198, 46, .025);
  font-size: 12px;
  letter-spacing: .14em;
}
.creator-credit:hover { color: white; }

.terminal {
  width: min(760px, 92vw);
  padding: clamp(25px, 4vw, 52px);
  border: 1px solid rgba(247, 233, 173, .22);
  border-top: 4px solid var(--yellow);
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(0, 0, 0, .72), inset 0 0 65px rgba(255, 198, 46, .025);
}

.terminal.compact { width: min(580px, 92vw); }
.terminal.centered { text-align: center; }
.terminal-copy { min-height: 180px; margin: 28px 0; }

.terminal-copy p,
.terminal > p:not(.eyebrow):not(.copy-status) {
  color: #c5cfba;
  line-height: 1.7;
}

.terminal h2 {
  margin: 15px 0 21px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  color: #f1f1da;
  font-size: clamp(37px, 6vw, 68px);
  letter-spacing: .04em;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .95);
}

.hud-record,
.objective-panel,
.trace-panel,
.meters,
.flashlight-state {
  position: absolute;
  padding: 12px 14px;
  border-left: 2px solid var(--yellow);
  background: linear-gradient(90deg, rgba(3, 8, 7, .69), rgba(3, 8, 7, .05));
}

.hud-record { top: 23px; left: 25px; min-width: 192px; }
.hud-record > div { display: flex; justify-content: space-between; margin-top: 5px; }
.hud-record strong { color: #ef6a4c; font-size: 11px; letter-spacing: .13em; }
.hud-record strong b { animation: recBlink 1s steps(1) infinite; }
.hud-record #timer { font-size: 13px; font-weight: 800; }
@keyframes recBlink { 50% { opacity: .2; } }

.objective-panel {
  top: 23px;
  left: 50%;
  width: min(390px, 48vw);
  padding: 11px 20px 13px;
  border: 1px solid rgba(255, 198, 46, .24);
  border-top: 3px solid var(--yellow);
  background: rgba(4, 10, 8, .76);
  text-align: center;
  transform: translateX(-50%);
}

.objective-panel > strong {
  display: block;
  overflow: hidden;
  margin: 4px 0 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  letter-spacing: .05em;
}

#mission-step {
  display: block;
  overflow: hidden;
  margin: 0 0 8px;
  color: #d7dfc9;
  font-size: 9px;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compass-row { display: flex; align-items: center; justify-content: center; gap: 13px; }
#compass-arrow {
  display: inline-block;
  color: var(--yellow);
  font-style: normal;
  filter: drop-shadow(0 0 7px var(--yellow));
  transform-origin: 50% 54%;
}
#objective-distance { color: var(--yellow-soft); font-size: 11px; font-weight: 900; }

.trace-panel { top: 23px; right: 25px; min-width: 130px; text-align: right; border-left: 0; border-right: 2px solid var(--yellow); }
.trace-panel strong { display: block; margin-top: 3px; font-size: 18px; }
.trace-panel strong b { color: var(--yellow); }

.meters { bottom: 42px; left: 25px; width: 248px; }
.meter-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px; margin: 8px 0; font-size: 10px; letter-spacing: .08em; }
.meter-row > i { height: 6px; overflow: hidden; background: rgba(255,255,255,.12); transform: skewX(-12deg); }
.meter-row > i > b { display: block; width: 100%; height: 100%; background: var(--yellow); box-shadow: 0 0 10px rgba(255, 198, 46, .65); transform-origin: left; }
.meter-row:first-child > i > b { background: #d8e6c4; }
.noise-row > i > b { background: #ec5d3f; box-shadow: 0 0 10px rgba(236,93,63,.6); }

.flashlight-state { right: 25px; bottom: 42px; min-width: 154px; text-align: right; border-left: 0; border-right: 2px solid var(--yellow); }
.flashlight-state strong { display: block; margin: 2px 0; color: var(--yellow); font-size: 16px; }
.flashlight-state small { color: var(--muted); font-size: 9px; }
.flashlight-state.off { border-color: #69726a; }
.flashlight-state.off strong { color: #8b938c; }

.gear-state {
  position: absolute;
  right: 25px;
  bottom: 135px;
  min-width: 154px;
  padding: 10px 14px;
  border-right: 2px solid #77c3b2;
  background: linear-gradient(270deg, rgba(3, 8, 7, .7), rgba(3, 8, 7, .08));
  text-align: right;
}

.gear-state .label { color: #77c3b2; }
.gear-state strong { display: block; margin: 2px 0; color: #b5eee1; font-size: 15px; }
.gear-state small { color: var(--muted); font-size: 9px; }

#control-strip {
  position: fixed;
  z-index: 13;
  left: 50%;
  bottom: 9px;
  display: grid;
  grid-template-columns: repeat(4, max-content);
  justify-content: center;
  gap: 5px 13px;
  width: auto;
  max-width: calc(100vw - 520px);
  padding: 7px 14px 8px;
  overflow: visible;
  border: 1px solid rgba(255,198,46,.2);
  border-bottom-color: rgba(255,198,46,.38);
  background: rgba(2,7,6,.82);
  box-shadow: 0 8px 28px rgba(0,0,0,.34);
  color: #93a197;
  font-size: 8px;
  letter-spacing: .06em;
  transform: translateX(-50%);
  pointer-events: none;
}

#control-strip span { white-space: nowrap; }
#control-strip kbd { color: var(--yellow); margin-right: 3px; }

#reticle {
  position: fixed;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 245, 205, .65);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 5px rgba(255,255,255,.3);
}

#interaction {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: 18%;
  width: min(340px, 75vw);
  padding: 13px 18px;
  border: 1px solid rgba(255, 198, 46, .5);
  background: rgba(4, 8, 7, .86);
  text-align: center;
  transform: translateX(-50%);
}

#interaction strong { color: var(--yellow-soft); font-size: 11px; letter-spacing: .09em; }
#interaction > i { display: block; height: 4px; margin-top: 9px; overflow: hidden; background: rgba(255,255,255,.1); }
#interaction-fill { display: block; width: 0; height: 100%; background: var(--yellow); box-shadow: 0 0 10px var(--yellow); }

#subtitle {
  position: fixed;
  z-index: 14;
  left: 50%;
  bottom: 10%;
  max-width: min(700px, 86vw);
  min-height: 30px;
  color: #f0efdc;
  font-size: clamp(12px, 1.35vw, 16px);
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  text-shadow: 0 2px 4px black, 0 0 14px black;
  transform: translateX(-50%);
  transition: opacity .25s ease;
}

#chapter-card {
  position: fixed;
  z-index: 18;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.96);
  transition: opacity .35s ease, transform .35s ease;
}

#chapter-card.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#chapter-number { color: var(--yellow); font-size: 11px; letter-spacing: .25em; }
#chapter-name { margin-top: 7px; font-family: Impact, sans-serif; font-size: clamp(34px, 7vw, 78px); letter-spacing: .06em; text-align: center; text-shadow: 4px 5px 0 rgba(0,0,0,.7); }

#toggle-toast {
  position: fixed;
  z-index: 16;
  right: 27px;
  bottom: 108px;
  padding: 7px 11px;
  opacity: 0;
  color: var(--yellow);
  border-right: 2px solid currentColor;
  background: rgba(3,8,7,.65);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  transform: translateX(10px);
  transition: opacity .2s, transform .2s;
}

#toggle-toast.show { opacity: 1; transform: translateX(0); }

#tuning-panel {
  position: fixed;
  z-index: 19;
  left: 50%;
  bottom: 16%;
  width: min(520px, 82vw);
  padding: 18px 22px;
  border: 1px solid rgba(255,198,46,.45);
  border-top: 3px solid var(--yellow);
  background: rgba(3,9,7,.93);
  text-align: center;
  transform: translateX(-50%);
}

#tuning-panel > strong { display: block; margin: 8px 0 15px; font-size: 10px; letter-spacing: .07em; }
.tuning-track { position: relative; height: 22px; overflow: hidden; background: #111b17; }
#tuning-lock { position: absolute; top: 0; bottom: 0; left: 63%; width: 13%; background: rgba(255,198,46,.24); border-left: 1px solid var(--yellow); border-right: 1px solid var(--yellow); }
#tuning-needle { position: absolute; top: 0; bottom: 0; left: 10%; width: 3px; background: #eff5df; box-shadow: 0 0 10px white; transition: left .04s linear; }
#tuning-status { display: block; margin-top: 9px; color: var(--yellow); }

.controls-terminal { width: min(900px, 94vw); }
.settings-layout { display: grid; grid-template-columns: 1.15fr .85fr; gap: 34px; margin: 24px 0 30px; text-align: left; }
.settings-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.settings-controls span { display: grid; grid-template-columns: 82px 1fr; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.settings-controls b { color: #b9c4b2; font-size: 10px; font-weight: 500; }
.settings-options { display: flex; flex-direction: column; gap: 15px; }
.settings-options label { display: flex; flex-direction: column; gap: 7px; color: var(--yellow); font-size: 9px; font-weight: 900; letter-spacing: .09em; }
.settings-options input { accent-color: var(--yellow); }
.settings-options select { border: 1px solid var(--line); padding: 9px; background: #0b1512; color: var(--ink); font: inherit; }

#camera-fx,
#camera-fx > * {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#camera-fx { z-index: 7; overflow: hidden; }
.vignette { box-shadow: inset 0 0 18vw 3vw rgba(0,0,0,.68); }
.scanlines { opacity: .06; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,.9) 4px); }
.grain { opacity: .085; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E"); animation: grain 1.1s steps(2) infinite; }
@keyframes grain { 0% { transform: translate(0,0); } 25% { transform: translate(-2%,1%); } 50% { transform: translate(1%,-2%); } 75% { transform: translate(2%,2%); } }
#fear-fx { opacity: 0; background: radial-gradient(circle, transparent 25%, rgba(123,0,0,.18) 72%, rgba(0,0,0,.8)); transition: opacity .16s linear; }
#damage-fx { opacity: 0; background: rgba(219,31,10,.36); mix-blend-mode: screen; }
#lightning { opacity: 0; background: rgba(213, 226, 210, .36); }

.death-stats,
.ending-stats {
  display: flex;
  justify-content: center;
  gap: 54px;
  margin: 27px 0;
}

.death-stats span,
.ending-stats span { display: flex; flex-direction: column; gap: 5px; }
.death-stats small,
.ending-stats small { color: var(--muted); font-size: 9px; letter-spacing: .17em; }
.death-stats b,
.ending-stats b { color: var(--yellow); font-size: 19px; }
.button-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 13px; }
.copy-status { min-height: 18px; margin: 18px 0 0; color: var(--yellow) !important; font-size: 10px; }

footer {
  position: fixed;
  z-index: 41;
  left: 18px;
  bottom: 12px;
  padding: 7px 10px 7px 12px;
  border-left: 2px solid rgba(255, 198, 46, .72);
  background: rgba(3, 7, 6, .72);
  color: rgba(224, 229, 210, .68);
  font-size: 9px;
  letter-spacing: .1em;
  pointer-events: auto;
}

footer a { color: rgba(255, 198, 46, .95); font-weight: 900; }

/* Touch controls are mounted only for coarse-pointer/mobile visitors. */
#mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: none;
  overflow: hidden;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.touch-device #mobile-controls.active { display: block; }

#touch-look-zone {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  bottom: 0;
  left: 36%;
  pointer-events: auto;
  touch-action: none;
}

#touch-look-zone > span {
  position: absolute;
  right: 19px;
  top: 46%;
  padding: 6px 8px;
  border-right: 2px solid rgba(255, 198, 46, .52);
  opacity: 0;
  background: rgba(2, 7, 6, .5);
  color: rgba(255, 231, 154, .72);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .11em;
  animation: mobileHint 4.5s ease .8s 1;
}

@keyframes mobileHint {
  0%, 100% { opacity: 0; transform: translateX(8px); }
  16%, 72% { opacity: 1; transform: translateX(0); }
}

.mobile-joystick {
  position: absolute;
  z-index: 4;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  width: 128px;
  height: 150px;
  pointer-events: auto;
  touch-action: none;
}

.joystick-ring {
  position: relative;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(239, 242, 218, .31);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(255,255,255,.08) 50%, transparent 50.5%),
    linear-gradient(0deg, transparent 49.5%, rgba(255,255,255,.08) 50%, transparent 50.5%),
    radial-gradient(circle, rgba(16, 28, 24, .7), rgba(2, 7, 6, .35));
  box-shadow: inset 0 0 30px rgba(0,0,0,.55), 0 8px 26px rgba(0,0,0,.35);
}

#mobile-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(255, 198, 46, .7);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, rgba(255, 231, 154, .3), rgba(255, 198, 46, .09) 50%, rgba(2, 7, 6, .8));
  box-shadow: 0 0 18px rgba(255, 198, 46, .12);
  transform: translate(-50%, -50%);
}

.mobile-joystick > span {
  display: block;
  margin-top: 7px;
  color: rgba(224, 229, 210, .58);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .2em;
  text-align: center;
}

.mobile-actions {
  position: absolute;
  z-index: 5;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(13px, calc(env(safe-area-inset-bottom) + 6px));
  width: 194px;
  height: 155px;
  pointer-events: none;
}

.mobile-button,
.mobile-utility {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(239, 242, 218, .34);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 27%, rgba(70, 91, 79, .74), rgba(4, 10, 8, .88) 68%);
  box-shadow: 0 7px 20px rgba(0,0,0,.43), inset 0 0 18px rgba(255,255,255,.025);
  color: #eff1df;
  pointer-events: auto;
  touch-action: none;
}

.mobile-button b,
.mobile-utility b { font-size: 10px; line-height: 1; letter-spacing: .07em; }
.mobile-button small,
.mobile-utility small { margin-top: 5px; color: #9eaa9e; font-size: 7px; line-height: 1; letter-spacing: .08em; }
.mobile-button:active,
.mobile-button.pressed,
.mobile-button.active,
.mobile-utility:active {
  border-color: var(--yellow);
  background: radial-gradient(circle at 36% 28%, rgba(255, 222, 112, .85), rgba(255, 198, 46, .36) 46%, rgba(25, 24, 8, .92));
  color: #fffbdc;
  filter: brightness(1.1);
  transform: scale(.94);
}

.mobile-button.active small,
.mobile-button.pressed small { color: #fff0ab; }
.mobile-button.active { transform: none; }
.mobile-button.unavailable { opacity: .42; filter: grayscale(.7); }

.action-button {
  position: absolute;
  top: 0;
  right: 54px;
  width: 82px;
  height: 82px;
  border-width: 2px;
  border-color: rgba(255, 198, 46, .75);
  background: radial-gradient(circle at 36% 28%, rgba(255, 222, 112, .24), rgba(52, 43, 9, .9) 63%);
  box-shadow: 0 0 26px rgba(255, 198, 46, .12), 0 8px 20px rgba(0,0,0,.48);
}

.action-button b { color: var(--yellow-soft); font-size: 13px; }
.run-button,
.jump-button { position: absolute; bottom: 0; width: 66px; height: 66px; }
.run-button { left: 0; }
.jump-button { right: 0; }

.mobile-equipment {
  position: absolute;
  z-index: 5;
  right: max(13px, env(safe-area-inset-right));
  bottom: max(183px, calc(env(safe-area-inset-bottom) + 175px));
  display: grid;
  grid-template-columns: repeat(2, 54px);
  gap: 8px;
  pointer-events: none;
}

.equipment-button { width: 54px; height: 54px; }
.equipment-button b { font-size: 8px; }
.equipment-button small { font-size: 6px; }

.mobile-utility {
  position: absolute;
  z-index: 5;
  top: max(95px, calc(env(safe-area-inset-top) + 88px));
  left: 50%;
  width: 45px;
  height: 45px;
  border-radius: 10px;
  transform: translateX(-50%);
}

.mobile-utility:active { transform: translateX(-50%) scale(.94); }

.mobile-control-guide {
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  max-width: 520px;
  margin-top: 27px;
}

.mobile-control-guide span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 8px;
  border-top: 1px solid var(--line);
}

.mobile-control-guide b { color: var(--ink); font-size: 9px; }
.mobile-control-guide small { color: var(--muted); font-size: 7px; letter-spacing: .07em; }

/* The title already carries the full-size creator signature. */
#title-screen.active ~ footer { display: none; }

@media (min-width: 1180px) {
  #control-strip {
    grid-template-columns: repeat(8, max-content);
    max-width: calc(100vw - 500px);
  }
}

/* JS applies this class after a coarse pointer, no-hover device, or touch-capable
   browser is detected. Keeping the rules class-driven also makes mobile QA deterministic. */
  html.touch-device,
  .touch-device body { overscroll-behavior: none; touch-action: none; }
  .touch-device .desktop-only { display: none !important; }
  .touch-device .mobile-only { display: grid !important; }
  .touch-device button:hover { transform: none; filter: none; }
  .touch-device .screen { overflow-x: hidden; overflow-y: auto; }
  .touch-device #title-screen { justify-content: center; padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); }
  .touch-device .title-content { width: min(560px, 100%); margin: auto; padding: 12px 0; text-align: center; }
  .touch-device .signal-mark { justify-content: center; height: 26px; margin-bottom: 12px; }
  .touch-device .signal-mark i:nth-child(3) { height: 24px; }
  .touch-device .title-content h1 { font-size: clamp(58px, 18.6vw, 105px); }
  .touch-device .title-content h2 { margin: 12px 0 18px; font-size: clamp(31px, 9.7vw, 56px); }
  .touch-device .tagline { margin: 0 auto 18px; font-size: 12px; }
  .touch-device .title-buttons { justify-content: center; }
  .touch-device .title-buttons button { min-width: 0; padding: 13px 15px; font-size: 10px; }
  .touch-device .title-buttons .primary { min-width: 205px; }
  .touch-device .meta { margin-top: 14px; }
  .touch-device .title-credit { margin-top: 13px; padding: 10px 12px; font-size: 10px; }
  .touch-device footer { display: none; }
  .touch-device #control-strip { display: none !important; }
  .touch-device .terminal { width: min(720px, calc(100vw - 24px)); padding: 22px 18px; }
  .touch-device .terminal h2 { font-size: clamp(34px, 11vw, 58px); }
  .touch-device .terminal-copy { min-height: 0; margin: 20px 0; }
  .touch-device .terminal-copy p { margin-bottom: 10px; font-size: 11px; }
  .touch-device .settings-layout { grid-template-columns: 1fr; gap: 18px; margin: 17px 0; }
  .touch-device .settings-controls { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .touch-device .settings-controls span { grid-template-columns: 56px 1fr; padding: 6px; }
  .touch-device .settings-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
  .touch-device .settings-options button { min-width: 0; }
  .touch-device #controls-resume-button { min-width: 210px; }
  .touch-device .objective-panel {
    top: max(8px, env(safe-area-inset-top));
    width: calc(100vw - 24px);
    padding: 8px 12px 9px;
  }
  .touch-device .objective-panel > strong { margin: 3px 0 4px; font-size: 12px; }
  .touch-device #mission-step { margin-bottom: 5px; font-size: 8px; }
  .touch-device .hud-record { top: max(82px, calc(env(safe-area-inset-top) + 74px)); left: 12px; min-width: 126px; padding: 8px 9px; }
  .touch-device .hud-record .label { display: none; }
  .touch-device .trace-panel { top: max(82px, calc(env(safe-area-inset-top) + 74px)); right: 12px; min-width: 92px; padding: 8px 9px; }
  .touch-device .trace-panel .label { font-size: 7px; }
  .touch-device .trace-panel strong { font-size: 14px; }
  .touch-device .meters { bottom: max(173px, calc(env(safe-area-inset-bottom) + 165px)); left: max(12px, env(safe-area-inset-left)); width: 146px; padding: 7px 8px; }
  .touch-device .meter-row { grid-template-columns: 52px 1fr; gap: 5px; margin: 5px 0; font-size: 7px; }
  .touch-device .flashlight-state,
  .touch-device .gear-state { display: none; }
  .touch-device #reticle { width: 13px; height: 13px; }
  .touch-device #interaction { bottom: max(340px, calc(env(safe-area-inset-bottom) + 332px)); width: min(310px, 78vw); padding: 9px 12px; }
  .touch-device #interaction strong { font-size: 9px; }
  .touch-device #subtitle { bottom: max(300px, calc(env(safe-area-inset-bottom) + 292px)); width: 76vw; font-size: 11px; }
  .touch-device #toggle-toast { right: 14px; bottom: max(318px, calc(env(safe-area-inset-bottom) + 310px)); }
  .touch-device #tuning-panel { bottom: max(330px, calc(env(safe-area-inset-bottom) + 322px)); width: min(410px, 82vw); padding: 12px 14px; }
  .touch-device #chapter-name { font-size: clamp(31px, 11vw, 62px); }

.touch-device .mobile-button:active,
.touch-device .mobile-button.pressed { transform: scale(.94); }

@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px), (hover: none) and (orientation: landscape) and (max-height: 560px) {
  .touch-device .title-content { max-width: 620px; padding: 6px 0; }
  .touch-device .signal-mark,
  .touch-device .tagline,
  .touch-device .mobile-control-guide,
  .touch-device .meta { display: none !important; }
  .touch-device .title-content h1 { font-size: clamp(55px, 12vw, 92px); }
  .touch-device .title-content h2 { margin: 8px 0 13px; font-size: clamp(28px, 6vw, 46px); }
  .touch-device .title-credit { margin-top: 10px; }
  .touch-device .objective-panel { width: min(330px, 43vw); }
  .touch-device .hud-record { display: none; }
  .touch-device .trace-panel { top: max(9px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  .touch-device .mobile-utility { top: max(10px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); transform: none; }
  .touch-device .mobile-utility:active { transform: scale(.94); }
  .touch-device .mobile-joystick { width: 108px; height: 125px; bottom: max(7px, env(safe-area-inset-bottom)); }
  .touch-device .joystick-ring { width: 108px; height: 108px; }
  .touch-device #mobile-stick { width: 49px; height: 49px; }
  .touch-device .mobile-actions { width: 174px; height: 126px; bottom: max(7px, env(safe-area-inset-bottom)); }
  .touch-device .action-button { right: 48px; width: 70px; height: 70px; }
  .touch-device .run-button,
  .touch-device .jump-button { width: 58px; height: 58px; }
  .touch-device .mobile-equipment { right: max(184px, calc(env(safe-area-inset-right) + 174px)); bottom: max(8px, env(safe-area-inset-bottom)); grid-template-columns: repeat(2, 48px); gap: 6px; }
  .touch-device .equipment-button { width: 48px; height: 48px; }
  .touch-device .meters { bottom: max(8px, env(safe-area-inset-bottom)); left: max(133px, calc(env(safe-area-inset-left) + 120px)); width: 135px; }
  .touch-device #interaction { bottom: max(143px, calc(env(safe-area-inset-bottom) + 133px)); }
  .touch-device #subtitle { bottom: max(116px, calc(env(safe-area-inset-bottom) + 106px)); }
  .touch-device #tuning-panel { bottom: max(137px, calc(env(safe-area-inset-bottom) + 127px)); width: min(390px, 54vw); }
  .touch-device .controls-terminal { margin: 12px auto; }
  .touch-device .controls-terminal h2 { display: none; }
  .touch-device .settings-layout { grid-template-columns: 1.1fr .9fr; margin: 9px 0 12px; }
  .touch-device .settings-controls span { padding: 4px 6px; }
  .touch-device .settings-options { gap: 7px; }
}

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