html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #251810;
}
#app {
  padding: 0;
}
.exploration-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.exploration-header {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 8px 16px;
  background: #191c30;
}
.exploration-header > strong {
  letter-spacing: 0.08em;
  white-space: nowrap;
}
#exploration-hud {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1;
}
.mini-resource {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 10px;
  text-transform: capitalize;
  flex: 1;
  font-size: 1rem;
}
.mini-resource progress {
  grid-column: 1 / -1;
  height: 6px;
  color: #ffcd79;
}
.mini-resource:nth-child(3) progress {
  color: #8cdaf4;
}
.mini-resource:nth-child(4) progress {
  color: #91dfba;
}
.sol-badge {
  color: #ffd08a;
  white-space: nowrap;
}
.resource-danger {
  color: #ff9c87;
}
.crew-picker {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px;
}
.crew-picker button {
  padding: 4px 12px;
  min-height: 44px;
}
.crew-picker [aria-pressed="true"] {
  background: #ffd08a;
  color: #271b23;
}
.map-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
#expedition-map {
  display: block;
  max-height: 100%;
  max-width: 100%;
  width: min(100vw, calc((100dvh - 245px) * 1.4286));
  height: auto;
  aspect-ratio: 320 / 224;
  image-rendering: pixelated;
  border: 3px solid #f58a1f;
  touch-action: none;
  background: #a9552a;
}
#expedition-map:focus-visible {
  outline: 2px solid #8cdaf4;
  outline-offset: -5px;
}
.game-message {
  padding: 4px 16px;
  background: #191c30;
}
.game-message p {
  margin: 0;
  font-size: 1rem;
  min-height: 26px;
}
.exploration-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #101323;
}
.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 44px);
  gap: 3px;
}
.direction-pad button {
  padding: 0;
  text-align: center;
  min-height: 44px;
  touch-action: none;
}
.direction-pad button:first-child {
  grid-column: 2;
}
.direction-pad button:nth-child(2) {
  grid-column: 1;
}
.control-help {
  color: #b7bdd5;
}
.decision-overlay {
  position: absolute;
  top: 90px;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, calc(100% - 24px));
  overflow: auto;
  box-shadow: 0 0 0 100vmax #080b14b0;
  z-index: 10;
}
.decision-overlay.is-idle {
  display: none;
}
.decision-overlay h2 {
  font-size: 1.3rem;
}
.decision-overlay .choice-list {
  margin: 12px 0;
}
.decision-overlay .science-explanation {
  margin: 12px 0;
}
@media (max-width: 700px) {
  .exploration-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
  }
  .exploration-header > strong {
    font-size: 1rem;
  }
  #exploration-hud {
    flex-basis: 100%;
    gap: 10px;
  }
  .mini-resource {
    font-size: 1rem;
  }
  .control-help {
    display: none;
  }
  .exploration-controls {
    gap: 5px;
    padding: 6px;
  }
  .exploration-controls > button {
    padding: 8px;
    max-width: 100px;
  }
  .crew-picker {
    gap: 4px;
  }
  .crew-picker button {
    padding: 4px 8px;
  }
  .game-message {
    max-height: 80px;
    overflow: auto;
  }
  .decision-overlay {
    top: 110px;
    bottom: 110px;
    padding: 18px;
  }
  .sol-badge {
    font-size: 1rem;
  }
}

/* Main-game accessibility and decision overlays. */
html,
body {
  overflow: auto;
}
.exploration-shell {
  height: auto;
  min-height: 100dvh;
}
.map-stage {
  height: max(224px, calc(100dvh - 270px));
  flex: none;
}
.mini-resource {
  grid-template-columns: 24px minmax(0, 1fr) auto;
}
.mini-resource .resource-icon {
  width: 24px;
  height: 24px;
}
.exploration-header {
  flex-wrap: wrap;
}
#exploration-hud {
  min-width: 0;
  flex-wrap: wrap;
}
.mini-resource {
  min-width: 140px;
}
.decision-overlay {
  position: fixed;
  transform: none;
  inset: 16px;
  margin: auto;
  width: min(600px, calc(100% - 32px));
  height: fit-content;
  max-height: calc(100dvh - 32px);
  box-shadow: none;
  color: #eeeef7;
}
.decision-overlay::backdrop {
  background: #080b14bd;
}
.decision-overlay:not([open]) {
  display: none;
}
.decision-overlay .panel {
  border: 0;
  padding: 0;
  box-shadow: none;
}
.decision-overlay h1 {
  font-size: 2rem;
}
.control-help {
  white-space: normal;
}
@media (max-width: 700px) {
  .control-help {
    display: block;
    font-size: 1rem;
    flex-basis: 100%;
    text-align: center;
  }
  .exploration-controls {
    flex-wrap: wrap;
  }
  #expedition-map {
    width: 100%;
    height: auto;
    max-height: 100%;
  }
  .mini-resource {
    min-width: 100px;
  }
  .mini-resource strong {
    font-size: 1rem;
  }
}

.crew-picker button {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.crew-portrait {
  display: block;
  width: 32px;
  height: 32px;
  background: url("assets/images/characters/astronauts/crew-helmet-sprites-1x.png")
    0 calc(32px * var(--crew-row)) / 384px 128px;
  image-rendering: pixelated;
}
.astronaut-selection {
  border: 0;
  margin: 18px 0;
  padding: 0;
}
.astronaut-selection legend {
  margin-bottom: 10px;
  font-weight: 700;
}
.astronaut-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.astronaut-option {
  display: flex;
  min-width: 0;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.astronaut-option[aria-pressed="true"] {
  background: #ffd08a;
  color: #271b23;
  outline: 3px solid #fff3aa;
}
.mini-resource progress {
  grid-column: 1 / -1;
}
@media (max-width: 700px) {
  .astronaut-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .crew-picker button {
    flex: 1;
    min-width: 0;
    padding: 4px;
    font-size: 1rem;
  }
  .crew-portrait {
    flex-shrink: 0;
  }
  .crew-picker {
    width: 100%;
  }
  .map-stage {
    min-height: 224px;
  }
}
/* Let enlarged content scroll in the document, rather than nested body scrollers. */
html {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
body {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
.map-stage {
  height: auto;
  min-height: 224px;
  flex: 1;
}
@media (max-width: 700px) {
  .crew-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* Keep enlarged HUD labels and action names from colliding. */
.mini-resource {
  min-width: min(100%, 10rem);
}
.mini-resource > span {
  overflow-wrap: anywhere;
}
@media (max-width: 700px) {
  .mini-resource {
    min-width: min(100%, 10rem);
  }
  .exploration-controls > button {
    max-width: none;
    min-width: min(100%, 8rem);
    flex: 1;
  }
}

/* A wide, responsive playfield, with camera resolution matched to its size. */
.exploration-shell {
  display: grid;
  /* Header, map, messages, controls. Crew selection now lives in the welcome dialog. */
  grid-template-rows: auto minmax(224px, 1fr) auto auto;
  height: 100dvh;
  min-height: 100dvh;
}
.map-stage {
  position: relative;
  width: 100%;
  min-height: 224px;
  height: auto;
  overflow: hidden;
}
#expedition-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  box-sizing: border-box;
}
#expedition-fullscreen {
  white-space: nowrap;
  min-height: 44px;
  padding: 6px 12px;
}
@media (max-width: 700px) {
  .control-help {
    display: none;
  }
  .exploration-controls > button {
    min-width: 0;
    max-width: none;
  }
  .crew-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .crew-picker button {
    overflow-wrap: anywhere;
  }
}
@media (max-width: 700px) and (min-resolution: 1dppx) {
  .crew-picker {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 6rem), 1fr));
  }
}

.exploration-header > strong {white-space:normal;overflow-wrap:anywhere;min-width:0}

/* Use the supplied Mars landscape for briefing and terminal scenes only. */
.decision-overlay:is([data-scene="welcome"], [data-scene="victory"], [data-scene="defeat"])::backdrop {
  background: linear-gradient(#14162666, #141626aa), url("assets/images/environment/mars/landscape-3x.png") center / cover;
  image-rendering: pixelated;
}
.decision-overlay:is([data-scene="welcome"], [data-scene="victory"], [data-scene="defeat"])::before {
  content: "";
  display: block;
  height: clamp(96px, 18dvh, 160px);
  margin-bottom: 20px;
  border-radius: 12px;
  border: 1px solid #80606b;
  background: #673f55 url("assets/images/environment/mars/landscape-3x.png") center 58% / cover;
  image-rendering: pixelated;
}


/* Keep the release identifier visible but unobtrusive in the game dashboard. */
.app-version {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
  opacity: 0.8;
}

/* Spec 009: changing resources and routine work remain visible during exploration. */
.survival-meter {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 6px;
  background: #0e1224;
}
.survival-meter i {
  display: block;
  height: 100%;
  background: #ffd08a;
  transition: width .35s ease;
}
[data-resource="oxygen"] .survival-meter i { background: #8cdaf4; }
[data-resource="shielding"] .survival-meter i { background: #91dfba; }
.game-message #survival-advice, .game-message #survival-deltas {
  min-height: 0;
  color: #fff0c4;
}
#survival-work label { font-size: 1rem; }
#survival-work progress { height: 8px; }
.game-message:has(#survival-work:not([hidden])) { overflow: visible; max-height: none; }
#survival-deltas { font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .survival-meter i { transition: none; }
}
@media (max-width: 700px) {
  .app-version { font-size: 0.65rem; }
}
