:root {
  --green-900: #1b4332;
  --green-700: #2d6a4f;
  --green-500: #40916c;
  --green-300: #95d5b2;
  --green-100: #eafaf1;
  --sky: #4a90c2;
  --sand: #f3ead6;
  --sun: #f4a300;
  --sun-dark: #d98600;
  --ink: #1f2d24;
  --white: #ffffff;
  --danger: #c0453a;
  --stamp-ink: #4a3b7c;
  --radius: 18px;
  --shadow: 0 6px 18px rgba(27, 67, 50, 0.15);
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--green-100);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Segoe UI, Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header.topbar {
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  color: var(--white);
  padding: 18px 20px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

header.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

header.topbar .subtitle {
  margin-top: 4px;
  font-size: 0.85rem;
  opacity: 0.85;
}

.stats-bar {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.stat-chip {
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 8px 12px;
  flex: 1;
  text-align: center;
}

.stat-chip .num { font-size: 1.25rem; font-weight: 800; display: block; }
.stat-chip .label { font-size: 0.68rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.03em; }

.stat-chip-tappable {
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease;
}
.stat-chip-tappable:active {
  transform: scale(0.96);
  background: rgba(255,255,255,0.25);
}

nav.tabs {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid #e2e8e4;
  position: sticky;
  top: 96px;
  z-index: 9;
}

nav.tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 4px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #6b8577;
  border-bottom: 3px solid transparent;
}

nav.tabs button.active {
  color: var(--green-700);
  border-bottom-color: var(--sun);
}

main {
  flex: 1;
  padding: 14px 16px 100px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-row input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #cfe3d6;
  font-size: 0.95rem;
  background: var(--white);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-pill {
  border: 1px solid #cfe3d6;
  background: var(--white);
  color: var(--green-700);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

.filter-pill.active {
  background: var(--green-700);
  color: var(--white);
  border-color: var(--green-700);
}

.park-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.park-emoji {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--green-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.park-card.visited .park-emoji {
  background: var(--sun);
}

.park-info { flex: 1; min-width: 0; }
.park-info .name { font-weight: 800; font-size: 1rem; margin: 0; }
.park-info .state { font-size: 0.78rem; color: #6b8577; margin: 2px 0 0; }
.park-info .visit-count { font-size: 0.72rem; color: var(--green-500); font-weight: 700; margin-top: 4px; }

.badge-check {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #cfe3d6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.park-card.visited .badge-check {
  background: var(--green-500);
  border-color: var(--green-500);
  color: white;
}

.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--sun);
  color: var(--white);
  font-size: 1.8rem;
  border: none;
  box-shadow: 0 8px 20px rgba(244,163,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,40,30,0.45);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.sheet {
  background: var(--white);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
  color: var(--green-900);
}

.sheet .sheet-sub {
  font-size: 0.8rem;
  color: #6b8577;
  margin-bottom: 16px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-700);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.field input[type="text"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cfe3d6;
  font-size: 0.95rem;
  background: var(--green-100);
  font-family: inherit;
}

.field textarea { min-height: 80px; resize: vertical; }

.photo-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.photo-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid #cfe3d6;
}

.photo-add-btn {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 2px dashed #cfe3d6;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 1.6rem;
}

.photo-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}
.photo-thumb-wrap .photo-thumb { width: 100%; height: 100%; }
.photo-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid white;
  background: var(--danger);
  color: white;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 13px;
  border-radius: 14px;
  border: none;
  font-weight: 800;
  font-size: 0.95rem;
}

.btn-primary { background: var(--green-700); color: white; }
.btn-secondary { background: #eef3ee; color: var(--green-700); }
.btn-danger { background: #fbe4e1; color: var(--danger); }

.visit-entry {
  border-top: 1px solid #eef3ee;
  padding: 12px 0;
}
.visit-entry .visit-date { font-weight: 800; font-size: 0.85rem; color: var(--green-700); }
.visit-entry .visit-notes { font-size: 0.88rem; margin: 6px 0; }
.visit-entry-head { display: flex; align-items: center; justify-content: space-between; }
.edit-visit-btn {
  border: none;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6b8577;
}
.empty-state .big-emoji { font-size: 3rem; }

.badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.badge-tile {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 8px;
  text-align: center;
  opacity: 0.35;
}

.badge-tile.earned { opacity: 1; }
.badge-tile .icon { font-size: 2rem; display: block; }
.badge-tile .title { font-size: 0.72rem; font-weight: 800; margin-top: 6px; color: var(--green-900); }
.badge-tile .desc { font-size: 0.62rem; color: #6b8577; margin-top: 2px; }

.progress-track {
  background: #e2e8e4;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 10px 0 4px;
}
.progress-fill {
  background: linear-gradient(90deg, var(--sun), var(--sun-dark));
  height: 100%;
  border-radius: 999px;
}

.section-title {
  font-weight: 800;
  color: var(--green-900);
  margin: 20px 0 10px;
  font-size: 1.05rem;
}

.toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--green-900);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 60;
  box-shadow: var(--shadow);
}

/* ---------- Auth / Household setup screens ---------- */
.auth-screen {
  max-width: 420px;
  margin: 0 auto;
  padding: 60px 20px 40px;
  padding-top: calc(60px + env(safe-area-inset-top));
}
.auth-logo { font-size: 3rem; text-align: center; margin-bottom: 8px; }
.auth-title {
  text-align: center;
  color: var(--green-900);
  font-size: 1.4rem;
  margin: 0 0 6px;
}
.auth-sub {
  text-align: center;
  color: #6b8577;
  font-size: 0.88rem;
  margin: 0 0 24px;
  line-height: 1.4;
}
.auth-toggle {
  display: flex;
  background: var(--green-100);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}
.auth-toggle-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--green-700);
}
.auth-toggle-btn.active {
  background: var(--green-700);
  color: white;
}
.auth-error {
  background: #fbe4e1;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.auth-hint {
  text-align: center;
  color: #6b8577;
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 14px 4px 0;
}

/* ---------- Park Stamps page (digital passport book) ---------- */
.stamps-overlay {
  position: fixed;
  inset: 0;
  background: var(--green-100);
  z-index: 70;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.stamps-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  color: var(--white);
  padding: calc(18px + env(safe-area-inset-top)) 20px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.stamps-progress {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 4px;
  font-weight: 700;
}

.stamps-close-btn {
  border: none;
  background: rgba(255,255,255,0.18);
  color: var(--white);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  flex-shrink: 0;
}

.stamp-mode-btn {
  border: none;
  background: rgba(255,255,255,0.18);
  color: var(--white);
  padding: 0 12px;
  height: 34px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.stamp-mode-btn.active {
  background: var(--sun);
  color: var(--green-900);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.stamps-hint {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-700);
}

.stamps-grid {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
  padding: 18px 16px calc(40px + env(safe-area-inset-bottom));
}

.stamp-card {
  position: relative;
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stamp-card.unstamping {
  opacity: 0.5;
}

/* Circular ink-stamp badge, styled after a real National Park Passport
   cancellation stamp: park name curves along the top of the ring, the
   state curves along the bottom, and the icon + date sit in the middle.
   Unvisited parks render the same layout in faded grey with a dashed ring. */
.stamp-svg {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.stamp-svg-text {
  font-family: "Caveat", "Segoe Script", cursive;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.stamp-svg-icon {
  font-size: 22px;
}

.stamp-svg-date {
  font-family: "Caveat", "Segoe Script", cursive;
  font-weight: 700;
  font-size: 11px;
}

@keyframes stampPop {
  0% { transform: scale(0.5) rotate(-16deg); opacity: 0.2; }
  60% { transform: scale(1.1) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.stamp-svg.stamp-pop {
  animation: stampPop 0.4s ease-out;
  transform-origin: center;
}

/* Stamp Mode: turns the pointer into a rubber-stamp icon over each card and
   lets a tap immediately mark that park visited (or, on an already-stamped
   park, offer to remove the stamp) instead of opening the full log-a-visit
   form. The cursor icon is a stamp seen from the front: handle on top, a
   wide base, and a smudge of ink beneath it. */
.stamps-overlay.stamp-mode-active .stamp-card {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Crect x='14' y='2' width='12' height='13' rx='3' fill='%232d6a4f'/%3E%3Crect x='17' y='13' width='6' height='7' fill='%232d6a4f'/%3E%3Crect x='6' y='19' width='28' height='11' rx='3' fill='%232d6a4f'/%3E%3Crect x='9' y='31' width='22' height='4' rx='2' fill='%23f4a300' opacity='0.85'/%3E%3C/svg%3E") 20 30, pointer;
}

.stamps-overlay.stamp-mode-active .stamp-card {
  box-shadow: 0 0 0 2px var(--sun), var(--shadow);
}

.stamps-overlay.stamp-mode-active .stamp-card.stamped {
  box-shadow: var(--shadow);
}
