:root {
  --ink: #1b1713;
  --paper: #f3eee4;
  --muted: #6d665c;
  --rule: #d8cfc0;
  --accent: #9b2d1f;
  --error: #8c1d18;
  --project: #14110e;
  --project-paper: #f6f0e4;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  color: var(--ink);
  background: var(--paper);
}

body.project {
  color: var(--project-paper);
  background: var(--project);
}

a {
  color: inherit;
}

.page {
  width: min(40rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
}

.brand {
  margin: 0 0 2.5rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand a {
  text-decoration: none;
}

h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.05;
  font-weight: 600;
}

label,
.field-label,
.helper,
.lead,
.create-link,
.host-home-link,
.country,
.country-fixed,
.atlas-title,
.atlas-date,
.atlas-counts,
.atlas-status,
.atlas-actions,
.share-instruction,
.join-code-label,
.share-copied,
.share-actions,
.share-copy-link,
.share-action,
.button {
  font-family: ui-sans-serif, system-ui, sans-serif;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: #fffdf8;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1.05rem;
}

.join input {
  width: 10.5rem;
  letter-spacing: 0.18em;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

button,
a.button {
  margin-top: 0.5rem;
  padding: 0.7rem 1.1rem;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.country-typeahead {
  margin-bottom: 1rem;
}

.country-typeahead [data-country-search] {
  margin-bottom: 0;
}

.country-typeahead-list {
  max-height: min(16rem, 50vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 0.35rem;
  padding: 0;
  list-style: none;
  border: 1px solid var(--rule);
  border-top: 0;
  background: #fffdf8;
}

.country-typeahead-list[hidden] {
  display: none;
}

.country-typeahead-list [role="option"],
.country-typeahead-empty {
  padding: 0.75rem 0.75rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1.05rem;
}

.country-typeahead-list [role="option"] {
  cursor: pointer;
}

.country-typeahead-empty {
  color: var(--muted);
}

.country-typeahead-list [role="option"]:hover {
  background: rgba(27, 23, 19, 0.12);
}

.country-typeahead-list [role="option"].is-active {
  background: var(--ink);
  color: var(--paper);
}

.helper {
  margin: -0.55rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.country-typeahead:has(.country-typeahead-list:not([hidden])) {
  margin-bottom: 0.25rem;
}

.country-typeahead:has(.country-typeahead-list:not([hidden])) + .helper {
  margin-top: 0.45rem;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.error {
  margin: 0 0 1rem;
  color: var(--error);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
}

.create-link,
.host-home-link {
  margin-top: 2.75rem;
}

.host-home-link + .create-link {
  margin-top: 0.85rem;
}

.page.share .host-home-link,
.page.create .host-home-link,
.page.request-link .host-home-link,
.page.dead-link .host-home-link,
.page.link-sent .host-home-link {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.create-form button {
  margin-top: 0.75rem;
}

.page.share {
  width: min(64rem, calc(100% - 2.5rem));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.atlas-title {
  margin: 0 0 0.55rem;
  color: #e4ddd2;
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
}

.share-instruction {
  margin: 0 0 2rem;
  max-width: 28rem;
  color: #c9c0b2;
  font-size: 1.05rem;
  line-height: 1.4;
}

.share-board {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.75rem 3.5rem;
}

.share-qr {
  margin: 0;
  width: min(28rem, 70vmin);
  padding: 0.85rem;
  background: var(--project-paper);
  color: var(--project);
}

.share-qr-svg {
  display: block;
  width: 100%;
  height: auto;
}

.join-code-label {
  margin: 0 0 0.25rem;
  color: #c9c0b2;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.share-code .join-code {
  margin: 0;
}

.join-code {
  margin: 0 0 2rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: clamp(4.5rem, 18vw, 11rem);
  line-height: 0.9;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.share-copied {
  margin: 0 0 0.85rem;
  min-height: 1.15rem;
  color: #c9c0b2;
  font-size: 0.95rem;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.share-copy-link,
.share-action {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.05rem;
  text-decoration: underline;
  cursor: pointer;
}

.country,
.country-fixed,
.atlas-date,
.atlas-counts,
.empty {
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.atlas-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.atlas-row {
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
}

.atlas-row:last-child {
  border-bottom: 1px solid var(--rule);
}

.atlas-row h2 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 600;
}

.atlas-date,
.atlas-counts {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.atlas-status {
  display: inline-block;
  margin: 0.15rem 0 0.45rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--rule);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}

.atlas-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
}

.atlas-action-primary {
  font-weight: 650;
}

.atlas-freeze {
  margin: 0;
}

.atlas-freeze button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
}

.atlas-freeze button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.page.host-atlas .atlas-actions {
  margin: 0 0 1.75rem;
}

body.atlas {
  height: 100%;
  overflow: hidden;
  color: #fff;
  background: #1b3b6f;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

html:has(body.atlas) {
  height: 100%;
}

.atlas-live {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

.atlas-map {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.map-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.map-country {
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 0.4;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.15s ease, filter 0.15s ease;
}

@media (hover: hover) {
  .map-country.is-hover {
    transform: scale(1.08);
    filter: brightness(1.08);
    stroke: #111;
    stroke-width: 1.1;
  }
}

.map-country.is-picked {
  filter: brightness(1.15);
  stroke: #111;
  stroke-width: 1.2;
}

.name-float {
  position: absolute;
  transform: translate(-50%, -140%);
  background: #111;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

.pin {
  pointer-events: auto;
  cursor: pointer;
}

.pin-dot {
  transform-origin: center;
  transform-box: fill-box;
}

.pin.pop .pin-dot {
  animation: pinpop 0.55s ease;
}

@keyframes pinpop {
  0% {
    transform: scale(0);
  }
  60% {
    transform: scale(1.55);
  }
  100% {
    transform: scale(1);
  }
}

.pin-count {
  fill: #fff;
  font: 700 12px/1 "Trebuchet MS", "Segoe UI", sans-serif;
  pointer-events: none;
}

.dlg-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.dlg-back[hidden] {
  display: none;
}

.dlg {
  width: min(22rem, 100%);
  padding: 16px 18px;
  border-radius: 12px;
  background: #fff;
  color: #111;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.dlg h3 {
  margin: 0 0 8px;
  font-size: 1.125rem;
}

.dlg label {
  color: #111;
}

.dlg input[type="text"],
.dlg input:not([type]),
.dlg input[name="displayName"] {
  margin-bottom: 0.75rem;
}

.dlg-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.dlg button {
  margin-top: 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.dlg .cancel {
  background: #eee;
  color: #111;
}

.roster-dlg {
  width: min(24rem, 100%);
  max-height: min(calc(100dvh - 2rem), 46rem);
  display: flex;
  flex-direction: column;
}

.roster-total {
  margin: 0 0 0.65rem;
  color: #444;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
}

.roster-names {
  --roster-row: 1.6rem;
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  max-height: calc(var(--roster-row) * 20);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.roster-names li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--roster-row);
  padding: 0.2rem 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
}

.roster-remove {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.host-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 100;
  isolation: isolate;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: min(22rem, calc(100% - 2rem));
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: #111;
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.host-toast[hidden] {
  display: none;
}

.host-toast p {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
}

.host-toast button {
  margin: 0;
  padding: 0.45rem 0.9rem;
  border-radius: 7px;
  background: #fff;
  color: #111;
  font-weight: 800;
}

.atlas-notice {
  position: absolute;
  left: 50%;
  top: 4.5rem;
  transform: translateX(-50%);
  z-index: 16;
  max-width: min(24rem, calc(100% - 2rem));
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #123;
  text-shadow: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
}

.atlas-notice[hidden] {
  display: none;
}

.pin-error {
  position: absolute;
  left: 50%;
  top: 4.5rem;
  transform: translateX(-50%);
  z-index: 15;
  max-width: min(24rem, calc(100% - 2rem));
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.atlas-overlay-top {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  pointer-events: none;
  text-shadow: 0 2px 8px #1b3b6f;
}

.atlas-live h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2.5rem);
}

.atlas-prompt {
  margin: 4px 0 0;
  font-size: 1.125rem;
}

.atlas-chrome-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.atlas-join,
.atlas-pin-chip {
  margin: 0;
  background: #ffd84d;
  color: #111;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  font-weight: 800;
  text-shadow: none;
}

.atlas-join {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.atlas-pin-chip {
  pointer-events: auto;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.atlas-pin-chip.is-readonly,
.atlas-pin-chip:disabled {
  cursor: default;
}

.atlas-share {
  margin: 0;
  pointer-events: auto;
  text-shadow: none;
}

.atlas-share a {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #123;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.atlas-stats {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: min(260px, 34vw);
  pointer-events: none;
}

.atlas-stats .stat {
  background: rgba(255, 255, 255, 0.92);
  color: #123;
  border-radius: 10px;
  padding: 6px 10px;
  text-shadow: none;
}

.atlas-stats .stat b {
  display: block;
  font-size: 1.35rem;
}

.atlas-stats .stat.wide {
  max-width: 100%;
}

.atlas-stats .stat.wide b {
  font-size: 0.9rem;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.atlas-stats .stat span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.atlas-picked {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.map-fail {
  margin: 20vh auto;
  max-width: 24rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  color: #123;
  border-radius: 10px;
}
