/* pnwtap — warm, minimal styling inspired by amybell.info (Hyde theme:
   forest green + manila cream, Open Sans). */
:root {
  --green: #2f523e;
  --green-soft: #4a7c59;
  --green-bright: #157123;
  --cream: #faf6ea;
  --cream-deep: #f0e6d0;
  --tan: #e2c48b;
  --ink: #2a2a2a;
  --ink-soft: #55605a;
  --target: #c0392b;
  --guess: #f4c542;
  --card-bg: rgb(250, 246, 234);
}

/* Open Sans, self-hosted and subset (scripts/subset_fonts.py; licence: LICENSE-open-sans.txt).
   Keep unicode-range in sync with that script. */
@font-face {
  font-family: "Open Sans";
  src: url("open-sans-1.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2248, U+2260, U+2264-2265;
}
@font-face {
  font-family: "Open Sans";
  src: url("open-sans-italic-1.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2248, U+2260, U+2264-2265;
}

* { box-sizing: border-box; }

html {
  overscroll-behavior-y: none;              /* no pull-to-refresh or rubber-banding around the map */
  -webkit-tap-highlight-color: transparent; /* :active styles below give the feedback instead */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Open Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.362;   /* Open Sans' own "normal", fixed so the font swapping in can't reflow the card */
  color: var(--ink);
}

/* Full-bleed map behind everything */
#map {
  position: fixed;
  inset: 0;
  background: #2b352e; /* solid frame around the rendered region */
  cursor: crosshair;
}

/* The shaded-relief overlay multiplies onto the coloured terrain for crisp mountains */
.hillshade-pane { mix-blend-mode: multiply; opacity: 0.55; }

/* Floating card, pinned near the top */
#card {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 380px);
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  /* opaque rather than frosted glass: a backdrop blur re-renders under every map frame */
  background: var(--card-bg);
  border: 1px solid var(--tan);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(30, 40, 30, 0.28);
  overflow: hidden;
}
/* the card is up from the first paint (with a loading line) and the game fills it in */
#card { animation: card-in 0.3s ease backwards; }
@keyframes card-in { from { opacity: 0; transform: translate(-50%, -8px); } }

#card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--green);
  color: #fff;
}
.wordmark {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 16px;
}
#puzzle-no { font-weight: 600; opacity: 0.7; margin-left: 4px; font-size: 14px; }
.head-right { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.round-pill, .head-action { white-space: nowrap; }
#card-head { gap: 10px; }
.round-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}
.round-pill:empty { display: none; }

#card-body { padding: 14px 16px 16px; overflow-y: auto; overscroll-behavior: contain; }
#card-body, #help, #feedback { touch-action: manipulation; }

/* Guess prompt */
.round-meta {
  display: flex;
  justify-content: space-between;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.ask { margin: 0 0 4px; font-size: 24px; line-height: 1.2; }
.ask strong { color: var(--green); }
.ask-text { margin: 0 0 8px; font-size: 17px; line-height: 1.4; font-weight: 600; color: var(--ink); }
.ask-where { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--green); }
.cat {
  display: inline-block;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-soft);
  text-transform: capitalize;
}
.hint { margin: -8px 0 12px; font-size: 13px; color: var(--ink-soft); font-style: italic; }
.cat + .clues, .pt-meta + .clues { margin-top: -8px; }
.clues { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--green-soft); }
.tagline { margin: -6px 0 12px; font-size: 14px; font-style: italic; color: var(--ink); }
.clues + .tagline { margin-top: -8px; }

/* Reveal fact card: one per landmark type */
.fact-card {
  margin: 0 0 10px;
  border: 1px solid var(--tan);
  border-radius: 9px;
  background: #fffdf6;
  overflow: hidden;
}
.fact-head {
  padding: 6px 10px;
  background: var(--cream-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--green);
}
.fact-tag { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink-soft); font-style: italic; }
.fact-tag::before { content: "· "; font-style: normal; }
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 12px;
  margin: 0;
  padding: 8px 10px;
  font-size: 13.5px;
  line-height: 1.35;
}
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; color: var(--ink); font-weight: 600; }
.prompt-img + button, .cat + button { margin-top: 0; }
.prompt-img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border-radius: 9px;
  margin: 0 0 12px;
  border: 1px solid var(--tan);
}

/* Buttons */
button {
  font: inherit;
  font-weight: 600;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
@media (hover: hover) { button:hover:not(:disabled) { background: var(--green-bright); } }
button:active:not(:disabled) { transform: scale(0.98); filter: brightness(0.92); transition-duration: 0s; }
a:active { opacity: 0.6; }
button:disabled { background: #b9c3bb; cursor: default; }
/* a round's main button stays in reach when a long result card scrolls (short phones,
   landscape); the halo in the card colour keeps scrolled text from peeking round it */
#card-body > button.primary:last-child {
  position: sticky;
  bottom: 0;
  /* card colour at its sides and down through the body's bottom padding (sticky stops at
     the padding edge), hiding text scrolled behind it; clipped by the card, so invisible
     unless the button is stuck */
  box-shadow: 0 8px 0 8px var(--card-bg), 0 48px 0 8px var(--card-bg);
}
#card-body > button.primary:last-child:active:not(:disabled) { filter: none; background: #26443a; }
/* content continues below: fade it out just above the stuck button */
#card-body.more > button.primary:last-child::before {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: 100%;
  height: 30px;
  background: linear-gradient(rgba(250, 246, 234, 0), rgba(250, 246, 234, 0.88));
  pointer-events: none;
}
#card-body.more > button.primary:last-child::after {
  content: "more \2193";
  position: absolute;
  right: 0;
  bottom: calc(100% + 5px);
  padding: 0 8px;
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: 0 0 0 1px var(--cream-deep);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  pointer-events: none;   /* a label, not part of the button: taps go to the text beneath */
}
button:focus-visible { outline: 3px solid var(--tan); outline-offset: 2px; }

.icon-btn {
  width: 24px; height: 24px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  line-height: 24px;
  background: rgba(255, 255, 255, 0.18);
}
@media (hover: hover) { .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.32); } }
.head-action {
  width: auto;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--cream);
  color: var(--green);
}
@media (hover: hover) { .head-action:hover:not(:disabled) { background: #fff; } }

/* Result view */
.verdict {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--green-soft);
}
.result-name {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-name .tier { font-size: 18px; }
.result-score {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--ink-soft);
}
.result-score b { color: var(--ink); }
.result-score .pts { color: var(--green-soft); font-weight: 700; }
.result-member { margin: -6px 0 10px; font-size: 14px; color: var(--ink-soft); }
.result-member b { color: var(--target); }
.reveal-img {
  display: block;
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  border-radius: 9px;
  margin: 0 0 10px;
  border: 1px solid var(--tan);
}
.reveal-blurb {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Final scoreboard */
.final-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.final { margin: 0 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); }
.final-score { font-size: 40px; font-weight: 700; color: var(--green); line-height: 1; font-variant-numeric: tabular-nums; }
.final-score small { font-size: 18px; color: var(--ink-soft); font-weight: 600; }
.next-in { text-align: right; }
#countdown { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
#countdown a { display: inline-block; padding: 4px 0; font-size: 14px; color: var(--green-soft); }

.breakdown { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--cream-deep); }
.breakdown li {
  display: grid;
  grid-template-columns: 20px 1fr auto 44px;
  gap: 8px;
  align-items: baseline;
  padding: 7px 2px;
  border-bottom: 1px solid var(--cream-deep);
  font-size: 14px;
  cursor: pointer;
}
@media (hover: hover) { .breakdown li:hover { background: var(--cream-deep); } }
.breakdown li:active { background: var(--cream-deep); }
.rn { font-weight: 700; color: var(--green-soft); }
.rname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rkm { color: var(--ink-soft); font-size: 13px; }
.rpts { text-align: right; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 12px; text-align: center; }
.stats b { display: block; font-size: 18px; color: var(--green); }
.stats span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--ink-soft); }
.share-box {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--tan);
  border-radius: 9px;
  background: var(--cream-deep);
  font: 16px/1.5 "Open Sans", sans-serif;   /* 16px+ keeps iOS from zooming in on focus */
  resize: none;
}
.feedback { margin: 2px 0 -8px; text-align: center; font-size: 12px; color: var(--ink-soft); }
.feedback a { display: inline-block; padding: 10px 2px; color: inherit; text-decoration: underline dotted; text-underline-offset: 2px; }
@media (hover: hover) { .feedback a:hover { color: var(--green); } }
.archive-link { display: block; margin-top: 4px; padding: 8px 0; font-size: 13px; color: var(--green-soft); text-align: center; }

/* Playtest controls */
.pt-bar { display: flex; gap: 6px; margin-bottom: 8px; }
.pt-bar select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--tan);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 16px;
}
.pt-btn { width: auto; padding: 6px 10px; font-size: 13px; }
.pt-all { display: block; margin-bottom: 10px; font-size: 13px; color: var(--ink-soft); }
.pt-meta { font-size: 13px; color: var(--ink-soft); }

/* Help + feedback overlays */
#help, #feedback {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 28, 22, 0.55);
}
#help[hidden], #feedback[hidden] { display: none; }
.help-card {
  width: min(100%, 400px);
  padding: 20px 20px 18px;
  background: var(--cream);
  border: 1px solid var(--tan);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: card-in-plain 0.2s ease backwards;
}
@keyframes card-in-plain { from { opacity: 0; transform: translateY(-8px); } }
.help-card h2 { margin: 0 0 8px; font-size: 20px; color: var(--green); }
.help-lead { margin: 0 0 14px; font-size: 15px; line-height: 1.5; }

/* Feedback form */
.fb-card { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.fb-card fieldset { margin: 0; padding: 0; border: 0; }
.fb-card fieldset[hidden] { display: none; }
.fb-card label { display: block; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.fb-card .opt { font-weight: 400; }
.fb-card input, .fb-card textarea, .fb-card select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--tan);
  border-radius: 8px;
  background: #fff;
  font: 16px/1.4 "Open Sans", sans-serif;   /* 16px+ keeps iOS from zooming in on focus */
  color: var(--ink);
}
.fb-card textarea { resize: vertical; }
.fb-card .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-status { min-height: 1em; margin: 4px 0 8px; font-size: 13px; color: var(--green-soft); }
.fb-status.error { color: var(--target); }
.fb-actions { display: flex; gap: 8px; }
.fb-actions button { flex: 1; }
button.secondary { background: var(--cream-deep); color: var(--green); }
@media (hover: hover) { button.secondary:hover:not(:disabled) { background: var(--tan); } }

.msg { margin: 0; font-size: 16px; line-height: 1.4; }
.loading { min-height: 150px; color: var(--ink-soft); }   /* about a prompt's height, so the card barely grows */

/* ---- Map markers & reveal animation ---- */
.guess-marker .guess-dot,
.answer-marker .answer-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
.guess-marker .guess-dot {
  width: 15px; height: 15px;
  background: var(--guess);
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 10px;
  text-align: center;
}
.guess-marker .guess-dot:not(:empty) { width: 18px; height: 18px; line-height: 13px; }
.answer-marker .answer-dot {
  width: 15px; height: 15px;
  background: var(--target);
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  animation: pop 0.2s ease backwards;
}
.answer-marker .answer-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  border: 2px solid var(--target);
  animation: pulse 1.6s ease-out 3 forwards;   /* a few beats, then still: no endless repaints */
}
.answer-marker.minor .answer-dot { width: 11px; height: 11px; border-width: 2px; opacity: 0.75; }   /* the other members of an "any of" place */
@keyframes pop { from { transform: translate(-50%, -50%) scale(0); } }
@keyframes pulse {
  from { opacity: 0.7; transform: scale(1); }
  to   { opacity: 0;   transform: scale(3.6); }
}

.leaflet-container { font-family: inherit; }

/* ---- Wide screens: dock the card on the left, out of the map's way ---- */
@media (min-width: 1000px) {
  #card {
    top: 20px;
    left: 20px;
    transform: none;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
  }
  #card { animation-name: card-in-plain; }
}

/* ---- Phones on their side: dock a narrow card on the left, as on wide screens ---- */
@media (min-width: 641px) and (max-width: 999px) and (max-height: 500px) {
  #card {
    top: 8px;
    left: calc(8px + env(safe-area-inset-left, 0px));
    width: min(340px, calc(45vw - env(safe-area-inset-left, 0px)));
    transform: none;
    max-height: calc(100vh - 16px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 16px - env(safe-area-inset-bottom, 0px));
  }
  #card { animation-name: card-in-plain; }
  #card-body { padding: 10px 14px 12px; }
  .ask { font-size: 20px; }
}

/* ---- Phones: the card becomes a bottom sheet so the map up top stays clear ---- */
@media (max-width: 640px) {
  #card {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    transform: none;
    border-radius: 16px 16px 0 0;
    border-width: 1px 0 0;
    max-height: 62vh;
    transition: transform 0.2s ease;
  }
  #card { animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
  #card.dragging { transition: none; }
  #card-head { position: relative; padding: 11px 14px 7px; cursor: grab; touch-action: none; user-select: none; }
  #card-head::before {                        /* grab handle */
    content: "";
    position: absolute;
    top: 4px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.35);
  }
  #card.collapsed #card-body { display: none; }
  #card-body { padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
  /* bigger touch targets than the header's small buttons show */
  .icon-btn, .head-action { position: relative; }
  .icon-btn::after { content: ""; position: absolute; top: -11px; bottom: -7px; left: -4px; right: -14px; }
  .head-action::after { content: ""; position: absolute; top: -8px; bottom: -6px; left: -4px; right: -4px; }
  .ask { font-size: 21px; }
  .reveal-blurb { font-size: 13.5px; }
  .reveal-img, .prompt-img { max-height: 140px; }
  .final-score { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
