:root {
  color-scheme: dark;
  --coal: #080b11;
  --steel: #171e29;
  --steel-2: #253142;
  --cyan: #64e9ff;
  --cyan-dim: #2a7180;
  --sodium: #ffc857;
  --danger: #ff4d5a;
  --bone: #e9e3d5;
  --muted: #8993a1;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--coal);
  overscroll-behavior: none;
  touch-action: none;
}

button, textarea { font: inherit; }

button {
  min-width: 44px;
  min-height: 44px;
  color: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.game {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 460px;
  isolation: isolate;
  background: var(--coal);
  user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.game-brand {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--bone);
  letter-spacing: .13em;
  pointer-events: none;
}

.game-brand__sigil {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--bone);
  color: var(--coal);
  font-size: 21px;
  font-weight: 900;
  transform: skewX(-7deg);
}

.game-brand__sigil span { color: var(--danger); }
.game-brand__text { font-size: 14px; font-weight: 900; }
.game-brand__text small { display: block; margin-top: 3px; color: var(--muted); font: 9px/1.2 ui-monospace, monospace; letter-spacing: .08em; }

.hud {
  position: absolute;
  top: 14%;
  left: clamp(20px, 5vw, 84px);
  width: min(620px, calc(100vw - 40px));
  pointer-events: none;
  text-shadow: 0 2px 12px #000;
  transition: opacity .22s ease;
}

.game[data-intro="warehouse"] .hud,
.game[data-intro="warehouse"] .system-readout,
.game[data-intro="warehouse"] .action-button { opacity: 0; }
.game[data-manual-showcase="true"] .game-brand,
.game[data-manual-showcase="true"] .hud,
.game[data-manual-showcase="true"] .system-readout,
.game[data-manual-showcase="true"] .corner-tools { display: none; }
.game[data-chip-showcase="true"] .game-brand,
.game[data-chip-showcase="true"] .hud,
.game[data-chip-showcase="true"] .system-readout,
.game[data-chip-showcase="true"] .action-button,
.game[data-chip-showcase="true"] .python-chip,
.game[data-chip-showcase="true"] .machine,
.game[data-chip-showcase="true"] .ending,
.game[data-chip-showcase="true"] .skill-journal,
.game[data-chip-showcase="true"] .corner-tools { display: none !important; }
.game[data-wake-reveal="true"] .hud { opacity: 0; }
.game[data-wake-reveal="true"] .skill-journal { opacity: 0; }

.hud__eyebrow,
.ending__eyebrow {
  margin: 0 0 12px;
  color: var(--sodium);
  font: 700 11px/1.2 ui-monospace, monospace;
  letter-spacing: .18em;
}

.hud h1 {
  margin: 0;
  max-width: 560px;
  color: var(--bone);
  font-size: clamp(32px, 6vw, 76px);
  line-height: .93;
  letter-spacing: -.055em;
  text-transform: uppercase;
}

#gameMessage {
  display: inline-block;
  margin: 20px 0 0;
  padding: 8px 11px;
  background: var(--bone);
  color: var(--coal);
  font: 800 13px/1 ui-monospace, monospace;
  letter-spacing: .08em;
  text-shadow: none;
  text-transform: uppercase;
}

.hud__progress {
  width: 210px;
  height: 3px;
  margin-top: 18px;
  background: #ffffff1f;
}

.hud__progress i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 13px var(--cyan);
  transition: width .2s ease;
}

.system-readout {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  right: max(112px, calc(env(safe-area-inset-right) + 112px));
  display: flex;
  gap: 24px;
  color: var(--muted);
  font: 9px/1.1 ui-monospace, monospace;
  letter-spacing: .09em;
}

.system-readout b { display: block; margin-top: 4px; color: var(--bone); font-size: 11px; }

.power-rack {
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: calc(24px + var(--safe-bottom));
  display: flex;
  gap: 9px;
}

.power {
  position: relative;
  width: 92px;
  height: 76px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid #ffffff2c;
  background: #0d131dcc;
  backdrop-filter: blur(8px);
  text-align: left;
}

.power:hover { border-color: var(--cyan); }
.power:active { transform: translateY(2px); }
.power__key { color: var(--muted); font: 9px ui-monospace, monospace; }
.power b { display: block; margin-top: 17px; font-size: 11px; letter-spacing: .08em; }
.power i { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: var(--cyan); box-shadow: 0 0 15px var(--cyan); }
.power--pulse i { background: var(--sodium); box-shadow: 0 0 15px var(--sodium); }
.power--shield i { background: var(--bone); box-shadow: 0 0 15px var(--bone); }
.power[disabled] { opacity: .22; filter: grayscale(1); }

.action-button {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: calc(24px + var(--safe-bottom));
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-left: 3px solid var(--sodium);
  background: var(--bone);
  color: var(--coal);
  font-size: 12px;
  letter-spacing: .08em;
}

.action-button__key { color: #6c665b; font: 9px ui-monospace, monospace; }

.python-chip {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(28px, calc(24px + var(--safe-bottom)));
  display: grid;
  grid-template-columns: 42px auto;
  gap: 2px 11px;
  min-width: 250px;
  padding: 10px 16px;
  transform: translateX(-50%) rotate(-1deg);
  border: 1px solid var(--cyan);
  border-left: 5px solid var(--sodium);
  background: #071921ed;
  box-shadow: 0 0 0 1px #64e9ff33, 0 0 30px #64e9ff44;
  color: var(--bone);
  text-align: left;
  animation: chip-call .76s ease-in-out infinite alternate;
}
.python-chip[hidden] { display: none; }
.python-chip span { grid-row: 1 / 3; display: grid; width: 42px; height: 42px; place-items: center; background: var(--cyan); color: var(--coal); font: 900 15px ui-monospace, monospace; }
.python-chip b { align-self: end; font: 900 12px/1 ui-monospace, monospace; letter-spacing: .08em; }
.python-chip small { color: var(--cyan); font: 10px/1 ui-monospace, monospace; }
@keyframes chip-call { from { box-shadow: 0 0 0 1px #64e9ff33, 0 0 20px #64e9ff33; } to { box-shadow: 0 0 0 1px #64e9ffbb, 0 0 42px #64e9ff77; } }

.storage-warning {
  position: absolute;
  z-index: 6;
  top: max(74px, calc(env(safe-area-inset-top) + 58px));
  left: 50%;
  width: min(520px, calc(100vw - 32px));
  padding: 11px 14px;
  transform: translateX(-50%);
  border: 1px solid #ff4d5a88;
  background: #1a090de8;
  box-shadow: 0 14px 45px #000b, inset 3px 0 0 var(--danger);
  color: #ffb4ba;
  font: 800 10px/1.35 ui-monospace, monospace;
  letter-spacing: .08em;
  text-align: center;
  pointer-events: none;
}

.storage-warning[hidden] { display: none; }

.corner-tools {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 6px;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #ffffff24;
  background: #080b11b8;
  color: var(--muted);
  font: 17px/1 ui-monospace, monospace;
}

.icon-button:hover { color: var(--bone); border-color: #ffffff66; }

.machine {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  width: min(470px, 34vw);
  height: 100%;
  padding: max(28px, env(safe-area-inset-top)) 34px calc(30px + var(--safe-bottom));
  border-left: 1px solid #64e9ff52;
  background: #0a1019f4;
  box-shadow: -28px 0 80px #000a;
  user-select: text;
  overflow-y: auto;
  touch-action: pan-y;
}

.machine[hidden], .ending[hidden] { display: none; }
.skill-journal[hidden] { display: none; }
.skill-journal {
  position: absolute;
  z-index: 3;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(22px + var(--safe-bottom));
  width: min(280px, calc(100vw - 40px));
  padding: 12px;
  border: 1px solid #64e9ff55;
  background: #080b11e8;
  box-shadow: 0 0 35px #64e9ff13;
  pointer-events: none;
}
.skill-journal > p { margin: 0 0 8px; color: var(--cyan); font: 800 9px/1.2 ui-monospace, monospace; letter-spacing: .12em; }
.skill-card { display: grid; gap: 3px; padding: 8px 10px; border-left: 3px solid #59687a; background: #ffffff08; }
.skill-card + .skill-card { margin-top: 5px; }
.skill-card b { color: var(--muted); font: 900 13px/1 ui-monospace, monospace; }
.skill-card span { color: var(--muted); font: 10px/1.25 ui-monospace, monospace; }
.skill-card small { color: #718398; font: 8px/1.2 ui-monospace, monospace; }
.skill-card[data-unlocked="true"] { border-left-color: var(--cyan); box-shadow: inset 18px 0 30px #64e9ff0b; }
.skill-card[data-unlocked="true"] b { color: var(--bone); }
.skill-card[data-unlocked="true"] span { color: var(--cyan); }
.skill-card[data-unlocked="false"] { opacity: .4; filter: grayscale(1); }
.machine__rail { position: absolute; left: -46px; top: 50%; width: 46px; height: 4px; background: var(--cyan); box-shadow: 0 0 20px var(--cyan); }
.machine__rail span { position: absolute; right: 8px; top: -5px; width: 13px; height: 13px; border-radius: 50%; background: white; box-shadow: 0 0 22px var(--cyan); }
.machine__header { display: flex; align-items: center; justify-content: space-between; }
.machine__status { color: var(--cyan); font: 10px ui-monospace, monospace; letter-spacing: .15em; }
.machine__status i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.machine h2 { max-width: 100%; margin: clamp(18px, 5vh, 44px) 0 10px; color: var(--bone); font-size: clamp(30px, 2.7vw, 41px); line-height: .96; letter-spacing: -.04em; overflow-wrap: anywhere; text-transform: uppercase; }
.machine p { max-width: 420px; color: var(--muted); line-height: 1.5; }
.machine-clue {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 16px;
  padding: 10px 13px;
  overflow: hidden;
  border: 1px dashed #ffc85770;
  background: #e9e3d50d;
  color: var(--sodium);
  transform: rotate(-.4deg);
}
.machine-clue::after { content: ""; position: absolute; right: -12px; top: -18px; width: 40px; height: 40px; background: #0a1019; transform: rotate(38deg); }
.machine-clue span { font: 8px/1.2 ui-monospace, monospace; letter-spacing: .14em; }
.machine-clue span, .machine-clue code { position: relative; z-index: 1; min-width: 0; }
.machine-clue code { color: var(--bone); font: 800 14px/1 ui-monospace, monospace; white-space: nowrap; }
.other-mind-status {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 5px 14px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #ffffff16;
  background: #05080d;
  color: #59687a;
  font: 9px/1.3 ui-monospace, monospace;
  letter-spacing: .12em;
}
.other-mind-glyph {
  position: relative;
  grid-row: 1 / 3;
  width: 48px;
  height: 48px;
  border: 2px solid #4c5868;
  border-radius: 52% 48% 58% 42%;
  background: #151b24;
  box-shadow: 0 0 6px #4c586844;
  transform: rotate(-24deg) scale(.72);
}
.other-mind-glyph span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 3px;
  border-radius: 50%;
  background: #4c5868;
  transform: translate(-50%, -50%);
}
.other-mind-status b { color: #718398; }
.other-mind-status p { grid-column: 2 / -1; min-height: 18px; margin: 0; color: inherit; font: 11px/1.45 ui-monospace, monospace; letter-spacing: 0; }
.other-mind-status[data-phase="waking"] { border-color: #ffc85766; color: var(--sodium); }
.other-mind-status[data-phase="waking"] .other-mind-glyph { border-color: var(--sodium); box-shadow: 0 0 22px #ffc85788; animation: other-mind-birth 1.2s cubic-bezier(.2, .8, .2, 1) 1 both; }
.other-mind-status[data-phase="waking"] .other-mind-glyph span { height: 7px; background: var(--sodium); }
.other-mind-status[data-phase="awake"] { border-color: #64e9ff78; color: var(--cyan); box-shadow: inset 3px 0 0 var(--cyan), 0 0 24px #64e9ff12; }
.other-mind-status[data-phase="awake"] .other-mind-glyph { border-color: var(--cyan); background: #0a2b33; box-shadow: 0 0 20px #64e9ff66; transform: none; }
.other-mind-status[data-phase="awake"] .other-mind-glyph span { height: 13px; border: 3px solid var(--bone); background: #071017; }
.other-mind-status[data-phase="silent"] { border-style: dashed; border-color: #ffc85755; color: #c5a86c; }
.other-mind-status[data-phase="silent"] .other-mind-glyph { border-style: dashed; border-color: #a98147; }
@keyframes other-mind-birth {
  0% { transform: rotate(-24deg) scale(.72); }
  45% { transform: rotate(5deg) scale(1.12); }
  100% { transform: rotate(0) scale(1); }
}
.code-label { display: block; margin: 22px 0 9px; color: var(--sodium); font: 9px ui-monospace, monospace; letter-spacing: .14em; }
.code-editor { display: grid; grid-template-columns: 36px 1fr; min-height: 150px; border: 1px solid #ffffff1f; background: #05080d; }
.code-editor > span { padding-top: 16px; border-right: 1px solid #ffffff12; color: #46505d; text-align: center; font: 12px ui-monospace, monospace; }
.code-editor textarea { width: 100%; padding: 15px; resize: none; border: 0; outline: 0; background: transparent; color: var(--cyan); caret-color: var(--bone); font: 14px/1.65 ui-monospace, monospace; }
.code-editor:focus-within { border-color: #64e9ff99; box-shadow: inset 3px 0 0 var(--cyan), 0 0 20px #64e9ff14; }
.code-feedback { min-height: 40px; padding: 11px 13px; background: #ffffff08; color: var(--muted); font: 11px/1.5 ui-monospace, monospace; }
.code-feedback[data-status="loading"] { color: var(--sodium); }
.code-feedback[data-status="success"] { color: var(--cyan); }
.code-feedback[data-status="error"] { color: #ff8b94; border-left: 2px solid var(--danger); }
.run-code { width: 100%; margin-top: 12px; padding: 14px 18px; background: var(--sodium); color: var(--coal); font-weight: 900; letter-spacing: .12em; }
.run-code:hover { background: var(--bone); }
.run-code:disabled { cursor: wait; opacity: .55; }

.ending {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100% - 36px));
  padding: 96px clamp(20px, 3vw, 34px) clamp(20px, 3vw, 34px);
  transform: translate(-50%, -50%);
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
  touch-action: pan-y;
  border: 1px solid #ffc85759;
  background: #090d14f2;
  box-shadow: 0 30px 100px #000;
  text-align: center;
  animation: ending-rise .38s cubic-bezier(.2, .8, .2, 1) both;
}
.ending h2 { margin: 0; color: var(--bone); font-size: clamp(30px, 4vw, 52px); line-height: .95; text-transform: uppercase; }
.game[data-scene="reward"] .hud { visibility: hidden; }
.cursor-companion { position: absolute; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 64px; height: 64px; border: 3px solid var(--cyan); background: #081b28f5; border-radius: 50%; display: flex; align-items: center; justify-content: center; gap: 14px; pointer-events: none; box-shadow: 0 0 24px #64e9ff44; animation: mind-breathe 2.4s ease-in-out infinite alternate; }
.cursor-companion i { width: 7px; height: 5px; background: var(--cyan); transform: translateY(-5px); }
.cursor-companion b { position: absolute; width: 20px; height: 5px; border-bottom: 2px solid var(--cyan); border-radius: 50%; bottom: 14px; }
.cursor-companion[data-biting="true"] b { height: 19px; width: 25px; bottom: 7px; background: #64e9ff; animation: companion-chomp .28s ease-in-out infinite alternate; }
@keyframes companion-chomp { to { transform: scaleY(.2); } }
@keyframes mind-breathe { from { box-shadow: 0 0 12px #64e9ff33; } to { box-shadow: 0 0 30px #64e9ff77; } }
.ending p { color: var(--muted); line-height: 1.6; }
.ending__future { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 24px 0; background: #ffffff24; }
.ending__future span { padding: 14px 6px; background: var(--steel); color: var(--cyan); font: 9px ui-monospace, monospace; }
@keyframes ending-rise {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.screen-noise,
.screen-vignette { position: absolute; inset: 0; pointer-events: none; }
.screen-noise { z-index: 8; opacity: .05; 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='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E"); mix-blend-mode: soft-light; }
.screen-vignette { z-index: 7; box-shadow: inset 0 0 150px 28px #000a; }

@media (max-width: 760px) {
  .game { min-height: 100dvh; }
  .game-brand__text small, .system-readout span:nth-child(-n + 2) { display: none; }
  .hud { top: 17%; }
  .hud h1 { font-size: clamp(33px, 11vw, 56px); max-width: 90%; }
  .system-readout { top: max(22px, env(safe-area-inset-top)); right: 118px; }
  .power-rack { right: max(12px, env(safe-area-inset-right)); bottom: calc(12px + var(--safe-bottom)); gap: 5px; }
  .power { width: 66px; height: 64px; padding: 7px; }
  .power__key { display: none; }
  .power b { margin-top: 22px; font-size: 10px; }
  .action-button { left: max(12px, env(safe-area-inset-left)); bottom: calc(12px + var(--safe-bottom)); height: 64px; gap: 0; }
  .action-button__key { display: none; }
  .python-chip { bottom: calc(84px + var(--safe-bottom)); min-width: 270px; }
  .game[data-first-action-guide="true"] .action-button {
    border-color: var(--sodium);
    box-shadow: 0 0 0 1px #ffc85788, 0 0 28px #ffc85744;
    animation: first-action-pulse .72s ease-in-out infinite alternate;
  }
  .machine { top: auto; bottom: 0; width: 100%; height: min(82dvh, 720px); padding: 20px 18px calc(18px + var(--safe-bottom)); border-top: 1px solid #64e9ff52; border-left: 0; }
  .machine__rail { left: 50%; top: -28px; width: 4px; height: 28px; }
  .machine__rail span { right: -4px; top: 6px; }
  .machine h2 { margin: 24px 0 8px; font-size: 32px; }
  .machine p { margin: 0; font-size: 13px; }
  .machine-clue { margin-top: 12px; }
  .other-mind-status { margin-top: 12px; padding: 9px 11px; }
  .other-mind-status p { font-size: 10px; }
  .code-label { margin-top: 18px; }
  .code-editor { min-height: 120px; }
  .ending__future { grid-template-columns: repeat(2, 1fr); }
  .skill-journal { right: 12px; bottom: calc(12px + var(--safe-bottom)); width: min(250px, calc(100vw - 24px)); }
}

@keyframes first-action-pulse {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

@media (max-height: 520px) and (orientation: landscape) {
  .game { min-height: 100dvh; }
  .hud { top: 20%; }
  .hud h1 { font-size: 38px; max-width: 430px; }
  #gameMessage { margin-top: 10px; }
  .power { height: 58px; }
  .power b { margin-top: 8px; }
  .machine { padding: 10px 16px; }
  .machine__header .icon-button { width: 44px; height: 44px; }
  .machine h2 { margin: 0 0 4px; font-size: 28px; }
  .machine p { margin: 0; font-size: 11px; line-height: 1.25; }
  .machine .other-mind-status { margin-top: 5px; padding: 5px 8px; }
  .machine .other-mind-glyph { width: 34px; height: 34px; }
  .code-label { margin: 7px 0 5px; }
  .code-editor { min-height: 88px; height: 88px; }
  .code-editor > span { padding-top: 9px; }
  .code-editor textarea { padding: 8px 12px; line-height: 1.35; }
  .code-feedback { min-height: 30px; padding: 6px 9px; }
  .run-code { min-height: 44px; margin-top: 5px; padding: 8px 14px; }
}

/* First-play layer: each action stays attached to its object, not the HUD. */
[hidden] { display: none !important; }
.game[data-started="false"] .hud, .game[data-started="false"] .system-readout { visibility: hidden; }
.game[data-scene="warehouse"] .hud, .game[data-scene="chip"] .hud,
.game[data-scene="machine"] .hud, .game[data-scene="automation"] .hud,
.game[data-scene="red-crate"] .hud, .game[data-scene="reward"] .hud { top: 105px; max-width: min(430px, 70vw); }
.game:not([data-scene="prologue"]):not([data-scene="collapse"]) .hud h1 { font-size: clamp(23px, 3vw, 42px); }
.hud { pointer-events: none; }
.game .action-button { position: absolute; z-index: 6; bottom: auto; height: auto; min-height: 52px; max-width: calc(100% - 24px); width: max-content; padding: 12px 18px; transform: translate(-50%, -100%); animation: none !important; border: 2px solid #ffe7a1; border-radius: 9px; box-shadow: 0 4px 0 #6e561d, 0 0 26px #ffc85735; gap: 8px; font-size: 13px; }
.game .action-button::after { content: ''; position: absolute; bottom: -12px; left: calc(50% - 9px); border: 9px solid transparent; border-top-color: #ffe7a1; border-bottom: 0; }
.game .action-button[data-direction="left"]::after, .game .action-button[data-direction="right"]::after { display: none; }
.game .action-button[data-walking="true"] { background: #b9f6ff; border-color: #b9f6ff; box-shadow: 0 4px 0 #244d5c; }
.action-button__key { font-size: 9px; white-space: nowrap; }
.world-coach { position: absolute; z-index: 4; transform: translate(-50%, -100%); max-width: calc(100% - 24px); padding: 14px 18px; background: #b9f6ff; color: #08171c; border-radius: 10px; font-weight: 800; text-align: center; pointer-events: none; }
.start-panel, .story-beat { position: absolute; z-index: 9; width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 150px); overflow-y: auto; touch-action: pan-y; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #0b1522f5; border: 1px solid #76dffb80; border-radius: 14px; padding: clamp(20px, 3vw, 34px); box-shadow: 0 30px 100px #000b; }
.start-panel h2, .story-beat h2 { margin: 8px 0 18px; font-size: clamp(27px, 3.5vw, 46px); line-height: 1.04; color: #f7eedb; }
.start-panel p, .story-beat p { font-size: 17px; line-height: 1.5; color: #c0ceda; }
.start-panel small { display: block; margin-top: 16px; color: #a3bccb; line-height: 1.4; }
.story-beat { z-index: 11; }
.wallet { position: absolute; z-index: 4; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: auto auto; align-items: center; gap: 3px 14px; border: 1px solid #64ffad55; background: #061710ee; border-radius: 12px; padding: 12px 20px; min-width: 250px; pointer-events: none; }
.wallet small { color: #a1bcb0; font: 10px ui-monospace, monospace; }
.wallet b { grid-row: span 2; color: #70ffac; font: 900 30px ui-monospace, monospace; }
.wallet span { font: 11px ui-monospace, monospace; color: #d3f5e0; }
.income-toast { position: absolute; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; width: min(360px, calc(100% - 28px)); padding: 16px; border-radius: 16px; background: #071b13ed; border: 1px solid #67ffa478; box-shadow: 0 0 60px #43ff9420; pointer-events: none; }
.income-toast b { display: block; font: 900 clamp(38px, 6vw, 64px)/1 ui-monospace, monospace; color: #70ff9b; text-shadow: 0 0 22px #41ff8477; }
.income-toast span { display: block; color: #d5ffe3; font-size: 15px; margin-top: 9px; }
.corner-tools { z-index: 15; align-items: center; }
.home-link { display: flex; align-items: center; justify-content: center; min-width: 70px; min-height: 44px; padding: 8px 10px; color: #dbe8ee; font: 800 11px ui-monospace, monospace; text-decoration: none; background: #0c1421e8; border: 1px solid #697c8d; border-radius: 5px; }
.journal-toggle { position: absolute; z-index: 6; top: 72px; right: 16px; min-height: 44px; border: 1px solid #64e9ff55; background: #07141eef; color: #9ce9ee; padding: 10px 14px; font: 11px ui-monospace, monospace; border-radius: 8px; }
.skill-journal { z-index: 7; top: 124px; bottom: auto !important; }
.system-readout { display: none; }
.machine { z-index: 10; width: min(470px, 45vw); padding: 22px; }
.machine__header { padding-top: 44px; }
.machine h2 { margin-top: 18px; font-size: 30px; }
.machine #otherMindStatus { display: none; }
.machine .code-editor { min-height: 76px; height: 76px; }
.machine .code-editor textarea { font-size: 20px; }
.signal-builder { padding: 14px; margin-top: 16px; background: #122b30; border: 1px solid #64e9ff55; border-radius: 10px; }
.machine .signal-builder p { color: #d8f6fa; margin: 0 0 12px; font-size: 15px; }
.signal-builder button { display: flex; align-items: center; gap: 15px; min-height: 52px; width: 100%; padding: 12px; background: #cff9ef; color: #102c32; border-radius: 7px; }
.signal-builder code { font: 900 20px ui-monospace, monospace; }
.signal-builder span { font-size: 14px; }
.machine .code-label { letter-spacing: .04em; line-height: 1.5; margin-top: 14px; }
.future-comic { position: absolute; z-index: 12; inset: 0; background: #050912; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.comic-art { position: relative; overflow: hidden; background-size: cover; background-position: center; min-height: 0; }
.comic-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 55%, #050912); pointer-events: none; }
.comic-copy { padding: 16px max(22px, calc((100% - 950px) / 2)) 22px; background: #050912; }
.comic-copy h2 { color: #fff1d4; font-size: clamp(24px, 3vw, 40px); margin: 3px 0 8px; line-height: 1.05; }
.comic-copy p { max-width: 840px; color: #c1d0dd; font-size: 16px; line-height: 1.45; margin: 6px 0; }
.comic-copy .run-code { max-width: 540px; letter-spacing: .06em; }
.friend-sandbox { position: absolute; inset: 80px max(16px, calc((100% - 650px)/2)) 20px; z-index: 12; background: #0c1827fa; border: 1px solid #64e9ff77; border-radius: 16px; padding: clamp(18px, 3vw, 30px); overflow-y: auto; touch-action: pan-y; }
.friend-sandbox h2 { color: #fff0d8; font-size: clamp(25px, 3vw, 38px); margin: 10px 0; line-height: 1.1; }
.friend-sandbox p { color: #c0d3dd; font-size: 15px; line-height: 1.5; }
.packet { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; padding: 18px; margin: 20px 0; background: #07101c; border: 1px solid #76b4c0; border-radius: 10px; color: #a4e9e5; }
.packet code { font: 800 22px ui-monospace, monospace; }
#chatOutput { white-space: pre-line; padding: 12px; border-left: 3px solid #68eeb8; background: #16352a55; }
.channel-choices { display: flex; gap: 12px; }
.channel-choices button { flex: 1; min-height: 56px; background: #c1f7eb; color: #092d32; border-radius: 8px; font-weight: 800; }
#chatStage:not([data-step="intercept"]) #interceptPacket, #chatStage:not([data-step="route"]) .channel-choices, #chatStage:not([data-step="joined"]) #chatContinue { display: none; }
.comic-order, .comic-hello { display: none; position: absolute; z-index: 2; padding: 12px 18px; border-radius: 10px; background: #052319ed; color: #a2ffc7; font: 700 14px ui-monospace, monospace; }
.comic-order { top: 18%; right: 8%; }
.comic-order b { display: block; font-size: 32px; margin-top: 5px; }
.future-comic[data-scene="shop"] .comic-order { display: block; animation: order-arrives 3.6s infinite both; }
.comic-beam { position: absolute; z-index: 1; top: 35%; left: 44%; width: 20%; height: 45%; opacity: 0; background: linear-gradient(transparent, #56ffc755); clip-path: polygon(47% 0, 53% 0, 100% 100%, 0 100%); }
.future-comic[data-scene="shop"] .comic-beam { animation: printing-light 3.6s infinite; }
.future-comic[data-scene="vika"] .comic-beam { top: 0; left: 15%; width: 70%; height: 100%; clip-path: none; background: repeating-linear-gradient(0deg, transparent 0 15px, #62edff22 16px 18px); animation: hologram-scan 4s linear infinite; }
.future-comic[data-scene="vika"] .comic-hello { display: block; top: 20%; right: 12%; background: #e5fffb; color: #153745; font: 800 30px Georgia, serif; animation: voice-arrives 2s both; }
.comic-particles { position: absolute; inset: 0; background-image: radial-gradient(circle at 25% 40%, #64efff 0 1px, transparent 3px), radial-gradient(circle at 65% 70%, #ffc75f 0 2px, transparent 4px); background-size: 127px 151px, 193px 183px; opacity: .35; animation: particle-drift 9s linear infinite; }
.comic-army { display: none; position: absolute; z-index: 2; left: 9%; top: 75%; width: 8%; height: 3px; background: #ffefa4; box-shadow: 0 0 12px 3px #ffac37, 30px 35px 0 #4eebff, -25px -40px 0 #4eebff, 40px -65px 0 #ffce66; transform: rotate(-23deg); }
.future-comic[data-scene="battle"] .comic-army { display: block; animation: cyber-volley 1.4s infinite; }
.future-comic[data-scene="battle"] .comic-beam { opacity: 1; top: 30%; left: 70%; height: 35%; width: 25%; clip-path: none; background: radial-gradient(ellipse, #ffcf7b88, transparent 65%); animation: impact-light 1.4s infinite; }
@keyframes order-arrives { 0%, 38% { opacity: 0; transform: translateY(12px); } 50%, 88% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-25px); } }
@keyframes printing-light { 0%, 70%, 100% { opacity: .05; transform: translateX(0); } 30%, 55% { opacity: .7; transform: translateX(20px); } }
@keyframes hologram-scan { from { opacity: .5; background-position: 0 0; } to { opacity: .5; background-position: 0 180px; } }
@keyframes voice-arrives { 0%, 45% { opacity: 0; transform: translateY(15px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes particle-drift { to { background-position: 127px -151px, -193px -183px; } }
@keyframes cyber-volley { 0% { transform: translate(0, 0) rotate(-23deg); opacity: 0; } 20% { opacity: 1; } 85% { opacity: 1; } 100% { transform: translate(55vw, -22vh) rotate(-23deg); opacity: 0; } }
@keyframes impact-light { 0%, 70%, 100% { opacity: .05; } 85% { opacity: 1; } }
@media (max-width: 760px) {
  .game .hud { left: 18px; }
  .game:not([data-scene="prologue"]):not([data-scene="collapse"]) .hud { max-width: calc(100% - 36px); top: 88px; }
  .game .hud h1 { font-size: 27px; max-width: 100%; }
  .game #gameMessage { font-size: 11px; max-width: 100%; }
  .game-brand__text { display: none; }
  .game-brand { top: 18px; left: 16px; }
  .game .action-button { min-height: 56px; font-size: 12px; }
  .machine { width: 100%; height: min(82dvh, 640px); padding: 16px 18px; }
  .machine__header { padding-top: 0; }
  .machine h2 { margin-top: 12px; font-size: 25px; }
  .machine .signal-builder p { font-size: 13px; }
  .machine .code-editor { height: 68px; min-height: 68px; }
  .comic-art { background-position: 58% center; }
  .comic-copy { padding: 12px 18px max(18px, env(safe-area-inset-bottom)); }
  .comic-copy p { font-size: 14px; }
  .comic-copy h2 { font-size: 27px; }
  .comic-hello { right: 5% !important; top: 25% !important; font-size: 24px !important; }
  .wallet { padding: 10px 15px; bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .future-comic { grid-template-columns: 55% 45%; grid-template-rows: 1fr; }
  .ending { max-height: calc(100dvh - 120px); padding: 82px 24px 14px; }
  .ending .ending__eyebrow { margin: 0 0 8px; font-size: 9px; }
  .ending h2 { font-size: 28px; }
  .ending p { font-size: 12px; line-height: 1.3; margin: 8px 0; }
  .ending__future { margin: 10px 0; }
  .ending__future span { padding: 8px 6px; }
  .wallet { padding: 4px 12px; bottom: 6px; gap: 2px 10px; }
  .wallet b { font-size: 24px; }
  .wallet small { font-size: 8px; }
  .wallet span { font-size: 9px; }
  .comic-copy { overflow-y: auto; touch-action: pan-y; padding: 72px 18px 12px; }
  .comic-copy h2 { font-size: 24px; }
  .comic-copy p { font-size: 13px; }
  .start-panel, .story-beat { max-height: calc(100dvh - 90px); top: 55%; }
  .start-panel h2, .story-beat h2 { font-size: 26px; }
  .start-panel p, .story-beat p { font-size: 14px; margin: 8px 0; }
  .machine { width: 52%; height: 100%; padding: 12px; }
  .machine h2, .machine-clue { display: none; }
  .signal-builder { margin-top: 6px; padding: 9px; }
  .machine .code-editor { height: 52px; min-height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .other-mind-status, .other-mind-glyph { animation: none !important; }
  .python-chip { animation: none; }
}
.exit-dialog { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: #03070ee8; }
.exit-dialog__card { width: min(440px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px; background: #101923; border: 1px solid #65ddef; }
.exit-dialog h2 { margin: 0 0 14px; font-size: 28px; }
.exit-dialog p { font-size: 18px; line-height: 1.4; }
.exit-dialog .run-code { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; margin-top: 12px; text-decoration: none; font-size: 16px; }
.exit-dialog #confirmExit { background: #253542; color: #e9e5d7; }
