:root {
  color-scheme: dark;
  --black: #020305;
  --panel: rgba(5, 9, 13, 0.9);
  --panel-line: rgba(171, 204, 211, 0.42);
  --text: #f1eee3;
  --muted: #9fb0b5;
  --amber: #e8a84a;
  --cyan: #70d4e6;
  --green: #94f94d;
  --danger: #df786d;
  font-family: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  position: fixed;
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--black);
  color: var(--text);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button {
  min-width: 48px;
  min-height: 48px;
  border: 0;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
}

.app,
.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.screen {
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.screen.is-active {
  opacity: 1;
  pointer-events: auto;
}

[hidden] {
  display: none !important;
}

.menu-screen {
  background: #15191d;
}

.menu-background,
.cinematic-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  image-rendering: pixelated;
}

.menu-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(2, 3, 5, 0.66), transparent 48%),
    linear-gradient(0deg, rgba(2, 3, 5, 0.8), transparent 44%),
    radial-gradient(circle at center, transparent 36%, rgba(2, 3, 5, 0.42));
  pointer-events: none;
}

.game-title {
  position: absolute;
  z-index: 2;
  top: max(22px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  text-shadow: 0 3px 8px #000;
}

.game-title span {
  color: #f3bf72;
  font-size: clamp(0.64rem, 1.2vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.game-title h1 {
  max-width: 11ch;
  margin: 0.08em 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 6.4vw, 5.6rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.8;
}

.game-title h1 em {
  display: inline-block;
  color: var(--amber);
  font-size: 0.48em;
  font-weight: 400;
  letter-spacing: 0;
}

.menu-panel {
  position: absolute;
  z-index: 3;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(330px, calc(100vw - 48px));
  border: 1px solid var(--panel-line);
  border-left: 4px solid var(--amber);
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(8px);
  transition: opacity 250ms ease, transform 250ms ease;
}

.menu-screen.is-prelaunch .menu-panel,
.menu-screen.is-prelaunch .game-title {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-24px);
}

.menu-kicker,
.save-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.menu-actions {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.menu-button {
  width: 100%;
  border: 1px solid rgba(184, 211, 218, 0.42);
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(40, 56, 61, 0.95), rgba(15, 23, 27, 0.95));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.menu-button:not(:disabled):active {
  transform: translateY(2px);
  background: rgba(89, 112, 117, 0.92);
}

.menu-button:disabled {
  opacity: 0.38;
}

.menu-button-danger:not(:disabled) {
  color: #f3b0a8;
}

.launch-console {
  position: absolute;
  z-index: 4;
  inset: auto max(18px, env(safe-area-inset-right)) max(124px, calc(env(safe-area-inset-bottom) + 106px)) auto;
  display: flex;
  align-items: flex-end;
  gap: clamp(6px, 1.5vw, 18px);
}

.console-control {
  position: relative;
  width: clamp(96px, 16vw, 170px);
  height: auto;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.75));
}

.console-control img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.console-control span {
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translate(-50%, 100%);
  color: #b9c7ca;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-shadow: 0 2px 4px #000;
  text-transform: uppercase;
}

.console-control:active:not(:disabled) {
  transform: translateY(3px);
}

.console-control:disabled {
  filter: grayscale(0.5) brightness(0.6) drop-shadow(0 8px 12px rgba(0, 0, 0, 0.75));
}

.console-launch.is-ready {
  animation: launch-ready 1.2s ease-in-out infinite alternate;
}

.abort-button {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 12px;
  background: rgba(3, 6, 8, 0.76);
  color: #b8c4c7;
  cursor: pointer;
  font-size: 0.65rem;
  text-transform: uppercase;
}

.cinematic-screen {
  background: #000;
}

.cinematic-image {
  transition: opacity 800ms ease;
}

.cinematic-black {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 1;
  transition: opacity 900ms ease;
}

.cinematic-black.is-clear {
  opacity: 0;
}

.countdown {
  position: absolute;
  z-index: 3;
  right: max(22px, env(safe-area-inset-right));
  top: max(18px, env(safe-area-inset-top));
  color: #f2c276;
  font-size: clamp(1rem, 3.2vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-shadow: 0 0 14px rgba(242, 194, 118, 0.58);
}

.title-card {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 10vw;
  text-align: center;
  animation: card-in 650ms ease both;
}

.title-card p {
  margin: 0;
  color: #b7b4ac;
  font-size: clamp(0.64rem, 1.8vw, 0.9rem);
  letter-spacing: 0.22em;
  line-height: 1.6;
  text-transform: uppercase;
}

.title-card h2 {
  margin: 0.22em 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 6.6rem);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.game-screen,
#game-canvas {
  background: #000;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.game-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.location-panel {
  border-left: 3px solid var(--cyan);
  padding: 7px 10px;
  background: rgba(2, 5, 8, 0.76);
  text-shadow: 0 2px 3px #000;
}

.game-hud span {
  display: block;
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.game-hud strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: clamp(0.62rem, 2vw, 0.84rem);
}

.game-hud button {
  border: 1px solid rgba(179, 208, 215, 0.48);
  min-width: 42px;
  min-height: 42px;
  padding: 8px 12px;
  background: rgba(2, 5, 8, 0.82);
  cursor: pointer;
  pointer-events: auto;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.game-hud-actions,
.zoom-controls {
  display: flex;
  align-items: stretch;
  gap: 5px;
}

.game-hud-actions {
  pointer-events: auto;
}

.zoom-controls {
  border: 1px solid rgba(121, 197, 211, 0.2);
  padding: 3px;
  background: rgba(2, 5, 8, 0.72);
}

.zoom-controls button {
  padding: 5px 10px;
  color: var(--cyan);
  font-size: 1.05rem;
  line-height: 1;
}

#zoom-readout {
  display: grid;
  min-width: 50px;
  place-items: center;
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}

.movement-hint {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  border: 1px solid rgba(121, 197, 211, 0.28);
  padding: 7px 12px;
  background: rgba(2, 5, 8, 0.72);
  color: #b8c7ca;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  pointer-events: none;
  text-transform: uppercase;
  transition: opacity 500ms ease;
}

.movement-hint.is-dismissed {
  opacity: 0;
}

.dialogue-box {
  position: fixed;
  z-index: 20;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: clamp(64px, 11vw, 104px) 1fr;
  gap: clamp(10px, 2vw, 18px);
  min-height: clamp(108px, 21vh, 154px);
  border: 1px solid rgba(165, 202, 211, 0.56);
  border-left: 5px solid var(--cyan);
  padding: clamp(10px, 2vw, 16px);
  padding-right: clamp(18px, 4vw, 34px);
  background:
    linear-gradient(105deg, rgba(26, 40, 45, 0.96), rgba(4, 8, 11, 0.97) 55%),
    #05080a;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.dialogue-portrait {
  width: 100%;
  aspect-ratio: 1;
  align-self: center;
  border: 2px solid #0a0c0e;
  background: #040608;
  object-fit: cover;
  image-rendering: pixelated;
  pointer-events: none;
}

.dialogue-copy {
  align-self: center;
}

.dialogue-speaker {
  display: block;
  margin-bottom: 5px;
  color: var(--cyan);
  font-size: clamp(0.68rem, 2vw, 0.88rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dialogue-text {
  margin: 0;
  max-width: 72ch;
  font-family: system-ui, sans-serif;
  font-size: clamp(0.86rem, 2.35vw, 1.1rem);
  line-height: 1.42;
}

.dialogue-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.dialogue-choice {
  min-height: 46px;
  border: 1px solid rgba(157, 201, 211, 0.56);
  padding: 9px 14px;
  background: linear-gradient(180deg, rgba(38, 55, 61, 0.98), rgba(10, 17, 20, 0.98));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 3px 0 rgba(0, 0, 0, 0.65);
  color: var(--text);
  cursor: pointer;
  font-size: clamp(0.68rem, 1.8vw, 0.82rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dialogue-choice:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 1px 0 rgba(0, 0, 0, 0.65);
}

.dialogue-choice-lever {
  border-color: rgba(232, 168, 74, 0.72);
  color: #ffd49a;
}

.dialogue-choice-radio {
  border-color: rgba(112, 212, 230, 0.72);
  color: #a6ecf6;
}

.dialogue-choice-secondary {
  border-color: rgba(166, 174, 176, 0.32);
  color: #9ca8aa;
}

.dialogue-choice-launch {
  border-color: rgba(148, 249, 77, 0.85);
  background: linear-gradient(180deg, rgba(47, 99, 34, 0.98), rgba(12, 34, 15, 0.98));
  color: #cfffad;
  animation: launch-choice-ready 650ms ease-in-out infinite alternate;
}

.dialogue-box.is-launch-ready {
  border-color: rgba(148, 249, 77, 0.74);
  border-left-color: var(--green);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.5), 0 0 28px rgba(93, 226, 59, 0.16);
}

.dialogue-box.is-launch-ready .dialogue-speaker {
  color: var(--green);
}

.dialogue-box.is-launch-ready .dialogue-portrait {
  animation: launch-portrait-ready 650ms ease-in-out infinite alternate;
}

.dialogue-prompt {
  position: absolute;
  right: 12px;
  bottom: 8px;
  color: #7d9297;
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loading-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  background: #020305;
  opacity: 1;
  transition: opacity 500ms ease;
}

.loading-screen span {
  color: var(--amber);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.loading-screen strong {
  color: #ccd4d3;
  font-size: 0.8rem;
  font-weight: 400;
}

.loading-screen.is-finished {
  opacity: 0;
  pointer-events: none;
}

@keyframes launch-ready {
  from { filter: brightness(0.9) drop-shadow(0 0 4px rgba(128, 255, 70, 0.15)); }
  to { filter: brightness(1.2) drop-shadow(0 0 24px rgba(128, 255, 70, 0.72)); }
}

@keyframes card-in {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes launch-choice-ready {
  from { filter: brightness(0.86); box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 0 4px rgba(148, 249, 77, 0.16); }
  to { filter: brightness(1.18); box-shadow: inset 0 1px rgba(255, 255, 255, 0.18), 0 0 18px rgba(148, 249, 77, 0.62); }
}

@keyframes launch-portrait-ready {
  from { filter: brightness(0.82); box-shadow: 0 0 3px rgba(148, 249, 77, 0.1); }
  to { filter: brightness(1.2); box-shadow: 0 0 20px rgba(148, 249, 77, 0.72); }
}

@media (max-width: 720px) {
  .game-title {
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
  }

  .game-title h1 {
    font-size: clamp(2rem, 9vw, 3.5rem);
  }

  .menu-panel {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: min(284px, calc(100vw - 24px));
    padding: 11px;
  }

  .menu-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .menu-button {
    padding: 9px 6px;
    font-size: 0.62rem;
    text-align: center;
  }

  .launch-console {
    inset: auto max(10px, env(safe-area-inset-right)) max(116px, calc(env(safe-area-inset-bottom) + 100px)) auto;
  }

  .console-control {
    width: clamp(72px, 18vw, 112px);
  }

  .dialogue-box {
    grid-template-columns: 58px 1fr;
    min-height: 96px;
    padding: 9px;
  }

  .dialogue-text {
    font-size: 0.82rem;
  }

  .dialogue-choice {
    flex: 1 1 140px;
  }

  #zoom-readout {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 620px) {
  .menu-background,
  .cinematic-image {
    object-position: center;
  }

  .game-title h1 {
    max-width: none;
  }

  .launch-console {
    right: 50%;
    bottom: 42%;
    transform: translate(50%, 50%);
  }

  .console-control {
    width: clamp(82px, 27vw, 124px);
  }
}

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