/* style.css */
:root {
  color-scheme: dark;
  --bg: #101716;
  --bg-deep: #0a100f;
  --panel: #172120;
  --panel-raised: #20302d;
  --line: #344440;
  --text: #edf1e7;
  --muted: #afbbb2;
  --faint: #77877d;
  --gold: #e0aa57;
  --gold-bright: #ffd487;
  --green: #79b893;
  --red: #dd8576;
  --amber: #e0b15d;
  --shadow: rgba(0, 0, 0, .34);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #e8e5d8;
    --bg-deep: #d8d4c5;
    --panel: #f7f4e9;
    --panel-raised: #fffdf5;
    --line: #c6c1ad;
    --text: #1a2723;
    --muted: #56645d;
    --faint: #738078;
    --gold: #9a6529;
    --gold-bright: #6f4317;
    --green: #397a58;
    --red: #a55043;
    --amber: #9e6d1f;
    --shadow: rgba(51, 44, 26, .16);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e8e5d8;
  --bg-deep: #d8d4c5;
  --panel: #f7f4e9;
  --panel-raised: #fffdf5;
  --line: #c6c1ad;
  --text: #1a2723;
  --muted: #56645d;
  --faint: #738078;
  --gold: #9a6529;
  --gold-bright: #6f4317;
  --green: #397a58;
  --red: #a55043;
  --amber: #9e6d1f;
  --shadow: rgba(51, 44, 26, .16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, rgba(155, 113, 57, .18), transparent 30rem),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

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

.eyebrow,
.event-kicker {
  color: var(--gold);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.quiet-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.quiet-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1d1710;
  box-shadow: 0 7px 18px rgba(126, 82, 24, .26);
  padding: .78rem 1rem;
}

.secondary-button {
  color: var(--text);
  background: var(--panel-raised);
  border-color: var(--line);
  padding: .76rem .9rem;
}

.quiet-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  padding: .6rem .75rem;
  min-height: 42px;
}

.start-screen,
.game-shell,
.ending-screen {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
}

.start-screen {
  padding: clamp(2.4rem, 8vw, 6.5rem) 0 2rem;
}

.masthead {
  width: min(760px, 100%);
}

.masthead h1,
.ending-card h1 {
  margin: .3rem 0 .85rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.65rem, 8vw, 5.8rem);
  font-weight: 500;
  letter-spacing: -.055em;
  line-height: .96;
}

.masthead h1 span {
  color: var(--gold);
  white-space: nowrap;
}

.lede {
  max-width: 650px;
  color: var(--muted);
  font-size: clamp(1.02rem, 2.5vw, 1.2rem);
  line-height: 1.65;
}

.history-note {
  display: flex;
  gap: 1rem;
  align-items: center;
  max-width: 770px;
  margin: 2.2rem 0 3.2rem;
  padding: 1rem 1.15rem;
  border-left: 3px solid var(--gold);
  background: rgba(224, 170, 87, .09);
  color: var(--muted);
}

.history-note p {
  margin: 0;
  line-height: 1.45;
}

.note-mark {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.outfit-section {
  padding: clamp(1.15rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 22px 55px var(--shadow);
}

.section-heading,
.panel-heading,
.game-header,
.journey-banner,
.departure-bar,
.game-footer {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.section-heading h2,
.panel-heading h2 {
  margin: .18rem 0 0;
  font-size: 1.28rem;
}

.trip-length,
.pace-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  padding: .48rem .68rem;
  white-space: nowrap;
}

.outfit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .9rem;
  margin: 1.5rem 0;
}

.outfit-card {
  position: relative;
  min-height: 235px;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border .16s ease, background .16s ease, transform .16s ease;
}

.outfit-card:hover,
.outfit-card.selected {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--panel-raised) 84%, var(--gold) 16%);
}

.outfit-card:hover {
  transform: translateY(-2px);
}

.outfit-card strong {
  display: block;
  padding-right: 1.3rem;
  color: var(--text);
  font-size: 1.1rem;
}

.outfit-card > span:not(.select-dot) {
  display: block;
  margin: .6rem 0 1.1rem;
  font-size: .88rem;
  line-height: 1.4;
}

.select-dot {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 18px;
  height: 18px;
  border: 2px solid var(--faint);
  border-radius: 50%;
}

.selected .select-dot {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 4px var(--panel-raised), inset 0 0 0 8px var(--gold);
}

.outfit-card dl,
.supply-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
  margin: 0;
}

.outfit-card dl div {
  display: flex;
  gap: .35rem;
  flex-direction: column;
}

.outfit-card dt,
.supply-list dt {
  color: var(--faint);
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.outfit-card dd,
.supply-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 750;
}

.departure-bar {
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.departure-bar > div {
  display: grid;
  gap: .2rem;
}

.departure-bar span {
  color: var(--muted);
  font-size: .86rem;
}

.start-footer {
  margin-top: 1.2rem;
  color: var(--faint);
  font-size: .78rem;
}

.game-shell {
  padding: 1.25rem 0 1.5rem;
}

.game-header {
  margin-bottom: 1.05rem;
}

.title-block h1 {
  margin: .12rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 5vw, 2.15rem);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: .55rem;
}

.journey-banner {
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  background: var(--panel-raised);
}

.date-stamp,
.location-stamp {
  display: grid;
  gap: .18rem;
}

.date-stamp span,
.location-stamp span {
  color: var(--faint);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .11em;
}

.date-stamp strong,
.location-stamp strong {
  font-size: 1rem;
}

.date-stamp small,
.location-stamp small {
  color: var(--muted);
  font-size: .8rem;
}

.distance-stamp {
  display: grid;
  justify-items: end;
}

.distance-stamp strong {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 2rem;
  line-height: .9;
}

.distance-stamp span {
  color: var(--muted);
  font-size: .72rem;
}

.route-card {
  padding: 1.2rem 1.15rem 1rem;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: var(--panel);
}

.route-card p {
  margin: .55rem 0 0;
  color: var(--muted);
  font-size: .84rem;
}

.route-track {
  position: relative;
  height: 35px;
  margin: 0 .35rem;
}

.route-track::before,
.route-progress {
  position: absolute;
  top: 8px;
  left: 0;
  height: 3px;
  border-radius: 20px;
  content: "";
}

.route-track::before {
  width: 100%;
  background: var(--line);
}

.route-progress {
  background: var(--gold);
  transition: width .5s ease;
}

.route-stop {
  position: absolute;
  top: 0;
  width: 0;
}

.route-stop i {
  display: block;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}

.route-stop.passed i {
  border-color: var(--gold);
  background: var(--gold);
}

.route-stop.next i {
  width: 14px;
  height: 14px;
  margin: -2px 0 0 -7px;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(224, 170, 87, .16);
}

.route-stop span {
  display: block;
  width: 74px;
  margin: .38rem 0 0 -37px;
  color: var(--faint);
  font-size: .57rem;
  line-height: 1.1;
  text-align: center;
}

.route-stop.passed span,
.route-stop.next span {
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .7rem;
  margin: 1rem 0;
}

.status-card {
  min-height: 111px;
  padding: .88rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.status-card > span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

.status-card strong {
  display: block;
  margin: .35rem 0 .25rem;
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.status-card.caution strong {
  color: var(--amber);
}

.status-card.danger strong {
  color: var(--red);
}

.status-card small {
  color: var(--faint);
  font-size: .7rem;
  line-height: 1.2;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, .75fr);
  gap: 1rem;
}

.trail-panel,
.command-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.trail-panel {
  overflow: hidden;
}

.trail-panel .panel-heading,
.command-panel .panel-heading {
  padding: 1.05rem 1.05rem .85rem;
}

.road-scene {
  position: relative;
  height: 175px;
  overflow: hidden;
  background:
    linear-gradient(180deg, transparent 60%, rgba(34, 58, 41, .55) 61%),
    linear-gradient(135deg, #af8651 0%, #d5ad6d 42%, #9b7549 100%);
}

.horizon {
  position: absolute;
  top: 52px;
  left: -5%;
  width: 110%;
  height: 55px;
  border-radius: 50% 50% 0 0;
  background:
    radial-gradient(ellipse at 25% 100%, #2b4c37 0 17%, transparent 18%),
    radial-gradient(ellipse at 72% 100%, #36543c 0 22%, transparent 23%),
    #668052;
}

.road {
  position: absolute;
  bottom: -10px;
  left: 21%;
  width: 58%;
  height: 108px;
  transform: perspective(120px) rotateX(9deg);
  background: linear-gradient(90deg, #7d5735, #c59657 35%, #e0bc79 55%, #8b5f39);
  clip-path: polygon(41% 0, 59% 0, 100% 100%, 0 100%);
  opacity: .92;
}

.wagon-art {
  position: absolute;
  right: 19%;
  bottom: 30px;
  width: 122px;
  height: 70px;
}

.wagon-cover {
  position: absolute;
  top: 0;
  left: 17px;
  width: 82px;
  height: 42px;
  border: 4px solid #593d29;
  border-bottom: 0;
  border-radius: 50px 50px 0 0;
  background: #ddd1ad;
}

.wagon-bed {
  position: absolute;
  left: 7px;
  bottom: 14px;
  width: 105px;
  height: 25px;
  border: 4px solid #513523;
  background: #876039;
}

.wheel {
  position: absolute;
  bottom: 0;
  width: 31px;
  height: 31px;
  border: 5px solid #4a3021;
  border-radius: 50%;
  background: #bc8650;
}

.wheel.one { left: 11px; }
.wheel.two { right: 5px; }

.trail-copy,
.event-placeholder {
  margin: 0;
  padding: 1rem 1.05rem;
  color: var(--muted);
  line-height: 1.5;
}

.event-placeholder {
  min-height: 145px;
  display: grid;
  place-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(115deg, rgba(224, 170, 87, .12), transparent);
  text-align: center;
}

.journal-list {
  border-top: 1px solid var(--line);
}

.journal-entry {
  padding: .8rem 1.05rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.journal-entry:last-child {
  border-bottom: 0;
}

.journal-entry strong {
  color: var(--gold);
  font-size: .74rem;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.journal-entry p {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.38;
}

.command-panel {
  padding-bottom: 1rem;
}

.supply-list {
  margin: 0 1.05rem;
  padding: .9rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.supply-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .45rem;
}

.supply-list dd {
  color: var(--gold-bright);
}

.pace-control {
  display: grid;
  gap: .55rem;
  padding: 1rem 1.05rem;
}

.pace-control > span {
  font-size: .8rem;
  font-weight: 750;
}

.pace-control small {
  min-height: 31px;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.35;
}

.pace-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem;
}

.pace-options button {
  min-height: 42px;
  padding: .35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: .73rem;
  font-weight: 700;
}

.pace-options button.active {
  border-color: var(--gold);
  background: rgba(224, 170, 87, .14);
  color: var(--gold-bright);
}

.action-stack {
  display: grid;
  gap: .6rem;
  padding: 0 1.05rem;
}

.action-stack button,
.event-choices button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  text-align: left;
}

.action-stack button span,
.event-choices button span {
  color: inherit;
  font-size: .72rem;
  font-weight: 600;
  opacity: .75;
  text-align: right;
}

.travel-button {
  margin-bottom: .12rem;
}

.game-footer {
  padding: 1rem .15rem 0;
  color: var(--faint);
  font-size: .72rem;
}

.event-overlay,
.guide-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(5, 10, 9, .72);
  backdrop-filter: blur(4px);
}

.event-card,
.guide-card {
  width: min(560px, 100%);
  padding: clamp(1.3rem, 5vw, 2rem);
  border: 1px solid color-mix(in srgb, var(--gold) 62%, var(--line));
  border-radius: 17px;
  background: var(--panel-raised);
  box-shadow: 0 26px 80px rgba(0, 0, 0, .5);
}

.event-card h2,
.guide-card h2 {
  margin: .35rem 0 .7rem;
  font-family: Georgia, serif;
  font-size: clamp(1.65rem, 6vw, 2.25rem);
  font-weight: 500;
}

.event-card > p,
.guide-card li {
  color: var(--muted);
  line-height: 1.55;
}

.event-choices {
  display: grid;
  gap: .65rem;
  margin-top: 1.3rem;
}

.event-choices button strong {
  font-size: .92rem;
}

.guide-card {
  position: relative;
}

.guide-card ul {
  display: grid;
  gap: .75rem;
  margin: 1.25rem 0;
  padding-left: 1.2rem;
}

.guide-card li strong {
  color: var(--text);
}

.close-guide {
  position: absolute;
  top: .65rem;
  right: .8rem;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.8rem;
}

.ending-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem 0;
}

.ending-card {
  width: min(680px, 100%);
  padding: clamp(1.4rem, 6vw, 3.25rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 22px 65px var(--shadow);
}

.ending-card h1 {
  font-size: clamp(2.45rem, 8vw, 4.7rem);
}

.ending-card > p {
  max-width: 580px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.final-ledger {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .65rem;
  margin: 1.8rem 0;
}

.final-ledger div {
  padding: .85rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.final-ledger span {
  display: block;
  color: var(--faint);
  font-size: .67rem;
  font-weight: 750;
  text-transform: uppercase;
}

.final-ledger strong {
  display: block;
  margin-top: .25rem;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 1.35rem;
}

.ending-journal {
  margin-bottom: 1.4rem;
  padding: 1rem;
  border-left: 3px solid var(--gold);
  background: rgba(224, 170, 87, .08);
}

.ending-journal h2 {
  margin-bottom: .65rem;
  font-size: 1rem;
}

.ending-journal p {
  margin: .45rem 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.4;
}

.ending-journal strong {
  color: var(--text);
}

.historical-footnote {
  margin: 1.1rem 0 0 !important;
  color: var(--faint) !important;
  font-size: .75rem !important;
}

.failure .ending-card {
  border-color: color-mix(in srgb, var(--red) 52%, var(--line));
}

.failure .ending-card h1 {
  color: var(--red);
}

@media (max-width: 760px) {
  .outfit-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .outfit-card {
    min-height: 0;
  }

  .journey-banner {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .location-stamp {
    grid-column: 1 / -1;
    padding-top: .75rem;
    border-top: 1px solid var(--line);
  }

  .status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-card {
    min-height: 100px;
  }

  .final-ledger {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 490px) {
  .start-screen,
  .game-shell,
  .ending-screen {
    width: min(100% - 20px, 1120px);
  }

  .game-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions button {
    flex: 1;
  }

  .departure-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .departure-bar button {
    width: 100%;
  }

  .journey-banner {
    padding: .9rem;
  }

  .route-card {
    padding-inline: .75rem;
  }

  .route-stop span {
    display: none;
  }

  .route-track {
    height: 20px;
  }

  .game-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .event-card,
  .guide-card {
    max-height: calc(100vh - 2rem);
    overflow: auto;
  }
}
