:root {
  --amber-50: #fff8ee;
  --amber-100: #ffedd0;
  --amber-300: #ffcb7d;
  --amber-500: #f5940c;
  --amber-600: #d97706;
  --clay-800: #4a3324;
  --clay-600: #6b4d38;
  --clay-400: #a3805f;
  --sage-500: #7a9e6e;
  --rose-500: #e8637a;
  --ink: #2b1d14;
  --paper: #fffdf9;
  --card: #ffffff;
  --border: #eeddc4;
  --shadow: 0 2px 10px rgba(74, 51, 36, 0.08);
  --radius: 18px;
  font-family: -apple-system, "Segoe UI", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(180deg, var(--amber-50), var(--paper) 220px);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 26px; }
.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--clay-800);
}

.collector input {
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  width: 140px;
  color: var(--ink);
}
.collector input:focus { outline: none; border-color: var(--amber-500); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px 16px 16px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: var(--clay-400);
  cursor: pointer;
}
.tab.active { background: var(--clay-800); color: var(--amber-50); }

#app { padding: 0 16px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.venue-row { display: flex; align-items: center; gap: 12px; }
.venue-emoji {
  font-size: 30px;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--amber-100);
  border-radius: 14px;
  flex-shrink: 0;
}
.venue-body { flex: 1; min-width: 0; }
.venue-name { font-weight: 800; font-size: 16px; color: var(--clay-800); }
.venue-meta { font-size: 13px; color: var(--clay-400); margin-top: 2px; }
.venue-desc { font-size: 13px; color: var(--clay-600); margin-top: 4px; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 6px;
}
.pill.in-range { background: #e7f4e2; color: var(--sage-500); }
.pill.out-range { background: #f4ece0; color: var(--clay-400); }

button.primary {
  background: var(--amber-500);
  color: white;
  border: none;
  font-weight: 800;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
}
button.primary:disabled { background: var(--amber-300); cursor: default; }
button.secondary {
  background: var(--amber-100);
  color: var(--clay-800);
  border: none;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
button.danger { background: #fbe3e6; color: var(--rose-500); border: none; font-weight: 700; padding: 8px 12px; border-radius: 10px; cursor: pointer; }

.checkin-bar { position: sticky; top: 0; padding: 10px 0 16px; background: linear-gradient(180deg, var(--amber-50) 60%, transparent); z-index: 5; }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.sticker {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
}
.sticker .emoji { font-size: 34px; display: block; }
.sticker .name { font-size: 11px; font-weight: 700; color: var(--clay-800); margin-top: 4px; }
.sticker.locked { opacity: 0.45; }
.sticker.locked .emoji { filter: grayscale(1); }
.rarity {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
  margin-top: 2px;
}
.rarity.common { color: var(--clay-400); }
.rarity.uncommon { color: var(--sage-500); }
.rarity.rare { color: var(--amber-600); }
.rarity.legendary { color: var(--rose-500); }

.empty { text-align: center; color: var(--clay-400); padding: 40px 20px; font-size: 14px; }

.section-title { font-weight: 800; color: var(--clay-800); font-size: 15px; margin: 18px 0 8px; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--clay-600); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

.sticker-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--amber-50);
  border-radius: 10px;
  padding: 6px 10px;
  margin-top: 6px;
  font-size: 13px;
}
.sticker-chip .sp { flex: 1; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--clay-800);
  color: var(--amber-50);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.unlock-banner {
  background: linear-gradient(135deg, var(--amber-500), var(--rose-500));
  color: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  font-weight: 700;
}
.unlock-banner .headline { font-size: 15px; margin-bottom: 8px; }

/* ---------- auth ---------- */
.account { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); }
.linkish { background: none; border: none; color: var(--clay-400); font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px; }

.login { text-align: center; padding: 48px 20px; max-width: 380px; margin: 0 auto; }
.login-mark { font-size: 56px; }
.login-title { font-size: 30px; font-weight: 800; margin: 6px 0 4px; color: var(--clay-800); letter-spacing: -0.02em; }
.login-sub { color: var(--clay-600); font-size: 14px; line-height: 1.5; margin-bottom: 26px; }
.login-btn { display: block; text-decoration: none; text-align: center; }
.card.warn { background: #fff6e6; border-color: var(--amber-300); text-align: left; font-size: 13px; color: var(--clay-600); }
.card.warn p { margin: 6px 0 0; }

/* ---------- shared ---------- */
button.block, label.block { display: block; width: 100%; text-align: center; margin-top: 10px; cursor: pointer; }
button.small { padding: 6px 12px; font-size: 12px; margin-top: 10px; }
.file-input { display: none; }
.note { font-size: 12px; color: var(--clay-400); margin-top: 8px; line-height: 1.45; }
.summary { text-align: center; font-weight: 800; color: var(--clay-800); }

/* ---------- drops ---------- */
.drop-row { display: flex; gap: 12px; align-items: flex-start; }
.thumb {
  width: 68px; height: 68px; flex-shrink: 0;
  border-radius: 14px; overflow: hidden;
  background: var(--amber-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.locked { opacity: 0.6; }
.drop-body { flex: 1; min-width: 0; }
.drop-name { font-weight: 800; font-size: 16px; color: var(--clay-800); }
.drop-meta { font-size: 12px; color: var(--clay-400); margin-top: 2px; }
.drop-desc { font-size: 13px; color: var(--clay-600); margin-top: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill.mine { background: var(--amber-100); color: var(--amber-600); }

/* ---------- collection grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cell { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 10px; text-align: center; }
.cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.cell-name { font-size: 13px; font-weight: 700; color: var(--clay-800); margin-top: 6px; }

/* ---------- add flow ---------- */
.preview { width: 100%; border-radius: 14px; display: block; }
.confirm { background: #fff6e6; border: 2px dashed var(--amber-300); border-radius: 14px; padding: 14px; }
.confirm-title { font-weight: 800; color: var(--clay-800); font-size: 14px; }
.confirm-coords { font-family: ui-monospace, Menlo, monospace; font-size: 17px; color: var(--amber-600); margin: 8px 0 4px; font-weight: 700; }
.confirm-sub { font-size: 13px; color: var(--clay-600); }
.confirm-btns { display: flex; gap: 8px; margin-top: 12px; }
.confirm-btns button { flex: 1; margin-top: 0; }
.coord-set { font-family: ui-monospace, Menlo, monospace; font-size: 16px; font-weight: 700; color: var(--clay-800); }
.manual { margin-top: 12px; font-size: 13px; color: var(--clay-600); }
.manual summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

/* ---------- map ---------- */
body.map-mode { overflow: hidden; padding-bottom: 0; }
body.map-mode #app { padding: 0; max-width: none; }

.map-wrap { position: relative; }
.map-stage {
  position: relative;
  height: calc(100vh - 124px);
  height: calc(100dvh - 124px);
  min-height: 320px;
  border-radius: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--amber-50);
}
.map-canvas { display: block; touch-action: none; cursor: grab; }
.map-canvas:active { cursor: grabbing; }

.map-controls {
  position: absolute;
  top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.map-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.94);
  border-radius: 12px;
  font-size: 17px; font-weight: 800;
  color: var(--clay-800);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.map-btn:active { background: var(--amber-100); }

.map-legend {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--clay-600);
  pointer-events: none;
}

.map-checkin {
  position: absolute;
  left: 16px; right: 16px; bottom: 16px;
  width: auto;
  box-shadow: 0 4px 16px rgba(74,51,36,0.25);
}

/* ---------- detail sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(43,29,20,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 40;
  animation: fade 0.16s ease;
}
.sheet {
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 18px;
  width: 100%; max-width: 640px;
  animation: slideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 84vh; overflow-y: auto;
}
.sheet-img { width: 100%; border-radius: 16px; display: block; max-height: 44vh; object-fit: cover; }
.sheet-locked {
  height: 140px; border-radius: 16px;
  background: var(--amber-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; opacity: 0.6;
}
.sheet-name { font-size: 20px; font-weight: 800; color: var(--clay-800); margin-top: 12px; }
.sheet-desc { font-size: 14px; color: var(--clay-600); line-height: 1.5; margin: 8px 0 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } }
