@import url('https://fonts.googleapis.com/css2?family=Patrick+Hand&family=Fredoka:wght@500;600;700&display=swap');

:root {
  --ink: #1e1710;
  --ink-soft: #3d2f24;
  --parchment: #f0dfb2;
  --parchment-dark: #d9c388;
  --grass: #a3d564;
  --grass-dark: #83b948;
  --forest: #4b8c3a;
  --forest-deep: #2d6324;
  --water: #68c4e3;
  --water-dark: #3e95b7;
  --sand: #ecd083;
  --mountain: #9f8a72;
  --mountain-snow: #f0e2c3;
  --fog: rgba(28, 18, 42, 0.82);
  --pink: #ec7aa8;
  --purple: #a57fd1;
  --yellow: #f4c943;
  --orange: #e8924f;
  --red: #d65a5a;
  --blue: #5fa3d1;
  --cream: #fff5dc;
  --panel-bg: #f9ecc6;
  --panel-bg-2: #ead7a2;
  --shadow: 3px 3px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --shadow-lg: 5px 5px 0 var(--ink);
  --sw: 2.5px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive;
  color: var(--ink);
  font-size: 17px;
  letter-spacing: 0.3px;
  background: #d8c186;
}

h1, h2, h3, h4, .fredoka { font-family: 'Fredoka', sans-serif; font-weight: 600; letter-spacing: 0; }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }

#app {
  display: grid;
  grid-template-columns: 290px 1fr 330px;
  grid-template-rows: 64px 1fr;
  height: 100vh;
  width: 100vw;
  gap: 10px;
  padding: 10px;
  background:
    radial-gradient(circle at 15% 25%, #efd89a 0, transparent 45%),
    radial-gradient(circle at 85% 75%, #efd89a 0, transparent 45%),
    #d8c186;
}

/* ======= HUD ======= */
header#hud {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--cream);
  border: var(--sw) solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.logo {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
}
.logo .logo-em { color: var(--pink); }
.hud-stats { display: flex; gap: 14px; margin-left: auto; }
.hud-stat {
  background: var(--panel-bg);
  border: var(--sw) solid var(--ink);
  border-radius: 22px;
  padding: 4px 14px;
  box-shadow: var(--shadow-sm);
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s;
}
.hud-stat.gold-flash { background: var(--yellow); transform: scale(1.08); }

/* small count badge for the contracts button */
.badge {
  display: inline-block;
  background: var(--red);
  color: var(--cream);
  font-size: 11px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 4px;
  border: 1.5px solid var(--ink);
  min-width: 14px;
  text-align: center;
}
.badge:empty { display: none; }

/* ======= CONTRACT BOARD ======= */
.contract-tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0 14px;
  border-bottom: 2px dashed var(--ink-soft);
  padding-bottom: 10px;
}
.contract-tab {
  padding: 6px 14px;
  border: 2px solid var(--ink);
  background: var(--cream);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}
.contract-tab.active {
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--ink);
  transform: translate(-1px, -1px);
}
.contract-card {
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--cream);
  box-shadow: 3px 3px 0 var(--ink);
  position: relative;
}
.contract-card.active-contract { background: #fff3d9; }
.contract-card.locked { opacity: 0.55; background: #e8e4d8; }
.contract-card .cc-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.contract-card .cc-portrait {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--panel-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.contract-card .cc-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.15;
}
.contract-card .cc-client {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
}
.contract-card .cc-desc {
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 8px;
}
.contract-card .cc-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}
.contract-card .cc-reward {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  background: var(--yellow);
  padding: 2px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--ink);
}
.contract-card .cc-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1.5px solid var(--ink);
  font-weight: 600;
}
.contract-card .cc-type.survey { background: #d8d0ff; }
.contract-card .cc-type.delivery { background: #ffe1b8; }
.contract-card .cc-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.contract-card .cc-progress {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 4px;
}
.contract-card .cc-locked-reason {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
  padding: 4px;
}

/* active contract summary in right rail */
.active-contracts-list .contract-card {
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.active-contracts-list .contract-card .cc-title { font-size: 14px; }

/* atlas progress bar lives in hud-stat, no extra styling needed */

/* ======= PANELS ======= */
.panel {
  background: var(--panel-bg);
  border: var(--sw) solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
}
.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--ink-soft); border-radius: 5px; }

#left-rail { display: flex; flex-direction: column; gap: 16px; }

.rail-section h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 2px dashed var(--ink-soft);
}

.list { display: flex; flex-direction: column; gap: 6px; }
.empty-hint { color: var(--ink-soft); font-style: italic; font-size: 14px; padding: 6px 2px; }

.crew-card, .roster-card {
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.roster-card {
  display: flex;
  align-items: center;
  gap: 8px;
}
.crew-card {
  display: flex;
  flex-direction: column;
}
.crew-card .crew-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.crew-card:hover, .roster-card:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.crew-card.selected { background: var(--yellow); }
.crew-card.selected .crew-card-actions .pill-btn { cursor: pointer; }
.crew-card .name { font-weight: 600; font-size: 16px; }
.crew-card .status { font-size: 13px; color: var(--ink-soft); font-style: italic; }

.roster-card .portrait, .crew-card .portrait {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 16px;
}

/* ======= BUTTONS ======= */
.pill-btn {
  background: var(--cream);
  border: var(--sw) solid var(--ink);
  border-radius: 20px;
  padding: 6px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s;
  font-size: 17px;
}
.pill-btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.pill-btn:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.pill-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pill-btn.primary { background: var(--pink); color: var(--cream); }
.pill-btn.good { background: var(--grass-dark); color: var(--cream); }
.pill-btn.warn { background: var(--orange); }

/* ======= WORLD ======= */
#world-stage {
  position: relative;
  background: var(--grass);
  border: var(--sw) solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden; /* keep rounded corners intact; inner div scrolls */
}
#world-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  /* Fancy scrollbars to match the whimsical vibe */
  scrollbar-width: thin;
  scrollbar-color: var(--ink) var(--cream);
}
#world-scroll::-webkit-scrollbar { width: 12px; height: 12px; }
#world-scroll::-webkit-scrollbar-track { background: var(--cream); }
#world-scroll::-webkit-scrollbar-thumb { background: var(--ink); border: 3px solid var(--cream); border-radius: 10px; }
/* SVG is larger than container — user scrolls to explore the edges */
#world { display: block; cursor: grab; width: 1500px; height: 1050px; }
#world.panning { cursor: grabbing; }
/* Clickable map elements override the grab cursor */
#world .poi-group,
#world .waypoint-marker-group,
#world g[data-crew] { cursor: pointer; }

.floating-tip {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 4px 14px;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}
.floating-tip.show { opacity: 1; }

/* ======= ZOOM CONTROLS ======= */
#zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 6;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  padding: 3px;
  box-shadow: 3px 3px 0 var(--ink);
}
.zoom-btn {
  background: var(--cream);
  border: none;
  border-radius: 16px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
  min-width: 32px;
  transition: background 0.1s;
}
.zoom-btn:hover { background: var(--yellow); }
#zoom-level {
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
#zoom-reset-btn { padding: 3px 8px; }

/* ======= ROUTE / WAYPOINTS (A, B, C…) ======= */
.route-pin {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  display: inline-block;
  background: var(--pink);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 18px;
  font-size: 12px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ======= RIGHT CONTEXT ======= */
#right-panel { display: flex; flex-direction: column; }
#context-content { display: flex; flex-direction: column; gap: 10px; }
#context-content h2 { font-size: 22px; }
#context-content p { font-size: 16px; line-height: 1.4; margin-bottom: 6px; }
#context-content em { color: var(--purple); font-style: normal; font-weight: 600; }
#context-content strong { color: var(--red); }

.hire-card {
  background: var(--cream);
  border: var(--sw) solid var(--ink);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.hire-card .header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.hire-card .portrait-lg {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: var(--sw) solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}
.hire-card .role { font-size: 13px; color: var(--ink-soft); font-style: italic; }
.hire-card .tagline { font-size: 14px; color: var(--ink-soft); font-style: italic; margin-bottom: 8px; padding-left: 2px; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  margin-bottom: 8px;
  font-size: 14px;
}
.stat-row { display: flex; align-items: center; gap: 6px; }
.stat-row .label { width: 58px; color: var(--ink-soft); }
.stat-row .bar {
  flex: 1; height: 10px;
  background: var(--panel-bg-2);
  border: 1.5px solid var(--ink);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.stat-row .bar-fill { height: 100%; background: var(--pink); }
.stat-row.accuracy .bar-fill { background: var(--purple); }
.stat-row.speed .bar-fill { background: var(--orange); }
.stat-row.stamina .bar-fill { background: var(--grass-dark); }
.stat-row.charisma .bar-fill { background: var(--yellow); }

.traits { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.trait {
  font-size: 12px;
  background: var(--panel-bg-2);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  padding: 1px 8px;
}
.trait.danger { background: #f5b8a8; }
.trait.good { background: #b8e7a0; }

.hire-card .actions { display: flex; gap: 6px; justify-content: space-between; align-items: center; }
.hire-card .fee { font-size: 15px; color: var(--ink-soft); }

.context-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
}

/* ======= MODALS ======= */
#modal-root {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 45, 0.5);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 30px;
}
#modal-root.show { display: grid; }

.modal {
  background: var(--panel-bg);
  border: var(--sw) solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 26px;
  margin-bottom: 4px;
}
.modal .subtitle {
  font-size: 15px;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 18px;
}

/* crew builder */
.builder-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-bottom: 20px;
}
.builder-roster {
  background: var(--panel-bg-2);
  border: 2px dashed var(--ink-soft);
  border-radius: 12px;
  padding: 10px;
  min-height: 200px;
  max-height: 360px;
  overflow-y: auto;
}
.builder-roster h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); margin-bottom: 8px; }
.builder-roster .roster-item {
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
}
.builder-roster .roster-item:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.builder-roster .roster-item.assigned { opacity: 0.35; pointer-events: none; }

.slots {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.slot {
  background: var(--cream);
  border: var(--sw) dashed var(--ink-soft);
  border-radius: 14px;
  padding: 14px 10px;
  min-height: 130px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.1s;
  position: relative;
}
.slot:hover { transform: translate(-1px, -1px); }
.slot.filled { border-style: solid; background: var(--cream); }
.slot.leader.filled { background: #ffe9c4; }
.slot .role-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  font-family: 'Fredoka', sans-serif;
  font-weight: 500;
}
.slot .role-hint { font-size: 13px; color: var(--ink-soft); font-style: italic; }
.slot .member-portrait {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: var(--sw) solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.slot .member-name { font-size: 15px; font-weight: 600; }
.slot .remove-btn {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; font-size: 18px; color: var(--red);
  cursor: pointer;
}

.resources {
  background: var(--panel-bg-2);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.resources h4 { font-size: 14px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.resource-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.resource-row .res-label { flex: 1; }
.resource-row .res-controls { display: flex; align-items: center; gap: 6px; }
.resource-row button {
  width: 26px; height: 26px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--cream);
  font-size: 16px;
  line-height: 1;
}
.resource-row .res-value { min-width: 24px; text-align: center; font-size: 16px; }

.builder-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  margin-bottom: 14px;
}
.summary-name { font-size: 19px; font-weight: 600; font-family: 'Fredoka', sans-serif; }
.summary-cost { font-size: 16px; color: var(--ink-soft); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ======= OBSTACLE DIALOG ======= */
.obstacle-modal {
  max-width: 440px;
  text-align: center;
  padding: 22px 22px 18px;
}
.obstacle-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(3px 3px 0 var(--ink));
}
.obstacle-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.obstacle-choice {
  border: var(--sw) solid var(--ink);
  border-radius: 10px;
  padding: 14px 10px;
  cursor: pointer;
  background: var(--cream);
  text-align: center;
  font-family: inherit;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 3px 3px 0 var(--ink);
}
.obstacle-choice:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}
.obstacle-choice:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.obstacle-choice.through { background: #ffe1b8; }
.obstacle-choice.around { background: #d9efd3; }
.obstacle-choice .oc-label {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 4px;
}
.obstacle-choice .oc-sub {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.3;
}

/* ======= CHART REVEAL ======= */
.chart-paper {
  background: var(--parchment);
  border: var(--sw) solid var(--ink);
  border-radius: 6px;
  padding: 24px;
  margin: 10px auto;
  position: relative;
  max-width: 500px;
  box-shadow: var(--shadow);
  font-family: 'Patrick Hand', cursive;
  transform: rotate(-0.8deg);
}
.chart-paper .chart-title {
  text-align: center;
  font-size: 24px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  margin-bottom: 2px;
}
.chart-paper .chart-byline {
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 14px;
}
.chart-paper .chart-sketch {
  width: 100%; height: 220px;
  position: relative;
  margin: 6px 0 12px;
}
.chart-paper .chart-footer {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding-top: 8px;
  border-top: 1.5px dashed var(--ink-soft);
  margin-bottom: 8px;
}
.chart-paper .quote {
  font-style: italic;
  text-align: center;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.3;
}

/* ======= CHART GALLERY ======= */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gallery-item {
  background: var(--parchment);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 4px;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: var(--shadow-sm);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.gallery-item:hover { transform: translate(-1px, -1px) rotate(-1deg); }
.gallery-item .gi-icon { font-size: 22px; margin: 4px 0; }
.gallery-item .gi-name { font-family: 'Fredoka', sans-serif; font-weight: 500; font-size: 12px; line-height: 1.1; }
.gallery-item .gi-mood { font-size: 10px; color: var(--ink-soft); font-style: italic; }

/* ======= CLIENT CARD ======= */
.client-card {
  background: var(--pink);
  border: var(--sw) solid var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  color: var(--cream);
}
.client-card .cli-name { font-family: 'Fredoka', sans-serif; font-size: 18px; font-weight: 600; margin-bottom: 2px; }
.client-card .cli-desc { font-size: 14px; margin-bottom: 8px; font-style: italic; }
.client-card .cli-vibe {
  display: inline-block;
  background: var(--cream);
  color: var(--ink);
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-size: 13px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 500;
}

/* ======= MISC ======= */
.divider { border-top: 2px dashed var(--ink-soft); margin: 10px 0; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.5px); } }
@keyframes popin {
  0% { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  70% { transform: scale(1.1) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(-0.8deg); opacity: 1; }
}
.chart-paper.popping { animation: popin 0.6s cubic-bezier(0.3, 1.5, 0.5, 1); }

@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(3deg); } 75% { transform: rotate(-3deg); } }

.thought-bubble {
  position: absolute;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  pointer-events: none;
  animation: popin 0.3s ease-out;
}

.help-overlay {
  position: absolute;
  top: 76px; right: 20px;
  width: 300px;
  background: var(--cream);
  border: var(--sw) solid var(--ink);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: 15px;
  line-height: 1.5;
}
.help-overlay h3 { margin-bottom: 6px; }
.help-overlay ul { padding-left: 20px; }

/* svg styles */
#world text { font-family: 'Patrick Hand', cursive; pointer-events: none; }
/* NOTE: Cannot use CSS `transform` on hover for .poi-group — the group has an
   SVG transform attribute (translate to map position), and CSS transform would
   replace it, teleporting the element. Use filter-based lift instead. */
.poi-group { cursor: pointer; transition: filter 0.15s ease; }
.poi-group:hover { filter: drop-shadow(0 2px 0 var(--ink)) brightness(1.04); }
.waypoint-marker { animation: wiggle 0.6s ease-in-out; pointer-events: none; }
/* Contract markers on the map (📜/✉ above POIs) — gentle bob so they catch the eye */
@keyframes contract-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* Contract-button attention shake: periodic wiggle while contracts are available */
@keyframes contract-shake {
  0%, 86%, 100% { transform: translateY(0) rotate(0); }
  88% { transform: translateY(-1px) rotate(-4deg); }
  90% { transform: translateY(-1px) rotate(4deg); }
  92% { transform: translateY(-1px) rotate(-4deg); }
  94% { transform: translateY(-1px) rotate(3deg); }
  96% { transform: translateY(-1px) rotate(-2deg); }
  98% { transform: translateY(0) rotate(0); }
}
#contracts-btn.has-contracts {
  animation: contract-shake 5.5s ease-in-out infinite;
  transform-origin: center;
}
.contract-marker { pointer-events: none; animation: contract-bob 1.8s ease-in-out infinite; }

/* TRIP SUMMARY (v17) */
.trip-summary { max-width: 520px; }
.trip-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px;
}
.trip-chip {
  background: var(--parchment); border: 1.5px solid var(--ink); border-radius: 10px;
  padding: 2px 9px; font-size: 12px; font-family: 'Fredoka', sans-serif; font-weight: 600;
}
.trip-events {
  max-height: 320px; overflow-y: auto; padding: 2px 4px;
  display: flex; flex-direction: column; gap: 8px;
}
.trip-event {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--cream); border: 1.5px solid var(--ink); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; line-height: 1.35;
}
.trip-event .trip-ico {
  font-size: 18px; flex-shrink: 0; margin-top: 1px;
}
.trip-event .trip-sub {
  display: block; color: var(--ink-soft); font-style: italic; font-size: 13px; margin-top: 2px;
}

/* HOLD INDICATOR (v18) — progress ring that fills during the 400ms hold */
.hold-indicator {
  position: fixed;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  animation: hold-ring-fadein 120ms ease-out forwards;
}
@keyframes hold-ring-fadein {
  to { opacity: 1; }
}
@keyframes hold-ring-fill {
  to { stroke-dashoffset: 0; }
}

/* ROYAL PROCESSION / ROUTE PLANNING (v19) */
.modal.route-planning {
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}
.route-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--ink-soft);
}
.route-section:first-of-type { border-top: none; padding-top: 0; }
.route-section h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin: 0 0 8px 0;
}
.route-reqs {
  display: flex; flex-direction: column; gap: 4px;
}
.route-req {
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--cream);
  border: 1.5px solid var(--ink);
}
.route-req[data-met="true"]  { background: #e3f2da; }
.route-req[data-met="false"] { background: #fdecea; }
.route-sequence {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 8px; background: var(--parchment); border: 2px solid var(--ink);
  border-radius: 10px; font-size: 13px;
}
.route-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border: 1.5px solid var(--ink); border-radius: 10px;
  background: var(--cream); cursor: pointer;
  font-size: 13px; white-space: nowrap;
}
.route-chip:hover { background: #ffd1c9; }
.route-chip-start, .route-chip-end {
  background: var(--yellow); cursor: default;
  font-weight: 600;
}
.route-chip-start:hover, .route-chip-end:hover { background: var(--yellow); }
.route-chip-sep {
  color: var(--ink-soft); font-weight: 600; font-size: 14px;
}
.mood-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border: 1.5px solid var(--ink); border-radius: 9px;
  font-size: 11px; font-family: 'Fredoka', sans-serif; font-weight: 600;
  background: var(--cream);
}
.mood-pill.pref  { background: #e3f2da; }
.mood-pill.avoid { background: #fdecea; }
.poi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.poi-option {
  padding: 8px 10px; background: var(--cream);
  border: 2px solid var(--ink); border-radius: 8px;
  cursor: pointer; transition: transform 0.1s, background 0.1s;
  display: flex; flex-direction: column; gap: 3px;
}
.poi-option:hover { background: var(--yellow); transform: translate(-1px, -1px); }
.poi-option.poi-bad { opacity: 0.7; }
.poi-option-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.poi-mood-chip {
  display: inline-block; align-self: flex-start;
  padding: 1px 7px; border: 1px solid var(--ink); border-radius: 9px;
  font-size: 10px; font-family: 'Fredoka', sans-serif; font-weight: 600;
}
.crew-opts {
  display: flex; flex-direction: column; gap: 6px;
}
.crew-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: var(--cream);
  border: 2px solid var(--ink); border-radius: 8px; cursor: pointer;
}
.crew-opt:hover { background: var(--yellow); }
.crew-opt.selected { background: var(--yellow); }
.crew-opt .portrait {
  border-radius: 50%; border: 2px solid var(--ink);
  display: grid; place-items: center; flex-shrink: 0;
}
.score-preview {
  margin-top: 8px; padding: 6px 10px;
  background: var(--parchment); border: 1.5px solid var(--ink);
  border-radius: 8px; font-size: 13px;
}
/* Trip event styles for VIP events */
.trip-event.vip-stop    { background: #fef7e0; }
.trip-event.vip-reaction { background: #ffe8bf; border-color: #c59a1a; }

/* Route-type badge */
.cc-type.route { background: var(--purple); color: var(--cream); }

/* MAP EXPANSION (v20) */
.modal.expansions-modal { max-width: 560px; max-height: 88vh; overflow-y: auto; }
.expansion-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.expansion-card {
  background: var(--cream); border: 2px solid var(--ink); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.expansion-card.unlocked {
  background: var(--parchment); opacity: 0.85;
}
.expansion-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.expansion-name {
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 18px; line-height: 1.2;
}
.expansion-tagline {
  font-size: 13px; color: var(--ink-soft); font-style: italic; margin-top: 2px;
}
.expansion-status {
  padding: 2px 8px; border: 1.5px solid var(--ink); border-radius: 10px;
  font-family: 'Fredoka', sans-serif; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.expansion-status.unlocked  { background: var(--grass); }
.expansion-status.available { background: #ffd96b; }
.expansion-status.locked    { background: var(--parchment); color: var(--ink-soft); }
.expansion-desc {
  font-size: 13px; margin-top: 8px; line-height: 1.45;
}
.expansion-pois {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px;
}
.expansion-poi-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border: 1.5px solid var(--ink); border-radius: 9px;
  background: var(--parchment); font-size: 12px; white-space: nowrap;
}
/* Expand button pulse when something is ready to commission */
#expand-btn.has-expansion-ready {
  animation: expand-ready-pulse 3s ease-in-out infinite;
  background: #ffd96b;
}
@keyframes expand-ready-pulse {
  0%, 92%, 100% { transform: scale(1); box-shadow: var(--shadow-sm); }
  94% { transform: scale(1.04); box-shadow: 3px 3px 0 var(--ink); }
  96% { transform: scale(1.04); box-shadow: 3px 3px 0 var(--ink); }
}

/* START SCREEN (v20) — full-viewport orientation overlay shown on fresh start */
#start-screen {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--parchment);
  background-image:
    radial-gradient(ellipse at top, rgba(255,255,255,0.35), transparent 70%),
    radial-gradient(circle at 20% 80%, rgba(120,80,40,0.08), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(120,80,40,0.08), transparent 40%);
  display: grid; place-items: center;
  overflow-y: auto;
  padding: 20px;
  animation: startFadeIn 420ms ease-out;
}
@keyframes startFadeIn { from { opacity: 0; } to { opacity: 1; } }
#start-screen.closing { animation: startFadeOut 260ms ease-in forwards; }
@keyframes startFadeOut { to { opacity: 0; transform: scale(0.98); } }

.start-panel {
  max-width: 560px; width: 100%;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 28px 32px;
  box-shadow: 6px 6px 0 var(--ink);
  position: relative;
}
.start-panel::before,
.start-panel::after {
  content: ''; position: absolute; width: 30px; height: 30px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  top: -14px;
}
.start-panel::before { left: -14px; }
.start-panel::after  { right: -14px; }
.start-title { text-align: center; margin-bottom: 18px; }
.start-eyebrow {
  font-family: 'Fredoka', sans-serif; text-transform: uppercase;
  letter-spacing: 3px; font-size: 11px; color: var(--ink-soft);
  margin-bottom: 4px;
}
.start-panel h1 {
  font-family: 'Patrick Hand', 'Fredoka', sans-serif;
  font-size: 40px; line-height: 1.05; margin: 4px 0;
  color: var(--ink);
  letter-spacing: -0.5px;
}
.start-tagline {
  font-style: italic; color: var(--ink-soft); font-size: 14px; margin-top: 4px;
}
.start-section {
  background: var(--parchment);
  border: 2px dashed var(--ink-soft);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 14px;
}
.start-section h3 {
  margin: 0 0 8px 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 14px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--ink-soft);
}
.start-section ul {
  padding-left: 18px;
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}
.start-section li { margin-bottom: 4px; }
.start-flavor {
  background: transparent;
  border: none;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 14px;
  padding: 14px 12px;
}
.start-flavor p { margin: 0; line-height: 1.55; }
.start-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 18px;
}
.start-begin {
  font-size: 16px !important; padding: 10px 18px !important;
  font-family: 'Fredoka', sans-serif; font-weight: 600;
}
.start-footnote {
  margin-top: 14px; text-align: center;
  font-size: 11px; color: var(--ink-soft); font-style: italic;
}

@media (max-width: 520px) {
  .start-panel { padding: 20px 18px; }
  .start-panel h1 { font-size: 30px; }
}

/* WANDERER ENCOUNTER MODAL (v21) */
.modal.encounter-modal { max-width: 480px; }
.encounter-body {
  display: flex; gap: 14px; margin-top: 8px;
  padding: 12px; background: var(--parchment);
  border: 2px dashed var(--ink-soft); border-radius: 10px;
}
.encounter-portrait {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: 50%; border: 2.5px solid var(--ink);
  display: grid; place-items: center; font-size: 28px;
  box-shadow: var(--shadow-sm);
}
