:root {
  color-scheme: dark;
  --ink: #fff1bd;
  --cream: #f5df9d;
  --muted: #b5b796;
  --dark: #111a13;
  --darkest: #09100c;
  --panel: #203124;
  --panel2: #2b422d;
  --line: #71905b;
  --gold: #dca84e;
  --gold2: #ffdc7a;
  --green: #a8cd69;
  --red: #df755b;
  --button-art: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Green/Default/button_rectangle_depth_gloss.png");
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #1f2819;
  --cream: #4c391b;
  --muted: #59624d;
  --dark: #dfe6c9;
  --darkest: #cbd6b6;
  --panel: #f4e8bf;
  --panel2: #e1d29e;
  --line: #6d884e;
  --gold: #a96e25;
  --gold2: #85551a;
  --green: #63893c;
  --red: #a54c3c;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --ink: #1f2819;
    --cream: #4c391b;
    --muted: #59624d;
    --dark: #dfe6c9;
    --darkest: #cbd6b6;
    --panel: #f4e8bf;
    --panel2: #e1d29e;
    --line: #6d884e;
    --gold: #a96e25;
    --gold2: #85551a;
    --green: #63893c;
    --red: #a54c3c;
  }
}

* { box-sizing: border-box; }
html { background: var(--darkest); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--darkest);
  image-rendering: pixelated;
}

button, input, select { font: inherit; }
button {
  min-height: 44px;
  padding: .65rem .8rem;
  cursor: pointer;
  color: var(--ink);
  border: 3px solid #10180f;
  outline: 2px solid var(--line);
  border-radius: 0;
  background: #3c5733;
  box-shadow: 4px 4px 0 #09100a;
  transition: transform .12s ease, filter .12s ease;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #09100a; }
button:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.5); }
button.tiny { min-height: 36px; padding: .35rem .5rem; font-size: .72rem; }
button.danger { color: #ffe2c8; background: #773c31; outline-color: #bd6c52; }

.primary {
  color: #1b210e;
  font-weight: 900;
  letter-spacing: .04em;
  background-color: #b5d46b;
  background-image: linear-gradient(rgba(255,255,255,.18), rgba(0,0,0,.08)), var(--button-art);
  background-size: 100% 100%;
  outline-color: #f3d77f;
}
.secondary { background: #30482e; }
.icon-button { font-size: .72rem; }

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: .55rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 8vw, 5rem);
  letter-spacing: -.07em;
  line-height: .88;
  text-shadow: 3px 3px 0 #172016;
}
h2 {
  margin-bottom: .75rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  letter-spacing: -.035em;
}
h3 { margin-bottom: .35rem; font-size: 1rem; }
p { line-height: 1.55; }

.loading {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 2rem;
  background: radial-gradient(circle at 50% 20%, #3f6538, var(--darkest) 65%);
}

.eyebrow, .panel-label {
  display: block;
  color: var(--gold2);
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.eyebrow { margin-bottom: .45rem; }
.panel-label { margin-bottom: .5rem; color: var(--gold); }
.lede { max-width: 61ch; color: var(--muted); font-size: 1rem; }
.muted { color: var(--muted); font-size: .83rem; }

.pixel-panel {
  border: 3px solid #10180f;
  outline: 2px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 50%, transparent 50%) 0 0 / 4px 4px,
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 25%),
    var(--panel);
  box-shadow: 6px 6px 0 rgba(0,0,0,.38);
}

.title-screen, .end-screen { min-height: 100vh; overflow: hidden; }
.pixel-sky {
  position: relative;
  height: clamp(210px, 32vw, 340px);
  overflow: hidden;
  background: linear-gradient(#315d69 0 58%, #79a86b 58% 100%);
  image-rendering: pixelated;
}
.pixel-sky::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .18;
  background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(255,255,255,.18) 7px 8px);
}
.sun {
  position: absolute;
  z-index: 1;
  top: 18%;
  right: 13%;
  width: 52px;
  height: 52px;
  background: #ffe68b;
  box-shadow: 0 0 0 7px rgba(255,220,104,.17);
}
.cloud {
  position: absolute;
  z-index: 1;
  height: 16px;
  background: #d9e3bb;
  box-shadow: 12px -8px 0 #d9e3bb, 26px 0 0 #d9e3bb, 39px -5px 0 #d9e3bb;
}
.cloud-a { top: 23%; left: 13%; width: 38px; }
.cloud-b { top: 39%; left: 60%; width: 30px; transform: scale(.7); }
.mountains {
  position: absolute;
  z-index: 2;
  right: -2%;
  bottom: 27%;
  width: 102%;
  height: 72px;
  background: #3b694e;
  clip-path: polygon(0 100%, 0 72%, 9% 42%, 16% 69%, 28% 10%, 39% 65%, 51% 35%, 60% 69%, 73% 14%, 86% 63%, 96% 35%, 100% 63%, 100% 100%);
}
.prairie {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 39%;
  background:
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(38,78,38,.25) 18px 20px),
    linear-gradient(#628a4d, #2e5c39);
}
.title-wagon {
  position: absolute;
  z-index: 4;
  bottom: 18%;
  left: 18%;
  width: 102px;
  height: 35px;
  background: #432c1d;
  box-shadow: inset 0 8px #8c5831, 8px 6px 0 rgba(0,0,0,.2);
}
.title-wagon i {
  position: absolute;
  width: 60px;
  height: 31px;
  top: -27px;
  left: 18px;
  background: #e4d49d;
  border: 5px solid #4b3423;
  border-bottom: 0;
}
.title-wagon b {
  position: absolute;
  bottom: -14px;
  width: 27px;
  height: 27px;
  background: #171512;
  border: 5px solid #8e6337;
}
.title-wagon b:first-of-type { left: 9px; }
.title-wagon b:last-of-type { right: 9px; }

.shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
}
.title-content { position: relative; z-index: 6; padding: 1.2rem 0 3rem; }
.masthead { margin: 0 0 1.5rem; }

.save-bar, .launch-panel {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}
.save-bar h2 { margin-bottom: .2rem; }
.save-bar p { margin: 0; color: var(--muted); font-size: .8rem; }
.save-slots { display: flex; flex-wrap: wrap; gap: .6rem; }
.save-slot {
  width: 130px;
  min-height: 67px;
  display: grid;
  gap: .1rem;
  padding: .45rem .55rem;
  text-align: left;
  font-size: .69rem;
}
.save-slot.selected { outline-color: var(--gold2); background-color: #526a36; }
.save-slot strong { font-size: .75rem; }
.save-slot small { color: var(--muted); font-size: .62rem; }
.slot-number { color: var(--gold2); font-size: .58rem; }

.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.setup-card { padding: 1rem; }
.route-list { display: grid; gap: .65rem; }
.route-option, .difficulty {
  display: grid;
  grid-template-columns: auto 12px 1fr;
  align-items: start;
  gap: .6rem;
  padding: .7rem;
  border: 2px solid rgba(151,184,108,.38);
  background: rgba(0,0,0,.13);
  cursor: pointer;
}
.route-option input, .difficulty input { margin: .2rem 0 0; accent-color: var(--gold); }
.route-marker {
  width: 10px;
  height: 10px;
  margin-top: .24rem;
  background: #6d894d;
  box-shadow: 3px 3px 0 #172516;
}
.route-option strong, .route-option small, .route-option em { display: block; }
.route-option small, .route-option em { color: var(--muted); font-size: .72rem; line-height: 1.45; }
.route-option em { margin-top: .18rem; font-style: normal; }
.route-option.chosen, .difficulty.chosen { border-color: var(--gold2); background: rgba(213,162,67,.12); }
.route-option.chosen .route-marker { background: var(--gold2); }

.roster { display: grid; gap: .5rem; margin-bottom: .8rem; }
.roster-row {
  display: grid;
  grid-template-columns: 22px 1.35fr .55fr 1fr auto;
  align-items: end;
  gap: .4rem;
  padding-bottom: .55rem;
  border-bottom: 2px dashed rgba(151,184,108,.3);
}
.pixel-person {
  width: 16px;
  height: 23px;
  margin-bottom: 9px;
  background: #e5b67c;
  box-shadow: 0 -6px #5b3823, 0 9px #456d45, -4px 15px #263e29, 4px 15px #263e29;
}
label {
  display: grid;
  gap: .35rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
}
input, select {
  width: 100%;
  min-height: 42px;
  padding: .45rem .55rem;
  color: var(--ink);
  border: 2px solid #10180f;
  border-radius: 0;
  outline: 1px solid var(--line);
  background: #1a291c;
}
.difficulty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.difficulty { grid-template-columns: auto 1fr; min-height: 88px; }
.difficulty strong, .difficulty small { display: block; }
.difficulty small { margin-top: .25rem; color: var(--muted); font-size: .69rem; line-height: 1.4; }

.historical-note {
  margin-top: .9rem;
  padding: .75rem;
  border-left: 5px solid var(--gold);
  background: rgba(221,168,78,.1);
  color: var(--muted);
  font-size: .82rem;
}
.historical-note strong { color: var(--gold2); }
.historical-note p { margin: .35rem 0 0; }

.launch-panel { margin-top: 1rem; }
.launch-panel strong { display: block; max-width: 65ch; line-height: 1.5; }
.launch { min-height: 54px; padding-inline: 1.2rem; }

.game-shell {
  width: min(1450px, calc(100% - 1rem));
  margin: 0 auto;
  padding: .7rem 0 1.5rem;
}
.game-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem;
}
.game-title h1 { margin-bottom: .35rem; font-size: clamp(1.75rem, 5vw, 3.2rem); }
.game-title p:last-child { margin: 0; color: var(--muted); font-size: .74rem; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .55rem; }

.world-frame { margin-top: .8rem; overflow: hidden; background: #648950; }
#trail-map {
  display: block;
  width: 100%;
  height: clamp(210px, 30vw, 340px);
  image-rendering: pixelated;
}
.map-readout {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem .75rem;
  color: #fceab0;
  background: #162517;
  font-size: .68rem;
}
.map-readout strong { color: #ffdd73; }

.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: .85rem;
  margin-top: .85rem;
}
.dashboard > article { padding: 1rem; }
.resources-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.resource {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .22rem .35rem;
  align-items: center;
}
.resource span { color: var(--muted); font-size: .69rem; }
.resource strong { color: var(--cream); font-size: .85rem; }
.resource i, .standing i {
  grid-column: 1 / -1;
  display: block;
  height: 7px;
  background: #10190f;
}
.resource i b, .standing i b {
  display: block;
  height: 100%;
  background: var(--green);
}
.resource.water i b { background: #67b9bf; }
.resource.wagon i b { background: var(--gold); }

.command-card { display: grid; gap: .8rem; }
.command-card h2 { margin-bottom: 0; }
.command-selects { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.activity-grid button {
  min-height: 61px;
  display: grid;
  gap: .14rem;
  padding: .45rem .55rem;
  text-align: left;
  background: #314d32;
}
.activity-grid strong { color: var(--cream); font-size: .78rem; letter-spacing: .05em; }
.activity-grid small { color: var(--muted); font-size: .62rem; }
.action-status { margin: 0; color: var(--gold2); font-size: .67rem; font-weight: 900; letter-spacing: .08em; }
.travel-button { width: 100%; }

.party-list { display: grid; gap: .75rem; }
.party-card {
  display: grid;
  grid-template-columns: 33px 1fr;
  gap: .65rem;
  align-items: center;
}
.party-card.gone { opacity: .42; }
.traveler-sprite {
  position: relative;
  width: 27px;
  height: 34px;
  background: #39603b;
  border: 3px solid #172617;
  box-shadow: inset 0 9px #e4b67b, 4px 4px 0 #10170f;
}
.traveler-sprite i {
  position: absolute;
  width: 17px;
  height: 7px;
  top: -5px;
  left: 2px;
  background: #784b2e;
}
.sprite-1 { background: #375d6d; }
.sprite-1 i { background: #304a58; }
.sprite-2 { background: #75473d; }
.sprite-2 i { background: #e0bb65; }
.sprite-3 { background: #6e5c37; }
.sprite-3 i { background: #51341f; }
.party-card strong, .party-card small, .party-card em { display: block; }
.party-card strong { font-size: .82rem; }
.party-card small { color: var(--muted); font-size: .67rem; }
.party-card em { margin-top: .2rem; color: #ffb19c; font-size: .65rem; }
.vital-bars { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin-top: .3rem; }
.vital-bars span { display: grid; grid-template-columns: 19px 1fr; gap: .2rem; align-items: center; color: var(--muted); font-size: .57rem; }
.vital-bars b { display: block; height: 5px; background: var(--green); }
.vital-bars span:last-child b { background: var(--gold); }

.standing {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .25rem .5rem;
  margin-bottom: .8rem;
  font-size: .72rem;
}
.standing span { color: var(--muted); }
.standing strong { color: var(--gold2); }
.standing i b { background: var(--gold); }
.reputation-panel p { margin: .5rem 0 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
.reputation-panel p b { color: var(--cream); }
.journal-panel ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.45;
}
.journal-panel li { padding: .22rem 0; }

.overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 10, 6, .78);
  backdrop-filter: blur(3px);
}
.event-modal {
  width: min(600px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1.2rem;
  background-color: #263b27;
}
.event-modal.compact { width: min(440px, 100%); }
.event-modal h2 { font-size: clamp(1.65rem, 7vw, 2.7rem); }
.event-modal > p { color: #e6e0bc; }
.event-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--gold2);
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .12em;
}
.event-banner i {
  width: 22px;
  height: 13px;
  background: var(--gold);
  box-shadow: 6px 6px 0 #5c3e20;
}
.countdown {
  display: flex;
  justify-content: space-between;
  margin: .8rem 0;
  padding: .7rem;
  color: #ffe19a;
  font-size: .75rem;
  background: #743f31;
  border: 2px solid #bb7259;
}
.countdown strong { font-size: 1rem; }
.choices { display: grid; gap: .65rem; margin: 1rem 0; }
.choices button {
  min-height: 61px;
  display: grid;
  gap: .16rem;
  text-align: left;
}
.choices small { color: var(--muted); font-size: .69rem; font-weight: 400; }
.event-modal details {
  padding-top: .8rem;
  border-top: 2px dashed rgba(151,184,108,.4);
  color: var(--muted);
  font-size: .78rem;
}
.event-modal summary { color: var(--gold2); cursor: pointer; font-weight: 900; font-size: .7rem; }

.guide {
  width: min(920px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1rem;
}
.guide header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.guide-grid { display: grid; grid-template-columns: 1fr; gap: .75rem; }
.guide-grid article {
  padding: .75rem;
  border: 2px solid rgba(151,184,108,.38);
  background: rgba(0,0,0,.11);
}
.guide-grid h3 { color: var(--gold2); }
.guide-grid p { margin: 0; color: var(--muted); font-size: .8rem; }

.end-sky { height: clamp(170px, 24vw, 265px); }
.end-content { position: relative; z-index: 5; padding: 1.3rem 0 3rem; }
.ending-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
  margin: 1.1rem 0;
}
.ending-score div {
  padding: .8rem;
  border: 3px solid #10180f;
  outline: 2px solid var(--line);
  background: var(--panel);
}
.ending-score span, .ending-score strong { display: block; }
.ending-score span { color: var(--muted); font-size: .62rem; }
.ending-score strong { margin-top: .28rem; color: var(--gold2); font-size: .96rem; }
.end-grid { display: grid; grid-template-columns: 1fr; gap: .85rem; }
.end-grid > article { padding: 1rem; }
.full-journal { max-height: 430px; overflow: auto; }
.end-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }

@media (min-width: 700px) {
  .setup-grid { grid-template-columns: 1.15fr .85fr; }
  .dashboard { grid-template-columns: 1fr 1.15fr; }
  .ledger-card, .party-panel { grid-row: span 2; }
  .journal-panel { grid-column: span 2; }
  .guide-grid { grid-template-columns: 1fr 1fr; }
  .end-grid { grid-template-columns: 1fr 1fr; }
  .full-journal { grid-column: span 2; }
  .ending-score { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1100px) {
  .dashboard { grid-template-columns: 1fr 1.15fr .88fr; }
  .party-panel { grid-column: 3; grid-row: span 1; }
  .reputation-panel { grid-column: 3; }
  .journal-panel { grid-column: span 3; }
}

@media (max-width: 620px) {
  .save-bar, .launch-panel, .game-topbar { flex-direction: column; align-items: stretch; }
  .save-slots { display: grid; grid-template-columns: repeat(3, 1fr); }
  .save-slot { width: auto; min-width: 0; }
  .save-slot strong { font-size: .64rem; }
  .save-slot small { font-size: .55rem; }
  .top-actions { justify-content: stretch; }
  .top-actions button { flex: 1; }
  .roster-row { grid-template-columns: 19px 1fr 1fr; }
  .roster-row label:nth-of-type(1) { grid-column: 2 / span 2; }
  .roster-row label:nth-of-type(3) { grid-column: 2 / span 2; }
  .roster-row button { grid-column: 2 / span 2; }
  .difficulty-grid, .command-selects { grid-template-columns: 1fr; }
  .map-readout { font-size: .56rem; }
}
