:root {
  color-scheme: light;
  --ink: #3f2c18;
  --muted: #8a6a3c;
  --paper: #f1e4c5;
  --paper-2: #fff8e9;
  --field: #241a12;
  --field-2: #2e2016;
  --line: #6e4a22;
  --line-soft: rgba(120, 84, 44, 0.3);
  --river: #4a8cb5;
  --brass: #c98a3f;
  --danger: #c0392b;
  --white: #fff8e9;
  --shadow: rgba(40, 24, 10, 0.28);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(0,177,255,0.18), rgba(4,22,58,0.18)),
    #063152;
  font-family: "Segoe UI", system-ui, ui-sans-serif, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 2px solid #0b4066;
  border-radius: 4px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #bfe4ff);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.95), inset -2px -2px 0 rgba(20,93,145,0.32), 0 6px 0 rgba(3,31,52,0.18);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid #1f728d;
  outline-offset: 2px;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.95), inset -2px -2px 0 rgba(20,93,145,0.32), 0 8px 0 rgba(3,31,52,0.2);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.48;
}

button.danger {
  color: #ffffff;
  background: linear-gradient(180deg, #e85a4f, #a82e2a);
  border-color: #78231e;
}

.app-shell {
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(0,164,230,0.42), rgba(26,74,153,0.42)),
    #061f45;
  border-bottom: 3px solid #48c8ff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.brand-lockup {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.kicker {
  margin: 0;
  color: #ffcf4d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-family: "Trebuchet MS", "Arial Black", system-ui, sans-serif;
  font-size: clamp(1.55rem, 2.6vw, 2.35rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #43341f;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0;
}

.run-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 8px;
  min-width: 0;
}

.metric,
.situation-grid > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border: 2px solid #8a6a3c;
  border-radius: 4px;
  background: #f7fcff;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.9), inset -2px -2px 0 rgba(26,116,176,0.18);
}

.map-toolbar > div {
  min-width: 0;
}

.metric {
  color: var(--ink);
  background: #f7fcff;
}

.metric span,
.situation-grid span,
.label,
.turn-heading span,
.section-heading span,
.ground-list dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
  text-transform: uppercase;
}

.metric strong,
.map-toolbar strong,
.situation-grid strong {
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 8px;
  min-width: 0;
}

.save-row button {
  min-height: 38px;
  padding-inline: 12px;
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  overflow: hidden;
}

.map-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1.2fr) auto auto;
  gap: 10px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(33,190,255,0.08), rgba(0,0,0,0.12)),
    var(--field);
  border-right: 3px solid #0f5f91;
  overflow: hidden;
}

.map-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  padding: 9px 11px;
  border: 2px solid #48c8ff;
  border-radius: 4px;
  color: #f7fbff;
  background:
    linear-gradient(90deg, rgba(176, 137, 80, 0.5), rgba(124, 98, 56, 0.4)),
    #5b452a;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.1);
}

.map-toolbar .label {
  color: #bed9e7;
}

.map-toolbar strong {
  color: #ffffff;
}

.map-wrap {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#map-canvas {
  display: block;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  border: 3px solid #48c8ff;
  border-radius: 4px;
  background: #06233b;
  box-shadow: 0 18px 0 rgba(0, 0, 0, 0.18);
}

.latest-log {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 8px 11px;
  border: 2px solid #48c8ff;
  border-radius: 4px;
  color: #f8fcff;
  background: #5b452a;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.1);
}

.latest-log span {
  color: #ffcf4d;
  font-size: 0.72rem;
  font-weight: 780;
  text-transform: uppercase;
}

.latest-log strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(250px, 0.95fr) minmax(340px, 1.18fr) minmax(240px, 0.86fr);
  gap: 10px;
}

.turn-panel,
.panel-section {
  border: 2px solid #8a6a3c;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.56), rgba(255,255,255,0)),
    var(--paper);
  box-shadow: 0 10px 0 rgba(4, 25, 42, 0.12);
}

.turn-panel {
  min-width: 0;
  padding: 8px;
}

.turn-heading,
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.move-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.move-panel .turn-heading {
  display: grid;
  margin-bottom: 0;
}

.move-pad {
  width: 166px;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 42px);
  gap: 5px;
}

.pad-btn {
  width: 52px;
  min-height: 42px;
  display: grid;
  place-items: center;
  gap: 0;
  padding: 2px;
  font-weight: 900;
}

.pad-btn span {
  font-size: 1rem;
  line-height: 1;
}

.pad-btn small {
  max-width: 50px;
  overflow: hidden;
  color: currentColor;
  font-size: 0.55rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.north {
  grid-column: 2;
}

.west {
  grid-column: 1;
  grid-row: 2;
}

.east {
  grid-column: 3;
  grid-row: 2;
}

.south {
  grid-column: 2;
  grid-row: 3;
}

.pad-center {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 4px;
  border: 2px solid #8a6a3c;
  border-radius: 4px;
  color: #43341f;
  background: #ffffff;
  font-size: 0.58rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.action-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.action-strip button {
  min-width: 0;
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 6px;
}

.action-strip span {
  font-weight: 900;
}

.action-strip small {
  overflow: hidden;
  color: currentColor;
  font-size: 0.68rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ground-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.ground-list div {
  min-width: 0;
  padding: 7px;
  border: 2px solid var(--line-soft);
  border-radius: 4px;
  background: #ffffff;
}

.ground-list dd {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.48), rgba(75,183,255,0.14)),
    #9bd7ff;
}

.panel-section {
  padding: 11px;
}

.side-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 2px solid #8a6a3c;
  border-radius: 4px;
  background: #e8f6ff;
}

.side-tab {
  min-width: 0;
  min-height: 34px;
  padding: 6px 7px;
  border-color: transparent;
  color: #43341f;
  background: transparent;
  box-shadow: none;
  font-size: 0.8rem;
  font-weight: 850;
}

.side-tab:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}

.side-tab.is-active {
  color: #f8fcff;
  background: linear-gradient(180deg, #0aa1e2, #086294);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.18), 0 6px 0 rgba(21, 41, 52, 0.16);
}

.tab-panel {
  align-self: start;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.tab-panel[hidden] {
  display: none;
}

.situation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.supply-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.supply-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 9px;
  border-bottom: 2px solid rgba(27, 93, 145, 0.18);
  background: #ffffff;
}

.supply-row span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supply-row strong {
  color: var(--ink);
}

.supply-row.is-warning strong {
  color: #b47700;
}

.supply-row.is-danger strong {
  color: var(--danger);
}

.crew-list {
  display: grid;
  gap: 8px;
}

.crew-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(148px, 0.9fr) minmax(126px, 0.86fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 2px solid rgba(27, 93, 145, 0.28);
  border-radius: 4px;
  background: #ffffff;
}

.crew-row.is-inactive {
  opacity: 0.55;
}

.crew-name {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.crew-name strong,
.crew-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crew-name span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.crew-vitals {
  display: grid;
  gap: 5px;
}

.meter {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  color: #6a5436;
  font-size: 0.74rem;
  font-weight: 780;
}

.meter span {
  white-space: nowrap;
}

.meter i {
  display: block;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--river) var(--value), rgba(27,93,145,0.18) var(--value));
}

select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 2px solid #8a6a3c;
  border-radius: 4px;
  color: var(--ink);
  background: #ffffff;
}

.event-log,
.journal-list {
  display: grid;
  gap: 7px;
}

.event-log {
  max-height: none;
  overflow: auto;
  margin: 0;
  padding-left: 20px;
  font-size: 0.84rem;
  line-height: 1.35;
}

.journal-entry {
  display: grid;
  gap: 4px;
  padding-bottom: 9px;
  border-bottom: 2px solid rgba(27, 93, 145, 0.18);
}

.journal-entry span,
.empty-text {
  color: var(--muted);
  font-size: 0.74rem;
}

.journal-entry strong {
  color: #43341f;
}

.journal-entry p {
  font-size: 0.84rem;
  line-height: 1.36;
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 370px;
  }

  .command-row {
    grid-template-columns: 1fr 1fr;
  }

  .ground-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .app-shell {
    height: auto;
    min-height: 100svh;
    overflow: visible;
  }

  .topbar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-layout,
  .map-column {
    overflow: visible;
  }

  .map-column {
    border-right: 0;
  }

  .map-wrap {
    min-height: min(66svh, 520px);
  }

  #map-canvas {
    min-height: min(66svh, 520px);
  }

  .side-panel {
    overflow: visible;
  }

  .tab-panel {
    overflow: visible;
  }
}

@media (max-width: 620px) {
  html,
  body,
  .app-shell,
  .topbar,
  .game-layout,
  .map-column,
  .side-panel {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .app-shell {
    padding-bottom: 116px;
  }

  .topbar,
  .map-column,
  .side-panel {
    padding-left: 8px;
    padding-right: 8px;
  }

  .command-row,
  .action-strip,
  .situation-grid,
  .supply-list,
  .crew-row {
    grid-template-columns: 1fr;
  }

  .run-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .map-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
  }

  .map-toolbar strong {
    font-size: 0.88rem;
  }

  .map-toolbar .label {
    font-size: 0.64rem;
  }

  .metric {
    padding: 6px;
  }

  .metric span {
    font-size: 0.66rem;
  }

  .metric strong {
    font-size: 0.9rem;
  }

  .save-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .save-row button {
    min-width: 0;
  }

  .latest-log {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .map-wrap {
    min-height: 0;
  }

  #map-canvas {
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .move-pad {
    justify-self: center;
  }

  .move-panel {
    position: fixed;
    right: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 20;
    grid-template-columns: minmax(0, 1fr) auto;
    box-shadow: 0 18px 40px rgba(11, 20, 24, 0.34);
  }

  .action-strip button {
    min-height: 50px;
  }
}

/* --- Village interaction panel (Stage 5) --- */
.village-panel {
  border: 1px solid rgba(150, 104, 54, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 247, 230, 0.5), rgba(255, 247, 230, 0)),
    #f0e2c4;
  box-shadow: 0 10px 26px rgba(60, 40, 18, 0.22);
}
.village-panel #village-name {
  color: #5b3a1c;
}
.village-panel #village-disposition {
  color: #8a6a3c;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}
.village-trust {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  color: #6a4a24;
  font-size: 0.74rem;
  font-weight: 800;
}
.village-trust i {
  display: block;
  height: 9px;
  border-radius: 99px;
  background: linear-gradient(90deg, #3f9a52 var(--value, 0%), rgba(120, 92, 50, 0.22) var(--value, 0%));
}
.village-rivals {
  margin: -2px 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9a531f;
}
.village-rivals[hidden] {
  display: none;
}
.village-rivals span {
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.64rem;
  color: #b5732a;
  margin-right: 4px;
}
.trade-section {
  display: grid;
  gap: 5px;
}
.trade-label {
  color: #8a6a3c;
  font-size: 0.66rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.trade-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.trade-chip {
  padding: 4px 10px;
  border: 1px solid rgba(120, 84, 44, 0.4);
  border-radius: 99px;
  background: #fff8e9;
  font-size: 0.74rem;
  font-weight: 800;
  color: #6a4a24;
}
.trade-chip.is-active {
  background: #5b3a1c;
  border-color: #5b3a1c;
  color: #fff3da;
}
.trade-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.trade-row-name {
  font-size: 0.78rem;
  font-weight: 750;
  color: #4f351b;
}
.trade-row-name small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}
.trade-row-name.is-wanted small {
  color: #b5732a;
}
.trade-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(120, 84, 44, 0.4);
  border-radius: 7px;
  overflow: hidden;
  background: #fff8e9;
}
.trade-stepper button {
  width: 28px;
  height: 28px;
  border: none;
  background: linear-gradient(180deg, #fff8e9, #ecd7ad);
  font-size: 1rem;
  font-weight: 900;
  color: #5b3a1c;
}
.trade-stepper button:disabled {
  opacity: 0.35;
}
.trade-stepper strong {
  min-width: 26px;
  text-align: center;
  font-size: 0.82rem;
  color: #4f351b;
}
.trade-empty {
  color: var(--muted);
  font-size: 0.74rem;
  font-style: italic;
}
.trade-verdict {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 0.8rem;
}
.trade-verdict small {
  font-size: 0.66rem;
  font-weight: 700;
  opacity: 0.85;
}
.trade-verdict.is-ok {
  background: rgba(63, 154, 82, 0.16);
  color: #2f6b3c;
}
.trade-verdict.is-short {
  background: rgba(176, 90, 40, 0.14);
  color: #9a531f;
}
.trade-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}
.trade-propose {
  padding: 8px 12px;
  border: 1px solid #2f6b3c;
  border-radius: 7px;
  background: linear-gradient(180deg, #4fae63, #357a45);
  color: #f3ffe9;
  font-weight: 850;
  font-size: 0.82rem;
}
.trade-propose:disabled {
  background: linear-gradient(180deg, #d9d2c0, #c3bba6);
  border-color: rgba(120, 84, 44, 0.35);
  color: rgba(79, 53, 27, 0.5);
}
.trade-clear {
  padding: 8px 12px;
  border: 1px solid rgba(120, 84, 44, 0.4);
  border-radius: 7px;
  background: #fff8e9;
  color: #6a4a24;
  font-weight: 800;
  font-size: 0.82rem;
}

/* --- Endgame overlay --- */
.endgame-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 30%, rgba(12, 26, 38, 0.62), rgba(8, 18, 28, 0.86));
  backdrop-filter: blur(3px);
}
.endgame-overlay[hidden] {
  display: none;
}
.endgame-card {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 28px 24px;
  border: 1px solid rgba(150, 104, 54, 0.6);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 247, 230, 0.7), rgba(255, 247, 230, 0)),
    #f2e6c8;
  box-shadow: 0 26px 70px rgba(8, 16, 24, 0.6);
  text-align: center;
  animation: endgame-rise 0.4s ease;
}
@keyframes endgame-rise {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.endgame-kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9a7438;
}
.endgame-card h2 {
  margin: 6px 0 8px;
  font-size: 1.7rem;
  color: #4f3015;
  letter-spacing: 0.01em;
}
.endgame-stars {
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  color: #e0a52a;
  text-shadow: 0 1px 0 rgba(120, 80, 20, 0.3);
  margin-bottom: 10px;
}
.endgame-stars[hidden] {
  display: none;
}
.endgame-reaction {
  margin: 0 auto 16px;
  max-width: 46ch;
  font-size: 0.94rem;
  line-height: 1.55;
  color: #4a3a26;
}
.endgame-scoreline {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(120, 84, 44, 0.3);
  border-bottom: 1px solid rgba(120, 84, 44, 0.3);
}
.endgame-scoreline span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a6a3c;
}
.endgame-scoreline strong {
  font-size: 1.8rem;
  color: #5b3a1c;
}
.endgame-breakdown {
  display: grid;
  gap: 3px;
  margin: 12px auto 16px;
  max-width: 320px;
  text-align: left;
}
.endgame-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: #4f3b24;
  padding: 2px 2px;
}
.endgame-row strong {
  color: #2f6b3c;
  font-variant-numeric: tabular-nums;
}
.endgame-row.is-penalty strong {
  color: #9a531f;
}
.endgame-reward {
  margin: 0 0 18px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #8a5a1c;
}
.endgame-reward[hidden] {
  display: none;
}
.endgame-new {
  padding: 11px 26px;
  border: 1px solid #5b3a1c;
  border-radius: 9px;
  background: linear-gradient(180deg, #c98a3f, #9a5f24);
  color: #fff6e6;
  font-weight: 850;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}
.endgame-overlay.is-loss .endgame-card {
  background:
    linear-gradient(180deg, rgba(232, 236, 242, 0.7), rgba(232, 236, 242, 0)),
    #dfe3ea;
  border-color: rgba(90, 104, 120, 0.6);
}
.endgame-overlay.is-loss .endgame-kicker {
  color: #6b7686;
}
.endgame-overlay.is-loss .endgame-card h2 {
  color: #36404c;
}
.endgame-overlay.is-loss .endgame-new {
  background: linear-gradient(180deg, #6b7686, #4a5562);
  border-color: #36404c;
}

/* --- Village sidebar council button --- */
.village-council-btn {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #5b3a1c;
  border-radius: 8px;
  background: linear-gradient(180deg, #c98a3f, #9a5f24);
  color: #fff6e6;
  font-weight: 850;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

/* --- Council overlay --- */
.council-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(120% 120% at 50% 25%, rgba(12, 26, 38, 0.6), rgba(8, 18, 28, 0.85));
  backdrop-filter: blur(3px);
}
.council-overlay[hidden] { display: none; }
.council-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  border: 1px solid rgba(150, 104, 54, 0.6);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 247, 230, 0.55), rgba(255, 247, 230, 0)),
    #f1e4c5;
  box-shadow: 0 26px 70px rgba(8, 16, 24, 0.62);
  animation: endgame-rise 0.35s ease;
}
.council-leave {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 14, 8, 0.55);
  color: #f4e8cb;
  font-size: 1rem;
  font-weight: 800;
}
.council-scene {
  display: block;
  width: 100%;
  height: auto;
  border-bottom: 3px solid #6e4a22;
  border-radius: 14px 14px 0 0;
}
.council-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px 4px;
}
.council-title h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.6rem;
  color: #4f3015;
  line-height: 1.05;
}
.council-region {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9a7438;
}
.council-disposition {
  flex-shrink: 0;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e6d2a8;
  color: #6a4a24;
  border: 1px solid rgba(120, 84, 44, 0.4);
}
.council-disposition.is-welcoming { background: #cde7c6; color: #2f6b3c; border-color: #8cc69a; }
.council-disposition.is-hostile { background: #f0c7be; color: #9a3b2a; border-color: #d59585; }
.council-disposition.is-skeptical { background: #ead8b0; color: #8a6a2c; }
.council-disposition.is-allied { background: #5b3a1c; color: #ffe8b8; border-color: #5b3a1c; }
.council-trust {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 20px 0;
  color: #6a4a24;
  font-size: 0.72rem;
  font-weight: 800;
}
.council-trust i {
  display: block;
  height: 9px;
  border-radius: 99px;
  background: linear-gradient(90deg, #3f9a52 var(--value, 0%), rgba(120, 92, 50, 0.22) var(--value, 0%));
}
.council-trust em {
  grid-column: 1 / -1;
  font-style: normal;
  font-weight: 700;
  font-size: 0.66rem;
  color: #9a531f;
}
.council-narration {
  margin: 10px 20px 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #4a3a26;
}
.council-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid rgba(120, 84, 44, 0.3);
}
.council-tab {
  flex: 1;
  padding: 9px 6px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #8a6a3c;
  font-weight: 850;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.council-tab.is-active {
  color: #5b3a1c;
  border-bottom-color: #c98a3f;
}
.council-body {
  padding: 14px 20px 20px;
  display: grid;
  gap: 10px;
}
.council-lede {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #6a5436;
}
.council-empty {
  margin: 0;
  font-size: 0.84rem;
  font-style: italic;
  color: var(--muted);
}
.council-cta {
  justify-self: start;
  padding: 9px 18px;
  border: 1px solid #2f6b3c;
  border-radius: 8px;
  background: linear-gradient(180deg, #4fae63, #357a45);
  color: #f3ffe9;
  font-weight: 850;
  font-size: 0.86rem;
}
.council-cta:disabled {
  background: linear-gradient(180deg, #d9d2c0, #c3bba6);
  border-color: rgba(120, 84, 44, 0.35);
  color: rgba(79, 53, 27, 0.5);
}

/* Gifts */
.gift-list { display: grid; gap: 6px; }
.gift-row { display: flex; align-items: center; gap: 10px; }
.gift-name { font-size: 0.84rem; font-weight: 750; color: #4f351b; }
.gift-name small { color: var(--muted); font-size: 0.68rem; font-weight: 700; margin-left: 4px; }
.gift-name.is-wanted small { color: #b5732a; }
.gift-reaction {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  background: rgba(120, 92, 50, 0.12);
  color: #5b452a;
}
.gift-reaction small { font-size: 0.68rem; font-weight: 700; opacity: 0.85; }
.gift-reaction.is-pleased { background: rgba(63, 154, 82, 0.14); color: #2f6b3c; }
.gift-reaction.is-delighted { background: rgba(63, 154, 82, 0.22); color: #276035; }
.gift-reaction.is-none { background: rgba(120, 92, 50, 0.1); color: #8a6a3c; }

/* Stories */
.story-list { display: grid; gap: 6px; }
.story-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid rgba(120, 84, 44, 0.4);
  border-radius: 9px;
  background: linear-gradient(180deg, #fff8e9, #ecd7ad);
  font-weight: 800;
  font-size: 0.9rem;
  color: #4f3015;
}
.story-item small { font-size: 0.68rem; font-weight: 750; color: var(--muted); }
.story-item.is-known { opacity: 0.72; }
.story-item.is-known small { color: #3f9a52; }
.story-item.is-locked { opacity: 0.55; }
.story-full { display: grid; gap: 10px; }
.story-back {
  justify-self: start;
  border: none;
  background: transparent;
  color: #9a7438;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 0;
}
.story-full h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  color: #4f3015;
}
.story-body {
  margin: 0;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.62;
  color: #43341f;
}
.story-foot { margin-top: 2px; }
.story-recorded { font-size: 0.82rem; font-weight: 800; color: #3f9a52; }
.story-locked { font-size: 0.82rem; font-style: italic; color: var(--muted); }

/* Diplomacy */
.council-action {
  display: grid;
  gap: 7px;
  padding: 13px 15px;
  border: 1px solid rgba(120, 84, 44, 0.4);
  border-radius: 10px;
  background: rgba(255, 248, 233, 0.6);
}
.council-action.is-locked { opacity: 0.72; }
.council-action h3 {
  margin: 0;
  font-size: 1rem;
  color: #5b3a1c;
}
.council-action p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #5b452a;
}
.council-locked-note {
  font-size: 0.74rem;
  font-style: italic;
  font-weight: 700;
  color: #9a531f;
}

.supply-row.skills-row {
  border-top: 1px dashed rgba(120, 84, 44, 0.3);
  margin-top: 4px;
  padding-top: 6px;
}
.supply-row.skills-row span { color: #8a6a3c; }
.supply-row.skills-row strong {
  font-size: 0.74rem;
  font-weight: 800;
  color: #8a5a1c;
  text-align: right;
}

.craft-effect {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  color: #8a5a1c;
}

/* --- Journal map overlay --- */
.journalmap-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(120% 120% at 50% 25%, rgba(12, 26, 38, 0.62), rgba(8, 18, 28, 0.88));
  backdrop-filter: blur(3px);
}
.journalmap-overlay[hidden] { display: none; }
.journalmap-card {
  width: min(760px, 100%);
  max-height: 95vh;
  overflow-y: auto;
  padding: 16px 18px 18px;
  border: 1px solid rgba(150, 104, 54, 0.6);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 247, 230, 0.6), rgba(255, 247, 230, 0)), #efe2c2;
  box-shadow: 0 26px 70px rgba(8, 16, 24, 0.62);
}
.journalmap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.journalmap-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.4rem;
  color: #4f3015;
}
.journalmap-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 14, 8, 0.5);
  color: #f4e8cb;
  font-weight: 800;
}
.journalmap-hint {
  margin: 4px 0 10px;
  font-size: 0.8rem;
  color: #6a5436;
}
.journalmap-wrap {
  border: 2px solid #6e4a22;
  border-radius: 8px;
  overflow: hidden;
  background: #cabf9e;
  box-shadow: inset 0 0 0 1px rgba(120, 84, 44, 0.4);
}
#journalmap-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}
.journalmap-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #5b3a1c;
}
.journalmap-name[hidden] { display: none; }
.journalmap-name input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid rgba(120, 84, 44, 0.5);
  border-radius: 7px;
  background: #fff8e9;
  font-size: 0.86rem;
}
.journalmap-name button {
  padding: 7px 13px;
  border-radius: 7px;
  font-weight: 800;
  font-size: 0.82rem;
}
#journalmap-plant {
  border: 1px solid #2f6b3c;
  background: linear-gradient(180deg, #4fae63, #357a45);
  color: #f3ffe9;
}
#journalmap-cancel {
  border: 1px solid rgba(120, 84, 44, 0.4);
  background: #fff8e9;
  color: #6a4a24;
}
.journalmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #5b452a;
}
.journalmap-legend span { display: inline-flex; align-items: center; gap: 5px; }
.journalmap-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; border: 1px solid rgba(90,60,30,0.4); }
#open-journalmap {
  background: linear-gradient(180deg, #e9d9b5, #cbb589);
  color: #4f3015;
  font-weight: 800;
}

.journalmap-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 10px;
}
.journalmap-bar .journalmap-hint { margin: 0; }
.journalmap-zoom { display: flex; gap: 4px; flex-shrink: 0; }
.journalmap-zoom button {
  min-width: 30px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(120, 84, 44, 0.5);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff8e9, #ecd7ad);
  color: #5b3a1c;
  font-weight: 850;
  font-size: 0.82rem;
}

/* --- Crew notification toasts --- */
.toast-stack {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 8px 22px rgba(8, 16, 24, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.25);
  animation: toast-in 0.28s ease;
}
@keyframes toast-in {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast.is-out { opacity: 0; transition: opacity 0.6s ease; }
.toast-danger { background: linear-gradient(180deg, #c0392b, #8e2820); }
.toast-warn { background: linear-gradient(180deg, #c98a3f, #9a5f24); }
.toast-info { background: linear-gradient(180deg, #6a5436, #54422a); }

/* --- Crew fate pop-up (death / desertion, with a story) --- */
.fate-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(120% 120% at 50% 30%, rgba(20, 10, 8, 0.66), rgba(6, 8, 12, 0.9));
  backdrop-filter: blur(3px);
}
.fate-overlay[hidden] { display: none; }
.fate-card {
  width: min(440px, 100%);
  padding: 26px 26px 22px;
  text-align: center;
  border: 1px solid rgba(150, 60, 44, 0.5);
  border-radius: 14px;
  background: linear-gradient(180deg, #2a1d18, #1a1310);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6);
  animation: endgame-rise 0.4s ease;
}
.fate-kicker {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d98a6a;
}
.fate-overlay.is-desertion .fate-kicker { color: #cBA06a; color: #c9a86a; }
.fate-card h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 1.5rem;
  color: #f1e3d6;
}
.fate-story {
  margin: 0 auto 20px;
  max-width: 36ch;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.6;
  font-style: italic;
  color: #d8c6b6;
}
.fate-continue {
  padding: 10px 26px;
  border: 1px solid #7a3b2a;
  border-radius: 9px;
  background: linear-gradient(180deg, #8e4636, #6a2f24);
  color: #f3e2d6;
  font-weight: 800;
  font-size: 0.9rem;
}

/* =========================================================================
   EXPLORER'S-JOURNAL RE-SKIN â€” overrides the original blue/white shell with
   the parchment + period-serif + brass identity of the in-game overlays.
   ========================================================================= */
body {
  background:
    radial-gradient(130% 90% at 50% 0%, rgba(110, 74, 34, 0.28), rgba(0, 0, 0, 0)),
    #241a12;
}

button {
  border: 1px solid #6e4a22;
  border-radius: 7px;
  color: #4f3015;
  background: linear-gradient(180deg, #fff8e9, #e6d2a8);
  box-shadow: 0 2px 0 rgba(70, 46, 22, 0.34);
}
button:hover:not(:disabled) {
  filter: brightness(1.03);
  box-shadow: 0 3px 0 rgba(70, 46, 22, 0.4);
}
button:focus-visible, select:focus-visible { outline: 3px solid #c98a3f; }
button.danger { color: #fff6ef; background: linear-gradient(180deg, #c0503f, #8e2c22); border-color: #6a201a; }

.topbar {
  color: #f4e8cb;
  background: linear-gradient(180deg, #3a2a1a, #241811);
  border-bottom: 3px solid #c98a3f;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
}
.kicker { color: #d9a441; letter-spacing: 0.16em; }
h1 { font-family: var(--serif); color: #f6ecd0; font-weight: 700; letter-spacing: 0.01em; }
h2 { font-family: var(--serif); color: #5b3a1c; font-weight: 700; }

.metric, .situation-grid > div {
  border: 1px solid rgba(120, 84, 44, 0.45);
  border-radius: 7px;
  background: linear-gradient(180deg, #fff8e9, #f0e2c4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.metric, .metric strong, .situation-grid strong, .map-toolbar strong { color: #4f3015; }
.metric span, .situation-grid span, .label, .turn-heading span,
.section-heading span, .ground-list dt { color: #8a6a3c; letter-spacing: 0.04em; }
#stat-score, .metric strong { font-variant-numeric: tabular-nums; }

.map-column {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(110, 74, 34, 0.2), rgba(0, 0, 0, 0)),
    #2a1d14;
  border-right: 3px solid #6e4a22;
}
.map-toolbar {
  color: #f4e8cb;
  border: 1px solid #6e4a22;
  background: linear-gradient(180deg, #3a2a1a, #2a1d14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.map-toolbar .label { color: #d9bd8e; }
#map-canvas { border: 3px solid #6e4a22; background: #2a1d14; box-shadow: 0 14px 0 rgba(0, 0, 0, 0.22); }
.latest-log {
  color: #f4e8cb;
  border: 1px solid #6e4a22;
  background: linear-gradient(180deg, #3a2a1a, #2a1d14);
}
.latest-log span { color: #d9a441; }

.turn-panel, .panel-section {
  border: 1px solid rgba(120, 84, 44, 0.45);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 248, 233, 0.7), rgba(255, 248, 233, 0)), #f1e4c5;
  box-shadow: 0 8px 0 rgba(40, 24, 10, 0.12);
}
.pad-center { border: 1px solid #6e4a22; color: #5b3a1c; background: #fff8e9; }
.ground-list div { border: 1px solid rgba(120, 84, 44, 0.4); background: #fff8e9; }
.ground-list dd { color: #4f3015; }

.side-panel {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(110, 74, 34, 0.18), rgba(0, 0, 0, 0)),
    #2a1d14;
}
.side-tabs { border: 1px solid #6e4a22; background: #e6d2a8; }
.side-tab { color: #6a4a24; }
.side-tab.is-active {
  color: #fff6e6;
  background: linear-gradient(180deg, #c98a3f, #9a5f24);
  box-shadow: 0 4px 0 rgba(70, 46, 22, 0.3);
}

.supply-row {
  border: 1px solid rgba(120, 84, 44, 0.22);
  border-radius: 6px;
  background: #fff8e9;
}
.supply-row span { color: #8a6a3c; }
.supply-row strong { color: #4f3015; }
.supply-row.is-warning strong { color: #b5732a; }
.supply-row.is-danger strong { color: #c0392b; }

.crew-row { border: 1px solid rgba(120, 84, 44, 0.4); background: #fff8e9; }
.event-log li { color: #4a3a26; }
.journal-entry { color: #43341f; }
.empty-text { color: #8a6a3c; }

/* The map toolbar sits on dark leather â€” its values must stay light. */
.map-toolbar strong { color: #fff8e9 !important; }

/* --- Expedition setup (outfitting) overlay --- */
.setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(120% 120% at 50% 20%, rgba(20, 12, 6, 0.66), rgba(8, 10, 14, 0.9));
  backdrop-filter: blur(3px);
}
.setup-overlay[hidden] { display: none; }
.setup-card {
  width: min(680px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  padding: 22px 24px 18px;
  border: 1px solid rgba(150, 104, 54, 0.6);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 248, 233, 0.6), rgba(255, 248, 233, 0)), #f1e4c5;
  box-shadow: 0 26px 70px rgba(8, 16, 24, 0.62);
  animation: endgame-rise 0.35s ease;
}
.setup-kicker { margin: 0; font-size: 0.7rem; font-weight: 850; letter-spacing: 0.16em; text-transform: uppercase; color: #9a7438; }
.setup-card h2 { margin: 2px 0 12px; font-family: var(--serif); font-size: 1.7rem; color: #4f3015; }
.setup-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.setup-level { border: 1px solid rgba(120, 84, 44, 0.45); border-radius: 8px; background: #fff8e9; color: #6a4a24; font-weight: 800; font-size: 0.86rem; min-height: 40px; }
.setup-level.is-active { background: linear-gradient(180deg, #c98a3f, #9a5f24); color: #fff6e6; border-color: #6e4a22; }
.setup-blurb { margin: 0 0 14px; font-size: 0.86rem; line-height: 1.5; color: #6a5436; font-style: italic; }
.setup-body { display: grid; gap: 16px; }
.setup-section { display: grid; gap: 7px; }
.setup-label { font-size: 0.68rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.05em; color: #8a6a3c; }
.setup-label small { color: #9a7438; font-weight: 800; margin-left: 4px; }
.setup-crew { display: grid; gap: 6px; }
.setup-crew-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid rgba(120, 84, 44, 0.35); border-radius: 8px; background: #fff8e9; }
.setup-captain {
  font-style: normal;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #f7edd4;
  background: linear-gradient(180deg, #8a5a28, #6e441b);
  border-radius: 99px;
  padding: 2px 9px 3px;
  margin-left: 7px;
  vertical-align: 2px;
  white-space: nowrap;
}
.setup-crew-row.is-out { opacity: 0.5; }
.setup-crew-id strong { font-size: 0.9rem; color: #4f3015; }
.setup-crew-id small { display: block; font-size: 0.72rem; color: #8a6a3c; line-height: 1.3; }
.setup-pick { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(120, 84, 44, 0.5); background: #fff8e9; color: #6a4a24; font-weight: 900; }
.setup-pick.is-on { background: linear-gradient(180deg, #4fae63, #357a45); color: #f3ffe9; border-color: #2f6b3c; }
.setup-role { min-height: 34px; min-width: 132px; border: 1px solid rgba(120, 84, 44, 0.45); border-radius: 7px; background: #fff8e9; color: #4f3015; font-weight: 700; padding: 0 8px; justify-self: end; }
.setup-role-fixed {
  justify-self: end;
  min-width: 108px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6a4a24;
  border: 1px solid rgba(120, 84, 44, 0.45);
  border-radius: 99px;
  background: linear-gradient(180deg, #f7efd9, #eddfbd);
  padding: 6px 12px;
  white-space: nowrap;
}
.setup-budget { height: 9px; border-radius: 99px; background: rgba(120, 92, 50, 0.22); overflow: hidden; }
.setup-budget i { display: block; height: 100%; background: linear-gradient(90deg, #4fae63, #357a45); }
.setup-supply-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.setup-supply-row { display: flex; align-items: center; gap: 9px; }
.setup-supply-name { font-size: 0.82rem; font-weight: 750; color: #4f3b24; }
.setup-supply-name small { color: var(--muted); font-size: 0.66rem; font-weight: 700; }
.setup-supply-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; font-size: 0.82rem; color: #5b452a; }
.setup-supply-summary span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid rgba(120, 84, 44, 0.3);
  border-radius: 7px;
  background: #fff8e9;
}
.setup-supply-summary strong { color: #4f3015; }
.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.setup-validation { font-size: 0.76rem; font-weight: 700; color: #8a6a3c; }
.setup-depart {
  padding: 11px 24px;
  border: 1px solid #5b3a1c;
  border-radius: 9px;
  background: linear-gradient(180deg, #c98a3f, #9a5f24);
  color: #fff6e6;
  font-weight: 850;
  font-size: 0.95rem;
}
.setup-depart:disabled { background: linear-gradient(180deg, #d9d2c0, #c3bba6); color: rgba(79,53,27,0.5); border-color: rgba(120,84,44,0.35); }

/* --- Crew avatars --- */
.avatar {
  display: block;
  flex-shrink: 0;
  border-radius: 3px;
  border: 2px solid #2b1d10;
  box-shadow: 0 0 0 1px #c98a3f, 0 1px 3px rgba(0,0,0,0.4);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.setup-crew-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.setup-crew-text { display: grid; min-width: 0; }
.crew-name { display: flex; align-items: center; gap: 8px; }
.crew-name-text { display: grid; gap: 2px; min-width: 0; }
.crew-name-text strong, .crew-name-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Settings panel --- */
#open-settings { padding-inline: 10px; font-size: 16px; line-height: 1; }
.settings-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(20, 12, 6, 0.6); }
.settings-overlay[hidden] { display: none; }
.settings-card {
  position: relative; width: min(440px, 96vw);
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--line); border-radius: 10px;
  box-shadow: 0 18px 50px var(--shadow);
  padding: 22px 24px 26px; font-family: var(--serif);
}
.settings-close { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; }
.settings-kicker { margin: 0; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.settings-card h2 { margin: 2px 0 18px; font-size: 24px; }
.settings-body { display: grid; gap: 14px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-label { font-size: 15px; }
.settings-range { width: 160px; accent-color: var(--brass); }
.settings-toggle { min-width: 58px; padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--paper-2); color: var(--muted); cursor: pointer; }
.settings-toggle.is-on { background: var(--brass); border-color: var(--brass); color: #2a1a08; font-weight: 600; }
.settings-seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 6px; overflow: hidden; }
.settings-seg button { padding: 6px 12px; border: none; border-right: 1px solid var(--line-soft); background: var(--paper-2); color: var(--muted); cursor: pointer; }
.settings-seg button:last-child { border-right: none; }
.settings-seg button.is-on { background: var(--brass); color: #2a1a08; font-weight: 600; }

/* --- Accessibility modes --- */
html.text-large body { zoom: 1.12; }
html.text-small body { zoom: 0.9; }

html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

html.high-contrast {
  --ink: #1a0f04;
  --muted: #563912;
  --paper: #fbf3df;
  --paper-2: #ffffff;
  --line: #38240f;
  --line-soft: rgba(40, 24, 8, 0.55);
  --brass: #b06a16;
  --river: #2f6f9c;
}
html.high-contrast .panel-section,
html.high-contrast .turn-panel,
html.high-contrast .map-toolbar { border-width: 2px; }

/* --- Discovery naming --- */
.discovery-overlay { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; padding: 20px; background: rgba(20, 12, 6, 0.62); }
.discovery-overlay[hidden] { display: none; }
.discovery-card { width: min(460px, 96vw); background: var(--paper); color: var(--ink); border: 2px solid var(--line); border-radius: 10px; box-shadow: 0 18px 50px var(--shadow); padding: 22px 24px 24px; font-family: var(--serif); }
.discovery-kicker { margin: 0; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--brass); }
.discovery-card h2 { margin: 2px 0 12px; font-size: 22px; }
.discovery-sight { margin: 0 0 16px; line-height: 1.5; }
.discovery-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
#discovery-input { width: 100%; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--paper-2); color: var(--ink); font: inherit; }
.discovery-note { margin: 12px 0 0; font-size: 12.5px; font-style: italic; color: var(--muted); line-height: 1.45; }
.discovery-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.discovery-skip { padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--paper-2); color: var(--muted); cursor: pointer; }
.discovery-name { padding: 8px 16px; border: 1.5px solid var(--brass); border-radius: 6px; background: var(--brass); color: #2a1a08; font-weight: 600; cursor: pointer; }
.journal-note { display: block; margin-top: 5px; font-size: 11.5px; font-style: italic; color: var(--muted); line-height: 1.4; }

/* --- Review-fix additions: choice events, confirm, tips, readers ------------------ */

.event-card { max-width: 540px; }
.event-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.event-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid #8a6a3c;
  border-radius: 8px;
  background: linear-gradient(180deg, #f3e9cf, #e8dcbf);
  color: #43341f;
  font: 600 1rem var(--serif, Georgia, serif);
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.event-option:hover, .event-option:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(40, 28, 12, 0.35);
  outline: 2px solid #8a6a3c;
}
.event-option small {
  font: 500 0.78rem var(--sans, "Segoe UI", sans-serif);
  color: #7c6238;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.setup-cancel {
  margin-right: 10px;
  padding: 10px 16px;
  border: 1px solid #8a6a3c;
  border-radius: 8px;
  background: transparent;
  color: #6a5436;
  font: 600 0.9rem var(--serif, Georgia, serif);
  cursor: pointer;
}
.setup-cancel:hover { background: rgba(138, 106, 60, 0.12); }

.crew-conditions {
  display: block;
  font-size: 0.74rem;
  color: #9c3d22;
  margin-top: 2px;
}

/* Full readers: the journal and log scroll instead of amputating history. */
.journal-list { max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.event-log { max-height: 46vh; overflow-y: auto; padding-right: 4px; }

/* Sticky tip cards: dismissed by hand, never auto-vanish. */
.tip-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 4px solid #8a6a3c;
  max-width: 360px;
}
.tip-card p { margin: 0; }
.tip-card button {
  align-self: flex-end;
  padding: 5px 12px;
  border: 1px solid #8a6a3c;
  border-radius: 6px;
  background: #e8dcbf;
  color: #43341f;
  font-weight: 600;
  cursor: pointer;
}

/* Sources & acknowledgments */
.open-sources {
  margin-top: 14px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #8a6a3c;
  border-radius: 8px;
  background: transparent;
  color: #6a5436;
  font: 600 0.9rem var(--serif, Georgia, serif);
  cursor: pointer;
}
.open-sources:hover { background: rgba(138, 106, 60, 0.12); }
.sources-card { max-width: 640px; max-height: 84vh; overflow-y: auto; }
.sources-statement p { margin: 0 0 10px; font-size: 0.92rem; line-height: 1.5; color: #5b452a; }
.sources-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.sources-row strong { display: block; font-family: var(--serif, Georgia, serif); color: #43341f; }
.sources-row p { margin: 2px 0 0; font-size: 0.82rem; color: #7c6238; line-height: 1.45; }

/* Honor the OS preference even before the user finds the toggle. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast reaches the heavy-read surfaces, not just var-driven chrome. */
html.high-contrast .council-narration,
html.high-contrast .council-lede,
html.high-contrast .sources-statement p,
html.high-contrast .sources-row p,
html.high-contrast .journal-entry p,
html.high-contrast .fate-story,
html.high-contrast .endgame-reaction { color: #1a0f04; }
html.high-contrast .setup-validation { color: #6b2a00; font-weight: 700; }
html.high-contrast .event-option small,
html.high-contrast .journal-note { color: #4a3008; }
/* --- Title menu: the front door --- */
.title-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(214, 178, 116, 0.10), transparent 60%),
    linear-gradient(160deg, #2c2118, #241a12 55%, #1a1209);
}
.title-overlay[hidden] { display: none; }
.title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 560px;
}
.title-compass { margin-bottom: 10px; filter: drop-shadow(0 4px 14px rgba(0,0,0,0.5)); }
.title-kicker {
  margin: 0;
  font: 600 12px var(--serif, Georgia, serif);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #c39a5d;
}
.title-name {
  margin: 6px 0 14px;
  font: 700 clamp(40px, 7vw, 64px) var(--serif, Georgia, serif);
  letter-spacing: 0.02em;
  color: #f0e4c8;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.55);
}
.title-tagline {
  margin: 0 0 30px;
  font: 400 1.02rem/1.6 var(--serif, Georgia, serif);
  color: #cdb588;
}
.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 86vw);
}
.title-btn {
  padding: 13px 18px;
  border: 1px solid #8a6a3c;
  border-radius: 9px;
  background: linear-gradient(180deg, #f3e9cf, #e4d6b4);
  color: #43341f;
  font: 700 1rem var(--serif, Georgia, serif);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.title-btn:hover, .title-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  outline: 2px solid #c39a5d;
}
.title-btn-primary {
  background: linear-gradient(180deg, #8a5a28, #6e441b);
  border-color: #a87a3e;
  color: #f7edd4;
}
.title-btn-minor {
  background: transparent;
  color: #c2a878;
  border-color: rgba(138, 106, 60, 0.55);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
}
