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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f1923;
  color: white;
}

/* Map page needs a fixed full-viewport flex column so the map fills remaining height */
body.page-map {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Site Nav ── */
.site-nav {
  display: flex;
  align-items: center;
  background: #0f2d4a;
  border-bottom: 2px solid #1a4a6e;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 1001;
}

.otter-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.popup-otter-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 3px;
  margin-top: -2px;
}

.site-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  letter-spacing: 0.01em;
  padding: 13px 0;
  margin-right: 24px;
  white-space: nowrap;
}

.site-nav .nav-links {
  display: flex;
  align-items: center;
  list-style: none;
  flex: 1;
}

.site-nav .nav-links a {
  display: block;
  padding: 15px 14px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px; /* aligns active underline flush with nav border */
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.site-nav .nav-links a:hover {
  color: white;
}

.site-nav .nav-links a.active {
  color: white;
  border-bottom-color: #2e86c1;
  font-weight: 600;
}

/* ── Map page toolbar (below nav) ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #0a2035;
  border-bottom: 1px solid #1a4a6e;
  z-index: 1000;
  flex-shrink: 0;
}

#new-sightings-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 20px;
  background: rgba(240, 165, 0, 0.12);
  border-bottom: 1px solid rgba(240, 165, 0, 0.28);
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.88);
  flex-shrink: 0;
  z-index: 999;
}
#new-sightings-banner.hidden { display: none; }
#new-sightings-banner strong { color: #f0a500; }
.banner-dismiss {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.banner-dismiss:hover { color: rgba(255, 255, 255, 0.75); }

.banner-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.banner-view {
  background: none;
  border: 1px solid rgba(240, 165, 0, 0.4);
  color: #f0a500;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 4px;
}
.banner-view:hover { background: rgba(240, 165, 0, 0.1); }

#new-sightings-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(10, 32, 53, 0.97);
  border-bottom: 1px solid rgba(240, 165, 0, 0.2);
  max-height: 220px;
  overflow-y: auto;
  flex-shrink: 0;
}
#new-sightings-list.hidden { display: none; }

#controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

#status {
  font-size: 0.82rem;
  opacity: 0.75;
}

#refresh-btn {
  padding: 6px 16px;
  background: #2e86c1;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s;
}

#refresh-btn:hover {
  background: #1a6fa0;
}

#refresh-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Info icon with CSS tooltip ── */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  font-size: 0.7rem;
  font-style: normal;
  cursor: default;
  position: relative;
  flex-shrink: 0;
  user-select: none;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #0f2d4a;
  border: 1px solid #1a4a6e;
  color: rgba(255, 255, 255, 0.88);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  line-height: 1.5;
  width: 230px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}

.info-icon:hover::after {
  opacity: 1;
}

/* ── Filter group (date + region + limit) ── */
#filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

/* ── Date / region / limit filters ── */
#date-filter,
#region-filter,
#limit-filter {
  display: flex;
  align-items: center;
  gap: 4px;
}

.date-btn {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  color: white;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}

.date-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.date-btn.active {
  background: #2e86c1;
  border-color: #2e86c1;
  font-weight: 600;
}

/* ── Sources panel ── */
#sources {
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.source-chip:hover {
  background: rgba(255, 255, 255, 0.14);
}

.source-chip input[type="checkbox"] {
  display: none;
}

.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Dim chip when its source is unchecked */
.source-chip:has(input:not(:checked)) {
  opacity: 0.4;
}

/* ── Map ── */
#map-wrapper {
  flex: 1;
  position: relative;
}

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

/* ── Species legend ── */
#species-legend {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 1000;
  background: rgba(10, 28, 46, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  padding: 8px 12px;
  pointer-events: auto;
  min-width: 170px;
}

#species-legend.hidden { display: none; }

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 2px 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  user-select: none;
}
.legend-header:hover { color: rgba(255, 255, 255, 0.9); }
.legend-chevron { font-size: 0.68rem; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 4px;
  margin: 0 -4px;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.15s;
}

.legend-row:hover { background: rgba(255, 255, 255, 0.08); }

.legend-row-active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-weight: 600;
}

.legend-row-active:hover { background: rgba(255, 255, 255, 0.14); }

.legend-row-dim { opacity: 0.38; }

.legend-clear {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  padding-bottom: 5px;
  margin-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-count {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.68rem;
}

.recent-badge-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  min-width: 0;
}

.recent-species {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ── Sightings overlay panels ── */
#sightings-panels {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.sightings-panel {
  width: 250px;
  background: rgba(10, 28, 46, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  overflow: hidden;
  pointer-events: auto;
}

.recent-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
}

.recent-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.panel-chevron {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: 0.4;
  transition: transform 0.2s;
}

/* Cards shown only when 1 other panel is collapsed */
.recent-card.extra-1 { display: none; }
.sightings-panel.expanded .recent-card.extra-1,
.sightings-panel.super-expanded .recent-card.extra-1 { display: flex; }

/* Cards shown only when 2 other panels are collapsed */
.recent-card.extra-2 { display: none; }
.sightings-panel.super-expanded .recent-card.extra-2 { display: flex; }

.sightings-panel.collapsed .recent-card { display: none; }
.sightings-panel.collapsed .recent-header { border-bottom: none; }
.sightings-panel.collapsed .panel-chevron { transform: rotate(-90deg); }

.recent-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 12px;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.recent-card:last-child {
  border-bottom: none;
}

.recent-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.recent-photo {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
}

.recent-photo-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.recent-info {
  flex: 1;
  min-width: 0;
}

.recent-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f0a500;
  background: rgba(240, 165, 0, 0.15);
  border: 1px solid rgba(240, 165, 0, 0.35);
  border-radius: 3px;
  padding: 1px 5px;
  margin-bottom: 3px;
}

.rare-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2ec4b6;
  background: rgba(46, 196, 182, 0.12);
  border: 1px solid rgba(46, 196, 182, 0.35);
  border-radius: 3px;
  padding: 1px 5px;
  margin-bottom: 3px;
}

.hot-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 3px;
  padding: 1px 5px;
  margin-bottom: 3px;
}

.fav-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #f472b6;
  background: rgba(244, 114, 182, 0.12);
  border: 1px solid rgba(244, 114, 182, 0.35);
  border-radius: 3px;
  padding: 1px 5px;
  margin-bottom: 3px;
}

/* Heart SVG icon */
.heart-icon {
  width: 1em;
  height: 1em;
  vertical-align: middle;
}

/* Favorite button on sighting cards */
.fav-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  z-index: 1;
  transition: color 0.15s;
}
.fav-btn:hover { color: #f472b6; }
.fav-btn.fav-active { color: #f472b6; }

/* Favorite button in map popups */
.popup-fav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  background: rgba(244, 114, 182, 0.08);
  border: 1px solid rgba(244, 114, 182, 0.4);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 10px;
  margin-top: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.popup-fav-btn:hover { color: #f472b6; border-color: #f472b6; background: rgba(244, 114, 182, 0.1); }
.popup-fav-btn.fav-active { color: #f472b6; border-color: #f472b6; background: rgba(244, 114, 182, 0.08); }

/* Favorites popup panel */
.fav-popup {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1100;
  background: rgba(10, 28, 46, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  width: 280px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.78rem;
}
.fav-popup.hidden { display: none; }

.fav-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f472b6;
}

.fav-popup-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
}
.fav-popup-close:hover { color: white; }

.favorites-empty {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.35);
  padding: 14px;
  font-style: italic;
  text-align: center;
}

.recent-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-place {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

@media (max-width: 640px) {
  #sightings-panels {
    display: none;
  }
}

/* ── Popup ── */
.leaflet-popup-content-wrapper {
  background: rgba(10, 28, 46, 0.95);
  backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.88);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-tip {
  background: rgba(10, 28, 46, 0.95);
}

.leaflet-popup-close-button {
  color: rgba(255, 255, 255, 0.5) !important;
}
.leaflet-popup-close-button:hover {
  color: white !important;
}

.popup-content {
  max-width: 230px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.popup-content img {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 8px;
  display: block;
}

.popup-content .popup-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 5px;
  color: white;
}

.popup-content .popup-meta {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

.popup-content .popup-link {
  display: inline-block;
  margin-top: 7px;
  font-size: 0.8rem;
  color: #4a9eed;
  text-decoration: none;
  font-weight: 500;
}

.popup-content .popup-link:hover {
  text-decoration: underline;
  color: #6bb5f5;
}

.popup-source-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin: 0 2px;
}

.popup-obscured {
  color: #f0a500;
  font-size: 0.75rem;
}

/* Popup button row */
.popup-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.popup-btn-row .popup-fav-btn,
.popup-btn-row .popup-share-btn {
  flex: 1;
  margin-top: 0;
}

.popup-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(74, 158, 237, 0.08);
  border: 1px solid rgba(74, 158, 237, 0.35);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.popup-share-btn:hover {
  color: #4a9eed;
  border-color: #4a9eed;
  background: rgba(74, 158, 237, 0.15);
}

/* Share button on sighting cards */
.share-btn {
  position: absolute;
  bottom: 28px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  z-index: 1;
}
.share-btn:hover { opacity: 0.9; }

.share-icon {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
  opacity: 0.35;
  transition: opacity 0.15s;
}
.share-btn:hover .share-icon { opacity: 0.8; }

.share-icon-popup {
  width: 12px !important;
  height: 15px;
  filter: brightness(0) invert(1);
  opacity: 0.85;
  margin-bottom: 0px !important;
}

/* Share toast */
#share-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(10, 28, 46, 0.92);
  backdrop-filter: blur(10px);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10000;
}
#share-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Content pages (about, contribute) ── */
.content-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.content-main h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: white;
}

.content-main h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 48px 0 14px;
  color: white;
  padding-bottom: 10px;
  border-bottom: 1px solid #1a4a6e;
}

.content-main p {
  font-size: 0.975rem;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 14px;
}

.content-main ul,
.content-main ol {
  padding-left: 1.5em;
  margin-bottom: 14px;
}

.content-main li {
  font-size: 0.975rem;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 6px;
}

.content-main a {
  color: #4a9eed;
  text-decoration: none;
}

.content-main a:hover {
  text-decoration: underline;
}

/* ── Fact grid (about page) ── */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 20px 0 40px;
}

.fact-card {
  background: #0f2d4a;
  border: 1px solid #1a4a6e;
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
}

.fact-card .fact-number {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  color: #4a9eed;
  line-height: 1.1;
  margin-bottom: 6px;
}

.fact-card .fact-label {
  display: block;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── CTA cards (contribute page) ── */
.cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin: 20px 0 32px;
}

.cta-card {
  background: #0f2d4a;
  border: 1px solid #1a4a6e;
  border-radius: 10px;
  padding: 28px 24px;
}

.cta-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: white;
}

.cta-card p {
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.cta-card ul,
.cta-card ol {
  padding-left: 0;
  margin-bottom: 20px;
}

.cta-card li {
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.cta-steps {
  list-style: none;
}

.cta-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
}

.cta-steps li::before {
  content: attr(data-step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: #2e86c1;
  color: white;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.btn-primary {
  display: inline-block;
  padding: 9px 20px;
  background: #2e86c1;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #1a6fa0;
  text-decoration: none;
}

/* ── Callout box ── */
.callout {
  background: rgba(46, 134, 193, 0.1);
  border-left: 3px solid #2e86c1;
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin: 20px 0;
}

.callout p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.88);
}

/* ── Site footer ── */
.site-footer {
  margin-top: 48px;
  padding: 20px 24px;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.35);
  border-top: 1px solid #1a4a6e;
}

.site-footer a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
}

.site-footer a:hover {
  color: rgba(255, 255, 255, 0.8);
}

/* ── Mobile responsive ── */
@media (max-width: 640px) {

  /* Nav: hide site title so all three links fit on one row */
  .nav-title {
    display: none;
  }

  .site-nav {
    padding: 0 12px;
  }

  .site-nav .nav-logo {
    margin-right: 10px;
    padding: 10px 0;
  }

  .site-nav .nav-links a {
    padding: 12px 8px;
    font-size: 0.78rem;
  }

  /* Map header: filter-group takes full width, sources + controls share next row */
  #header {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  #filter-group {
    flex: none;
    width: 100%;
    flex-wrap: wrap;
    gap: 5px;
  }

  /* Hide vertical separators — buttons wrap naturally on mobile */
  .filter-sep {
    display: none;
  }

  /* Slightly larger tap targets */
  .date-btn {
    padding: 6px 12px;
  }

  #sources {
    flex: 1;
  }

  #controls {
    flex: none;
  }

  /* Status text: keep but truncate if too long */
  #status {
    font-size: 0.75rem;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Tooltip: also show on tap via focus */
  .info-icon:focus::after {
    opacity: 1;
  }

  /* Content pages */
  .content-main {
    padding: 28px 16px 48px;
  }

  .content-main h1 {
    font-size: 1.6rem;
  }

  .content-main h2 {
    font-size: 1.15rem;
    margin-top: 32px;
  }

  .fact-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cta-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Gamification ─────────────────────────────────────────────────────────── */

/* Streak indicator */
.streak-indicator {
  font-size: 0.78rem;
  color: #f0a500;
  font-weight: 600;
  margin-right: 4px;
}
.streak-indicator.hidden { display: none; }

/* Game panel */
.game-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 1001;
  width: 280px;
  background: rgba(10, 28, 46, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  overflow-y: auto;
  pointer-events: auto;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.78rem;
}
.game-panel.hidden { display: none; }

.game-panel-header {
  padding: 12px 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.game-stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 10px;
}

.game-tabs {
  display: flex;
  gap: 6px;
  padding-bottom: 10px;
}

.game-tab {
  flex: 1;
  padding: 5px 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 0.72rem;
  transition: background 0.15s, color 0.15s;
}
.game-tab:hover { color: rgba(255, 255, 255, 0.8); }
.game-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
}

/* Otter-dex grid */
.otterdex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 12px;
}

.otterdex-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.otterdex-cell.undiscovered {
  opacity: 0.35;
}

.otterdex-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.otterdex-name {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.2;
}

.otterdex-date {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
}

/* Challenge list */
.challenge-list {
  padding: 10px 12px;
}

.challenge-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.challenge-item:last-child { border-bottom: none; }

.challenge-item.completed {
  opacity: 0.5;
}

.challenge-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.challenge-info {
  flex: 1;
  min-width: 0;
}

.challenge-title {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.challenge-desc {
  display: block;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 1px;
}

.challenge-check {
  color: #34d399;
  font-weight: 700;
  font-size: 0.9rem;
}

.challenge-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.challenge-progress-fill {
  height: 100%;
  background: #2e86c1;
  border-radius: 2px;
  transition: width 0.3s;
}

.challenge-progress-text {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.4);
}

/* Toast notifications */
.game-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: rgba(10, 28, 46, 0.97);
  border: 1px solid #2e86c1;
  border-radius: 10px;
  padding: 12px 24px;
  min-width: 240px;
  max-width: 360px;
  text-align: center;
  animation: toast-in 0.3s ease-out;
  pointer-events: none;
}
.game-toast.hidden { display: none; }

.game-toast-discovery { border-color: #f0a500; }
.game-toast-challenge { border-color: #34d399; }
.game-toast-streak { border-color: #fb923c; }
.game-toast-completion { border-color: #f0a500; box-shadow: 0 0 20px rgba(240, 165, 0, 0.3); }

.toast-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.toast-msg {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Shift species legend when game panel is open */
.game-panel:not(.hidden) ~ #species-legend {
  right: 300px;
}

@media (max-width: 640px) {
  .game-panel {
    width: 100%;
    right: 0;
    top: 0;
    bottom: 0;
    border-radius: 0;
  }
  .game-panel:not(.hidden) ~ #species-legend {
    right: 14px;
    display: none;
  }
}
