:root {
  color-scheme: dark;
  font-family: Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: #f5dfae;
  background: #081421;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(#0d2233e8, #081421f7),
    repeating-linear-gradient(105deg, #12364a 0 2px, #0b1b2b 2px 18px);
}

button,
select,
input {
  min-height: 42px;
  padding: 8px 12px;
  border: 2px solid #d4ad5d;
  border-radius: 0;
  color: #fff1c9;
  background: #183b4c;
  box-shadow: 0 3px 0 #050b12;
  font: bold 15px Arial, sans-serif;
}

button {
  cursor: pointer;
  touch-action: none;
}

button:hover,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid #ffe087;
  outline-offset: 2px;
  background: #24556a;
}

button:active,
button.active {
  translate: 0 2px;
  box-shadow: 0 1px 0 #050b12;
  background: #b75d32;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

h1 {
  margin-bottom: 5px;
  color: #ffd66b;
  font-size: clamp(29px, 5vw, 48px);
  line-height: 1;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 6px;
  color: #fff1c9;
  font-size: 20px;
}

h3 {
  margin-bottom: 4px;
  color: #fff1c9;
  font-size: 16px;
}

.eyebrow,
.panel-kicker {
  margin-bottom: 6px;
  color: #7fd2c6;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.select-screen {
  width: min(1120px, calc(100% - 30px));
  margin: 0 auto;
  padding: clamp(36px, 8vh, 92px) 0 50px;
}

.select-header {
  max-width: 760px;
  margin-bottom: 30px;
}

.select-header > p:last-child {
  color: #b8d3ce;
  font-size: 18px;
}

.account-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #537b7c;
  background: #0d2131;
}

.account-panel p {
  flex: 1 1 360px;
  margin: 0;
  color: #b8d3ce;
}

.adventure-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.adventure-card {
  display: grid;
  min-height: 230px;
  padding: 22px;
  border: 2px solid #b77d2c;
  background:
    linear-gradient(135deg, #17394a 0 56%, #10283a 56%),
    #10283a;
  box-shadow: 6px 6px 0 #050b12;
}

.adventure-card.featured {
  border-color: #f0b64f;
  background:
    linear-gradient(135deg, #1d4b58 0 56%, #173343 56%),
    #10283a;
}

.adventure-card p {
  color: #bdd4cf;
}

.adventure-card button {
  align-self: stretch;
}

.save-actions {
  display: grid;
  gap: 8px;
  align-self: end;
}

.save-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.save-row > button:first-child {
  text-align: left;
}

.reset-save {
  min-width: 76px;
}

.game-header {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px max(14px, calc((100vw - 1320px) / 2));
  border-bottom: 2px solid #b77d2c;
  background: #0b1c2aee;
  backdrop-filter: blur(9px);
}

.game-heading h1 {
  overflow: hidden;
  font-size: clamp(23px, 3vw, 35px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variant-wrap {
  display: grid;
  gap: 2px;
  color: #8fc9c1;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.variant-wrap select {
  min-height: 36px;
  padding: 5px 8px;
}

.quiet-button {
  border-color: #537b7c;
  color: #bde6d9;
}

.debug-toggle[aria-pressed="true"] {
  border-color: #64ffe0;
  color: #081421;
  background: #64d8c3;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  width: min(1320px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

body.debug-active .game-layout {
  grid-template-columns: minmax(640px, 1fr) minmax(360px, 0.48fr);
}

.game-panel,
.debug-panel > section,
.error-panel {
  border: 2px solid #b77d2c;
  background: #10283a;
  box-shadow: 5px 5px 0 #050b12;
}

.login-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 24px;
  border: 2px solid #d4ad5d;
  color: #f5dfae;
  background: #10283a;
  box-shadow: 8px 8px 0 #050b12;
}

.login-dialog::backdrop {
  background: #020810d9;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 42px;
  padding: 0;
  font-size: 24px;
}

#login-code-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#login-code-step label {
  grid-column: 1 / -1;
  color: #bde6d9;
  font-weight: bold;
}

#login-code {
  width: 100%;
  letter-spacing: 0.25em;
}

.login-error {
  min-height: 24px;
  margin: 12px 0 0;
  color: #ff9e8c;
}

.login-note {
  margin: 12px 0 0;
  color: #8fb1ad;
  font-size: 13px;
}

body.game-active:not(.debug-active) {
  overflow: hidden;
  background: #000;
}

body.game-active:not(.debug-active) .game-header,
body.game-active:not(.debug-active) .game-panel > :not(.canvas-shell) {
  display: none;
}

body.game-active:not(.debug-active) #game-app,
body.game-active:not(.debug-active) .game-layout,
body.game-active:not(.debug-active) .game-panel,
body.game-active:not(.debug-active) .canvas-shell {
  width: 100vw;
  max-width: none;
  height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

body.game-active:not(.debug-active) #game-app {
  position: fixed;
  z-index: 20;
  inset: 0;
}

body.game-active:not(.debug-active) .game-layout {
  display: block;
}

body.game-active:not(.debug-active) .canvas-shell {
  display: grid;
  overflow: hidden;
  place-items: center;
  background: #000;
}

.game-panel {
  min-width: 0;
  padding: 13px;
}

.scene-meta,
.choice-heading,
.play-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
}

.scene-meta h2 {
  margin-bottom: 0;
}

#actor-state {
  display: none;
  flex: none;
  width: min(400px, 48%);
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid #537b7c;
  color: #bde6d9;
  font: 12px/1.2 monospace;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.debug-active #actor-state {
  display: block;
}

.canvas-shell {
  width: fit-content;
  max-width: 100%;
  margin: 10px auto 0;
  overflow: auto;
  border: 3px solid #050b12;
  background: #050b12;
}

canvas {
  display: block;
  width: 320px;
  height: 180px;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

canvas:focus-visible {
  outline: 3px solid #ffe087;
  outline-offset: -3px;
}

canvas.over-point-of-interest {
  cursor: pointer;
}

.story-panel,
.choice-panel,
.player-inventory-panel,
.play-controls {
  margin-top: 13px;
  padding: 13px;
  border: 1px solid #537b7c;
  background: #0d2131;
}

#narrative {
  min-height: 50px;
  margin-bottom: 0;
  color: #fff1c9;
  font-size: 18px;
}

.prototype-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.point-of-interest-controls {
  display: contents;
}

.prototype-controls button {
  min-height: 36px;
  padding: 5px 9px;
  font-size: 13px;
}

.choice-heading {
  align-items: end;
}

#story-progress {
  color: #8fc9c1;
  font: 12px monospace;
}

.story-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  max-height: 330px;
  overflow: auto;
}

.story-choice {
  display: grid;
  gap: 5px;
  align-content: start;
  min-height: 72px;
  text-align: left;
}

.story-choice small {
  color: #a9cfca;
  font: 11px/1.25 monospace;
}

.story-choice.optional {
  border-color: #73999a;
}

.complete-message,
.no-choice-message {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px;
  border: 1px solid #537b7c;
  color: #bde6d9;
}

.player-inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.inventory-chip {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid #537b7c;
  color: #d7e8dc;
  background: #142f3f;
  font-size: 13px;
}

.inventory-placeholder {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px dashed #d4ad5d;
  color: #ffd66b;
  font: bold 12px monospace;
}

.empty-inventory {
  color: #8fb1ad;
}

.direction-pad {
  display: grid;
  flex: none;
  grid-template: repeat(2, 42px) / repeat(3, 42px);
  gap: 4px;
}

.direction {
  min-height: 42px;
  padding: 0;
  font-size: 22px;
}

.up {
  grid-column: 2;
}

.left {
  grid-column: 1;
  grid-row: 2;
}

.down {
  grid-column: 2;
  grid-row: 2;
}

.right {
  grid-column: 3;
  grid-row: 2;
}

.play-controls p {
  max-width: 620px;
  margin-bottom: 0;
  color: #a9c8c3;
}

kbd {
  padding: 1px 4px;
  border: 1px solid #d4ad5d;
  color: #fff1c9;
  background: #071522;
  font: inherit;
}

.debug-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.debug-panel > section {
  padding: 12px;
}

.debug-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.debug-controls button,
.debug-controls select {
  min-height: 34px;
  padding: 5px 8px;
  font-size: 13px;
}

.debug-controls label {
  display: flex;
  gap: 5px;
  align-items: center;
}

progress {
  width: 100%;
  height: 17px;
  margin-top: 9px;
  accent-color: #d88b3b;
}

.debug-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 9px;
  margin: 0;
  font: 12px/1.35 monospace;
}

.debug-facts dt {
  color: #8fc9c1;
  font-weight: bold;
}

.debug-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.event-log,
.history-list,
.transition-list {
  max-height: 290px;
  margin: 0;
  padding: 8px 8px 8px 29px;
  overflow: auto;
  border: 1px solid #537b7c;
  color: #bde6d9;
  background: #081421;
  font: 11px/1.35 monospace;
}

.event-log li,
.history-list li,
.transition-list li {
  margin-bottom: 4px;
}

.marker-event {
  color: #ffca71;
}

.cancelled-event {
  color: #ff9e8c;
}

.debug-inventories {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.debug-inventory {
  padding: 7px;
  border: 1px solid #537b7c;
}

.debug-inventory h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.debug-inventory ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
}

.lane {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 54px;
  gap: 7px;
  align-items: center;
  margin: 5px 0;
  font: 11px monospace;
}

.lane progress {
  margin: 0;
}

.transition-list {
  max-height: 700px;
}

.transition-list li {
  padding: 3px;
  color: #718b8a;
}

.transition-list li.enabled {
  color: #fff1c9;
  font-weight: bold;
}

.transition-list li.fired {
  color: #91aaa7;
  text-decoration: line-through;
}

.transition-list li.current {
  outline: 1px solid #ffd66b;
  color: #fff1c9;
  background: #17394a;
  text-decoration: none;
}

.transition-list li.alternative {
  color: #a39b8c;
  font-style: italic;
}

.error-panel {
  width: min(700px, calc(100% - 30px));
  margin: 60px auto;
  padding: 24px;
}

@media (max-width: 1040px) {
  body.debug-active .game-layout {
    grid-template-columns: 1fr;
  }

  .debug-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .adventure-list,
  .story-choices,
  .debug-panel {
    grid-template-columns: 1fr;
  }

  .game-header {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }

  .game-heading {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .variant-wrap {
    grid-column: 2;
    grid-row: 1;
  }

  .debug-toggle {
    grid-column: 3;
    grid-row: 1;
  }

  .scene-meta,
  .play-controls {
    align-items: stretch;
    flex-direction: column;
  }

  #actor-state {
    width: 100%;
    text-align: left;
  }

  .direction-pad {
    align-self: center;
  }

  .debug-inventories {
    grid-template-columns: 1fr;
  }
}
