*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body, div, h1, h2, h3, h4, input, span, button, select, p {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.01em;
}

body { background: #fff; color: #111; }

/* ── LAYOUT ── */
#main {
  display: flex;
  width: 100vw;
  height: 100dvh;
}

/* ── SIDEBAR ── */
#left {
  width: 380px;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid #e9e9e9;
}

#left-scroll {
  overflow-y: scroll;
  flex: 1;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#left-scroll::-webkit-scrollbar { display: none; }

#header {
  padding: 2.2rem 2rem 1.2rem;
  flex-shrink: 0;
}

#site-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: #111;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#title-animal { font-size: 2rem; font-weight: 700; line-height: 1.1; }
#title-bar    { font-size: 2rem; font-weight: 700; color: #ee352e; line-height: 1.1; }

#desc {
  margin-top: 10px;
  font-size: 0.9rem;
  color: #737373;
  line-height: 1.5;
}

/* ── FILTERS ── */
#filters {
  padding: 4px 2rem 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-label {
  font-size: 0.68rem; font-weight: 600; color: #aaa;
  text-transform: uppercase; letter-spacing: 0.08em;
}

.type-btns { display: flex; gap: 0; }
.type-btn {
  flex: 1; padding: 6px 8px; border: 1px solid #e9e9e9;
  background: #fff; color: #737373; cursor: pointer;
  font-size: 0.78rem; font-weight: 500;
  font-family: inherit; letter-spacing: -0.01em;
  transition: all 0.1s;
}
.type-btn:first-child { border-radius: 4px 0 0 4px; }
.type-btn:last-child  { border-radius: 0 4px 4px 0; border-left: none; }
.type-btn:not(:first-child):not(:last-child) { border-left: none; }
.type-btn:hover { background: #f5f5f5; color: #111; }
.type-btn.on-all    { background: #111; border-color: #111; color: #fff; }
.type-btn.on-bar    { background: #f97316; border-color: #f97316; color: #fff; }
.type-btn.on-rest   { background: #22c55e; border-color: #22c55e; color: #fff; }
.type-btn.on-coffee { background: #a0522d; border-color: #a0522d; color: #fff; }

#boro-select, #search-box {
  width: 100%; padding: 6px 9px;
  border: 1px solid #e9e9e9; border-radius: 4px;
  font-size: 0.8rem; font-family: inherit;
  color: #111; background: #fff; outline: none;
  appearance: none;
}
#boro-select:focus, #search-box:focus { border-color: #aaa; }
#search-box::placeholder { color: #bbb; }

/* ── STATS BAR ── */
#stats {
  padding: 9px 2rem;
  border-bottom: 1px solid #e9e9e9;
  flex-shrink: 0;
}

#stat-chips { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.chip {
  font-size: 0.65rem; font-weight: 600;
  padding: 1px 6px; border-radius: 20px;
  letter-spacing: 0.01em; white-space: nowrap;
}
.chip-bar    { background: #fff7ed; color: #f97316; }
.chip-rest   { background: #dcfce7; color: #16a34a; }
.chip-coffee { background: #f5ede8; color: #a0522d; }

/* ── LIST HEADER ── */
#list-bar {
  padding: 6px 2rem 5px;
  border-bottom: 1px solid #f5f5f5;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
#list-count { margin-right: auto; }
#list-count { font-size: 0.7rem; color: #bbb; }
#clear-btn {
  font-size: 0.7rem; color: #bbb; background: none; border: none;
  cursor: pointer; font-family: inherit; padding: 0;
}
#clear-btn:hover { color: #ee352e; }

/* ── TAB BAR ── */
#tab-bar {
  display: flex;
  flex-shrink: 0;
}
#tab-leaderboard { display: none; }

.tab {
  flex: 1; padding: 8px; border: none; background: none;
  font-family: inherit; font-size: 0.78rem; font-weight: 500;
  color: #aaa; cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.1s; letter-spacing: -0.01em;
}
.tab:hover { color: #111; }
.tab.active { color: #111; border-bottom-color: #111; }

/* ── LEADERBOARD ── */
.lb-header {
  padding: 1.2rem 2rem 0.6rem;
  font-size: 0.65rem; font-weight: 700; color: #aaa;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.lb-podium {
  border-bottom: 1px solid #e9e9e9;
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}
.lb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 2rem; border-bottom: 1px solid #f0f0f0;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.lb-top { background: #fafafa; }
.lb-row.lb-me { background: #fef9e7 !important; }
.lb-row.lb-filtered { background: #eff6ff !important; }
.lb-row:hover { background: #f5f5f5; }
.lb-filter-clear { font-size: 0.7rem; font-weight: 400; color: #3b82f6; cursor: pointer; margin-left: 6px; }
.lb-filter-clear:hover { text-decoration: underline; }
.lb-rank { width: 34px; flex-shrink: 0; text-align: center; }
.lb-medal { font-size: 1.5rem; line-height: 1; }
.lb-rank-num { font-size: 0.75rem; font-weight: 700; color: #ccc; }
.lb-user { flex: 1; font-weight: 600; color: #111; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row.lb-top .lb-user { font-size: 1rem; }
.lb-row:not(.lb-top) .lb-user { font-size: 0.88rem; }
.lb-count { font-size: 0.88rem; font-weight: 600; color: #555; white-space: nowrap; }
.lb-row.lb-top .lb-count { font-size: 0.95rem; }
.lb-empty { color: #bbb; font-size: 0.82rem; text-align: center; padding: 2rem 0; line-height: 1.8; }
.lb-offline { color: #bbb; font-size: 0.78rem; text-align: center; padding: 2rem 0; }
.lb-search-wrap { padding: 8px 1.2rem 4px; }
.lb-search { width: 100%; box-sizing: border-box; font-family: inherit; font-size: 0.78rem; padding: 5px 8px; border: 1px solid #e9e9e9; border-radius: 4px; outline: none; }
.lb-search:focus { border-color: #aaa; }
.lb-separator { border-top: 1px dashed #e9e9e9; margin: 4px 1.2rem; }
.lb-more { font-size: 0.72rem; color: #bbb; text-align: center; padding: 8px 0; }

/* ── FAQ ── */
#panel-faq { padding: 1.2rem 2rem 2rem; }
.faq-item { margin-bottom: 1.4rem; }
.faq-q {
  font-size: 0.82rem; font-weight: 600; color: #111;
  margin-bottom: 4px; line-height: 1.4;
}
.faq-a {
  font-size: 0.78rem; color: #737373; line-height: 1.6;
}
.faq-a a { color: #111; text-decoration: underline; text-underline-offset: 2px; }

/* ── NICKNAME MODAL ── */
#modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
#modal[hidden] { display: none; }
#modal-box {
  background: #fff; border-radius: 10px;
  padding: 2rem; width: 300px; box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; gap: 12px;
}
#modal-title { font-size: 1.1rem; font-weight: 600; color: #111; }
#modal-desc { font-size: 0.8rem; color: #737373; line-height: 1.5; }
#modal-input {
  width: 100%; padding: 8px 10px; border: 1px solid #e9e9e9;
  border-radius: 6px; font-family: inherit; font-size: 0.88rem;
  outline: none; color: #111;
}
#modal-input:focus { border-color: #aaa; }
#modal-join {
  padding: 9px; border: none; border-radius: 6px;
  background: #111; color: #fff; font-family: inherit;
  font-size: 0.88rem; font-weight: 500; cursor: pointer;
  transition: background 0.1s;
}
#modal-join:hover { background: #333; }
#modal-emoji-picker {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
#modal-emoji-picker button {
  font-size: 1.4rem; background: none; border: 2px solid transparent;
  border-radius: 8px; padding: 3px; cursor: pointer; line-height: 1;
  transition: border-color 0.1s, background 0.1s;
}
#modal-emoji-picker button:hover { background: #f5f5f5; }
#modal-emoji-picker button.selected { border-color: #111; background: #f5f5f5; }

#modal-logout {
  padding: 9px; border: 1px solid #e9e9e9; border-radius: 6px;
  background: #fff; color: #999; font-family: inherit;
  font-size: 0.88rem; font-weight: 500; cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
#modal-logout:hover { color: #ee352e; border-color: #ee352e; }

/* ── VENUE ROWS ── */
.venue-row {
  display: flex;
  padding: 11px 2rem;
  border-bottom: 1px solid #e9e9e9;
  gap: 18px;
  cursor: pointer;
  transition: background 0.1s;
  align-items: flex-start;
}
.venue-row:hover { background: #f7f7f7; }
.venue-row.is-checked .vname { text-decoration: line-through; color: #bbb; }
.venue-row.is-checked .vmeta { opacity: 0.4; }
.venue-row.is-hidden { display: none; }

.vcol-left {
  display: flex; flex-direction: column;
  align-items: center; width: 18px; min-width: 18px;
  padding-top: 3px;
}
.ember {
  width: 11px; height: 11px; border-radius: 50%;
  flex-shrink: 0; cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.ember-bar    { background: #f97316; }
.ember-rest   { background: #22c55e; }
.ember-coffee { background: #a0522d; }
.ember-visited { background: #ccc; }

.venue-row:hover .ember:not(.ember-visited) {
  transform: scale(1.4);
}
.venue-row:hover .ember:not(.ember-visited)::after {
  content: '✓'; font-size: 7px; font-weight: 700; color: #fff; line-height: 1;
}
.venue-row:hover .ember.ember-visited {
  background: #ee352e; transform: scale(1.4);
}
.venue-row:hover .ember.ember-visited::after {
  content: '×'; font-size: 8px; font-weight: 700; color: #fff; line-height: 1;
}

.vcol-right { flex: 1; min-width: 0; }
.vname {
  font-weight: 600; font-size: 0.88rem;
  color: #111; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vmeta { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; align-items: center; }

.tag {
  font-size: 0.66rem; padding: 1px 6px; border-radius: 3px;
  font-weight: 500; letter-spacing: 0.02em; white-space: nowrap;
  display: inline-block;
}
.tag-phrase { background: #f0f0f0; color: #555; font-style: italic; }
.tag-boro   { background: #f5f5f5; color: #999; }
.tag-visits { background: #eff6ff; color: #3b82f6; }
.tag-grade  { background: #fef9e7; color: #c8870a; font-weight: 600; }

/* ── MAP PANEL ── */
#right {
  flex: 1;
  height: 100%;
  position: relative;
}


/* ── AUTH MODAL ── */
#auth-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
#auth-modal[hidden] { display: none; }
#auth-box {
  background: #fff; border-radius: 12px; padding: 1.5rem;
  width: 300px; box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; gap: 10px;
}
.auth-title { font-size: 1rem; font-weight: 600; color: #111; }
.auth-desc { font-size: 0.78rem; color: #737373; line-height: 1.5; margin-top: -4px; }
.auth-desc[hidden] { display: none; }
#auth-tabs { display: flex; gap: 0; border-bottom: 1px solid #e9e9e9; margin-bottom: 4px; }
.auth-tab {
  flex: 1; padding: 8px; border: none; background: none;
  font-family: inherit; font-size: 0.82rem; font-weight: 500;
  color: #aaa; cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.1s; margin-bottom: -1px;
}
.auth-tab.active { color: #111; border-bottom-color: #111; }
#auth-username, #auth-password {
  width: 100%; padding: 8px 10px; border: 1px solid #e9e9e9;
  border-radius: 6px; font-family: inherit; font-size: 0.88rem;
  outline: none; color: #111;
}
#auth-username:focus, #auth-password:focus { border-color: #aaa; }
#auth-error {
  font-size: 0.78rem; color: #ee352e; padding: 2px 0;
}
#auth-error[hidden] { display: none; }
#auth-submit {
  padding: 9px; border: none; border-radius: 6px;
  background: #111; color: #fff; font-family: inherit;
  font-size: 0.88rem; font-weight: 500; cursor: pointer;
  transition: background 0.1s; margin-top: 2px;
}
#auth-submit:hover { background: #333; }
#auth-submit:disabled { background: #ccc; cursor: default; }

/* ── RESET VIEW BUTTON ── */
#reset-view {
  position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%);
  z-index: 10; background: #fff; border: none; border-radius: 20px;
  padding: 7px 16px; font-family: inherit; font-size: 0.78rem; font-weight: 500;
  color: #111; cursor: pointer; box-shadow: 0 2px 12px rgba(0,0,0,0.13);
  transition: box-shadow 0.1s, opacity 0.2s;
}
#reset-view:hover { box-shadow: 0 4px 18px rgba(0,0,0,0.18); }
#reset-view[hidden] { display: none; }

/* ── MAP CARD ── */
#map-card {
  position: absolute; z-index: 10;
  background: #fff; border-radius: 12px;
  padding: 13px 15px; min-width: 210px; max-width: 270px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  pointer-events: all;
}
#map-card[hidden] { display: none; }
#map-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#map-card-name { font-weight: 700; font-size: 0.9rem; color: #111; line-height: 1.3; }
#map-card-close {
  background: none; border: none; cursor: pointer;
  color: #bbb; font-size: 0.9rem; padding: 0; flex-shrink: 0;
  line-height: 1; margin-top: 1px;
}
#map-card-close:hover { color: #111; }
#map-card-meta { display: flex; gap: 5px; margin-bottom: 7px; }
#map-card-addr { font-size: 0.78rem; }

/* ── LEADERBOARD OVERLAY ── */
#lb-overlay {
  position: absolute; top: 48px; left: 48px; z-index: 10;
  background: #fff; border-radius: 20px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.13);
  overflow: hidden; min-width: 200px;
  user-select: none;
}
#lb-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; cursor: pointer;
  font-size: 0.88rem; font-weight: 600; color: #111;
  transition: background 0.1s;
}
#lb-toggle:hover { background: #f7f7f7; }
#lb-chevron { margin-left: auto; font-size: 1.1rem; color: #aaa; }
#lb-body { border-top: 1px solid #f0f0f0; max-height: 280px; overflow-y: auto; }
#lb-body .lb-header { padding: 0.7rem 1.2rem 0.3rem; }
#lb-body .lb-row { padding: 9px 1.2rem; }
#lb-body .lb-podium { border-bottom: 1px solid #f0f0f0; }

/* ── USER BADGE ── */
#user-badge {
  position: absolute; top: 48px; right: 48px; z-index: 10;
  background: #fff; border-radius: 20px;
  padding: 10px 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.13);
  display: flex; flex-direction: column; gap: 7px;
  cursor: pointer; transition: box-shadow 0.1s;
  user-select: none;
}
#user-badge:hover { box-shadow: 0 4px 22px rgba(0,0,0,0.18); }
#user-badge-main { display: flex; align-items: center; gap: 9px; }
#user-badge-emoji { font-size: 1.15rem; line-height: 1; }
#user-badge-name { font-weight: 600; color: #111; font-size: 0.92rem; }
#user-badge-count {
  background: #111; color: #fff;
  border-radius: 10px; padding: 2px 9px;
  font-size: 0.75rem; font-weight: 600;
}
#user-badge-breakdown { display: flex; flex-direction: column; gap: 4px; }
.badge-pill {
  font-size: 0.65rem; font-weight: 600; padding: 1px 7px;
  border-radius: 20px; white-space: nowrap;
}
.badge-pill-bar    { background: #fff7ed; color: #f97316; }
.badge-pill-rest   { background: #dcfce7; color: #16a34a; }
.badge-pill-coffee { background: #f5ede8; color: #a0522d; }

#map {
  width: 100%; height: 100%;
  overflow: hidden;
}

/* ── EMOJI MARKERS ── */
.emoji-marker {
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s, font-size 0.2s;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.emoji-marker:hover { transform: scale(1.3); }

/* ── MAPLIBRE OVERRIDES ── */
.maplibregl-popup-content {
  font-family: 'Inter', sans-serif;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 12px;
  max-width: 240px;
}
.maplibregl-popup-close-button {
  font-size: 16px; color: #aaa; padding: 6px 10px;
}
.maplibregl-popup-tip { border-top-color: #fff !important; }

.popup-name { font-weight: 600; font-size: 13px; color: #111; margin-bottom: 7px; line-height: 1.3; }
.popup-badges { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.popup-type { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 3px; letter-spacing: 0.04em; }
.popup-type-bar    { background: #fff7ed; color: #f97316; }
.popup-type-rest   { background: #dcfce7; color: #16a34a; }
.popup-type-coffee { background: #f5ede8; color: #a0522d; }
.popup-grade { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 3px; background: #fef9e7; color: #c8870a; }
.popup-phrase { font-size: 10px; padding: 2px 7px; border-radius: 3px; background: #f0f0f0; color: #555; font-style: italic; }
.popup-row { color: #737373; margin: 3px 0; font-size: 11px; line-height: 1.4; }
.popup-row span { color: #333; }
.maps-link { color: #3b82f6; text-decoration: none; margin-left: 4px; }
.maps-link:hover { text-decoration: underline; }

.maplibregl-ctrl-zoom-in, .maplibregl-ctrl-zoom-out, .maplibregl-ctrl-compass {
  font-family: 'Inter', sans-serif !important;
}
.maplibregl-ctrl-attrib { font-family: 'Inter', sans-serif; font-size: 10px; }

@media (max-width: 800px) {
  /* ── Layout ── */
  #main {
    flex-direction: column;
    height: auto;
  }
  #right {
    width: 100%;
    height: 70vw;
    min-height: 280px;
    max-height: 420px;
    flex-shrink: 0;
    order: 1;
    padding: 0;
  }
  #map { border-radius: 0; height: 70vw; min-height: 280px; max-height: 420px; }
  #lb-overlay { display: none; }
  #tab-leaderboard { display: block; }
  #left {
    width: 100%; min-width: 0; height: auto;
    display: flex; flex-direction: column;
    border-right: none;
    overflow: visible;
    order: 2;
  }
  #left-scroll {
    overflow: visible;
    height: auto;
    flex: none;
  }

  /* ── Header ── */
  #header { padding: 0.6rem 1.2rem 0.5rem; }
  #title-animal { font-size: 1.4rem; }
  #title-bar    { font-size: 1.4rem; }
  #desc { font-size: 0.82rem; }

  /* ── Filters ── */
  #filters { padding: 6px 1.2rem; flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: center; }
  .filter-group { flex-shrink: 0; }
  .filter-label { display: none; }
  .type-btn { padding: 5px 6px; font-size: 0.74rem; }
  #boro-select { font-size: 0.8rem; padding: 5px 8px; max-width: 130px; }
  #search-box { font-size: 0.8rem; padding: 5px 8px; flex: 1; min-width: 80px; }

  /* ── Stats ── */
  #stats { padding: 6px 1.2rem; }

  /* ── Tab bar ── */
  .tab { padding: 7px; font-size: 0.75rem; }

  /* ── List bar ── */
  #list-bar { padding: 5px 1.2rem; }

  /* ── Venue rows ── */
  .venue-row { padding: 10px 1.2rem; }
  .ember { width: 14px; height: 14px; }
  .venue-row:hover .ember:not(.ember-visited)::after,
  .venue-row:hover .ember.ember-visited::after { font-size: 9px; }

  /* ── Map overlays ── */
  #user-badge {
    top: 16px; right: 16px;
    padding: 7px 12px; gap: 7px;
    border-radius: 16px;
  }
  #user-badge-main { gap: 7px; }
  #user-badge-emoji { font-size: 1rem; }
  #user-badge-name  { font-size: 0.8rem; }
  #user-badge-count { font-size: 0.7rem; padding: 1px 7px; }
  #user-badge-breakdown { gap: 3px; }
  .badge-pill { font-size: 0.6rem; padding: 1px 6px; }

  #lb-overlay { top: 16px; left: 16px; min-width: 160px; }
  #lb-toggle  { padding: 8px 12px; font-size: 0.82rem; }
  #lb-body    { max-height: 200px; }
  #lb-body .lb-row { padding: 8px 1rem; }
  .lb-user    { font-size: 0.82rem; }

  #reset-view { bottom: 20px; padding: 6px 14px; font-size: 0.74rem; }

  /* ── Map card ── */
  #map-card {
    left: 10px !important; right: 10px !important;
    bottom: 14px !important; top: auto !important;
    max-width: none; min-width: 0; width: auto;
    border-radius: 10px;
  }

  /* ── Modals ── */
  #auth-box, #modal-box {
    width: calc(100vw - 40px);
    max-width: 360px;
  }
}
