:root {
  color-scheme: dark;
  --night: #101923;
  --night-soft: #1b2a36;
  --shell: #e8ddbd;
  --shell-edge: #b7a982;
  --shell-shadow: #716b5a;
  --screen: #18252b;
  --ink: #19222c;
  --accent: #b83255;
  --accent-dark: #6f1d3a;
  --button: #313946;
  --button-edge: #111821;
  --cream: #fff6dc;
  --muted: #b9c4cb;
  font-family: "Trebuchet MS", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--night);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 18%, rgba(83, 126, 143, 0.24), transparent 42rem),
    linear-gradient(160deg, #0a1119 0%, var(--night-soft) 48%, #090f16 100%);
}

button {
  font: inherit;
}

.hub {
  display: grid;
  align-content: start;
  justify-items: center;
  width: min(100% - 28px, 880px);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) 0;
}


.direct-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  max-width: 100%;
  margin-top: clamp(24px, 4vw, 36px);
  padding-inline: 8px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(0.875rem, 1.6vw, 1rem);
  line-height: 1.5;
  text-align: center;
}

.direct-links-label {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.direct-links a {
  color: var(--cream);
  overflow-wrap: anywhere;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.direct-links a:hover {
  color: #c8f2d0;
}

.direct-links a:focus-visible {
  outline: 2px solid #fff6dc;
  outline-offset: 4px;
}


.console {
  position: relative;
  width: min(100%, 760px);
  padding: clamp(18px, 4vw, 34px) clamp(16px, 4.5vw, 40px) clamp(28px, 6vw, 52px);
  color: var(--ink);
  background:
    linear-gradient(105deg, rgba(255, 255, 255, 0.5), transparent 19%),
    var(--shell);
  border: 2px solid #f8efcf;
  border-right-color: var(--shell-shadow);
  border-bottom-color: var(--shell-shadow);
  border-radius: 26px 26px 84px 26px;
  box-shadow:
    0 4px 0 var(--shell-edge),
    0 30px 70px rgba(0, 0, 0, 0.42);
}

.console-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 8% 9px;
  color: #d8d8c7;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.console-top::before,
.console-top::after {
  flex: 1;
  height: 3px;
  content: "";
  border-block: 1px solid #58646a;
}

.screen-bezel {
  padding: clamp(15px, 3.6vw, 28px);
  color: #d5e2df;
  background: #31414a;
  border: 4px solid #68757a;
  border-right-color: #17252c;
  border-bottom-color: #17252c;
  border-radius: 18px 18px 48px 18px;
  box-shadow: inset 0 0 0 2px #0f1b21;
}

.screen-frame {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--screen);
  border: 5px solid #101b21;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.65);
}

.screen-frame::before {
  position: absolute;
  z-index: 6;
  inset: 0;
  content: "";
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.12) 100%);
  pointer-events: none;
}

.screen-frame[data-boot-transition]::after {
  position: absolute;
  z-index: 7;
  inset: 0;
  content: "";
  background: #000;
  pointer-events: none;
}

.screen-frame[data-boot-transition="out"]::after {
  animation: boot-fade-out 220ms ease-in both;
}

.screen-frame[data-boot-transition="in"]::after {
  animation: boot-fade-in 240ms ease-out both;
}

@keyframes boot-fade-out {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes boot-fade-in {
  from { opacity: 1; }
  to { opacity: 0; }
}

.boot-screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(10px, 3vw, 24px);
  overflow: hidden;
  padding: 12px;
  color: #263eb6;
  background: radial-gradient(ellipse at center, #fff 25%, #f0f3fb 100%);
  text-align: center;
}

.boot-screen[hidden],
.boot-screen [hidden] {
  display: none;
}

.boot-wordmark {
  position: relative;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(1.2rem, 7.4vw, 4rem);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.065em;
  line-height: 1;
  white-space: nowrap;
}

.boot-wordmark::after {
  position: absolute;
  inset: 0;
  content: attr(data-wordmark);
  color: transparent;
  background: linear-gradient(100deg, #e829bb 10%, #813fe1 35%, #00aedb 58%, #263eb6 82%);
  background-size: 260% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  opacity: 0;
}

.boot-signature {
  color: #292d49;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(0.75rem, 2.5vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.boot-screen[data-motion="full"] .boot-wordmark {
  animation: boot-arrive 2.4s cubic-bezier(0.2, 0.65, 0.3, 1) both;
}

.boot-screen[data-motion="full"] .boot-wordmark::after {
  animation: boot-color 2.4s linear both;
}

.boot-screen[data-motion="full"] .boot-signature {
  animation: boot-signature 2.4s ease-out both;
}

@keyframes boot-arrive {
  0%, 8% { opacity: 0; transform: translate(85%, -160%) scale(0.35) rotate(-20deg); }
  22% { opacity: 1; }
  48% { transform: translate(-5%, 8%) scale(1.08) rotate(3deg); }
  68%, 100% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0); }
}

@keyframes boot-color {
  0%, 24% { opacity: 1; background-position: 0% 50%; }
  68% { opacity: 1; background-position: 100% 50%; }
  86%, 100% { opacity: 0; background-position: 100% 50%; }
}

@keyframes boot-signature {
  0%, 54% { opacity: 0; transform: translateY(5px); }
  74%, 100% { opacity: 1; transform: translateY(0); }
}

.boot-screen[data-state="error"] {
  gap: 6px;
  padding: 8px;
}

.boot-screen[data-state="error"] .boot-signature {
  display: none;
}

.boot-message {
  max-width: 34ch;
  margin: 0;
  color: #292d49;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  line-height: 1.3;
}

.boot-retry {
  min-height: 44px;
  padding: 6px 16px;
  color: #fff;
  background: #263eb6;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}

.boot-retry:focus-visible {
  outline: 2px solid #292d49;
  outline-offset: 2px;
}

.screen-ui {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 308px;
  height: 231px;
  transform-origin: 0 0;
  transform: scale(var(--screen-scale, 1));
  pointer-events: none;
}

.screen-ui > * {
  pointer-events: auto;
}

.game-dialogue.dev-dialogue {
  z-index: 5;
  height: 48%;
  max-height: 48%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.game-dialogue.dev-dialogue.has-error {
  height: calc(48% + 6px);
  max-height: calc(48% + 6px);
}

.game-dialogue.dev-dialogue.is-narrative { padding-block: 6px; }
.dev-dialogue.is-narrative .dev-speaker { line-height: 13px; }
.game-dialogue.dev-dialogue.is-narrative :where(.dialogue-option) {
  height: 1lh;
  min-height: 1lh;
  padding-block: 0;
}

.game-dialogue.dev-dialogue.is-menu { padding-block: 6px; }
.dev-dialogue.is-menu .dev-speaker { line-height: 13px; }
.dev-menu-choices {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0;
}
.game-dialogue.dev-dialogue.is-menu :where(.dialogue-option) {
  width: 100%;
  height: 1lh;
  min-height: 1lh;
  padding-block: 0;
}

.dev-dialogue[hidden] { display: none; }
.dev-speaker { display: flex; justify-content: space-between; gap: 4px; font-size: 12px; line-height: 12px; }
.dev-dialogue .dev-speaker-label { background: #172126; color: #fffdf0; }
.dev-text { min-width: 0; white-space: pre; margin: 0; overflow: hidden; }
.dev-dialogue.is-response .dev-text { display: flex; align-items: flex-end; }
.dev-dialogue.is-response .dev-speaker { justify-content: flex-end; min-height: 12px; }
.dev-continuation, .dev-footer { font-size: 10px; line-height: 10px; }
.dev-footer:empty { display: none; }
.dev-dialogue .dev-options { display: flex; gap: 2px; min-width: 0; justify-content: end; }
.dev-dialogue .dev-decision-choices {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 0;
}
.dev-dialogue .dev-decision-choices :where(.dialogue-option) { width: 100%; }
.game-dialogue.dev-dialogue :where(.dialogue-option) {
  height: 44px;
  flex: 0 1 auto;
  max-width: 100%;
  padding: 4px;
  overflow: hidden;
}
.dev-dialogue .dialogue-option.is-selected { padding-left: 21px; }
.dev-dialogue .dialogue-option:hover,
.dev-dialogue .dialogue-option:focus-visible {
  outline: none;
  text-decoration: none;
}
.dev-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(60px, 38%); gap: 4px; }
.dev-form input, .dev-form textarea {
  min-width: 0;
  width: 100%;
  height: 44px;
  max-height: 44px;
  box-sizing: border-box;
  font-family: inherit;
  color: #172126;
  background: white;
}
.dev-form input {
  height: calc(1lh + 8px);
  max-height: calc(1lh + 8px);
  padding: 3px 4px;
  border: 1px solid currentColor;
}
.dev-form.is-single-line :where(.dialogue-option) {
  height: calc(1lh + 8px);
  min-height: calc(1lh + 8px);
}
.dev-error { color: #861f31; }
.dev-footer.dev-error { line-height: 12px; }
.dev-options select { max-width: 30%; min-width: 0; height: 44px; font: inherit; }

.welcome-menu {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 9px;
  color: var(--cream);
  background: linear-gradient(rgba(20, 37, 42, 0.92), rgba(10, 25, 32, 0.96));
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.welcome-menu[hidden] {
  display: none;
}

.character-menu {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7.02px;
  padding: 10px;
  color: var(--cream);
  background: linear-gradient(rgba(20, 37, 42, 0.94), rgba(10, 25, 32, 0.97));
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.character-menu[hidden] {
  display: none;
}

.character-menu-title {
  margin: 0;
  color: #c8f2d0;
  font-size: 12.8px;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.character-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, 88px));
  gap: 7.02px;
}

.character-option {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  width: 66.3px;
  aspect-ratio: 1;
  padding: 5px;
  background: #203b42;
  border: 2px solid #54777a;
  border-radius: 6px;
  box-shadow: inset 0 -4px rgba(7, 20, 26, 0.42);
  cursor: pointer;
  touch-action: manipulation;
}

.character-option.is-selected {
  border-color: #f5da66;
  box-shadow:
    inset 0 0 0 2px #4b612e,
    0 0 0 2px rgba(245, 218, 102, 0.32);
}

.character-option:focus-visible {
  outline: 3px solid #fff6dc;
  outline-offset: -5px;
}

.character-option:active {
  transform: translateY(1px);
}

.character-preview {
  display: block;
  width: min(100%, 56px);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  pointer-events: none;
}

.menu-title {
  margin: 0;
  color: #c8f2d0;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 16.8px;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-shadow: 2px 2px 0 #1b5c54;
}

.menu-subtitle {
  margin: 6px 0 0;
  color: #9fc9c4;
  font-size: 9.28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
}

.menu-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.menu-action {
  display: grid;
  align-items: center;
  justify-items: center;
  min-height: 44px;
  padding: 5px 8px;
  color: #e9f0db;
  font: inherit;
  font-size: 8.96px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  background: #203b42;
  border: 2px solid #54777a;
  border-radius: 4px;
  box-shadow: inset 0 -3px rgba(7, 20, 26, 0.42);
  cursor: pointer;
  touch-action: manipulation;
}

.menu-start {
  width: min(100%, 320px);
  justify-self: center;
  font-size: 12.48px;
}

.menu-action.is-selected {
  color: #fffde6;
  border-color: #f5da66;
  box-shadow:
    inset 0 0 0 2px #4b612e,
    0 0 0 2px rgba(245, 218, 102, 0.32);
}

.menu-action:focus-visible {
  outline: 3px solid #fff6dc;
  outline-offset: -5px;
}

.menu-action:active {
  transform: translateY(1px);
}

.screen-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  image-rendering: pixelated;
  background: #14252a;
}

.game-dialogue {
  position: absolute;
  z-index: 4;
  right: 5px;
  bottom: 5px;
  left: 5px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 7px;
  overflow-wrap: anywhere;
  color: #172126;
  background: #fffdf0;
  border: 4px double #172126;
  border-radius: 3px;
  box-shadow:
    0 0 0 2px rgba(255, 253, 240, 0.92),
    0 4px 0 rgba(16, 27, 33, 0.58);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.game-dialogue[hidden] {
  display: none;
}

.game-dialogue[inert] {
  pointer-events: none;
}

.game-dialogue-text {
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.dialogue-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(44px, max-content));
  justify-content: end;
  justify-items: start;
  gap: 3.9px;
}

.dialogue-options[hidden] {
  display: none;
}

.dialogue-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 10px 4px 30px;
  color: #172126;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.dialogue-option[hidden] {
  display: none;
}

.dialogue-option[data-dialogue-option="close"] {
  grid-column: 1 / -1;
  justify-self: end;
}

.dialogue-option.is-selected::before {
  position: absolute;
  left: 8px;
  width: 0;
  height: 0;
  content: "";
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid #172126;
}

.dialogue-option:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.dialogue-option:focus-visible {
  outline: 3px solid #b83255;
  outline-offset: -3px;
}

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

.console-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 11px 2% 24px;
  color: #334a5c;
  font-style: italic;
  letter-spacing: -0.04em;
}

.console-brand strong {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(1rem, 4vw, 1.65rem);
}

.console-brand span {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.console-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 150px;
  padding: 0 4%;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.game-control {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
  cursor: pointer;
}

.game-control:focus-visible {
  outline: 4px solid #117a9b;
  outline-offset: 4px;
}

.game-control:active {
  transform: translateY(3px);
  box-shadow: none;
}

.d-pad {
  position: relative;
  display: grid;
  grid-template: repeat(3, 48px) / repeat(3, 48px);
  filter: drop-shadow(0 7px 0 rgba(74, 67, 57, 0.28));
}

.d-pad .game-control,
.d-pad-center {
  color: #0d1117;
  background: var(--button);
  border: 0;
}

.d-pad .game-control {
  position: relative;
  z-index: 1;
  padding: 0;
  color: #171c24;
  font-size: 0.72rem;
  text-shadow: 0 1px rgba(255, 255, 255, 0.15);
}

.d-pad-up {
  grid-area: 1 / 2;
  border-radius: 7px 7px 0 0 !important;
}

.d-pad-right {
  grid-area: 2 / 3;
  border-radius: 0 7px 7px 0 !important;
}

.d-pad-down {
  grid-area: 3 / 2;
  border-radius: 0 0 7px 7px !important;
}

.d-pad-left {
  grid-area: 2 / 1;
  border-radius: 7px 0 0 7px !important;
}

.d-pad-center {
  grid-area: 2 / 2;
  box-shadow: inset 0 0 0 10px #2a313d;
}

.action-pad {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: rgba(142, 125, 98, 0.22);
  border-radius: 999px;
  transform: rotate(-18deg);
}

.action-key {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--accent-dark);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.75rem;
}

.action-key-b {
  margin-top: 16px;
}

.action-button {
  width: clamp(56px, 12vw, 72px);
  aspect-ratio: 1;
  padding: 0;
  color: rgba(255, 255, 255, 0.72);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 1.15rem;
  background: linear-gradient(145deg, #cf4166, var(--accent));
  border: 3px solid var(--accent-dark);
  border-radius: 50%;
  box-shadow: 0 7px 0 #711e3b;
  transform: rotate(18deg);
}

.action-button:active {
  transform: rotate(18deg) translateY(3px);
}

.control-hint {
  margin: 20px 0 0;
  color: #5c5a50;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.74rem;
  text-align: center;
}

.speaker {
  position: absolute;
  right: 38px;
  bottom: 25px;
  display: flex;
  gap: 8px;
  transform: rotate(-24deg);
}

.speaker i {
  display: block;
  width: 5px;
  height: 34px;
  background: #8f886f;
  border-radius: 999px;
  box-shadow: inset 1px 0 rgba(255, 255, 255, 0.35);
}


@media (max-width: 720px) {
  .hub {
    width: min(100% - 16px, 880px);
    padding-top: 22px;
  }

  .console {
    padding-inline: 10px;
    border-radius: 20px 20px 58px 20px;
  }

  .screen-bezel {
    padding: 12px;
    border-radius: 12px 12px 32px 12px;
  }

  .console-controls {
    min-height: 126px;
    gap: 10px;
    padding-inline: 2%;
  }

  .d-pad {
    grid-template: repeat(3, 44px) / repeat(3, 44px);
  }

  .action-pad {
    gap: 9px;
    padding: 10px;
  }

  .action-button {
    width: 54px;
  }

  .speaker {
    display: none;
  }

  .control-hint {
    padding-inline: 20px;
    line-height: 1.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen-frame[data-boot-transition]::after {
    animation: none;
    opacity: 0;
  }

  .boot-wordmark,
  .boot-wordmark::after,
  .boot-signature {
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 720px) and (max-height: 740px) {
  .hub {
    min-height: 100dvh;
    padding-top: max(env(safe-area-inset-top), 4px);
    padding-bottom: max(env(safe-area-inset-bottom), 4px);
  }


  .console {
    width: min(100%, 330px);
    padding: 7px 8px 12px;
    border-radius: 16px 16px 44px 16px;
  }

  .console-top {
    gap: 6px;
    margin: 0 7% 3px;
    font-size: 0.4rem;
    line-height: 1.15;
  }

  .console-top::before,
  .console-top::after {
    height: 2px;
  }

  .screen-bezel {
    padding: 7px;
    border-width: 3px;
    border-radius: 10px 10px 25px 10px;
  }

  .screen-frame {
    border-width: 3px;
  }

  .console-brand {
    gap: 5px;
    margin: 5px 2% 4px;
    line-height: 1;
  }

  .console-brand strong {
    font-size: 0.85rem;
  }

  .console-brand span {
    font-size: 0.55rem;
  }

  .console-controls {
    min-height: 132px;
    gap: 8px;
    padding-inline: 3%;
    transform: none;
  }

  .d-pad {
    grid-template: repeat(3, 44px) / repeat(3, 44px);
  }

  .d-pad-center {
    box-shadow: inset 0 0 0 9px #2a313d;
  }

  .action-pad {
    gap: 6px;
    padding: 6px;
  }

  .action-key {
    gap: 2px;
    font-size: 0.62rem;
  }

  .action-key-b {
    margin-top: 10px;
  }

  .action-button {
    width: 48px;
    border-width: 2px;
    box-shadow: 0 5px 0 #711e3b;
  }

  .control-hint {
    margin: 4px 4px 0;
    padding-inline: 0;
    font-size: 0.58rem;
    line-height: 1.25;
  }
}
