:root {
  --bg: #0b1026;
  --panel: rgba(16, 22, 52, 0.96);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f1ea;
  --muted: #a9b0cf;
  --red: #e2433b;
  --gold: #f5c451;
  --green: #5fd39a;
  --violet: #b9a6ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); }
.leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(0.8) saturate(0.5); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom { bottom: calc(env(safe-area-inset-bottom) + 64px); }

/* ---------- 頂部 ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 500; pointer-events: none;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 16px;
  background: linear-gradient(var(--bg) 60%, rgba(11,16,38,0)); }
.top > * { pointer-events: auto; }
.top .row { display: flex; align-items: center; justify-content: space-between; max-width: 560px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 20px; letter-spacing: 1px; }
.pill { border: 1px solid rgba(245,196,81,0.4); background: rgba(245,196,81,0.12); color: var(--gold);
  border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; overflow-x: auto; max-width: 560px; margin: 10px auto 0; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: rgba(255,255,255,0.06); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; opacity: 0.5; }
.chips button[aria-pressed="true"] { opacity: 1; background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); }
.event { display: block; max-width: 560px; margin: 8px auto 0; padding: 8px 12px; border-radius: 12px; font-size: 13px;
  background: rgba(226,67,59,0.2); border: 1px solid rgba(226,67,59,0.5); color: #ffd9d6; text-decoration: none; }
.gps-note { max-width: 560px; margin: 6px auto 0; font-size: 12px; color: var(--muted); min-height: 1em; text-align: center; }

/* ---------- 地圖標記 ---------- */
.pin { position: relative; display: flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 50%; font-size: 20px; background: rgba(16,22,52,0.85); border: 2px solid rgba(255,255,255,0.35);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.pin b { position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); font-size: 10px; line-height: 1;
  background: var(--gold); color: #2a1a00; border-radius: 999px; padding: 2px 5px; white-space: nowrap; }
.pin-quest { border-color: var(--gold); }
.pin-wish { border-color: var(--green); }
.pin-ghost { border-color: var(--violet); }
.pin-bottle { border-color: #7cc7ff; animation: bob 3s ease-in-out infinite; }
.pin.locked { filter: grayscale(0.6); }
.pin.done { opacity: 0.55; border-style: dashed; }
.pin.glow { box-shadow: 0 0 0 4px rgba(245,196,81,0.25), 0 0 22px 6px rgba(245,196,81,0.7); }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
.me-icon { width: 16px; height: 16px; border-radius: 50%; background: #4aa3ff; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(74,163,255,0.3); }

/* ---------- 底部 ---------- */
.fab { position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 80px); z-index: 500;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  font-size: 20px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; display: flex; justify-content: center; gap: 8px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); background: var(--panel); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; max-width: 170px; border: 0; background: transparent; padding: 10px 6px; border-radius: 12px;
  font-size: 15px; cursor: pointer; }
.tabbar .primary { background: var(--red); color: #fff; font-weight: 700; }

/* ---------- 抽屜 ---------- */
.sheet { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); animation: up 0.18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-close { position: absolute; top: 10px; right: 10px; border: 0; background: rgba(255,255,255,0.08);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.sheet h2 { margin: 0 36px 4px 0; font-size: 20px; line-height: 1.35; }
.sheet h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.meta { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.1); margin-right: 4px; }
.tag.gold { background: rgba(245,196,81,0.18); color: var(--gold); }
.body { white-space: pre-wrap; line-height: 1.7; font-size: 15px; margin: 10px 0; }
.locked-box { padding: 14px; border-radius: 12px; border: 1px dashed rgba(185,166,255,0.5); background: rgba(185,166,255,0.1);
  color: #ddd6ff; font-size: 14px; line-height: 1.6; text-align: center; }
.status { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.06); font-size: 14px; margin: 10px 0; line-height: 1.6; }
.proof img { width: 100%; border-radius: 12px; display: block; margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { border: 0; border-radius: 999px; padding: 10px 16px; font-size: 15px; font-weight: 600;
  background: var(--red); color: #fff; cursor: pointer; }
.btn.gold { background: var(--gold); color: #2a1a00; }
.btn.ghost { background: rgba(255,255,255,0.1); color: var(--text); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 4px 0; }

/* 表單 */
.kinds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kinds button { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,0.05); border-radius: 14px;
  padding: 10px; cursor: pointer; }
.kinds button[aria-pressed="true"] { border-color: var(--gold); background: rgba(245,196,81,0.12); }
.kinds b { display: block; font-size: 15px; }
.kinds small { color: var(--muted); font-size: 12px; line-height: 1.4; }
label.field { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }
.field input, .field textarea, .field select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); font-size: 16px; }
.field textarea { min-height: 90px; resize: vertical; }
.field select option { color: #000; }
.rules { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 12px 0 0; padding-left: 18px; }

/* 列表 */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li .ic { font-size: 22px; }
.list li .tx { flex: 1; min-width: 0; }
.list li .tx div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .tx small { color: var(--muted); font-size: 12px; }
.list li .rt { font-size: 13px; color: var(--gold); white-space: nowrap; }
.ledger li { cursor: default; font-size: 13px; }
.plus { color: var(--green); } .minus { color: #ff8a80; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stats div { text-align: center; padding: 10px 4px; border-radius: 12px; background: rgba(255,255,255,0.06); }
.stats b { display: block; font-size: 20px; }
.stats small { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 16px; }

.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); transform: translateX(-50%);
  z-index: 2000; background: rgba(0,0,0,0.85); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: 90vw; text-align: center; }
.dev-hint { position: fixed; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 500;
  font-size: 11px; background: rgba(0,0,0,0.6); padding: 4px 8px; border-radius: 8px; color: var(--gold); }
