:root {
  --bg: #f6f1e4;
  --surface: #fffdf7;
  --surface-2: #efe8d6;
  --ink: #1d2a1f;
  --ink-soft: #56645a;
  --line: #ddd3bb;
  --accent: #2f6b3a;       /* frog green */
  --accent-ink: #ffffff;
  --accent-soft: #dcebd6;
  --x-red: #d2432f;
  --river: #6fa9c9;
  --river-bank: #b9d4c0;

  --map-paper: #f3ecd9;
  --map-speck: #d9cdb0;
  --map-street: #e2d6b9;
  --map-street-major: #d3c29c;
  --map-freeway: #e9b85b;
  --map-label: #4c6d7d;

  --frog: #5cae4f;
  --frog-dark: #3d8a3a;
  --frog-belly: #c8e6a2;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 35, 20, .06), 0 6px 18px rgba(40, 35, 20, .07);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121814;
    --surface: #1a221c;
    --surface-2: #232d25;
    --ink: #eaf0e6;
    --ink-soft: #a4b1a5;
    --line: #2f3a31;
    --accent: #7fcf6e;
    --accent-ink: #0f1a10;
    --accent-soft: #24382a;
    --map-paper: #18201a;
    --map-speck: #273128;
    --map-street: #263027;
    --map-street-major: #34402f;
    --map-label: #8fb8cc;
    --river: #3b7392;
    --river-bank: #25402f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #121814; --surface: #1a221c; --surface-2: #232d25; --ink: #eaf0e6; --ink-soft: #a4b1a5;
  --line: #2f3a31; --accent: #7fcf6e; --accent-ink: #0f1a10; --accent-soft: #24382a;
  --map-paper: #18201a; --map-speck: #273128; --map-street: #263027; --map-street-major: #34402f;
  --map-label: #8fb8cc; --river: #3b7392; --river-bank: #25402f;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; }

/* ================= Splash ================= */
#splash {
  position: fixed; inset: 0; z-index: 10;
  background: var(--map-paper);
  overflow: hidden;
  transition: opacity .6s ease, transform .6s ease;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  outline: none;
}
#splash.leaving { opacity: 0; transform: scale(1.04); pointer-events: none; }
#splash.leaving.to-up    { transform: translateY(-40%); }
#splash.leaving.to-down  { transform: translateY(40%); }
#splash.leaving.to-left  { transform: translateX(-40%); }
#splash.leaving.to-right { transform: translateX(40%); }
#splashMap { width: 100%; height: 100%; display: block; }

.streets line { stroke: var(--map-street); stroke-width: 6; stroke-linecap: round; }
.streets line.major { stroke: var(--map-street-major); stroke-width: 11; }
.bank { fill: none; stroke: var(--river-bank); stroke-width: 120; stroke-linecap: round; }
.river { fill: none; stroke: var(--river); stroke-width: 62; stroke-linecap: round; }
.ripple { fill: none; stroke: #fff; stroke-linecap: round; animation: shimmer var(--dur, 2.4s) ease-in-out var(--delay, 0s) infinite alternate; }
@keyframes shimmer { from { opacity: var(--lo, .1); } to { opacity: var(--hi, .5); } }
.freeway { fill: none; stroke: var(--map-freeway); stroke-width: 14; stroke-linecap: round; opacity: .85; }
.map-label { font: 700 22px var(--font-body); letter-spacing: .35em; fill: var(--map-label); opacity: .75; }
.map-label.small { font-size: 16px; letter-spacing: .1em; }

.trail { fill: none; stroke: var(--x-red); stroke-width: 3.5; stroke-dasharray: 2 12; stroke-linecap: round; opacity: .75; }

.xmark line { stroke: var(--x-red); stroke-width: 9; stroke-linecap: round; }
.xmark .ring { fill: none; stroke: var(--x-red); stroke-width: 4; opacity: 0; transform-box: fill-box; transform-origin: center; }
.xmark.hit .ring { animation: ring .5s ease-out forwards; }
.xmark.hit line { animation: stamp .35s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes ring { from { opacity: .9; transform: scale(.4); } to { opacity: .55; transform: scale(1); } }
@keyframes stamp { 40% { transform: scale(1.35); } }

.frog-skin { fill: var(--frog); }
.frog-dark { fill: var(--frog-dark); }
.frog-belly { fill: var(--frog-belly); }
.frog-shadow { fill: rgba(0,0,0,.18); }
/* little frogs sitting on the map: a slow little "ribbit" bob */
.tiny-bob { animation: ribbit 3s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes ribbit { 0%, 80%, 100% { transform: none; } 86% { transform: scale(1.06, .92); } 92% { transform: translateY(-6px); } }

#splashTitle {
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  text-align: center; pointer-events: none;
  padding: 48px 16px;
}
#splashTitle::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--map-paper) 92%, transparent), transparent);
  opacity: 0; transition: opacity .5s ease;
}
#splash.titled #splashTitle::before { opacity: 1; }
#splashTitle h1 {
  margin: 0;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(44px, 11vw, 112px);
  line-height: 1; letter-spacing: -.02em;
  color: var(--accent);
  text-shadow: 0 3px 0 var(--map-paper), 0 -3px 0 var(--map-paper), 3px 0 0 var(--map-paper), -3px 0 0 var(--map-paper), 0 10px 30px rgba(0,0,0,.15);
  opacity: 0; transform: translateY(24px) scale(.94);
  transition: opacity .5s ease, transform .6s cubic-bezier(.2,1.4,.4,1);
}
#splashTitle h1 .wm-map { color: var(--x-red); }
#splashTitle p {
  margin: 14px 0 0; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  font-size: 13px; color: var(--ink);
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--map-paper) 85%, transparent);
  opacity: 0; transition: opacity .5s ease .25s;
}
#splash.titled #splashTitle h1 { opacity: 1; transform: none; }
#splash.titled #splashTitle p { opacity: 1; }
#splashTitle h1 { padding-bottom: .22em; }
#splashTitle .wm-credit {
  font-size: clamp(11px, 1.5vw, 15px); top: calc(100% + 2px);
  text-shadow: 0 0 4px var(--map-paper), 0 0 2px var(--map-paper);
}
#splashTitle p { margin-top: 18px; }

#splashHint {
  position: absolute; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0; padding: 10px 18px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
}
#splash.ready #splashHint { opacity: 1; animation: nudge 1.6s ease-in-out .4s infinite; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }

/* ================= App ================= */
#app { min-height: 100vh; display: flex; flex-direction: column; animation: appIn .5s ease; }
@keyframes appIn { from { opacity: 0; } }

.topbar {
  position: sticky; top: 0; z-index: 5;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--accent);
}
.brand .wm-map { color: var(--x-red); }
.brand .wordmark { padding-bottom: 11px; }

/* "Created by Big Criminal" sits under "Town Map", nudged right and running past it */
.wordmark { white-space: nowrap; }
.wm-tail { position: relative; }
.wm-credit {
  position: absolute; left: .7em; top: 100%;
  font-family: var(--font-body); font-size: 10.5px; font-weight: 500; font-style: italic;
  letter-spacing: .03em; line-height: 1; color: var(--ink-soft); white-space: nowrap;
}

main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; outline: none; }

.hero h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(26px, 5vw, 36px); line-height: 1.15; margin: 8px 0 6px;
}
.hero p { margin: 0 0 18px; color: var(--ink-soft); }

.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 16px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.search svg { flex: none; color: var(--ink-soft); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 16px;
}
.search:focus-within { border-color: var(--accent); }

.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 12px;
}

.cat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.cat {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; min-height: 128px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.cat:hover { transform: translateY(-2px); border-color: var(--accent); }
.cat:active { transform: scale(.98); }
.cat .ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; background: var(--accent-soft);
}
.cat strong { font-weight: 600; font-size: 16px; line-height: 1.25; }
.cat small { color: var(--ink-soft); font-size: 13px; margin-top: auto; }

.group-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 860px) { .group-grid { grid-template-columns: repeat(4, 1fr); } }
.group {
  --tint: var(--accent);
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 16px 16px; min-height: 200px;
  background: color-mix(in srgb, var(--tint) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tint) 30%, var(--line));
  border-radius: 20px; box-shadow: var(--shadow); text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.group:hover { transform: translateY(-2px); border-color: var(--tint); }
.group:active { transform: scale(.98); }
.group .ico {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  font-size: 30px; margin-bottom: 6px;
  background: color-mix(in srgb, var(--tint) 24%, var(--surface));
}
.ico-row { display: flex; gap: 8px; flex: none; }
/* 3+ icons: one straight row of smaller bubbles that shrink to fit the card */
.ico-row.many { display: flex; gap: 5px; width: 100%; }
.ico-row.many .ico {
  flex: 0 1 42px; min-width: 0; width: auto; height: auto; aspect-ratio: 1;
  font-size: clamp(15px, 4.6vw, 22px); border-radius: 11px;
}
/* page headers: keep the row compact so the title stays beside it */
.cat-head { flex-wrap: wrap; row-gap: 10px; }
.cat-head .ico-row.many { width: auto; }
.cat-head .ico-row.many .ico { flex: none; width: 42px; height: 42px; font-size: 22px; }
.group .ico-row { margin-bottom: 6px; }
.group .ico-row .ico { margin-bottom: 0; }
.group strong { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.15; }
.group small { color: var(--ink-soft); font-size: 13px; line-height: 1.35; }
.group .count { margin-top: auto; padding-top: 8px; font-size: 13px; font-weight: 600; color: color-mix(in srgb, var(--tint) 70%, var(--ink)); }
.cat .ico.tinted, .cat-head .ico.tinted { background: color-mix(in srgb, var(--tint) 20%, var(--surface)); }
.cat .cat-sub { color: var(--ink-soft); font-size: 13px; line-height: 1.35; }

/* subcategory picker: full-width rows on phones, three across on wide screens */
.sub-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.sub-grid .cat {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 2px;
  align-items: center; min-height: 0;
}
.sub-grid .cat .ico { grid-row: span 3; }
.sub-grid .cat small { margin-top: 4px; }
@media (min-width: 720px) {
  .sub-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .sub-grid .cat { display: flex; }
}

.back {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  color: var(--ink-soft); font-size: 14px; font-weight: 500; margin-bottom: 8px;
}
.back:hover { color: var(--accent); }
.cat-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.cat-head .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; background: var(--accent-soft); }
.cat-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 30px; margin: 0; }
.cat-desc { color: var(--ink-soft); margin: 0 0 20px; }

.see-map {
  display: inline-flex; align-items: center; gap: 6px; margin: -8px 0 18px;
  padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 14px;
  background: var(--accent); color: var(--accent-ink);
}
.see-map:hover { filter: brightness(1.08); }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.legend .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.map {
  height: min(62vh, 560px); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface-2);
  position: relative; z-index: 0;
}
.map-loading { margin: 0; padding: 24px; color: var(--ink-soft); text-align: center; }
.map-note { color: var(--ink-soft); font-size: 13px; margin: 8px 0 20px; }
.map-pop { font: 13px/1.4 var(--font-body); color: #1d2a1f; max-width: 240px; }
.map-pop strong { font-size: 14px; }
.map-pop .pop-meta { color: #56645a; }
.map-pop a { display: inline-block; margin-top: 4px; color: #2f6b3a; font-weight: 600; }
.map-pop hr { border: 0; border-top: 1px solid #ddd3bb; margin: 8px 0; }

.places { display: grid; gap: 12px; }
.place {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.place h3 { margin: 0; font-size: 17px; font-weight: 600; }
.place-emoji { font-size: 18px; }
.emoji-pin span {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; font-size: 16px; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.place .meta { color: var(--ink-soft); font-size: 14px; margin: 2px 0 8px; }
.place p { margin: 0 0 10px; }
.place .happy {
  font-size: 13px; margin: -4px 0 12px; padding: 8px 10px; border-radius: 10px;
  background: color-mix(in srgb, #e0a53a 16%, var(--surface));
}
.place .happy strong { font-weight: 600; margin-right: 4px; }
.badge {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; background: var(--x-red); color: #fff;
}
.place .hours { font-size: 13px; color: var(--ink-soft); margin: -2px 0 12px; }
.place .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  padding: 7px 14px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}

.empty {
  text-align: center; padding: 40px 16px; color: var(--ink-soft);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

.foot { padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; color: var(--ink-soft); font-size: 13px; }
.foot p { max-width: 520px; margin: 0 auto; }
.foot .foot-note { margin-top: 10px; font-size: 12px; opacity: .85; }

@media (prefers-reduced-motion: reduce) {
  .ripple { animation: none; opacity: .35; }
  .tiny-bob { animation: none; }
  #splash.ready #splashHint { animation: none; }
  #app { animation: none; }
}
