:root {
  --ink: #2b1a0e;
  --ink-soft: #5a3b1f;
  --parchment: #f1dcaa;
  --parchment-deep: #e2c283;
  --parchment-light: #f8ebcb;
  --blood: #8b1a10;
  --blood-dark: #5e0f08;
  --gold: #c8973e;
  --sea: #1f5fa8;
  --sea-light: #4a92e0;
  --bg: #1d130b;
  --display: "Cinzel", "Times New Roman", serif;
  --body: "IM Fell English", Georgia, serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: radial-gradient(ellipse at center, #3a2614 0%, var(--bg) 75%);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

button {
  font: inherit;
  color: inherit;
}

/* ------------------------------------------------------------- world map */

.world {
  position: relative;
  max-width: 1774px;
  margin: 0 auto;
  padding: 16px;
}

.world-frame {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.6);
  background: var(--parchment);
}

.world-map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1774 / 887;
  cursor: grab;
  touch-action: none;
}

.world-map:active {
  cursor: grabbing;
}

.country {
  fill: none;
  stroke: none;
  pointer-events: none;
  outline: none;
}

.world-map.over-country {
  cursor: pointer;
}

.highlight,
.tints image {
  pointer-events: none;
  image-rendering: pixelated;
}

.landmarks circle {
  fill: #00a2ff;
  stroke: white;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.seal {
  cursor: pointer;
}

.seal circle {
  fill: var(--blood);
  stroke: var(--gold);
  stroke-width: 2;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.6));
}

.seal text {
  fill: var(--parchment-light);
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 14px));
  padding: 4px 10px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: var(--blood-dark);
  color: var(--parchment-light);
  font-family: var(--display);
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.5);
}

/* Top-right corner: the Ninth Age emblem with the "put yourself on the map" call below it. */
.corner {
  position: absolute;
  top: 26px;
  right: calc(16px + 1.2%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: clamp(72px, 9%, 150px);
}

.t9a-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  color: var(--parchment-light);
  text-decoration: none;
  transition: transform 0.15s;
  isolation: isolate;
}

/* A thick cloud of black smoke behind the emblem so it stands out from the map. */
.t9a-link::before {
  content: "";
  position: absolute;
  inset: -14% -24% -10%; /* stays inside the page margin: no sideways scroll */
  z-index: -1;
  background:
    radial-gradient(ellipse 46% 30% at 50% 22%, rgb(8 4 2 / 0.9), transparent 72%),
    radial-gradient(ellipse 40% 26% at 34% 48%, rgb(8 4 2 / 0.85), transparent 70%),
    radial-gradient(ellipse 40% 26% at 66% 52%, rgb(8 4 2 / 0.85), transparent 70%),
    radial-gradient(ellipse 50% 22% at 50% 80%, rgb(8 4 2 / 0.9), transparent 72%),
    radial-gradient(ellipse 30% 18% at 24% 84%, rgb(20 12 6 / 0.7), transparent 70%),
    radial-gradient(ellipse 30% 18% at 76% 88%, rgb(20 12 6 / 0.7), transparent 70%),
    radial-gradient(ellipse 55% 50% at 50% 50%, rgb(8 4 2 / 0.6), transparent 75%);
  filter: blur(9px);
  pointer-events: none;
}

.t9a-link img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 6px rgb(0 0 0 / 0.9)) drop-shadow(0 3px 10px rgb(0 0 0 / 0.7));
}

.t9a-link span {
  padding: 3px 8px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: rgb(94 15 8 / 0.9);
  font-family: var(--display);
  font-size: clamp(9px, 0.95vw, 13px);
  line-height: 1.2;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 2px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.5);
}

.t9a-link:hover,
.t9a-link:focus-visible {
  transform: scale(1.04);
}

.t9a-link:hover span,
.t9a-link:focus-visible span {
  background: var(--blood);
}

.join-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 112%;
}

.join-cta p {
  margin: 0;
  padding: 5px 8px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: rgb(20 12 6 / 0.85);
  color: var(--parchment-light);
  font-family: var(--display);
  font-size: clamp(9px, 0.85vw, 12px);
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.5);
}

.join-button {
  display: grid;
  place-items: center;
  width: clamp(34px, 3.2vw, 46px);
  height: clamp(34px, 3.2vw, 46px);
  padding: 0 0 3px;
  border: 2px solid var(--parchment-light);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--sea-light), var(--sea) 70%);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: clamp(24px, 2.3vw, 34px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgb(20 12 6 / 0.7), 0 3px 10px rgb(0 0 0 / 0.6);
  transition: transform 0.15s, box-shadow 0.15s;
}

.join-button:hover,
.join-button:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px rgb(20 12 6 / 0.7), 0 0 14px var(--sea-light);
}

.join-button[aria-pressed="true"] {
  transform: rotate(45deg); /* turns into an × to cancel */
}

/* While choosing a country to join, a banner on the map says what to do. */
.join-hint {
  position: absolute;
  top: 17%;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 16px;
  border: 2px solid var(--parchment-light);
  border-radius: 999px;
  background: var(--sea);
  color: #fff;
  font-family: var(--display);
  font-size: clamp(13px, 1.3vw, 17px);
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 3px 12px rgb(0 0 0 / 0.6);
}

.join-hint[hidden] {
  display: none;
}

.join-hint button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.2);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.map-controls {
  position: absolute;
  right: 1.4%;
  bottom: 14%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-controls button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: rgb(94 15 8 / 0.85);
  color: var(--parchment-light);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.map-controls button:hover {
  background: var(--blood);
}

.country-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px auto 0;
  color: var(--parchment);
}

.country-search input {
  width: min(280px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: var(--parchment-light);
  font: inherit;
  color: var(--ink);
}

.country-search button,
.copy {
  padding: 8px 14px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: var(--blood);
  color: var(--parchment-light);
  font-family: var(--display);
  cursor: pointer;
}

/* -------------------------------------------------------- country dialog */

.country-dialog {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.country-dialog::backdrop {
  background: rgb(15 8 3 / 0.7);
  backdrop-filter: blur(2px);
}

.country-dialog[open] .parchment {
  animation: unfurl 0.25s ease-out;
}

@keyframes unfurl {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

.parchment {
  position: relative;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 18px 20px 20px;
  border: 3px solid var(--ink-soft);
  border-radius: 8px;
  background:
    radial-gradient(ellipse at center, var(--parchment-light) 0%, var(--parchment) 60%, var(--parchment-deep) 100%);
  box-shadow:
    inset 0 0 60px rgb(122 74 28 / 0.45),
    0 0 0 6px var(--parchment-deep),
    0 0 0 8px var(--ink-soft),
    0 20px 60px rgb(0 0 0 / 0.7);
}

.country-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.ribbon {
  margin: 0;
  padding: 6px 42px;
  border: 2px solid var(--gold);
  border-radius: 40px;
  background: linear-gradient(var(--blood), var(--blood-dark));
  color: var(--parchment-light);
  font-family: var(--display);
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
}

.close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink-soft);
  border-radius: 50%;
  background: var(--parchment-light);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.country-header .close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.close:hover {
  background: var(--blood);
  color: var(--parchment-light);
}

.country-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
}

.country-map-wrap {
  position: relative;
  border: 2px solid var(--ink-soft);
  border-radius: 4px;
  overflow: hidden;
}

.country-map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 560;
  touch-action: none;
  cursor: grab;
}

.sea {
  fill: #e9cf98;
}

.graticule {
  fill: none;
  stroke: rgb(90 59 31 / 0.18);
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
}

.neighbour {
  fill: #ecd6a4;
  stroke: rgb(90 59 31 / 0.55);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}

.chosen {
  fill: #f7e6bd;
  stroke: var(--ink);
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgb(139 26 16 / 0.35));
}

.leader {
  stroke: var(--ink-soft);
  stroke-width: 1.2;
  stroke-dasharray: 3 2;
}

.anchor {
  fill: var(--blood);
}

.badge {
  cursor: pointer;
  outline: none;
  transition: transform 0.15s;
}

.badge-ring {
  fill: var(--gold);
  stroke: var(--ink);
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.5));
}

.badge-bg {
  fill: var(--parchment-light);
}

.badge-label {
  fill: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--parchment-light);
  stroke-width: 5px;
  stroke-linejoin: round;
  pointer-events: none;
}

.badge:hover .badge-ring,
.badge:focus-visible .badge-ring,
.marker.active .badge-ring {
  fill: var(--blood);
  stroke: var(--gold);
  stroke-width: 2.5;
}

/* --------------------------------------------------------- community card */

.community-card {
  position: absolute;
  z-index: 2;
  width: min(330px, calc(100% - 16px));
  max-height: calc(100% - 16px);
  overflow: auto;
  padding: 14px 14px 12px;
  border: 2px solid var(--ink-soft);
  border-radius: 6px;
  background: var(--parchment-light);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45), inset 0 0 24px rgb(200 151 62 / 0.25);
  animation: unfurl 0.15s ease-out;
}

.community-card .close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  font-size: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 26px;
}

.card-head h4 {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  line-height: 1.2;
}

.region {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-style: italic;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 5px 0 0;
}

.facts .tag {
  padding: 1px 7px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: rgb(200 151 62 / 0.18);
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
}

.desc {
  margin: 10px 0 0;
  line-height: 1.35;
}

.logo {
  display: inline-grid;
  flex: none;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--parchment-light);
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-logo {
  width: 52px;
  height: 52px;
}

.list-logo {
  width: 36px;
  height: 36px;
}

.links {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid rgb(90 59 31 / 0.35);
  border-left: 4px solid var(--brand);
  border-radius: 4px;
  background: rgb(255 255 255 / 0.35);
  color: var(--ink);
  text-decoration: none;
}

a.link:hover,
a.link:focus-visible {
  background: rgb(255 255 255 / 0.7);
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  background: var(--brand);
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
}

.link-text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.link-text strong {
  font-family: var(--display);
  font-size: 13px;
}

.link-text small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy {
  padding: 3px 8px;
  font-size: 12px;
}

/* --------------------------------------------------------- side list */

.country-aside h3 {
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink-soft);
  font-family: var(--display);
  font-size: 18px;
}

.community-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.community-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.community-list button:hover,
.community-list button:focus-visible {
  border-color: var(--gold);
  background: rgb(255 255 255 / 0.4);
}

.community-list span:last-child {
  display: grid;
}

.community-list strong {
  font-family: var(--display);
  font-size: 14px;
}

.community-list small {
  color: var(--ink-soft);
  font-style: italic;
}

.empty {
  margin: 0;
  line-height: 1.4;
}

.empty a {
  color: var(--blood);
}

/* ------------------------------------------------- street map (street.js) */

/* Over the painted map, which stays underneath to keep the frame's size.
   isolation keeps Leaflet's own z-indexes below the card and hints. */
.street-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  isolation: isolate;
  background: #aad3df;
  font: inherit;
}

.street-map[hidden],
.street-search[hidden] {
  display: none;
}

.country-map-wrap.street-view {
  min-height: min(62vh, 560px);
}

.street-view .country-map {
  visibility: hidden;
}

.map-toolbar {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none; /* only its buttons and search catch clicks */
}

.map-toolbar > * {
  pointer-events: auto;
}

.street-search button {
  padding: 7px 12px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: rgb(94 15 8 / 0.92);
  color: var(--parchment-light);
  font-family: var(--display);
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
}

.street-search button:hover {
  background: var(--blood);
}

/* The big switch between the painting and the real map, under the country name. */
.view-switch {
  display: flex;
  justify-content: center;
  margin: -4px 0 12px;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 12px;
  border: 2px solid var(--parchment-light);
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, var(--sea-light), var(--sea) 70%);
  color: #fff;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgb(20 12 6 / 0.6), 0 4px 12px rgb(0 0 0 / 0.5);
  transition: transform 0.15s;
}

.view-toggle::before {
  content: "";
  width: 26px;
  height: 26px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M2 12h20M12 2a15 15 0 0 1 0 20M12 2a15 15 0 0 0 0 20'/%3E%3C/svg%3E") center / contain no-repeat;
}

.view-toggle:hover,
.view-toggle:focus-visible {
  transform: scale(1.05);
}

.street-search {
  display: flex;
  flex: 1 1 220px;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 420px;
  margin: 0;
}

.street-search input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: var(--parchment-light);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
}

.street-status {
  flex-basis: 100%;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-style: italic;
  text-shadow: 0 0 4px #fff, 0 0 4px #fff;
}

.street-status:empty {
  display: none;
}

.street-marker img {
  width: 100%;
  height: 100%;
  border: 3px solid var(--gold);
  border-radius: 50%;
  background: var(--parchment-light);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.5);
  cursor: pointer;
}

.street-banner img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / 0.55));
}

/* Leaflet's own blank icon box around our markers. */
.street-marker,
.street-banner {
  border: 0;
  background: none;
}

/* --------------------------------------------- planting a banner (join.js) */

.add-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 16px;
  padding: 8px 10px;
  border: 2px solid var(--sea);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.45);
  color: var(--ink);
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.add-button:hover,
.add-button:focus-visible,
.add-button[aria-pressed="true"] {
  background: rgb(74 146 224 / 0.18);
}

.add-button .plus {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  padding-bottom: 3px;
  border: 2px solid var(--parchment-light);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--sea-light), var(--sea) 70%);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px rgb(20 12 6 / 0.5), 0 2px 6px rgb(0 0 0 / 0.4);
  transition: transform 0.15s;
}

.add-button[aria-pressed="true"] .plus {
  transform: rotate(45deg);
}

.planting .country-map,
.planting .badge,
.planting .street-map,
.planting .street-map .leaflet-interactive {
  cursor: none;
}

/* Touch screens have no pointer to follow: keep the normal cursor and rely on the hint. */
@media (hover: none) {
  .planting .country-map,
  .planting .street-map {
    cursor: crosshair;
  }
}

.plant-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 14px;
  border: 2px solid var(--parchment-light);
  border-radius: 999px;
  background: var(--sea);
  color: #fff;
  font-family: var(--display);
  font-size: 15px;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 3px 12px rgb(0 0 0 / 0.5);
  transition: background 0.2s;
}

.plant-hint[hidden],
.banner-cursor[hidden] {
  display: none;
}

.plant-hint.warn {
  background: var(--blood);
}

.plant-hint button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.2);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

/* The waving banner that stands in for the cursor: its pole's foot is the hotspot. */
.banner-cursor {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: none;
  /* the foot of the pole (3, 80 of 61 x 80) sits on the pointer */
  transform: translate(-3px, -80px);
}

.banner-cursor img {
  width: 61px;
  height: 80px;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.5));
  animation: banner-wave 1.6s ease-in-out infinite;
}

.banner-cursor span {
  margin: 4px 0 0 -40px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgb(20 12 6 / 0.85);
  color: var(--parchment-light);
  font-family: var(--display);
  font-size: 12px;
  white-space: nowrap;
}

.planted-banner {
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / 0.55));
}

/* The cloth sways about the pole; the pole's foot stays put. */
@keyframes banner-wave {
  0%, 100% { transform: skewY(0deg) scaleX(1); transform-origin: 5% 100%; }
  50% { transform: skewY(-3deg) scaleX(0.96); transform-origin: 5% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .banner-cursor img {
    animation: none;
  }
}

/* ------------------------------------------------------------ join form */

.join-dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.join-dialog::backdrop {
  background: rgb(15 8 3 / 0.55);
}

.join-dialog[open] .parchment {
  animation: unfurl 0.25s ease-out;
}

.join-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 30px 12px;
}

.join-header .ribbon {
  padding: 4px 28px;
  font-size: clamp(18px, 2.4vw, 24px);
}

.join-header .close {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* The send button sits right under the title, with any problem shown under it. */
.join-submit-row {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 0 0 14px;
}

.join-form .join-submit-row .plant-submit {
  padding: 10px 22px;
  border: 2px solid var(--parchment-light);
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgb(20 12 6 / 0.6), 0 4px 12px rgb(0 0 0 / 0.4);
}

.join-submit-row .join-error {
  justify-self: stretch;
}

/* minmax(0, 1fr) and min-width: 0 let inputs shrink to narrow phones
   instead of pushing the form wider than the screen. */
.join-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.join-form .field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  min-width: 0;
}

.join-form .field > span,
.join-form legend {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
}

/* The address's promise of privacy has to be noticed. */
.join-form em.privacy-note {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.join-form em {
  font-family: var(--body);
  font-weight: 400;
  color: var(--ink-soft);
}

.join-form input:not([type="file"]):not([type="hidden"]):not([type="radio"]),
.join-form select,
.join-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  background: var(--parchment-light);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.join-form textarea {
  resize: vertical;
}

.join-form select {
  cursor: pointer;
}

/* Yes / No side by side under their question. */
.join-form .choice {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 6px 22px;
  margin: 0;
  padding: 0;
  border: 0;
}

.join-form .choice legend {
  width: 100%;
  margin-bottom: 4px;
  padding: 0;
}

.join-form .choice label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.join-form .choice input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--sea);
}

.join-form input:focus-visible,
.join-form textarea:focus-visible,
.join-form select:focus-visible {
  outline: 2px solid var(--sea);
  outline-offset: 1px;
}

.contacts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 8px;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--ink-soft);
  border-radius: 6px;
}

.contacts legend {
  padding: 0 4px;
}

.field.contact > span {
  padding-left: 8px;
  border-left: 4px solid var(--brand);
}

.logo-pick {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-preview {
  display: grid;
  flex: none;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border: 2px dashed var(--ink-soft);
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 24px;
}

.logo-preview.has-image {
  border-style: solid;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-pick input {
  min-width: 0;
  font-size: 14px;
}

.join-error {
  margin: 0;
  padding: 8px 10px;
  border-left: 4px solid var(--blood);
  background: rgb(139 26 16 / 0.12);
  color: var(--blood-dark);
}

/* A required section left empty: red outline and a note under it. */
.join-form .field.missing input:not([type="radio"]),
.join-form .field.missing select {
  border-color: var(--blood);
  box-shadow: 0 0 0 2px rgb(139 26 16 / 0.25);
}

/* For a section of several fields it's the heading that's required. */
.join-form .missing > legend {
  color: var(--blood);
}

.join-form fieldset.missing.contacts {
  border: 2px solid var(--blood);
  box-shadow: 0 0 0 2px rgb(139 26 16 / 0.2);
}

.required-note {
  position: relative;
  width: fit-content;
  margin: 6px 0 0;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--blood);
  color: #fff;
  font-family: var(--display);
  font-size: 13px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
  animation: unfurl 0.15s ease-out;
}

/* A little arrow pointing up at the section. */
.required-note::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 14px;
  border: 5px solid transparent;
  border-top: 0;
  border-bottom-color: var(--blood);
}

/* Under the Yes / No row, not beside it. */
.choice .required-note {
  grid-column: 1 / -1;
}

.join-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.join-form .primary,
.join-form .secondary {
  padding: 8px 18px;
  border-radius: 4px;
  font-family: var(--display);
  cursor: pointer;
}

.join-form .primary {
  border: 1px solid var(--gold);
  background: var(--sea);
  color: #fff;
}

.join-form .primary:hover {
  background: var(--sea-light);
}

.join-form .primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.join-form .secondary {
  border: 1px solid var(--ink-soft);
  background: transparent;
}

/* After sending, only the thank-you note shows. */
.join-form.sent .join-fields,
.join-form.sent .join-submit-row,
.join-form.sent .join-actions {
  display: none;
}

.join-done {
  text-align: center;
}

.join-done p {
  margin: 0 0 8px;
}

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }

  /* The home page fills the phone screen, centred top to bottom. */
  .world {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100svh;
    padding: 8px;
  }

  /* Taller than the artwork: the map shows its middle slice at full height
     (see fitWorldView in app.js). */
  .world-map {
    height: min(118vw, 62svh);
    aspect-ratio: auto;
  }

  .parchment {
    padding: 14px 12px 14px;
  }

  .country-body {
    grid-template-columns: 1fr;
  }

  .ribbon {
    padding: 4px 20px;
    margin-right: 40px;
  }

  .corner {
    position: static;
    align-items: stretch;
    gap: 8px;
    width: auto;
    margin-bottom: 8px;
  }

  .t9a-link {
    flex-direction: row;
    justify-content: flex-end;
    gap: 8px;
  }

  .join-cta {
    flex-direction: row;
    justify-content: flex-end;
    width: auto;
    gap: 8px;
  }

  .join-cta p {
    font-size: 13px;
    text-align: left;
  }

  .join-button {
    flex: none;
    width: 48px;
    height: 48px;
    font-size: 34px;
  }

  .t9a-link::before {
    display: none; /* above the map on phones, already on a dark background */
  }

  .t9a-link img {
    width: 44px;
  }

  .t9a-link span {
    padding: 6px 10px;
    font-size: 14px;
  }

  .map-controls {
    bottom: 10px;
    gap: 8px;
  }

  .map-controls button {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .country-search input,
  .country-search button {
    padding: 11px 14px;
    font-size: 17px;
  }
}

.card-logo-link {
  display: inline-flex;
  flex: none;
  border-radius: 50%;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card-logo-link:hover,
.card-logo-link:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px var(--gold), 0 4px 12px rgb(0 0 0 / 0.4);
}
