/* Passport / border-control look: green cover, security-printed data page,
   rubber stamps for results. One bold element (the stamp); the rest is quiet. */
:root {
  --cover: #123d35;
  --cover-deep: #0c2c26;
  --foil: #cfae62;
  --paper: #eef1e8;
  --paper-line: rgba(18, 61, 53, .055);
  --ink: #17231f;
  --ink-soft: #56655f;
  --rule: #c9d2c6;
  --red: #b8322e;
  --violet: #4b3c9e;
  --serif: "Young Serif", Georgia, serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--cover);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app, .screen { position: absolute; inset: 0; }
.hidden { display: none !important; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--foil); outline-offset: 2px; }

/* --- cover screens (start, preload, pass, end) --- */
.cover {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.06), transparent 60%),
    var(--cover);
  color: var(--paper);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#preload { z-index: 900; }
/* Pass overlay must sit above the game panel it covers */
#pass { z-index: 1000; }
#preload, #pass { display: flex; align-items: center; justify-content: center; }

.cover-inner {
  width: 100%; max-width: 460px; margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 16px 40px;
}
.cover-inner.narrow { text-align: center; padding-top: 16px; }
.cover-head { text-align: center; margin-bottom: 28px; }
.emblem {
  width: 76px; height: 76px; fill: none; stroke: var(--foil); stroke-width: 2.2;
  margin-bottom: 14px;
}
.cover h1, .cover h2 {
  font-family: var(--serif); font-weight: 400; color: var(--foil);
  margin: 0; letter-spacing: -.01em;
}
.cover h1 { font-size: clamp(38px, 10vw, 52px); line-height: 1.02; }
.cover h2 { font-size: 30px; margin-bottom: 14px; }
.cover-sub { color: #b9c9c2; font-size: 16px; line-height: 1.55; margin: 14px 0 0; text-wrap: pretty; }
.cover-sub b { color: var(--paper); }
.install { margin: 22px 4px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: #b9c9c2; font-size: 14px; line-height: 1.5; }
.install b { color: var(--paper); font-size: 15px; }
.install-btn { background: transparent; color: var(--foil); border: 1px solid var(--foil); border-radius: 8px; padding: 10px 22px; font-weight: 700; font-size: 15px; cursor: pointer; }
.install-btn:hover { background: rgba(207, 174, 98, .12); }
.share-ico { width: 14px; height: 16px; vertical-align: -2px; margin: 0 2px; }
.support { margin: 26px 4px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: #b9c9c2; font-size: 14px; }
.support.in-card { margin: 18px 0 4px; padding: 12px 0 2px; border-top: 1px dashed var(--rule); color: var(--ink-soft); font-size: 13px; gap: 6px; }
.support.in-card .support-btn { font-size: 14px; padding: 8px 16px; }
.support-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--foil); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px; padding: 10px 20px; border-radius: 8px; }
.support-btn:hover { background: #dcbe78; }
.support-btn svg { width: 20px; height: 20px; }
.credits { color: #86a197; font-size: 13px; line-height: 1.55; text-align: center; margin: 28px 8px 0; }

.bar { height: 4px; background: rgba(207,174,98,.2); border-radius: 2px; overflow: hidden; margin: 22px auto 0; max-width: 280px; }
.bar > div { height: 100%; width: 0; background: var(--foil); transition: width .12s linear; }

/* --- the data page: security-printed paper --- */
.paper {
  background-color: var(--paper);
  background-image:
    repeating-radial-gradient(circle at 0 0, transparent 0 9px, var(--paper-line) 9px 10px),
    repeating-radial-gradient(circle at 100% 100%, transparent 0 9px, var(--paper-line) 9px 10px);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 18px 40px rgba(0,0,0,.28);
}
.form { padding: 10px 22px 22px; }

.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0; border-bottom: 1px dashed var(--rule);
  font-size: 15px; color: var(--ink-soft);
}
.field select, .field input[type=text] { color: var(--ink); }
.fieldend { display: inline-flex; align-items: center; gap: 8px; }
.unit { font-size: 13px; color: var(--ink-soft); }
.field.check { cursor: pointer; }
.field small { display: block; font-size: 12px; color: #86958f; margin-top: 2px; }

select {
  appearance: none; -webkit-appearance: none;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2317231f' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 2px center;
  border: none; padding: 2px 18px 2px 4px; font-size: 17px; font-weight: 700;
  cursor: pointer;
}
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--cover); margin: 0; cursor: pointer; }

#player-names { display: flex; flex-direction: column; }
#player-names input {
  background: transparent; border: none; border-bottom: 1px dashed var(--rule);
  padding: 14px 0; font-size: 17px; font-weight: 600; border-radius: 0;
}
#player-names input::placeholder { color: #93a19b; font-weight: 500; }
#player-names input:focus { outline: none; border-bottom: 1px solid var(--cover); }

.err { color: var(--red); min-height: 0; font-size: 14px; margin: 10px 0 0; }
.err:empty { display: none; }

button.primary {
  display: block; width: 100%; margin-top: 18px;
  background: var(--cover); color: var(--paper);
  border: none; border-radius: 6px;
  padding: 15px 18px; font-size: 17px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .05s;
}
button.primary:hover { background: var(--cover-deep); }
button.primary:active { transform: translateY(1px); }
button.primary.gold { background: var(--foil); color: var(--ink); max-width: 280px; margin: 26px auto 0; }
button.primary.gold:hover { background: #dcbd74; }
/* A disabled button does nothing on tap — let taps pass through to whatever is
   behind it (the map), so the "Tap the map to place a pin" placeholder can't
   swallow taps that land in the strip it overlaps. */
button.primary:disabled {
  background: transparent; color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--rule);
  cursor: default; pointer-events: none; font-weight: 600;
}

.skip {
  display: block; width: 100%; background: none; border: none;
  color: var(--ink-soft); font-size: 14px; cursor: pointer;
  padding: 10px 8px 2px;
}
.skip:hover { color: var(--ink); text-decoration: underline; }
.flag:disabled { color: #93a19b; cursor: default; text-decoration: none; }

/* --- game layout --- */
#game { display: flex; background: var(--cover); }
/* The panel is a flex column: a scrolling content area (#panel-scroll) plus a
   never-scrolling action footer (#panel-actions). The button lives in the
   footer in normal flow — no position:fixed/sticky — so it is ALWAYS visible
   even when the content above overflows (e.g. the multiplayer turn banner).
   Avoids the iOS Safari bug where a fixed element inside an overflow:auto
   container that is actively scrolling vanishes. */
#panel {
  width: 360px; flex: 0 0 360px;
  padding: 18px 20px 16px; display: flex; flex-direction: column;
  z-index: 500; min-height: 0; border-radius: 0;
}
#panel-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 14px;
}
#panel-actions { flex: 0 0 auto; }
#panel-actions .primary { margin-top: 12px; }
#map { flex: 1; height: 100%; background: #dfe4de; }

/* Map hidden until the player asks for it: the data page floats on the cover */
#game.no-map #map { display: none; }
#game.no-map { justify-content: center; align-items: center; }
#game.no-map #panel {
  width: calc(100% - 32px); max-width: 420px; flex: 0 0 auto;
  border-radius: 8px; max-height: calc(100% - 32px);
}

.topline {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
#timer-label { color: var(--ink); font-weight: 800; font-size: 16px; }
#timer-label.warn { color: var(--red); }
#score-label { color: var(--ink); }
.topline .exit {
  font: inherit; font-size: 13px; color: var(--ink-soft); background: none; cursor: pointer;
  border: 1px solid currentColor; border-radius: 4px; padding: 2px 8px; margin-right: 8px;
}
.topline .exit:hover { color: var(--ink); }
#round-label { flex: 1; }
.skip.light, .skip.light:hover { color: rgba(255,255,255,.75); margin-top: 10px; }

.turn {
  font-weight: 700; font-size: 15px; padding: 10px 12px;
  border-radius: 6px; background: rgba(255,255,255,.55);
  border-left: 5px solid var(--cover);
}

/* the ID block: photo + printed fields */
.photo { position: relative; }
#portrait {
  display: block; width: 100%; aspect-ratio: 3/4; max-height: 50vh;
  object-fit: cover; border-radius: 3px;
  background: #d6ddd3; border: 1px solid #b8c2b5;
}
#game.no-map #portrait { max-height: 56vh; }
.fields { margin: 14px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: baseline; }
.fields dt { font-size: 12px; color: var(--ink-soft); }
.fields dd { margin: 0; font-family: var(--serif); font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.fields dd.bio { font-family: var(--sans); font-size: 15px; line-height: 1.35; }
.bio-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-soft); }
.bio-meta a { color: inherit; }
#region { text-align: right; max-width: 80%; font-size: 15px; }
.credit { margin: 6px 0 0; font-size: 11px; line-height: 1.4; color: var(--ink-soft); overflow-wrap: anywhere; }
.credit a, .credits a { color: inherit; }
.redact { display: inline-block; width: 9em; max-width: 100%; height: .8em; background: var(--ink); border-radius: 1px; vertical-align: -.02em; }
.blank { color: #93a19b; letter-spacing: .1em; }

/* the stamp — the one loud element */
.stamp {
  position: absolute; right: -8px; bottom: 22px;
  transform: rotate(-8deg);
  color: var(--red); border: 4px double currentColor; border-radius: 6px;
  padding: 6px 14px 7px; text-align: center; line-height: 1;
  background: rgba(238,241,232,.7);
  font-weight: 800; font-size: 26px; letter-spacing: .02em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  -webkit-mask-image: repeating-linear-gradient(115deg, #000 0 3px, rgba(0,0,0,.82) 3px 4px, #000 4px 9px);
  mask-image: repeating-linear-gradient(115deg, #000 0 3px, rgba(0,0,0,.82) 3px 4px, #000 4px 9px);
  animation: thud .28s cubic-bezier(.2,.9,.3,1.2) both;
  pointer-events: none;
}
.stamp small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .12em; margin-top: 4px; }
.stamp.far { color: var(--violet); }
@keyframes thud {
  from { opacity: 0; transform: rotate(-8deg) scale(1.9); }
  to   { opacity: 1; transform: rotate(-8deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .stamp { animation: none; } }

.result { font-size: 15px; line-height: 1.5; color: var(--ink-soft); }
.result b { color: var(--ink); }
.result .born { font-size: 14px; }

/* per-player rows (multiplayer reveal + scoreboard) */
.prow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--rule); color: var(--ink); }
.prow:last-child { border-bottom: none; }
.prow .dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.prow .pname { flex: 1; text-align: left; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pkm, .prow .plvl { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.prow .ppts { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 76px; text-align: right; }
.prow.win .pname::after { content: " — winner"; font-weight: 500; color: var(--ink-soft); font-size: 13px; }
.result .prow.win .pname::after { content: " +1 point"; color: var(--red); font-weight: 700; }
.prow .prank { width: 1.2em; flex: 0 0 auto; color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.prow.phead { padding: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.prow.phead .pname { font-weight: 600; }
.prow.phead .ppts { font-weight: 600; }
.board-title { margin: 20px 0 4px; font-family: var(--serif); font-weight: 400; font-size: 18px; text-align: left; color: var(--ink); }
.board-title:first-child { margin-top: 0; }
.board-title small { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); margin-left: 6px; }

/* today's score distribution (daily) */
.dist { margin: 18px 0 4px; text-align: left; }
.dist-head { margin: 0 0 10px; font-size: 15px; color: var(--ink); }
.dist-head b { font-family: var(--serif); font-weight: 400; font-size: 20px; color: var(--red); }
.dist-plot { display: flex; align-items: flex-end; gap: 1px; height: 120px; padding-top: 20px; border-bottom: 1px solid var(--ink-soft); }
.dist-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; cursor: default; }
.dist-col:hover .dist-bar { opacity: .75; }
.dist-bar { flex-shrink: 0; background: var(--cover); opacity: .45; border-radius: 2px 2px 0 0; }
.dist-col.me .dist-bar { background: var(--red); opacity: 1; min-height: 3px; }
.dist-you { align-self: center; margin-bottom: 2px; font-size: 11px; font-weight: 700; color: var(--red); white-space: nowrap; }
.dist-ticks { position: relative; height: 16px; font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.dist-ticks span { position: absolute; top: 2px; }
.dist-ticks span:last-child { left: auto !important; right: 0; }
.dist-axis { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

/* --- end screen --- */
.verdict { padding: 30px 22px 22px; text-align: center; }
.you-are { font-family: var(--serif); font-size: 22px; color: var(--ink-soft); }
.stamp.big {
  position: relative; right: auto; bottom: auto; display: block;
  width: max-content; max-width: 100%; margin: 18px auto 28px;
  font-size: clamp(28px, 8vw, 38px); line-height: 1.05; padding: 12px 22px 14px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.stats div { padding: 12px 4px; border-top: 1px dashed var(--rule); }
.stats dt { font-size: 12px; color: var(--ink-soft); }
.stats dd { margin: 4px 0 0; font-family: var(--serif); font-size: clamp(16px, 4.6vw, 21px); white-space: nowrap; font-variant-numeric: tabular-nums; }
.verdict .prow { text-align: left; }

/* --- start-screen boxes: challenge, daily, free play, your record --- */
.box { padding: 18px 22px 20px; margin-bottom: 18px; }
.form { margin-bottom: 18px; }
.box-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.form .box-head { padding-top: 10px; margin-bottom: 2px; }
.box-title { font-family: var(--serif); font-size: 23px; }
.box-note { font-size: 13px; color: var(--ink-soft); }
.box-note.center { display: block; text-align: center; margin: 12px 0 0; }
.box-text { margin: 8px 0 0; font-size: 15px; line-height: 1.5; color: var(--ink-soft); }
.box-text b { color: var(--ink); }
#challenge { border-left: 6px solid var(--red); }
.daily-done { margin: 10px 0 0; font-size: 15px; color: var(--ink-soft); }
.daily-done b { color: var(--ink); }
.squares { display: block; font-size: 26px; letter-spacing: 3px; margin-bottom: 4px; }
.squares.big { font-size: 30px; margin: 0 0 14px; }
.next-daily-box { margin: 16px 0 0; padding-top: 14px; border-top: 1px dashed var(--ink-soft); text-align: center; }
.next-daily-box p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.next-daily { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--ink); margin: 2px 0 6px; }
.next-daily-box .box-note { margin-bottom: 10px; }
.versus { margin: 16px 0 0; font-size: 15px; font-weight: 600; }
.stats.four { grid-template-columns: repeat(4, 1fr); margin-top: 8px; }
.stats dd small { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }

button.secondary {
  display: block; width: 100%; margin-top: 10px;
  background: transparent; color: var(--cover);
  border: 1.5px solid var(--cover); border-radius: 6px;
  padding: 13px 18px; font-size: 16px; font-weight: 700; cursor: pointer;
}
button.secondary:hover { background: rgba(18,61,53,.06); }
.verdict .skip { margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 2000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 6px;
  font-size: 15px; font-weight: 600; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .stats.four { grid-template-columns: repeat(2, 1fr); }
}

/* --- map --- */
.pin-svg { width: 30px; height: 38px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.truth-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--red); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(184,50,46,.25), 0 2px 4px rgba(0,0,0,.4);
}
.pin.num {
  font-size: 13px; font-weight: 800; color: #fff; width: 24px; height: 24px;
  border-radius: 50%; line-height: 20px; text-align: center; border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.45);
}
.leaflet-container { font-family: var(--sans); }
.leaflet-popup-content-wrapper { border-radius: 6px; background: var(--paper); color: var(--ink); }
.leaflet-popup-content { margin: 10px 14px; font-size: 14px; }
.leaflet-popup-tip { background: var(--paper); }
.leaflet-bar a { color: var(--ink); }

/* --- mobile: stack panel on top of the map --- */
@media (max-width: 760px) {
  #game:not(.no-map) { flex-direction: column; }
  /* Panel sizes to its content, capped so the map always keeps room; the
     button footer is normal-flow, so always tappable. */
  #game:not(.no-map) #panel {
    width: 100%; flex: 0 0 auto; max-height: 62%;
    padding: 12px 16px 12px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  }
  /* Map open: photo shrinks to an ID-card thumbnail beside the fields */
  #game:not(.no-map) #person { display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: center; }
  #game:not(.no-map) .credit { grid-column: 1 / -1; order: 3; margin: -4px 0 0; }
  #game:not(.no-map) .fields { margin: 0; grid-template-columns: 1fr; gap: 2px; }
  #game:not(.no-map) .fields dd { font-size: 17px; margin-bottom: 6px; }
  #game:not(.no-map) .fields dd.bio { font-size: 14px; }
  #game:not(.no-map) #portrait { max-height: none; }
  #game:not(.no-map) .stamp { font-size: 15px; padding: 4px 6px 5px; right: -18px; bottom: 6px; border-width: 3px; }
  #game:not(.no-map) .stamp small { font-size: 8px; }
  #game:not(.no-map) #panel-scroll { gap: 10px; }
  #game:not(.no-map) #panel-actions .primary { margin-top: 10px; padding: 13px; }
  #game.no-map #portrait { max-height: 50vh; }
  #game.no-map #panel { padding: 14px 16px; }

  /* Map fills the leftover space, with a floor so it never collapses. */
  #game:not(.no-map) #map { flex: 1 1 0%; height: auto; min-height: 30vh; }
}
.verdict { margin-bottom: 18px; }

/* --- "How it works" FAQ on the start screen (also the page's text for search engines) --- */
.faq { margin: 34px 4px 0; color: #b9c9c2; }
.faq h2 { font-size: 26px; margin: 0 0 6px; }
.faq h3 { font-size: 16px; font-weight: 700; color: var(--paper); margin: 20px 0 4px; }
.faq p { font-size: 15px; line-height: 1.6; margin: 0; }
.faq a { color: var(--foil); }

/* backup basemap (Natural Earth): ocean colour + zoom-dependent labels */
#map.fallback { background: #b3c8cf; }
.map-label { pointer-events: none; }
.map-label span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-family: var(--sans); color: #56655f;
  text-shadow: 0 0 3px #f4f6f0, 0 0 3px #f4f6f0, 0 0 3px #f4f6f0;
}
.map-label.country span { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6f7d77; }
.map-label.city span { font-size: 12px; font-weight: 600; }
