:root {
  --ink: #1d2a1c;
  --paper: #f4efe2;
  --moss: #2f6b3a;
  --pine: #1f4d32;
  --sun: #f0c44c;
  --clay: #c45c26;
  --water: #2f8fbe;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  background: #123322;
  color: var(--paper);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

#game-root {
  position: relative;
  height: 100%;
  overflow: hidden;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  background: #7ec8ea;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud > * {
  pointer-events: none;
}

.place-chip,
.field-guide,
.control-hint,
.inspect-prompt,
.journal-toggle,
.map-toggle,
.summit-toggle,
.hud-dock,
.hud-tools {
  pointer-events: auto;
}

.hud-dock {
  position: absolute;
  inset: auto 0 0 0;
  pointer-events: none;
}

.hud-tools {
  position: absolute;
  right: 16px;
  bottom: 22px;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.map-toggle,
.journal-toggle,
.summit-toggle {
  position: static;
  pointer-events: auto;
}

.map-toggle {
  border: 0;
  background: rgba(20, 40, 24, 0.82);
  color: var(--paper);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.summit-toggle {
  border: 0;
  background: #2c4a38;
  color: var(--paper);
  font-weight: 700;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.summit-toggle-face {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8d9b8;
  display: block;
  flex: 0 0 28px;
}

.journal-toggle {
  border: 0;
  background: var(--sun);
  color: var(--ink);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}

@media (min-width: 901px) {
  .map-toggle {
    order: 1;
  }

  .summit-toggle {
    order: 2;
  }

  .journal-toggle {
    order: 3;
  }
}

.field-guide {
  position: absolute;
  top: 64px;
  left: 16px;
  max-width: 320px;
  background: rgba(20, 40, 24, 0.82);
  color: var(--paper);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.field-guide-q {
  margin: 0 0 4px;
  opacity: 0.85;
  font-size: 0.75rem;
}

#game-root:has(#systems-map:not([hidden])) .field-guide,
#game-root:has(#aar:not([hidden])) .field-guide,
#game-root:has(#summit:not([hidden])) .field-guide {
  visibility: hidden;
  pointer-events: none;
}

.field-guide-next {
  margin: 0;
  font-weight: 600;
}

#guide-verb {
  letter-spacing: 0.04em;
  color: var(--sun);
}

.field-guide-where {
  margin: 4px 0 0;
  opacity: 0.8;
  font-size: 0.75rem;
}

.guide-pairs {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

input#geo-number {
  width: 100%;
  max-width: 12rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #7a8474;
  border-radius: 8px;
  background: #f7f1e4;
  color: #1d2a1c;
  font: inherit;
}

.place-chip {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(20, 40, 24, 0.72);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.place-chip small {
  display: block;
  opacity: 0.8;
  font-size: 0.75rem;
}

.control-hint {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(20, 40, 24, 0.7);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  max-width: 280px;
}

.control-hint:empty {
  display: none;
}

.inspect-prompt {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  border: 0;
  background: rgba(20, 40, 24, 0.86);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.summit-toggle.has-idea {
  box-shadow: 0 0 0 2px #c9a227;
}

.title-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

#title-screen,
#dialogue,
#conclusion,
#hypothesis,
#confirm-reset,
#atlas,
#flume,
#interpret,
#clearance,
#systems-map,
#aar,
#summit {
  position: absolute;
  inset: 0;
  place-items: center;
  pointer-events: auto;
}

#title-screen:not([hidden]),
#dialogue:not([hidden]),
#conclusion:not([hidden]),
#hypothesis:not([hidden]),
#confirm-reset:not([hidden]),
#atlas:not([hidden]),
#flume:not([hidden]),
#interpret:not([hidden]),
#clearance:not([hidden]),
#systems-map:not([hidden]),
#aar:not([hidden]) {
  display: grid;
  z-index: 8;
}

#summit:not([hidden]) {
  display: grid;
  z-index: 12;
  align-items: end;
  background: rgba(12, 28, 22, 0.42);
}

#atlas:not([hidden]) {
  z-index: 9;
  background: rgba(12, 28, 22, 0.42);
}

#flume:not([hidden]),
#interpret:not([hidden]),
#clearance:not([hidden]),
#systems-map:not([hidden]),
#aar:not([hidden]) {
  background: rgba(12, 28, 22, 0.42);
}

#title-screen {
  background: linear-gradient(180deg, rgba(16, 40, 28, 0.18), rgba(12, 28, 22, 0.55));
}

#title-screen[hidden],
#dialogue[hidden],
#conclusion[hidden],
#hypothesis[hidden],
#confirm-reset[hidden],
#atlas[hidden],
#flume[hidden],
#interpret[hidden],
#clearance[hidden],
#systems-map[hidden],
#aar[hidden],
#summit[hidden],
#toast[hidden],
#inspect-prompt[hidden],
#boot-error[hidden],
#journal-evidence-section[hidden],
#journal-sketch-section[hidden],
#journal-data-section[hidden],
#hypothesis-open[hidden],
#interpret-open[hidden],
#flume-numbers[hidden],
#atlas-travel[hidden],
.journal-section[hidden] {
  display: none;
}

.title-card,
.dialogue-card,
.conclusion-card,
#journal {
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.title-card {
  text-align: center;
  padding: 36px 42px 28px;
  max-width: 28rem;
}

.title-card p.kicker {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--moss);
  font-size: 0.78rem;
}

.title-card h1 {
  margin: 8px 0 6px;
  font-size: 3rem;
  letter-spacing: 0.04em;
}

.title-card p.tag {
  margin: 0 0 18px;
  color: #44553d;
}

#enter-btn,
.dialogue-card button,
.conclusion-card button,
.hypothesis-card button,
#journal-close,
#hypothesis-open,
#atlas-close,
#atlas-travel,
#open-atlas {
  border: 0;
  background: var(--moss);
  color: white;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.title-note {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: #66735f;
}

.dialogue-card {
  width: min(34rem, calc(100% - 40px));
  max-height: min(36rem, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px 24px;
}

.dialogue-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--moss);
}

.dialogue-card p {
  margin: 0 0 16px;
  font-size: 1.15rem;
  line-height: 1.4;
}

#dialogue-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding-top: 8px;
}

#journal {
  position: absolute;
  top: 72px;
  right: 16px;
  width: min(22rem, calc(100% - 32px));
  max-height: calc(100% - 120px);
  overflow: auto;
  padding: 16px 16px 12px;
  transform: translateX(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
  background-image:
    linear-gradient(180deg, rgba(244, 239, 226, 0.92), rgba(244, 239, 226, 0.97)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(140, 120, 80, 0.08) 28px);
  border: 1px solid #d7c39a;
}

#journal.is-open {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.journal-brand {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--moss);
}

.journal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 4px;
}

.journal-tabs button {
  flex: 1 1 18%;
  min-width: 3.4rem;
  border: 1px solid #cbbca0;
  background: #efe6d2;
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
}

.journal-tabs button.is-on {
  background: #e7f0c8;
  border-color: var(--moss);
}

.journal-tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.journal-foot {
  margin-top: 10px;
  border-top: 1px dashed #cbbca0;
  padding-top: 8px;
}

.quiet-btn {
  background: rgba(31, 77, 50, 0.12);
  color: var(--ink);
  border: 1px solid #cbbca0;
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.discovery-card.is-interpreted {
  background: #e7f0c8;
  padding: 8px 10px;
  border-radius: 10px;
  border-top: 0;
}

.interpreted-mark {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6238;
}

#journal header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
}

#journal header h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1.15rem;
}

#journal article {
  border-top: 1px solid #ddd4c0;
  padding-top: 8px;
}

#journal h3 {
  margin: 10px 0 4px;
  font-size: 0.95rem;
}

#journal p {
  margin: 0 0 8px;
  line-height: 1.35;
}

.dialogue-kicker {
  margin: 0 0 4px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #8a6238;
}

.journal-kicker {
  margin: 12px 0 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--moss);
}

.journal-section + .journal-section {
  border-top: 1px dashed #cbbca0;
  margin-top: 8px;
  padding-top: 4px;
}

#discovery-count {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #5c6b54;
}

.discovery-card {
  border-top: 1px solid #ddd4c0;
  padding-top: 8px;
}

.discovery-symbol {
  color: #8a6238;
}

.discovery-loc {
  margin: 0 0 4px;
  font-size: 0.78rem;
  color: #6a7360;
}

.toast-pop {
  animation: toast-pop 0.35s ease;
}

@keyframes toast-pop {
  from { transform: translateY(8px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

@media (max-width: 1366px) {
  #journal {
    width: min(20rem, calc(100% - 24px));
    top: 64px;
    max-height: calc(100% - 110px);
  }

  .hypothesis-card {
    width: min(36rem, calc(100% - 24px));
    max-height: calc(100% - 32px);
    overflow: auto;
  }

  .atlas-card {
    width: min(52rem, calc(100% - 20px));
    max-height: calc(100% - 24px);
  }

  .atlas-body {
    grid-template-columns: minmax(0, 1fr) 13.5rem;
  }
}

.journal-conclusion {
  background: #e7f0c8;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border-top: 0;
}

.evidence-card {
  border-top: 1px solid #ddd4c0;
  padding-top: 8px;
}

.evidence-kind {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6238;
}

.evidence-sig,
.evidence-q {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: #44553d;
}

.evidence-q {
  font-style: italic;
}

#field-sketch {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #efe6d2;
  border: 2px solid #d7c39a;
}

#hypothesis-open {
  margin-top: 8px;
  width: 100%;
}

.hypothesis-card {
  width: min(42rem, calc(100% - 32px));
  max-height: min(42rem, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 18px 16px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.hypothesis-lead {
  margin: 0 0 12px;
  color: #44553d;
}

.hypothesis-kicker {
  margin: 10px 0 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--moss);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-row button {
  background: #f4efe2;
  color: var(--ink);
  border: 2px solid #cbbca0;
  font-weight: 700;
}

.chip-row button.is-on {
  background: #e7f0c8;
  border-color: var(--moss);
}

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

.chip-scale {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6a7360;
  font-weight: 600;
}

#hypothesis-status {
  min-height: 2.4em;
  margin: 12px 0 8px;
  line-height: 1.4;
}

#hypothesis-status.is-success {
  background: #e7f0c8;
  padding: 8px 10px;
  border-radius: 10px;
}

#toast {
  position: absolute;
  left: 16px;
  bottom: 22px;
  width: min(24rem, calc(100% - 180px));
  background: rgba(20, 40, 24, 0.92);
  color: var(--paper);
  padding: 12px 14px;
  border-radius: 14px;
  border-left: 5px solid var(--sun);
  pointer-events: none;
}

#toast strong {
  display: block;
  color: var(--sun);
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

#toast p {
  margin: 4px 0 0;
}

.conclusion-card {
  width: min(40rem, calc(100% - 32px));
  max-height: min(40rem, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 18px 16px;
}

.sketch {
  position: relative;
  height: 280px;
  margin: 10px 0;
  border-radius: 14px;
  background:
    radial-gradient(circle at 48% 62%, #4aaad0 0 12%, transparent 13%),
    linear-gradient(180deg, #c8c2b4 0 22%, #7cb35c 22% 70%, #8fbe4f 70%);
  overflow: hidden;
  border: 3px solid #d7c39a;
}

.flow-node {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 0;
  background: #f4efe2;
  color: var(--ink);
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.flow-node:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.flow-node[data-order]::after {
  content: attr(data-order);
  margin-left: 6px;
  color: var(--moss);
}

#path-status,
#conclusion-hint {
  min-height: 1.4em;
  margin: 0 0 8px;
}

.conclusion-actions,
#reset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding-top: 8px;
}

#systems-map canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 42vh;
  border-radius: 12px;
  background: #e7f0d8;
  cursor: pointer;
  touch-action: manipulation;
}

.aar-wren {
  margin: 0 0 10px;
  font-size: 1.02rem;
  line-height: 1.45;
  color: #243226;
}

.aar-evidence {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}

.hypothesis-card button.aar-card-btn {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  white-space: normal;
  padding: 12px 14px;
  min-height: 52px;
  background: #f4efe2;
  color: #243226;
  border: 2px solid #cbbca0;
  border-radius: 14px;
  font-weight: 600;
}

.hypothesis-card button.aar-card-btn .chip-scale {
  color: #5a6d52;
  letter-spacing: 0.08em;
}

.hypothesis-card button.aar-card-btn strong {
  font-size: 1rem;
  color: #243226;
}

.hypothesis-card button.aar-card-btn span:last-child {
  font-weight: 500;
  color: #44553d;
  font-size: 0.92rem;
  line-height: 1.35;
}

.hypothesis-card button.aar-card-btn.is-on {
  border-color: #2f6b3a;
  background: #dce8cf;
  box-shadow: inset 0 0 0 1px #2f6b3a;
}

#systems-map .conclusion-actions {
  position: static;
}

#aar .conclusion-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--paper);
  box-shadow: 0 -12px 18px var(--paper);
}

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

.summit-sheet {
  width: min(26rem, calc(100% - 24px));
  max-height: min(38rem, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  margin: 12px 12px 16px auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 16px 12px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.summit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.summit-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.summit-portrait {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 50%;
  background: #d7e4c4;
  object-fit: cover;
}

.summit-identity-text {
  min-width: 0;
}

.summit-head h2 {
  margin: 0;
  line-height: 1.15;
}

.summit-role {
  margin: 2px 0 0;
  color: #44553d;
  font-size: 0.88rem;
}

.summit-lead {
  margin: 6px 0 8px;
  color: #44553d;
}

.summit-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding: 4px 2px 8px;
}

.summit-msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.4;
}

.summit-msg.is-summit {
  background: #e7f0d8;
}

.summit-msg.is-student {
  background: #f4efe2;
}

.summit-msg cite {
  display: block;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: #5a6d52;
  margin-bottom: 4px;
}

.summit-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
  flex: 0 1 auto;
}

.summit-quick button,
#summit-more {
  border: 2px solid #cbbca0;
  background: #f4efe2;
  color: #243226;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 44px;
  cursor: pointer;
}

#summit-more,
.summit-form {
  flex-shrink: 0;
}

.summit-form {
  display: flex;
  gap: 8px;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding-top: 8px;
}

.summit-form input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  border: 2px solid #cbbca0;
  border-radius: 12px;
  padding: 8px 10px;
  font: inherit;
  background: #fffdf8;
}

.summit-form button,
.summit-head button {
  border: 0;
  background: var(--moss);
  color: white;
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 999px;
  min-height: 44px;
  cursor: pointer;
}

.summit-lead.is-pending {
  min-height: 2.6em;
}
.summit-lead.is-pending::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-left: 0.45em;
  border-radius: 50%;
  background: #5a6d52;
  vertical-align: middle;
  animation: summit-think 1s ease-in-out infinite;
}
@keyframes summit-think {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .summit-lead.is-pending::after {
    animation: none;
    opacity: 0.55;
  }
}

.summit-diag {
  overflow-wrap: anywhere;
  font-size: 0.72rem;
  line-height: 1.35;
}

.summit-diag[hidden] {
  display: none;
}

.summit-fieldtest[hidden],
#summit-fieldtest-flag[hidden] {
  display: none;
}

.summit-sheet:has(#summit-fieldtest:not([hidden])) {
  overflow-y: auto;
}

.summit-sheet:has(#summit-fieldtest:not([hidden])) .summit-log {
  min-height: 5.5rem;
}

.summit-sheet:has(#summit-fieldtest:not([hidden])) .summit-quick {
  max-height: 4.25rem;
}

.summit-fieldtest {
  flex-shrink: 0;
  margin-top: 10px;
  padding: 8px 8px 4px;
  border-top: 1px dashed #c4b48a;
  background: #f3eee3;
  border-radius: 10px;
}

.summit-fieldtest-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5a6d52;
}

.summit-fieldtest-marks,
.summit-fieldtest-export {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.summit-fieldtest button {
  border: 2px solid #cbbca0;
  background: #f4efe2;
  color: #243226;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 44px;
  cursor: pointer;
}

.summit-fieldtest input {
  width: 100%;
  min-height: 44px;
  border: 2px solid #cbbca0;
  border-radius: 12px;
  padding: 8px 10px;
  font: inherit;
  background: #fffdf8;
  margin-bottom: 6px;
}

#journal-graph {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #efe6d2;
  border: 2px solid #d7c39a;
  margin: 8px 0;
}

#journal-graph[hidden],
#clearance-follow[hidden],
#clearance-follow-kicker[hidden],
#clearance-follow-try[hidden] {
  display: none;
}

#interpret-graph {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #efe6d2;
  border: 2px solid #d7c39a;
  margin: 8px 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 8px 0;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #ddd4c0;
  padding: 4px 6px;
  text-align: left;
}

#flume-log {
  max-height: 8rem;
  overflow: auto;
  font-size: 0.88rem;
}

#flume-status,
#interpret-status,
#clearance-status {
  min-height: 2.2em;
  margin: 10px 0 8px;
  line-height: 1.4;
}

#boot-error {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: #8a3324;
  padding: 10px 14px;
  border-radius: 10px;
}

.atlas-card {
  width: min(58rem, calc(100% - 28px));
  max-height: calc(100dvh - 28px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  padding: 14px 16px 16px;
}

.atlas-card header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
  margin-bottom: 8px;
}

.atlas-card header h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1.2rem;
}

.atlas-card header #atlas-close {
  grid-column: 2;
  grid-row: 1;
}

.atlas-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(16rem, 34%);
  gap: 12px;
  align-items: start;
}

.atlas-map-frame {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 3 / 2;
  border-radius: 12px;
  border: 2px solid #d7c39a;
  overflow: hidden;
  background: #8ec8ea;
}

#atlas-map {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: #8ec8ea;
  cursor: pointer;
}

.atlas-preview {
  background: #efe6d2;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #d7c39a;
}

.atlas-kicker,
.atlas-route-label {
  margin: 0 0 4px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--moss);
}

.atlas-preview h3 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.atlas-preview p {
  margin: 0 0 8px;
  line-height: 1.35;
}

#atlas-travel,
#open-atlas {
  width: 100%;
  margin: 8px 0;
}

.field-record-row {
  margin: 0 0 6px;
  font-size: 0.92rem;
}

.field-record-row.is-demonstrated {
  color: var(--pine);
}

.field-record-row.is-developing {
  color: #6a5a32;
}

.field-record-row.is-not-yet-observed {
  color: #5c6b54;
}

#region-map {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid #d7c39a;
  background: #c9d6c8;
}

#geo-board {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 28, 22, 0.35);
  z-index: 8;
}

#geo-board[hidden] {
  display: none;
}

#geo-body {
  max-height: 16rem;
  overflow: auto;
}

#geo-status {
  min-height: 2.2em;
  margin: 10px 0 8px;
  line-height: 1.4;
}

#sky-clock {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  z-index: 4;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 14px;
  border-radius: 18px;
  background: #f3ead4;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(20, 28, 22, 0.18), inset 0 0 0 2px #c4b48a;
}

#sky-clock[hidden] {
  display: none;
}

.sky-clock-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6a5a32;
}

#sky-clock-label {
  margin: 2px 0 8px;
  font-weight: 600;
}

.obs-marks,
#sky-clock-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}

.obs-marks button,
#sky-clock-jumps button {
  min-width: 76px;
  border-radius: 999px;
  border: 1px solid #b89a5a;
  background: #fff8e8;
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.obs-steps,
#sky-clock-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.obs-steps button,
#sky-clock-extra button {
  border: 0;
  background: rgba(90, 70, 40, 0.08);
  font: inherit;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

#sky-clock-full {
  margin-top: 8px;
}

.field-bench-kicker {
  margin: 0 0 4px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--moss);
}

.field-bench {
  border: 2px solid #c4b48a;
  background: #f6edd8;
}

@media (max-width: 900px) {
  #sky-clock {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}

#title-screen[hidden],
#dialogue[hidden],
#conclusion[hidden],
#hypothesis[hidden],
#confirm-reset[hidden],
#atlas[hidden],
#flume[hidden],
#interpret[hidden],
#clearance[hidden],
#systems-map[hidden],
#aar[hidden],
#summit[hidden],
#travel-card[hidden],
#appearance-setup[hidden],
#toast[hidden],
#inspect-prompt[hidden],
#boot-error[hidden],
#journal-evidence-section[hidden],
#journal-sketch-section[hidden],
#journal-data-section[hidden],
#hypothesis-open[hidden],
#interpret-open[hidden],
#flume-numbers[hidden],
#atlas-travel[hidden],
.journal-section[hidden] {
  display: none;
}

#travel-card:not([hidden]) {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 12;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(12, 28, 22, 0.28), rgba(12, 22, 18, 0.55));
}

#travel-card h2 {
  margin: 0;
  font-size: 2.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f4efe2;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

#travel-card p {
  margin: 6px 0 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #e8d7a8;
}

.travel-kicker {
  font-size: 0.78rem;
}

.appearance-setup {
  margin: 8px 0 4px;
}

.appearance-lead {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: #44553d;
}

.appearance-setup .chip-row {
  justify-content: center;
  margin-bottom: 6px;
}

#journal {
  border-left: 4px solid #2f6b3a;
}

.field-record-region {
  margin: 10px 0 4px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--moss);
}

@media (prefers-reduced-motion: reduce) {
  #journal {
    transition: none;
  }
}

/* Explicit mobile HUD: keep Look closer out of World map / Field tablet. */
@media (max-width: 900px) {
  .hud-dock {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    left: 12px;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    pointer-events: none;
  }

  .inspect-prompt {
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    align-self: center;
    max-width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    white-space: normal;
    line-height: 1.25;
    pointer-events: auto;
  }

  .hud-tools {
    display: flex;
    gap: 8px;
    pointer-events: none;
    position: static;
    right: auto;
    bottom: auto;
    width: 100%;
  }

  .map-toggle,
  .journal-toggle,
  .summit-toggle {
    position: static;
    right: auto;
    bottom: auto;
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: auto;
  }

  .summit-toggle {
    padding: 6px 8px 6px 6px;
    gap: 6px;
  }

  .summit-toggle-face {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
  }

  .place-chip {
    max-width: calc(100% - 24px);
    top: max(10px, env(safe-area-inset-top, 0px));
    left: 12px;
  }

  .control-hint {
    display: none;
  }

  .field-guide {
    top: 58px;
    left: 12px;
    right: 12px;
    max-width: none;
    max-height: min(22vh, 9.5rem);
    overflow: auto;
  }

  /* Blocking overlays must not sit on top of Look closer / World map / Field tablet. */
  #game-root:is(
    :has(#dialogue:not([hidden])),
    :has(#hypothesis:not([hidden])),
    :has(#conclusion:not([hidden])),
    :has(#confirm-reset:not([hidden])),
    :has(#atlas:not([hidden])),
    :has(#flume:not([hidden])),
    :has(#interpret:not([hidden])),
    :has(#clearance:not([hidden])),
    :has(#systems-map:not([hidden])),
    :has(#aar:not([hidden])),
    :has(#summit:not([hidden])),
    :has(#geo-board:not([hidden])),
    :has(#title-screen:not([hidden])),
    :has(#journal.is-open)
  ) .hud-dock,
  #game-root:is(
    :has(#dialogue:not([hidden])),
    :has(#hypothesis:not([hidden])),
    :has(#conclusion:not([hidden])),
    :has(#confirm-reset:not([hidden])),
    :has(#atlas:not([hidden])),
    :has(#flume:not([hidden])),
    :has(#interpret:not([hidden])),
    :has(#clearance:not([hidden])),
    :has(#systems-map:not([hidden])),
    :has(#aar:not([hidden])),
    :has(#summit:not([hidden])),
    :has(#geo-board:not([hidden])),
    :has(#title-screen:not([hidden])),
    :has(#journal.is-open)
  ) .field-guide {
    visibility: hidden;
    pointer-events: none;
  }

  #dialogue:not([hidden]),
  #hypothesis:not([hidden]),
  #conclusion:not([hidden]),
  #confirm-reset:not([hidden]),
  #systems-map:not([hidden]),
  #aar:not([hidden]),
  #summit:not([hidden]) {
    background: rgba(12, 28, 22, 0.28);
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }

  .summit-sheet {
    width: calc(100% - 16px);
    max-height: min(78dvh, calc(100dvh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    margin: auto 8px 8px;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
  }

  .summit-portrait {
    width: 64px;
    height: 64px;
    flex: 0 0 64px;
  }

  .summit-quick {
    max-height: 8.25rem;
    overflow-y: auto;
  }

  .summit-quick button {
    flex: 1 1 calc(50% - 6px);
  }

  #toast {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  }

  #sky-clock {
    left: 10px;
    right: 10px;
    bottom: calc(108px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }

  #journal {
    top: max(8px, env(safe-area-inset-top, 0px));
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100% - 16px - env(safe-area-inset-bottom, 0px));
  }

  .dialogue-card,
  .hypothesis-card,
  .conclusion-card,
  .title-card {
    width: min(42rem, calc(100% - 16px));
    margin-inline: 8px;
  }

  .title-card h1 {
    font-size: 2.2rem;
  }

  .title-card {
    padding: 24px 18px 20px;
  }
}

/* Explicit mobile portrait world map: stack, never squeeze the canvas. */
@media (max-width: 720px) {
  #atlas:not([hidden]) {
    align-items: start;
    justify-items: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    padding:
      max(8px, env(safe-area-inset-top, 0px))
      8px
      max(8px, env(safe-area-inset-bottom, 0px));
  }

  .atlas-card {
    width: 100%;
    max-width: none;
    max-height: none;
    height: auto;
    margin: 0;
    padding: 12px 12px 16px;
  }

  .atlas-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    grid-template-columns: none;
  }

  .atlas-map-frame {
    width: 100%;
    aspect-ratio: 3 / 2;
  }

  .atlas-preview {
    width: 100%;
  }

  .atlas-card header .journal-brand {
    min-width: 0;
    letter-spacing: 0.08em;
    line-height: 1.35;
    padding-right: 8px;
  }

  .dialogue-card,
  .hypothesis-card,
  .conclusion-card {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  #systems-map canvas {
    max-height: 38vh;
  }

  .hypothesis-card button.aar-card-btn {
    font-size: 0.95rem;
  }
}

@media (max-width: 900px) and (max-height: 500px) {
  .summit-sheet {
    max-height: calc(100dvh - 8px - env(safe-area-inset-bottom, 0px));
    margin: 4px 8px;
  }

  .summit-lead {
    display: none;
  }

  .summit-quick {
    max-height: 5.5rem;
    overflow: auto;
  }

  .summit-log {
    min-height: 4rem;
  }
}

@media (max-width: 900px) and (max-height: 700px) {
  .field-guide {
    top: 52px;
    max-height: min(18vh, 7.25rem);
    padding: 8px 10px;
  }
}
