:root {
  /* Brand colors, taken from the @chip.bagger logo */
  --navy: #334788;
  --navy-strong: #24336a;
  --orange: #f4a641;
  --orange-soft: #fde9cc;

  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #eceff7;
  --text: #1c2340;
  --muted: #5d6585;
  --border: #d9deeb;
  --accent: var(--navy);
  --accent-strong: var(--navy);
  --on-accent: #ffffff;
  --highlight: var(--orange);
  --collect: var(--navy);
  --curb: var(--orange);
  --on-collect: #ffffff;
  --on-curb: #1c2340;
  --overall: #7b8cc8;
  --gold: #f4a641;
  --silver: #c3c8d6;
  --bronze: #cf8b5a;
  --map-water: #dfe6f4;
  --map-land: #ffffff;
  --map-border: #9aa6cc;
  --shadow: 0 1px 2px rgba(28, 35, 64, .06), 0 4px 14px rgba(28, 35, 64, .08);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy-strong: #0d1430;
    --bg: #10152b;
    --surface: #182041;
    --surface-2: #222c55;
    --text: #eef1fa;
    --muted: #a3acc9;
    --border: #2d3866;
    --accent: #f4a641;
    --accent-strong: #f8bd6c;
    --on-accent: #1c2340;
    --collect: #8fa2e6;
    --on-collect: #10152b;
    --on-curb: #1c2340;
    --overall: #b7c2ec;
    --map-water: #0d1226;
    --map-land: #222c55;
    --map-border: #46538a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.15rem; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 4px; font-size: .9em; }
button { font: inherit; color: inherit; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 3px solid var(--highlight);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo-mark { width: 36px; height: 36px; display: block; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600;
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.1; color: var(--accent-strong); }
.stat span { color: var(--muted); font-size: .9rem; }

/* toolbar */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar input, .toolbar select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
.toolbar input { flex: 1 1 240px; min-width: 0; }
.toolbar select { flex: 0 1 auto; max-width: 100%; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 40px; }
.card {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(28, 35, 64, .16); border-color: var(--highlight); outline: none; }
.card-img { aspect-ratio: 3 / 4; background: var(--surface-2); overflow: hidden; }
.card-img img, .card-img .img-missing { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-missing { display: grid; place-items: center; font-size: 2rem; background: var(--surface-2); }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card-brand { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-strong); font-weight: 700; }
.card-flavor { font-weight: 700; line-height: 1.25; }
.card-notes { font-size: .82rem; color: var(--muted); }
.card-scores { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.pill { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.pill-label { font-weight: 500; opacity: .9; }
.pill-collect { background: var(--collect); color: var(--on-collect); }
.pill-curb { background: var(--curb); color: var(--on-curb); }
.pill-empty { background: transparent; color: var(--muted); border: 1px dashed var(--border); }

/* dialog */
.bag-dialog {
  border: none; border-radius: 18px; padding: 0; width: min(760px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.bag-dialog::backdrop { background: rgba(16, 21, 43, .6); }
.dialog-close { position: absolute; top: 8px; right: 8px; margin: 0; z-index: 2; }
.dialog-close button {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer; font-size: 1.4rem; line-height: 1;
  background: var(--surface-2); color: var(--text);
}
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.detail-img { background: var(--surface-2); }
.detail-img img, .detail-img .img-missing { width: 100%; height: 100%; max-height: 80vh; object-fit: contain; display: block; min-height: 260px; }
.detail-body { padding: 24px; }
.detail-body h2 { font-size: 1.5rem; margin: 2px 0 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 18px 0; align-items: center; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; font-weight: 600; }
.scorebar { display: flex; align-items: center; gap: 10px; }
.scorebar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.scorebar-fill { display: block; height: 100%; border-radius: 999px; }
.scorebar-num { font-size: .85rem; min-width: 64px; }
.bar-collect { background: var(--collect); }
.bar-curb { background: var(--curb); }
.bar-overall { background: var(--overall); }

/* leaderboard */
.board-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.board-head p { margin: 0; }
.notice { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--highlight); border-radius: 10px; padding: 10px 14px; }
.score-guide { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-size: .9rem; }
.detail-body .score-guide { margin: 0 0 16px; }
.score-guide summary { cursor: pointer; font-weight: 700; }
.score-guide[open] summary { margin-bottom: 8px; }
.guide-term h3 { font-size: 1rem; margin: 10px 0 2px; }
.guide-term p { margin: 0 0 4px; }
.guide-term ul { margin: 0; padding-left: 20px; }
.boards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.board { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.brand-board { margin-bottom: 40px; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.rank {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; background: var(--surface-2); color: var(--muted);
}
.rank-1 { background: var(--gold); color: #1c2340; }
.rank-2 { background: var(--silver); color: #222; }
.rank-3 { background: var(--bronze); color: #1c2340; }
.board-bag { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px; border: none; background: none; cursor: pointer; text-align: left; border-radius: 8px; }
.board-bag:hover { background: var(--surface-2); }
.thumb { width: 34px; height: 46px; object-fit: cover; border-radius: 5px; flex: none; }
div.thumb { display: grid; place-items: center; font-size: 1rem; }
.board-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.board-name strong { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-strong); }
.board-name span { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-score { display: flex; align-items: center; gap: 8px; }
.board-score b { min-width: 26px; text-align: right; }
.mini-track { width: 54px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.mini-fill { display: block; height: 100%; }
.board-more { text-align: center; padding-top: 4px; }
.empty { color: var(--muted); font-size: .9rem; padding: 8px 0; }
.link { background: none; border: none; color: var(--accent-strong); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }

/* map */
.chip-map { height: min(62vh, 560px); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); background: var(--surface-2); z-index: 0; }
.place-list { margin: 20px 0 40px; }
.places { columns: 2 280px; padding-left: 18px; margin: 0 0 12px; }
.places li { break-inside: avoid; margin-bottom: 4px; }
.popup strong { font-size: 1rem; }
.popup-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 6px; }
.popup-bag { padding: 0; border: none; background: none; cursor: pointer; }
.popup-bag .thumb { width: 100%; height: 48px; }
.leaflet-container { font: inherit; }

.site-footer { padding: 24px 16px 40px; text-align: center; }
.site-footer a { color: var(--accent-strong); font-weight: 600; }

/* instagram */
.ig-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 1.5px solid var(--accent); color: var(--accent-strong); font-weight: 700; text-decoration: none; font-size: .92rem;
}
.ig-link:hover { background: var(--accent); color: var(--on-accent); }
.ig-icon { width: 18px; height: 18px; flex: none; }

@media (max-width: 900px) {
  .boards { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .detail { grid-template-columns: 1fr; }
  .detail-img img { max-height: 46vh; }
  .header-inner { padding-top: 8px; padding-bottom: 8px; }
  .tabs a { padding: 6px 10px; font-size: .92rem; }
  .ig-handle { display: none; }
  .logo { margin-right: auto; }
  .tabs { order: 3; width: 100%; }
  .ig-link { padding: 7px; }
}
