@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Libre+Caslon+Text:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  color-scheme: dark;
  --bg: #171c19;
  --panel: #1c221e;
  --line: #353d34;
  --text: #deded0;
  --muted: #929d8e;
  --accent: #bdc79b;
  --serif: 'Libre Caslon Text', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  background-image: radial-gradient(
    ellipse at 10% 10%,
    #29332555,
    transparent 55%
  );
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  color: var(--text);
  border: 1px solid #505a47;
  background: transparent;
  padding: 11px 16px;
  border-radius: 3px;
  min-height: 44px;
}
button:hover:not(:disabled):not([aria-disabled="true"]) {
  background: #30392c;
  border-color: var(--accent);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
button:disabled,
button[aria-disabled="true"] {
  cursor: default;
}
[hidden] {
  display: none !important;
}
.entrance {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 40px;
  padding: 48px 24px;
  text-align: center;
}
.entrance h1 {
  margin: 0;
  font-size: clamp(58px, 11vw, 132px);
  line-height: 0.95;
  letter-spacing: -0.055em;
}
.entrance nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.entrance a {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-underline-offset: 5px;
  transition: color 0.2s;
}
.entrance a:hover {
  color: var(--text);
}
.shell {
  max-width: 1192px;
  margin: auto;
  padding: 0 48px;
}
header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 4px;
}
.controls {
  display: flex;
  gap: 15px;
  align-items: center;
}
.controls > span {
  font-size: 10px;
  color: var(--muted);
}
.quiet {
  border: 0;
  color: var(--muted);
  font-size: 11px;
  padding: 8px;
}
.heading {
  padding: 24px 0;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2.7px;
  color: var(--accent);
  font-weight: 600;
}
.eyebrow span {
  padding: 0 10px;
  color: #64705e;
}
h1 {
  font-family: var(--serif);
  font-size: clamp(26px, 3.5vw, 32px);
  font-weight: 400;
  line-height: 1.3;
  margin: 0 0 8px;
  letter-spacing: -0.7px;
}
.heading > p {
  margin: 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
}
.heading > .danger-level {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 11px;
  margin-top: 7px;
  font: 10px/1.5 var(--sans);
  font-style: normal;
  letter-spacing: 0.04em;
}
.danger-level strong {
  color: #d7ab8a;
  font-weight: 600;
  text-transform: uppercase;
}
.danger-level span {
  color: var(--muted);
}
.game-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 65px;
  align-items: start;
  min-height: 330px;
}
.section-title {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 11px;
  margin-bottom: 18px;
}
h2 {
  font-size: 11px;
  letter-spacing: 1.4px;
  font-weight: 500;
  margin: 0;
}
.section-title > span {
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--muted);
}
.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
#story {
  max-height: 610px;
  min-height: 200px;
  overflow-y: auto;
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-color: #45503c transparent;
  padding-right: 20px;
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0%,
    #000 60%,
    #0009 85%,
    #0004 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 0%,
    #000 60%,
    #0009 85%,
    #0004 100%
  );
}
.event {
  padding: 0 0 19px 20px;
  margin-left: 2px;
  border-left: 1px solid #35402f;
  position: relative;
  animation: appear 0.5s ease;
}
.event::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #59644c;
}
.event-time {
  font-size: 8px;
  color: #89947c;
  letter-spacing: 1.5px;
}
.event p {
  margin: 5px 0 0;
  font: 14px/1.95 var(--serif);
  color: #c9cebf;
}
.event.resource p {
  color: #97a28e;
  font: 12px/1.8 var(--sans);
}
.event.milestone p {
  color: #e0e5d0;
}
.event.milestone::before {
  background: var(--accent);
}
.event.warning p {
  color: #d7ab8a;
}
.event.discovery p {
  font-style: italic;
}
.play-panel > section,
.play-panel [role='tabpanel'] > section {
  margin-bottom: 30px;
}
.stat {
  margin-bottom: 13px;
}
.stat > div:first-child {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 7px;
}
.stat small {
  color: var(--muted);
  font-size: 9px;
}
.meter {
  height: 3px;
  background: #30382d;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: #a7b18a;
  transition: width 0.2s linear;
}
.danger .meter i {
  background: #c38c6e;
}
.health .meter i {
  background: #809e8a;
}
.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-top: 21px;
}
.inventory > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.inventory span {
  color: var(--muted);
  font-size: 11px;
}
.inventory strong {
  font-size: 18px;
  font-weight: 400;
}
.inventory small {
  color: #7f8a76;
  font-size: 10px;
}
.rail-distance {
  margin: 0;
  color: var(--text);
  font: 24px/1.3 var(--serif);
}
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action {
  text-align: left;
  padding: 13px 13px 12px;
  position: relative;
  overflow: hidden;
  min-height: 76px;
  background: #22291f77;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.action-content {
  position: relative;
  display: block;
}
.action-name {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  font-size: 12px;
}
.duration {
  color: var(--muted);
  font-size: 10px;
}
.action-detail {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  margin-top: 5px;
}
.action:disabled,
.action[aria-disabled="true"] {
  opacity: 0.45;
  border-color: #414938;
}
.action.in-progress {
  opacity: 1;
  border-color: #909d73;
}
.action-progress {
  position: absolute;
  inset: 0 auto 0 0;
  background: #7e916332;
  transition: width 0.2s linear;
}
.departure {
  grid-column: 1 / -1;
  border-style: dashed;
}
.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
  margin-top: 14px;
}
.companion {
  border-left: 1px solid #536345;
  padding-left: 14px;
  margin-bottom: 15px;
}
.companion strong {
  font-weight: 500;
}
.companion p {
  font-size: 12px;
  margin: 3px 0;
  color: var(--muted);
}
.companion small {
  font-size: 10px;
  color: var(--muted);
}
footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding: 23px 0 32px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #839078;
  font-size: 10px;
}
footer > span:first-child {
  font-family: var(--serif);
  font-style: italic;
}
#clock {
  font-size: 8px;
  letter-spacing: 1.5px;
}
/* The tunnel closes over the game before the final message appears. */
.ending:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 50;
  margin: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: #080b08;
  animation: tunnel-fade 3s ease-in both;
}
.ending-message {
  text-align: center;
  opacity: 0;
  animation: tunnel-fade 4s ease-out 3s forwards;
}
.ending h2 {
  font: 26px/1.5 var(--serif);
  margin-bottom: 24px;
}
.ending-message { width: min(100%, 680px); }
#ending-summary > h2,
#ending-summary > p { text-align: left; }
.ending-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.ending-lore { text-align: left; }
.ending-lore p { line-height: 1.7; margin-bottom: 20px; }
body.journey-complete { overflow: hidden; }
@keyframes tunnel-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .ending:not([hidden]), .ending-message { animation: none; opacity: 1; }
}
dialog {
  color: var(--text);
  background: #20271f;
  border: 1px solid #647352;
  border-radius: 4px;
  width: min(480px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 30px;
}
dialog::backdrop {
  background: #0c110ce3;
  backdrop-filter: blur(4px);
}
dialog h2 {
  font: 26px/1.4 var(--serif);
  letter-spacing: -0.5px;
}
dialog p {
  font-size: 12px;
  color: var(--muted);
}
dialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
}
input {
  width: 110px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid #59644b;
  padding: 10px;
  border-radius: 2px;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 23px;
}
.dialog-actions button {
  font-size: 11px;
}
.dialog-actions button:last-child {
  background: #bbc69a;
  color: #1c2419;
}
.dialog-actions button:disabled {
  opacity: 0.4;
}
@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (min-width: 761px) {
  .story-panel {
    position: sticky;
    top: 30px;
  }
}
@media (max-width: 760px) {
  .shell {
    padding: 0 22px;
  }
  header {
    min-height: 64px;
  }
  .controls {
    gap: 2px;
  }
  .controls > span {
    display: none;
  }
  .wordmark {
    font-size: 14px;
    letter-spacing: 3px;
  }
  .heading {
    padding: 20px 0;
  }
  .game-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  #story {
    max-height: 235px;
    min-height: 120px;
  }
  .event p {
    font-size: 13px;
  }
  .play-panel > section,
  .play-panel [role='tabpanel'] > section {
    margin-bottom: 25px;
  }
  .action {
    min-height: 83px;
  }
  .action-name {
    font-size: 12px;
  }
  footer {
    margin-top: 24px;
  }
  .ending {
    padding: 24px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    animation: none !important;
    transition: none !important;
  }
}

#condition-panel {
  margin-bottom: 28px;
}
.task-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.task-buttons button {
  font-size: 11px;
  padding: 8px 10px;
}
.task-buttons button[aria-pressed='true'] {
  border-color: var(--accent);
  background: #39432e;
}
.task-buttons button:disabled {
  opacity: 0.5;
}

.play-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  padding-bottom: 8px;
}
.play-tabs button {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  border-color: transparent;
}
.play-tabs button[aria-selected='true'] {
  color: var(--text);
  background: #30392c;
  border-color: #647352;
}
#companion-count, .tab-countdown {
  color: var(--accent);
}
.tab-countdown {
  margin-left: 0.4em;
  font-variant-numeric: tabular-nums;
}

#destination {
  max-width: 100%;
  padding: 0.5rem;
  font: inherit;
  color: inherit;
  background: var(--bg, #171c19);
  border: 1px solid #59665b;
}

#camp-scene-panel {
  container-type: inline-size;
}
#camp-scene {
  width: 57ch;
  height: 32.4em;
  margin: 0 auto;
  font-family: monospace;
  font-size: clamp(6px, 2.8cqw, 13px);
  line-height: 1.2;
  white-space: pre;
  color: var(--muted);
}
.scene-fire-lit {
  color: #ceb889;
}

#camp-fire-indicator {
  margin-left: 4px;
  font-family: monospace;
  white-space: pre;
  color: #929292;
}
#camp-fire-indicator.lit {
  color: #d49b60;
}

.play-tabs { gap: 4px; }
.play-tabs button { padding: 10px 6px; min-width: 0; }

.pack-resource {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}
.pack-resource label { margin: 0; }
.pack-max {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 11px;
}
