/* PinpoFinder — cream base, pinpo-red highlights, black text. Mobile-first. */

:root {
  --cream: #f7f1e4;
  --cream-panel: #fdfaf2;
  --cream-dark: #ece2cc;
  --red: #b3282d;
  --red-dark: #8e1f23;
  --red-soft: rgba(179, 40, 45, 0.08);
  --ink: #1a1613;
  --ink-soft: #5c5347;
  --ok: #2e7d43;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(26, 22, 19, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

.cursive { font-family: "Caveat", cursive; }

/* ---------- Header ---------- */
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: var(--cream-panel);
  border-bottom: 3px solid var(--red);
  z-index: 1200;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--ink);
}
.brand .word {
  font-family: "Caveat", cursive;
  font-size: 2rem;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
  transform: rotate(-3deg);
}
.brand .finder {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.userbox { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.userbox .name { font-weight: 700; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 2px solid var(--red);
  background: var(--red);
  color: var(--cream-panel);
  font: inherit;
  font-weight: 700;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { background: transparent; color: var(--red); }
.btn.ghost:hover { background: var(--red-soft); }
.btn.small { padding: 0.3rem 0.8rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: #fff;
  border-color: var(--cream-dark);
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 0.9rem;
}
.btn.google:hover { background: var(--cream); border-color: var(--ink-soft); }
.btn.google svg { width: 20px; height: 20px; flex: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.9rem;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--cream-dark);
  border-radius: 1px;
}

/* ---------- Layout / views ---------- */
main { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.view { flex: 1; display: none; flex-direction: column; overflow: auto; }
.view.active { display: flex; }

/* ---------- Bottom nav ---------- */
nav.tabs {
  display: flex;
  background: var(--cream-panel);
  border-top: 2px solid var(--cream-dark);
  z-index: 1200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
nav.tabs button {
  flex: 1;
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0.45rem 0 0.55rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}
nav.tabs button .ico { display: flex; }
nav.tabs button .ico svg { width: 22px; height: 22px; }
nav.tabs button.active { color: var(--red); }
nav.tabs button.active .ico { transform: scale(1.12); }

/* ---------- Map view ---------- */
#map { flex: 1; min-height: 0; background: var(--cream-dark); }

.progress-wrap {
  padding: 0.55rem 0.9rem 0.65rem;
  background: var(--cream-panel);
  border-bottom: 2px solid var(--cream-dark);
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.progress-label .count { color: var(--red); }
.progress-bar {
  height: 10px;
  background: var(--cream-dark);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red), var(--red-dark));
  border-radius: 999px;
  transition: width 0.6s ease;
}

.nudge {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 1100;
  background: var(--ink);
  color: var(--cream);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  display: none;
}
.nudge.visible { display: flex; align-items: center; gap: 0.55rem; }
.nudge strong { color: #f2b8ba; }
.nudge-ico { width: 20px; height: 20px; flex: none; color: #f2b8ba; }

/* Leaflet popup theming */
.leaflet-popup-content-wrapper {
  background: var(--cream-panel);
  color: var(--ink);
  border-radius: var(--radius);
  border: 2px solid var(--red);
}
.leaflet-popup-tip { background: var(--red); }
.popup-photo { width: 100%; max-width: 220px; border-radius: 8px; display: block; margin-top: 0.4rem; }
.popup-meta { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.3rem; }
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.badge.verified { background: var(--red); color: var(--cream-panel); }
.badge.unconfirmed { background: transparent; color: var(--red); border: 1.5px solid var(--red); }

/* Pin markers */
.pinpo-pin {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--red);
  border: 2.5px solid var(--cream-panel);
  box-shadow: 0 1px 5px rgba(26, 22, 19, 0.4);
}
.pinpo-pin.unconfirmed { background: var(--cream-panel); border-color: var(--red); }

/* ---------- Hunt view ---------- */
.hunt {
  padding: 1.2rem 1rem 2rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
}
.hunt h2 { font-size: 1.4rem; margin: 0.2rem 0 0.4rem; }
.hunt p.hint { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 1.2rem; }

.capture-choices { display: flex; gap: 0.7rem; }
.capture-choices .camera-cta { flex: 1; padding: 1.5rem 0.6rem; }
.capture-choices .big svg { width: 42px; height: 42px; }
.camera-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  background: var(--cream-panel);
  border: 2.5px dashed var(--red);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.camera-cta:hover { background: var(--red-soft); }
.camera-cta .big { display: flex; color: var(--red); }
.camera-cta .big svg { width: 52px; height: 52px; }
.camera-cta .label { font-weight: 800; color: var(--red); font-size: 1.05rem; }

.snap-preview { margin-top: 1rem; display: none; }
.snap-preview.visible { display: block; }
.snap-preview img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 2px solid var(--cream-dark);
  background: var(--ink);
}
.snap-actions { display: flex; gap: 0.6rem; justify-content: center; margin-top: 0.8rem; }

.guidance {
  margin-top: 1.4rem;
  text-align: left;
  background: var(--cream-panel);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  font-size: 0.85rem;
}
.guidance h3 { margin: 0 0 0.4rem; font-size: 0.9rem; color: var(--red); }
.guidance ul { margin: 0; padding-left: 1.1rem; }
.guidance li { margin-bottom: 0.25rem; }

/* ---------- Leaderboard ---------- */
.board { padding: 1.2rem 1rem 2rem; max-width: 480px; margin: 0 auto; width: 100%; }
.board h2 { text-align: center; margin: 0.2rem 0 1rem; }
.h2-ico { width: 24px; height: 24px; vertical-align: -4px; color: var(--red); }
.board table { width: 100%; border-collapse: collapse; background: var(--cream-panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.board th, .board td { padding: 0.55rem 0.8rem; text-align: left; font-size: 0.9rem; }
.board thead th {
  background: var(--red);
  color: var(--cream-panel);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.board tbody tr:nth-child(even) { background: var(--red-soft); }
.board td.rank { font-weight: 800; color: var(--red); width: 2.2rem; }
.board td.num { text-align: right; font-variant-numeric: tabular-nums; }
.board .empty { text-align: center; color: var(--ink-soft); padding: 1.5rem 0; }

.wall-of-fame {
  text-align: center;
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  display: none;
}
.wall-of-fame.visible { display: block; }
.wall-of-fame .cursive { color: #f2b8ba; font-size: 1.6rem; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 19, 0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}
.modal-backdrop.visible { display: flex; }
@media (min-width: 600px) { .modal-backdrop { align-items: center; } }

.modal {
  background: var(--cream-panel);
  border-radius: var(--radius);
  border-top: 4px solid var(--red);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: auto;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 0.8rem; font-size: 1.2rem; }
.modal .close-row { display: flex; justify-content: flex-end; margin-top: 0.9rem; }

.field { margin-bottom: 0.8rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.25rem; }
.field input {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--cream-dark);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--red); }
.tos { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 0.9rem; }
.tos input { margin-top: 0.15rem; }
.auth-error { color: var(--red-dark); font-size: 0.85rem; font-weight: 700; min-height: 1.2em; margin: 0.2rem 0 0.6rem; }
.auth-switch { text-align: center; font-size: 0.85rem; margin-top: 0.6rem; }
.auth-switch a { color: var(--red); font-weight: 700; cursor: pointer; }

/* Duplicate dispute — side by side */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.8rem 0;
}
.compare-grid figure { margin: 0; }
.compare-grid img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--cream-dark);
  background: var(--ink);
}
.compare-grid figcaption {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--ink-soft);
}
.dispute-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.dispute-note { font-size: 0.75rem; color: var(--ink-soft); text-align: center; margin-top: 0.5rem; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 4.5rem;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--cream);
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 3000;
  max-width: 90vw;
  text-align: center;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--ok); }
#toast.err { background: var(--red-dark); }

/* ---------- Spinner ---------- */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--red-soft);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Loading overlay (throbber) ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 19, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  padding: 1rem;
}
.loading-overlay.visible { display: flex; }
.loading-box {
  background: var(--cream-panel);
  border-radius: var(--radius);
  border-top: 4px solid var(--red);
  padding: 1.6rem 2rem;
  max-width: 80vw;
  text-align: center;
  box-shadow: var(--shadow);
}
.loading-box p { margin: 0.9rem 0 0; font-weight: 700; color: var(--ink); }
.spinner.big-spinner { width: 40px; height: 40px; border-width: 4px; }

/* ---------- Admin ---------- */
.admin-wrap { padding: 1rem; max-width: 760px; margin: 0 auto; width: 100%; }
.admin-wrap h2 { color: var(--red); font-size: 1.05rem; margin: 1.4rem 0 0.6rem; }
.card {
  background: var(--cream-panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  margin-bottom: 0.7rem;
}
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.card .meta { font-size: 0.8rem; color: var(--ink-soft); }
.card .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.card img.thumb { width: 110px; border-radius: 8px; border: 2px solid var(--cream-dark); }
