/* Cargo Captain — shared components (src/ui/components/*.js). */

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'ship stats nav'
    'next next next';
  align-items: center;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}

.topbar__ship {
  grid-area: ship;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.topbar__swatch {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 40% 40%;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px var(--line-strong);
}

.topbar__ship-text {
  min-width: 0;
}

/* Her name is the kid's own: up to two lines (long names wrap anywhere) rather than "WWWWWWW…". */
.topbar__ship-name {
  font-weight: 900;
  font-size: var(--fs-md);
  line-height: 1.1;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.topbar__ship-sub {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__stats {
  grid-area: stats;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  justify-content: center;
  min-width: 0;
}

.topbar__stat {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.topbar__stat-emoji {
  font-size: 1.4em;
  line-height: 1;
}

.topbar__stat-body {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar__stat-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-faint);
  white-space: nowrap;
}

.topbar__stat-value {
  font-weight: 900;
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar__stat.is-cash .topbar__stat-value {
  color: var(--gain);
}

.topbar__stat.is-debt .topbar__stat-value {
  color: var(--loss);
}

.topbar__next {
  grid-area: next;
  justify-self: start;
  padding: 0.15em 0.8em;
  border-radius: var(--r-pill);
  background: var(--accent-100);
  color: var(--accent-700);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.topbar__nav {
  grid-area: nav;
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}

.topbar__btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: var(--sp-1) var(--sp-2);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: var(--sea-50);
  color: var(--sea-800);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.topbar__btn:hover {
  background: var(--sea-100);
}

.topbar__btn.is-active {
  background: var(--sea-600);
  border-color: var(--sea-700);
  color: #ffffff;
}

.topbar__btn-emoji {
  font-size: 1.35em;
  line-height: 1;
}

.topbar__btn-label {
  font-size: var(--fs-xs);
  line-height: 1;
}

@media (max-width: 68.75em) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'ship nav'
      'stats stats'
      'next next';
  }

  .topbar__stats {
    justify-content: flex-start;
  }
}

@media (max-width: 37.5em) {
  .topbar {
    padding: var(--sp-3);
    border-radius: var(--r-md);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'ship'
      'stats'
      'nav'
      'next';
  }

  .topbar__nav {
    justify-content: space-between;
  }

  .topbar__btn {
    flex: 1 1 0;
  }

  .topbar__stats {
    gap: var(--sp-2) var(--sp-3);
  }
}

/* ── Map ───────────────────────────────────────────────── */
.map {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  background: var(--sea-200);
  font-family: var(--font);
  user-select: none;
}

.map text {
  font-family: var(--font);
}

.map-lane {
  fill: none;
  stroke: #1f6f9e;
  stroke-width: 3;
  stroke-dasharray: 2 9;
  stroke-linecap: round;
  opacity: 0.55;
}

.map-waypoint {
  fill: #1f6f9e;
  opacity: 0.55;
}

.map-route-casing {
  fill: none;
  stroke: #ffffff;
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.map-route-line {
  fill: none;
  stroke: var(--accent-600);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-route-alt {
  fill: none;
  stroke: var(--sea-700);
  stroke-width: 5;
  stroke-dasharray: 10 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}

.map-port-label {
  font-size: 25px;
  font-weight: 900;
  fill: #16324a;
  stroke: #ffffff;
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.map-water-label {
  font-size: 17px;
  font-style: italic;
  font-weight: 700;
  fill: #1f5f85;
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
  letter-spacing: 0.02em;
}

.map-nation-label {
  font-weight: 900;
  letter-spacing: 0.22em;
  text-anchor: middle;
  opacity: 0.6;
}

.map-compass-n {
  font-size: 16px;
  font-weight: 900;
  fill: #1f6f9e;
}

.map-port-dot {
  fill: #ffffff;
  stroke-width: 4.5;
}

.map-port-ring {
  fill: rgba(255, 255, 255, 0.55);
  stroke: none;
}

.map-port-hit,
.map-port-hit-label {
  fill: transparent;
}

.map--interactive .map-port-hit-label {
  cursor: pointer;
}

.map-port.is-here .map-port-dot {
  fill: #fff6df;
}

/* The player's ship rides over everything on the map (map.js), so taps go through her to the port or the
   exit under her. Her disc is white, rimmed in her paint (the rim's colour is the marker's stroke). */
.map-ship {
  pointer-events: none;
}

.map-ship-halo {
  fill: rgba(255, 255, 255, 0.72);
  stroke-width: 4;
  filter: drop-shadow(0 1px 2px rgba(13, 48, 71, 0.3));
}

.map-port-here {
  fill: none;
  stroke: var(--accent-500);
  stroke-width: 4;
  stroke-dasharray: 6 5;
  transform-origin: 0 0;
  animation: map-here 2.4s ease-in-out infinite;
}

@keyframes map-here {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.18);
    opacity: 0.6;
  }
}

.map-port.is-selected .map-port-ring {
  fill: var(--accent-200);
  stroke: var(--accent-600);
  stroke-width: 3;
}

.map--interactive .map-port {
  cursor: pointer;
}

.map--interactive .map-port:hover .map-port-ring {
  fill: var(--accent-100);
  stroke: var(--accent-500);
  stroke-width: 3;
}

.map-port:focus-visible .map-port-ring {
  fill: #fff3c4;
  stroke: var(--focus-dark);
  stroke-width: 4;
}

.map-port:focus-visible .map-port-label {
  fill: #000000;
  stroke: var(--focus);
}

.map-stop-badge text {
  font-size: 17px;
  font-weight: 900;
  fill: #ffffff;
}

.map-pirate-flag {
  font-size: 19px;
}

.map-pirate-level {
  font-size: 19px;
  font-weight: 900;
  fill: #6b4a07;
}

/* The word says how busy; the badge color only repeats it. */
.map-pirate-badge.is-very-busy rect {
  fill: #ffe3a6;
  stroke: #a8660a;
  stroke-width: 3.5;
}

.map-pirate-badge.is-quiet rect {
  fill: #f3f6f8;
  stroke: #8a9caa;
}

.map-pirate-badge.is-quiet .map-pirate-level {
  fill: #3d4f5c;
}

.map-rival {
  opacity: 0.9;
}

.map--compact .map-port-label {
  font-size: 27px;
}

/* Phones: bigger port names, and the italic sea names step aside to keep it clear */
@media (max-width: 37.5em) {
  .map-port-label,
  .map--compact .map-port-label {
    font-size: 27px;
    stroke-width: 7px;
  }

  /* The map is small here: grow the tap areas so they stay ≥ 44 px for fingers. */
  .map-port-hit,
  .map-port-hit-label {
    transform-box: fill-box;
    transform-origin: center;
    transform: scale(1.3);
  }

  .map-water-label {
    display: none;
  }
}

/* ── Ship art ──────────────────────────────────────────── */
.ship-art {
  display: block;
  max-width: 100%;
  height: auto;
  font-family: var(--font);
  overflow: visible;
}

.ship-art text {
  font-family: var(--font);
}

.ship-name {
  font-weight: 900;
  letter-spacing: 0.03em;
}

.ship-badge-emoji {
  font-size: 15px;
}

.ship-badge-fix {
  font-size: 12px;
}

.ship-part-fix__icon {
  font-size: 10px;
}

/* The radar bar turns (seen from the side it grows and shrinks). Calm motion stops it (base.css). */
.ship-radar-bar {
  transform-box: fill-box;
  transform-origin: center;
  animation: ship-radar-turn 2.4s ease-in-out infinite;
}

@keyframes ship-radar-turn {
  50% {
    transform: scaleX(0.15);
  }
}

.ship-slot-emoji {
  font-size: 17px;
}

.ship-slot-stop {
  font-size: 10px;
  font-weight: 900;
  fill: #ffffff;
}

.ship-slot-plug {
  font-size: 12px;
}

.ship-slot-plus {
  font-size: 20px;
  font-weight: 900;
  fill: var(--accent-600);
}

/* ── Stop badge ①②③ ────────────────────────────────────── */
.stop-badge {
  --stop-color: var(--stop-1);
  display: inline-grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--stop-color);
  color: #ffffff;
  font-weight: 900;
  font-size: var(--fs-sm);
  line-height: 1;
  box-shadow: 0 0 0 2px #ffffff, 0 1px 3px rgba(0, 0, 0, 0.25);
  flex: none;
}

.stop-badge--sm {
  font-size: var(--fs-xs);
  width: 1.55em;
  height: 1.55em;
}

/* ── Cargo box ─────────────────────────────────────────── */
.cargo-box {
  --box-color: var(--stop-1);
  --box-size: 64px;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--box-size);
  height: var(--box-size);
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  border: 4px solid var(--box-color);
  border-radius: 10px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0) 0 9px, rgba(13, 48, 71, 0.06) 9px 11px),
    linear-gradient(180deg, #ffffff 0%, #f1f5f8 100%);
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--box-color) 22%, transparent), var(--shadow-1);
  color: var(--ink);
  font: inherit;
  cursor: default;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

button.cargo-box {
  cursor: pointer;
}

.cargo-box--drag {
  cursor: grab;
}

.cargo-box--drag:active {
  cursor: grabbing;
}

.cargo-box__emoji {
  font-size: calc(var(--box-size) * 0.48);
  line-height: 1;
}

.cargo-box__grip {
  position: absolute;
  top: 3px;
  left: 50%;
  width: 22px;
  height: 6px;
  transform: translateX(-50%);
  background-image: radial-gradient(circle, rgba(13, 48, 71, 0.45) 1.3px, transparent 1.6px);
  background-size: 6px 6px;
  opacity: 0.9;
}

.cargo-box__cold {
  position: absolute;
  left: 2px;
  bottom: 1px;
  font-size: 15px;
  line-height: 1;
}

.cargo-box__stop {
  --stop-color: var(--stop-1);
  position: absolute;
  top: -10px;
  right: -10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--stop-color);
  color: #ffffff;
  font-weight: 900;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 0 0 2.5px #ffffff, 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cargo-box__count {
  position: absolute;
  bottom: -10px;
  right: -8px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: #ffffff;
  font-weight: 900;
  font-size: 14px;
  line-height: 1.5;
}

.cargo-box.is-chilled {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0) 0 9px, rgba(13, 48, 71, 0.06) 9px 11px),
    linear-gradient(180deg, #ffffff 0%, var(--cold-bg) 100%);
}

.cargo-box.is-selected {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
  transform: translateY(-4px);
  box-shadow: var(--shadow-3);
}

.cargo-box.is-ghost {
  opacity: 0.35;
  border-style: dashed;
}

/* ── Job card ──────────────────────────────────────────── */
.job-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'icon main side'
    'why why why';
  gap: var(--sp-2) var(--sp-4);
  align-items: start;
  padding: var(--sp-4);
  background: var(--card);
  border: 3px solid transparent;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}

.job-card.is-taken {
  border-color: var(--sea-500);
  background: var(--sea-50);
}

/* A job that does not fit: the card fades (background, border, pictures), the words do not.
   Every word on it keeps at least 4.5:1 contrast. */
.job-card.is-blocked {
  background: #f1f4f6;
  border-color: var(--line-strong);
  border-style: dashed;
  box-shadow: none;
}

.job-card.is-blocked .job-card__icon {
  background: #e3e8ec;
  filter: grayscale(0.85);
}

.job-card.is-blocked .job-card__mini {
  background: #c3ccd4;
}

.job-card.is-blocked .job-card__pay {
  color: var(--ink-soft);
}

.job-card.is-blocked .job-card__take[aria-disabled='true'] {
  --btn-bg: #e3e8ec;
  --btn-border: var(--line-strong);
  --btn-shadow: var(--line-strong);
  --btn-fg: var(--ink-soft);
  opacity: 1;
  filter: none;
}

.job-card__icon {
  grid-area: icon;
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  background: var(--sand-100);
  font-size: 38px;
  line-height: 1;
}

.job-card.is-chilled .job-card__icon {
  background: var(--cold-bg);
}

.job-card__cold {
  position: absolute;
  right: -6px;
  bottom: -6px;
  font-size: 22px;
}

.job-card__main {
  grid-area: main;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.job-card__title {
  font-size: var(--fs-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.job-card__dest {
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--sea-700);
}

.job-card__minis {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.job-card__mini {
  display: grid;
  place-items: center;
  width: 20px;
  height: 16px;
  border-radius: 3px;
  background: var(--sand-400);
  font-size: 10px;
  line-height: 1;
}

.job-card.is-chilled .job-card__mini {
  background: #a9d2f3;
}

.job-card__meta {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.job-card__rush {
  align-self: flex-start;
  margin-top: 2px;
  padding: 0.1em 0.6em;
  border-radius: var(--r-pill);
  background: var(--accent-100);
  color: var(--accent-700);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.job-card__side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.job-card__pay {
  font-size: var(--fs-xl);
  font-weight: 900;
  color: var(--gain);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.job-card__per-box {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.job-card__take {
  white-space: nowrap;
}

.job-card__why {
  grid-area: why;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--accent-100);
  color: var(--accent-700);
  font-weight: 800;
  font-size: var(--fs-sm);
}

@media (max-width: 32.5em) {
  .job-card {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      'icon main'
      'side side'
      'why why';
  }

  .job-card__icon {
    width: 52px;
    height: 52px;
    font-size: 30px;
  }

  .job-card__side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2) var(--sp-3);
    text-align: left;
  }

  .job-card__per-box {
    margin: 0;
    margin-right: auto;
  }

  .job-card__take {
    flex: 1 1 100%;
  }
}

/* ── Odds dots ─────────────────────────────────────────── */
.odds {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
}

.odds__dots {
  display: inline-flex;
  flex-wrap: wrap; /* big text (browser text size) wraps the 10 dots instead of pushing the card wider */
  max-width: 100%;
  gap: 1px;
  font-size: 1.15em;
  line-height: 1;
}

.odds-dot {
  display: inline-block;
  width: 1.05em;
  text-align: center;
}

.odds-dot--base {
  color: var(--sea-600);
}

.odds-dot--bonus {
  color: var(--accent-500);
  text-shadow: 0 0 1px var(--accent-700);
}

.odds-dot--empty {
  color: var(--line-strong);
}

.odds__text {
  font-weight: 900;
  white-space: nowrap;
}

.odds--sm .odds__dots {
  font-size: 0.95em;
}

/* ── Receipt ───────────────────────────────────────────── */
.receipt {
  position: relative;
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  background: #fffef9;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  font-variant-numeric: tabular-nums;
  /* zig-zag paper edge at the bottom */
  --zig: 12px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--zig) 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--zig) 100%;
  padding-bottom: calc(var(--sp-4) + var(--zig));
}

.receipt__title {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-3);
}

.receipt__group + .receipt__group {
  margin-top: var(--sp-4);
}

.receipt__group-title {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-md);
  padding-bottom: var(--sp-1);
  border-bottom: 2px solid var(--line);
  margin-bottom: var(--sp-1);
}

.receipt__group.is-in .receipt__group-total {
  color: var(--gain);
}

.receipt__group.is-out .receipt__group-total {
  color: var(--loss);
}

.receipt__lines {
  list-style: none;
  padding: 0;
}

.receipt__line {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 3px 0;
}

.receipt__label {
  display: inline-flex;
  gap: 0.4em;
  min-width: 0;
}

.receipt__emoji {
  flex: none;
}

.receipt__dots {
  flex: 1 1 auto;
  min-width: 12px;
  border-bottom: 2px dotted var(--line-strong);
  transform: translateY(-4px);
}

.receipt__amount {
  font-weight: 800;
  white-space: nowrap;
}

.receipt__line.is-in .receipt__amount {
  color: var(--gain);
}

.receipt__line.is-out .receipt__amount {
  color: var(--loss);
}

.receipt__rule {
  margin: var(--sp-3) 0;
  border-top: 3px double var(--ink-faint);
}

.receipt__kept {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-weight: 900;
}

.receipt__kept-label {
  font-size: var(--fs-lg);
}

.receipt__kept-amount {
  font-size: var(--fs-2xl);
  color: var(--gain);
}

.receipt.is-loss .receipt__kept-amount {
  color: var(--loss);
}

.receipt__per-day {
  text-align: right;
  font-weight: 800;
  font-size: var(--fs-md);
  color: var(--sea-700);
}

/* ── Insight cards ─────────────────────────────────────── */
.insight {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--sea-50);
  border-left: 6px solid var(--sea-400);
}

.insight--good {
  background: var(--gain-bg);
  border-left-color: var(--gain);
}

.insight--idea {
  background: var(--accent-100);
  border-left-color: var(--accent-500);
}

.insight__icon {
  font-size: 1.5em;
  line-height: 1.1;
}

.insight__text {
  font-weight: 700;
}

/* ── Pip, the first mate ───────────────────────────────── */
.mate {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  max-width: 460px;
  animation: mate-in var(--dur-3) var(--ease) both;
}

@keyframes mate-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.mate__avatar {
  flex: none;
  filter: drop-shadow(0 3px 4px rgba(13, 48, 71, 0.2));
}

.pip {
  display: block;
}

.mate__bubble {
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  background: var(--card);
  border: 3px solid var(--sea-300);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 6px;
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
}

.mate__bubble::before {
  content: '';
  position: absolute;
  left: -13px;
  bottom: 10px;
  border: 8px solid transparent;
  border-right-color: var(--sea-300);
  border-bottom-color: var(--sea-300);
}

.mate__name {
  font-size: var(--fs-xs);
  font-weight: 900;
  color: var(--sea-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mate__text {
  margin: 0 !important;
  font-weight: 700;
  font-size: var(--fs-md);
  line-height: 1.35;
}

.mate--compact .mate__text {
  font-size: var(--fs-base);
}

.mate-dock {
  position: fixed;
  left: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 40;
  max-width: calc(100vw - 2 * var(--sp-4));
  pointer-events: none;
}

.mate-dock > * {
  pointer-events: auto;
}

/* ── Modal ─────────────────────────────────────────────── */
body.has-modal {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(13, 48, 71, 0.45);
  animation: fade-in var(--dur-2) var(--ease) both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100dvh - 2 * var(--sp-4));
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--paper);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  animation: modal-in var(--dur-3) var(--ease) both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}

.modal__title {
  font-size: var(--fs-xl);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.modal__emoji {
  font-size: 1.2em;
}

.modal__close {
  margin: -8px -8px 0 0;
}

.modal__body {
  font-size: var(--fs-md);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: flex-end;
}

@media (max-width: 37.5em) {
  .modal {
    padding: var(--sp-4);
    border-radius: var(--r-lg);
  }

  .modal__actions .btn {
    flex: 1 1 100%;
  }
}

/* ── Toasts ────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: var(--sp-5);
  z-index: 70;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: max-content;
  max-width: calc(100vw - 2 * var(--sp-4));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-pill);
  background: var(--sea-800);
  color: #ffffff;
  font-weight: 800;
  font-size: var(--fs-md);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease) both;
  transition: opacity var(--dur-2), transform var(--dur-2);
}

.toast--good {
  background: var(--gain);
}

.toast--money {
  background: #1f6b46;
}

.toast--calm {
  background: var(--loss);
}

.toast__icon {
  font-size: 1.2em;
}

/* One toast, a few short lines ("A day went by…", "2 new jobs!", one news item). */
.toast--lines {
  align-items: flex-start;
  border-radius: var(--r-lg);
  max-width: 36rem;
}

.toast__lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast__line + .toast__line {
  font-weight: 700;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 37.5em) {
  .toast {
    border-radius: var(--r-lg);
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-base);
  }
}

/* ── The way to the shipyard's 🧰 Build tab (components/buildHint.js): the port's header and the Market ── */
.build-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-self: flex-start;
  gap: var(--sp-2) var(--sp-3);
  max-width: 640px;
  margin-top: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border: 2px dashed var(--sand-200);
  border-radius: var(--r-md); /* it may wrap on a phone: a soft box, not a pill */
  background: var(--card);
}

.build-hint__text {
  flex: 1 1 220px;
  margin: 0;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 800;
  overflow-wrap: anywhere;
}
