/* Phone first. Big screens get the same pieces, a little roomier, and the sheet moves to the right side. */
:root {
  --red: #E0312B; --red-d: #B8231E; --gold: #F2B21B; --ink: #1D2330; --ink-2: #4A5466; --paper: #FFFDF8; --line: #E7E1D4; --soft: #F3EEE3;
  --sea: #1F6E99; --radius: 18px; --shadow: 0 8px 24px rgba(20, 30, 50, .2);
  --ig: linear-gradient(45deg, #F9A825 0%, #E1306C 45%, #C13584 70%, #5B51D8 100%);
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --head: "Baloo 2", "Nunito", system-ui, sans-serif;
  --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px); --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --dock-h: 118px; --top-h: 58px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--sea); color: var(--ink); font: 500 15px/1.45 var(--font); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input, a { font: inherit; color: inherit; touch-action: manipulation; }
button { -webkit-user-select: none; user-select: none; }
a { color: var(--red-d); font-weight: 800; }
#canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.hud { position: fixed; z-index: 5; }
svg { display: block; }

/* ---------- Top bar: logo · search · numbers, one row ---------- */
.top { top: calc(10px + var(--st)); left: calc(10px + var(--sl)); right: calc(10px + var(--sr)); display: flex; align-items: center; gap: 8px; }
.brand { flex: none; display: flex; align-items: center; gap: 8px; background: var(--paper); height: 46px; padding: 0 12px 0 7px; border-radius: 14px; box-shadow: var(--shadow); font: 800 17px/1 var(--head); }
.brand svg { width: 32px; height: 32px; }
.findbar { flex: 1; min-width: 0; position: relative; max-width: 460px; margin: 0 auto; }
.find-field { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 14px; padding: 0 12px; height: 46px; box-shadow: var(--shadow); border: 2px solid transparent; }
.find-field:focus-within { border-color: var(--gold); }
.find-field svg { width: 18px; height: 18px; color: var(--ink-2); flex: none; }
/* 16px stops iPhone from zooming in when you tap the field */
.find-field input { flex: 1; border: 0; background: none; height: 100%; outline: none; min-width: 0; font-size: 16px; font-weight: 700; }
.find-list { position: absolute; left: 0; right: 0; top: 52px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; z-index: 8; }
.find-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px 14px; min-height: 52px; cursor: pointer; border-bottom: 1px solid var(--line); }
.find-list button:last-child { border-bottom: 0; }
.find-list button:hover, .find-list button:focus { background: #FFF3D6; outline: none; }
.find-list small { display: block; color: var(--ink-2); }
.chips { flex: none; display: flex; gap: 6px; }
.chip { background: var(--paper); height: 46px; display: flex; align-items: center; padding: 0 12px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 800; font-size: 13px; white-space: nowrap; }
.chip.strong { background: var(--red); color: #fff; letter-spacing: .03em; }

/* Under the top bar: back to the map, and which town you are in */
.subbar { top: calc(var(--top-h) + 14px + var(--st)); left: calc(10px + var(--sl)); right: calc(10px + var(--sr)); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.subbar > * { pointer-events: auto; }
.back { border: 0; background: var(--ink); color: #fff; height: 44px; padding: 0 16px; border-radius: 13px; font-weight: 800; box-shadow: var(--shadow); cursor: pointer; }
.town-tag { margin-left: auto; background: var(--paper); border-radius: 13px; padding: 6px 12px; box-shadow: var(--shadow); text-align: right; max-width: 60%; }
.town-tag b { display: block; font: 800 15px/1.15 var(--head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.town-tag span { font-size: 12px; color: var(--ink-2); }
.iab { top: calc(var(--top-h) + 14px + var(--st)); left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 20px)); background: #FFF3D6; border-radius: 12px; padding: 9px 40px 9px 12px; font-size: 13px; box-shadow: var(--shadow); z-index: 7; }
.iab button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: none; font-size: 22px; }

/* ---------- Turning the view ---------- */
.turns { right: calc(10px + var(--sr)); bottom: calc(var(--dock-h) + 24px + var(--sb)); display: grid; gap: 6px; transition: opacity .2s; }
.turns button { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--paper); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; padding: 0; position: relative; }
.turns button svg { width: 22px; height: 22px; color: var(--ink); }
#compass svg { width: 26px; height: 26px; transition: transform .05s linear; }
#compass span { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font: 800 9px/1 var(--font); color: var(--red); }
#compass { padding-top: 6px; }

/* ---------- Dock: one thumb ---------- */
.dock { left: 0; right: 0; bottom: 0; padding: 8px calc(10px + var(--sr)) calc(8px + var(--sb)) calc(10px + var(--sl)); background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(20, 30, 50, .18); transition: transform .22s ease; }
.dock-row { display: flex; gap: 8px; }
.dock-main { flex: 1; min-width: 0; border: 0; background: var(--red); color: #fff; font: 800 17px/1 var(--head); height: 52px; border-radius: 15px; cursor: pointer; box-shadow: inset 0 -3px 0 var(--red-d); }
.dock-share { flex: none; display: flex; align-items: center; gap: 7px; border: 0; color: #fff; background: var(--ig); height: 52px; padding: 0 16px; border-radius: 15px; font-weight: 800; cursor: pointer; }
.dock-share svg { width: 22px; height: 22px; }
.dock-main:active, .dock-share:active, .btn:active { transform: translateY(1px); filter: brightness(.96); }
.dock-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-top: 6px; }
.dock-tabs .heart-tab { color: #C2185B; }
.dock-tabs button { position: relative; border: 0; background: var(--soft); border-radius: 12px; height: 42px; font-weight: 800; cursor: pointer; }
.dot { position: absolute; top: 7px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--soft); }
.news-pill { left: 50%; transform: translateX(-50%); top: calc(var(--top-h) + 16px + var(--st)); border: 0; background: var(--ink); color: #fff; font-weight: 700; padding: 10px 14px; border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100% - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; z-index: 7; }
.news-pill b { background: var(--red); border-radius: 6px; padding: 1px 6px; margin-right: 6px; font-size: 12px; letter-spacing: .04em; }
body.in-town .news-pill { top: calc(var(--top-h) + 66px + var(--st)); }
/* A sheet takes the dock's place on phones */
body.sheet-open .dock { transform: translateY(110%); }
body.sheet-open .turns { opacity: 0; pointer-events: none; }

/* ---------- Labels on the 3D world ---------- */
.lab { position: absolute; left: 0; top: 0; pointer-events: auto; border: 0; cursor: pointer; white-space: nowrap; background: rgba(255, 253, 248, .95); color: var(--ink); font: 800 12px/1 var(--font); padding: 6px 9px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,.18); will-change: transform; }
.lab.mine { background: var(--red); color: #fff; }
.lab.house { font-size: 11px; padding: 5px 8px; }
.lab.peak { pointer-events: none; background: rgba(29, 35, 48, .72); color: #fff; font-size: 11px; padding: 4px 8px; box-shadow: none; }
.lab.peak::after { display: none; }
.lab.house.first { background: var(--gold); }
.lab.house.mine { background: var(--red); color: #fff; }
/* Bigger hit area for thumbs, without bigger labels */
.lab::after { content: ""; position: absolute; inset: -8px -4px; }

/* ---------- The sheet: bottom on phones ---------- */
.sheet { left: 0; right: 0; bottom: 0; max-height: min(72dvh, 640px); display: flex; flex-direction: column; background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(20, 30, 50, .25); z-index: 6; transform: translateY(105%); transition: transform .22s ease; padding-bottom: var(--sb); }
.sheet.tall { max-height: min(90dvh, 900px); }
.sheet.on { transform: none; }
.sheet-head { position: relative; flex: none; display: flex; justify-content: space-between; gap: 10px; padding: 20px 14px 10px calc(18px + var(--sl)); border-bottom: 1px solid var(--line); touch-action: none; cursor: grab; }
.grab { position: absolute; left: 50%; top: 7px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: #D9D2C3; }
.sheet-head h2 { margin: 0; font: 800 21px/1.15 var(--head); word-break: break-word; }
.sheet-head p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.round { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--soft); font-size: 24px; line-height: 1; cursor: pointer; }
.sheet-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px calc(18px + var(--sr)) 18px calc(18px + var(--sl)); }
.sheet-body h3 { font: 800 15px/1.2 var(--head); margin: 18px 0 6px; }
.lead { font: 800 19px/1.3 var(--head); margin: 2px 0 10px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 12px; }
.stats div { background: #F7F2E7; border-radius: 12px; padding: 8px 4px; text-align: center; }
.stats b { display: block; font: 800 20px/1.1 var(--head); }
.stats span { font-size: 11px; color: var(--ink-2); }
.goal { background: #FFF3D6; border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.goal.done { text-align: center; font-weight: 800; }
.goal-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar { height: 10px; background: #F1DFB3; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--red)); border-radius: inherit; }
.chips-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.pill { font-size: 12px; font-weight: 800; background: #EFEAE0; color: #8A8474; border-radius: 999px; padding: 5px 10px; }
.pill small { margin-left: 4px; font-weight: 700; opacity: .7; }
.pill.on { background: #DDF1E3; color: #1D6B3F; }
.tag { font-size: 11px; font-weight: 800; border-radius: 6px; padding: 2px 6px; margin-left: 6px; vertical-align: 1px; }
.tag.gold { background: var(--gold); color: var(--ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.col { display: grid; gap: 8px; margin-top: 14px; }
.btn { flex: 1; display: inline-flex; gap: 8px; justify-content: center; align-items: center; text-decoration: none; border: 0; border-radius: 14px; min-height: 50px; padding: 10px 14px; font-weight: 800; background: var(--soft); color: var(--ink); cursor: pointer; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.main { background: var(--red); color: #fff; box-shadow: inset 0 -3px 0 var(--red-d); }
.btn.ig { width: 100%; margin: 10px 0 4px; background: var(--ig); color: #fff; font: 800 17px/1.1 var(--head); min-height: 54px; }
.btn.ig svg { width: 24px; height: 24px; }
.btn:disabled { opacity: .55; }
.link { border: 0; background: none; padding: 0; color: var(--red-d); font-weight: 800; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; align-items: center; gap: 4px; min-height: 46px; border-bottom: 1px solid var(--line); }
.people .link { text-decoration: none; color: var(--ink); padding: 10px 0; text-align: left; }
.people .fl { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.perks { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.perks li { padding: 8px 10px; border-radius: 10px; background: var(--soft); color: #8A8474; }
.perks li.on { background: #DDF1E3; color: #1D6B3F; }
.steps { padding-left: 20px; margin: 4px 0; }
.steps li { margin: 9px 0; }
.news { border-bottom: 1px solid var(--line); padding: 6px 0 12px; }
.news:last-child { border-bottom: 0; }
.news h3 { margin: 4px 0 4px; font-size: 18px; }
.news p { margin: 0 0 4px; }
.news-meta { font-size: 12px; color: var(--ink-2); }
.tag.red { background: var(--red); color: #fff; margin: 0 6px 0 0; }
.btn.heart { background: #FCE4EC; color: #AD1457; }
.btn.heart.big { width: 100%; background: linear-gradient(90deg, #F06292, #E0312B); color: #fff; min-height: 54px; font: 800 18px/1 var(--head); margin: 8px 0 2px; }
.pill.heart { background: #FCE4EC; color: #AD1457; }
.supporter { margin: -4px 0 8px; color: #AD1457; font-size: 14px; }
.goal.fund { background: #FCE4EC; }
.goal.fund .bar { background: #F8C6D8; }
.goal.fund .bar i { background: linear-gradient(90deg, #F06292, #E0312B); }
.lab.house.donor::before { content: '♥ '; color: #E91E63; }
.lab.house.mine.donor::before { color: #fff; }
.btn.ig-soft { background: #FBE9F1; color: #B1246A; }
.sponsor { font-size: 13px; background: #EEF4FB; border-radius: 10px; padding: 8px 10px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-weight: 800; font-size: 13px; }
.form input { border: 2px solid var(--line); border-radius: 13px; height: 50px; padding: 0 13px; background: #fff; outline: none; font-weight: 700; font-size: 16px; }
.form input:focus { border-color: var(--gold); }
.err { color: var(--red-d); font-weight: 800; margin: 0; }
.share-prev { display: grid; place-items: center; background: #EAF2F8; border-radius: 16px; aspect-ratio: 9 / 16; max-height: 42dvh; margin: 0 auto 4px; overflow: hidden; }
.share-prev img { width: 100%; height: 100%; object-fit: contain; -webkit-touch-callout: default; }

/* ---------- Toast, coach, modal, loading ---------- */
.toast { position: fixed; z-index: 9; left: 50%; top: calc(var(--top-h) + 16px + var(--st)); transform: translate(-50%, -8px); opacity: 0; transition: .25s; background: var(--ink); color: #fff; font-weight: 800; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); width: max-content; max-width: min(440px, calc(100% - 24px)); text-align: center; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.coach { left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h) + 22px + var(--sb)); margin: 0; width: max-content; max-width: calc(100% - 90px); background: rgba(29, 35, 48, .88); color: #fff; font-size: 13px; text-align: center; padding: 9px 14px; border-radius: 12px; pointer-events: none; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: end center; background: rgba(15, 25, 45, .45); padding: 0; }
.modal .card { background: var(--paper); border-radius: 24px 24px 0 0; padding: 24px calc(20px + var(--sr)) calc(20px + var(--sb)) calc(20px + var(--sl)); width: 100%; max-width: 520px; box-shadow: var(--shadow); text-align: center; }
.modal h1 { font: 800 25px/1.15 var(--head); margin: 0 0 10px; }
.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: linear-gradient(#6FA8DC, #1F6E99); color: #fff; font: 800 18px var(--head); transition: opacity .4s; }
.loading.gone { opacity: 0; pointer-events: none; }
.spin { width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin 1s linear infinite; }
.spin.dark { border-color: rgba(0,0,0,.1); border-top-color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; color: #fff; }
[hidden] { display: none !important; }

/* ---------- Small phones ---------- */
.pop-unit { display: none; }
@media (max-width: 560px) {
  .brand { padding: 0 7px; }
  .brand b { display: none; }
  .chips { flex-direction: column; gap: 3px; }
  .chip { height: 21px; padding: 0 8px; font-size: 11px; border-radius: 8px; justify-content: center; }
  .pop-label { display: none; }
  .pop-unit { display: inline; font-weight: 700; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .dock-tabs { display: none; }
  :root { --dock-h: 70px; }
  .sheet { max-height: 86dvh; }
}

/* ---------- Big screens: floating dock, sheet on the right ---------- */
@media (min-width: 1000px) {
  :root { --dock-h: 126px; }
  .dock { left: 50%; right: auto; bottom: calc(14px + var(--sb)); width: 460px; transform: translateX(-50%); border-radius: 20px; padding: 8px; }
  body.sheet-open .dock { transform: translateX(-50%); }
  body.sheet-open .turns { opacity: 1; pointer-events: auto; }
  .turns { bottom: calc(20px + var(--sb)); right: 430px; }
  .sheet { left: auto; right: 16px; bottom: auto; top: calc(var(--top-h) + 20px + var(--st)); width: 400px; max-height: calc(100dvh - 100px); border-radius: var(--radius); transform: translateX(110%); }
  .sheet.tall { max-height: calc(100dvh - 100px); }
  .sheet-head { cursor: default; }
  .grab { display: none; }
  .modal { place-items: center; padding: 16px; }
  .modal .card { border-radius: 24px; padding: 24px; }
  .coach { bottom: calc(var(--dock-h) + 30px); }
}
@media (min-width: 1000px) and (max-width: 1300px) { .turns { right: 16px; bottom: calc(var(--dock-h) + 30px); } body.sheet-open .turns { opacity: 0; } }
