/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* === Content wrapper === */
#content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* === Map === */
#map { flex: 1; min-height: 0; }

/* === Sidebar === */
#sidebar {
  width: 100%;
  max-height: 45vh;
  overflow-y: auto;
  background: #f8f9fa;
  border-top: 2px solid #dee2e6;
  flex-shrink: 0;
}

#sidebar-header {
  background: #fff;
  color: #2c3e50;
  padding: 4px 16px 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #dee2e6;
}
.header-top {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 8px;
}
.header-logo {
  height: 56px;
  width: auto;
  flex-shrink: 0;
  margin: -8px 0 -8px -16px;
}
.header-text {
  flex: 1;
  min-width: 0;
}
#sidebar-header h1 { font-size: 17px; margin-bottom: 3px; padding-right: 36px; }
#sidebar-header p { font-size: 13px; opacity: 0.7; margin: 0; }

/* === Hamburger Menu === */
.menu-toggle {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #2c3e50;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  opacity: 0.85;
}
.menu-toggle:hover { opacity: 1; }
.menu-dropdown {
  display: none;
  position: absolute;
  top: 38px;
  right: 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  overflow: hidden;
  z-index: 100;
  min-width: 180px;
}
.menu-dropdown.menu-open { display: block; }
.menu-dropdown a {
  display: block;
  padding: 12px 16px;
  color: #2c3e50;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #eee;
}
.menu-dropdown a:last-child { border-bottom: none; }
.menu-dropdown a:hover { background: #f0f0f0; }

.legend {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #2c3e50; }
.legend-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
}

/* === Shop List Toggle === */
.shop-list-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: #f0f0f0;
  border: none;
  border-bottom: 1px solid #dee2e6;
  width: calc(100% + 32px);
  cursor: pointer;
  font-size: 12px;
  color: #666;
  font-weight: 600;
  margin: 12px -16px -12px -16px;
}
.shop-list-toggle:hover {
  background: #e8e8e8;
}
.shop-list-toggle .toggle-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}
.shop-list-toggle.collapsed .toggle-arrow {
  transform: rotate(180deg);
}

/* === Shop Cards === */
.shop-list { padding: 0; }
.shop-list.shop-list-collapsed {
  display: none;
}

.shop-card {
  background: #fff;
  margin: 0;
  border-radius: 0;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #eee;
}
.shop-card:hover {
  background: #f8f9fa;
}

.shop-card-body {
  display: flex;
  gap: 12px;
}
.shop-info {
  flex: 1;
  min-width: 0;
}
.shop-thumbnail {
  flex-shrink: 0;
  height: 80px;
  overflow: hidden;
}
.shop-thumbnail img {
  height: 100%;
  width: auto;
  display: block;
}

.shop-card .shop-name {
  font-size: 13px; font-weight: 700;
  margin-bottom: 3px; color: #2c3e50;
}
.shop-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.shop-card .shop-category {
  display: inline-block; font-size: 10px;
  padding: 1px 6px; border-radius: 3px; color: #fff;
}
.shop-card .shop-distance {
  font-size: 11px; color: #c0392b;
  font-weight: 600;
}
.cat-umeco-badge { background: #e91e8c; }
.cat-food-badge { background: #e67e22; }
.cat-kamaboko-badge { background: #2980b9; }
.cat-goods-badge { background: #27ae60; }

.shop-card .shop-detail { font-size: 11px; color: #666; line-height: 1.5; }
.shop-card .shop-detail .label { color: #999; margin-right: 2px; }

.shop-card .base-link,
.shop-card .gmap-link {
  display: inline-block; margin-top: 6px;
  padding: 4px 12px; color: #fff;
  text-decoration: none; border-radius: 4px; font-size: 12px;
  line-height: 1; vertical-align: middle;
}
.shop-card .base-link { background: #333; }
.shop-card .base-link:hover { background: #555; }
.shop-card .base-link-disabled {
  background: #999;
  cursor: not-allowed;
  pointer-events: none;
}
.shop-card .gmap-link { background: #4285F4; margin-left: 4px; }
.shop-card .gmap-link:hover { background: #3367D6; }

/* === Markers === */
.marker-icon {
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  text-align: center;
  width: 28px; height: 28px;
  line-height: 22px;
  font-size: 12px; font-weight: 700; color: #fff;
}
.marker-umeco { background: #e91e8c; }
.marker-food { background: #e67e22; }
.marker-kamaboko { background: #2980b9; }
.marker-goods { background: #27ae60; }

.marker-acquired {
  opacity: 0.55;
}
.marker-check {
  font-size: 16px;
  line-height: 22px;
}

.marker-nearby {
  width: 40px !important;
  height: 40px !important;
  line-height: 34px !important;
  font-size: 16px !important;
  box-shadow: 0 0 12px 4px rgba(243, 156, 18, 0.5), 0 2px 6px rgba(0,0,0,0.35);
  border: 3px solid #f39c12;
  animation: marker-pulse 1.5s ease-in-out infinite;
}

@keyframes marker-pulse {
  0%, 100% { box-shadow: 0 0 12px 4px rgba(243, 156, 18, 0.5), 0 2px 6px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 0 20px 8px rgba(243, 156, 18, 0.7), 0 2px 6px rgba(0,0,0,0.35); }
}

/* === Popups === */
.leaflet-popup-content-wrapper { border-radius: 8px; }
.popup-content h3 { font-size: 14px; margin-bottom: 4px; color: #2c3e50; }
.popup-content p { font-size: 12px; margin: 2px 0; color: #555; }
.popup-content .popup-label { font-weight: 600; color: #888; }
.popup-content .popup-distance { color: #c0392b; font-weight: 700; margin-top: 4px; }

.popup-content a.popup-base,
.popup-content a.popup-gmap {
  display: inline-block; margin-top: 6px;
  padding: 4px 12px; color: #fff;
  text-decoration: none; border-radius: 4px; font-size: 12px;
}
.popup-content a.popup-base { background: #333; }
.popup-content a.popup-base:hover { background: #555; }
.popup-content .popup-base-disabled {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 12px;
  background: #999;
  cursor: not-allowed;
}
.popup-content a.popup-gmap { background: #4285F4; margin-left: 4px; }
.popup-content a.popup-gmap:hover { background: #3367D6; }

/* === Stamp Card (inside sidebar-header) === */
#stamp-card {
  margin-bottom: 4px;
}
.stamp-slots {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.stamp-slot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.3s ease;
}
.stamp-empty {
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.25);
  border: 2px solid rgba(0,0,0,0.1);
}
.stamp-acquired {
  color: #fff;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.stamp-acquired:hover {
  transform: scale(1.15);
}

/* === Shop Card Acquired === */
.shop-card.shop-acquired {
  opacity: 0.45;
  position: relative;
}
.shop-card.shop-acquired::after {
  content: '済';
  position: absolute;
  top: 8px;
  right: 10px;
  background: #e74c3c;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
}

/* === Toast === */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #fff;
  color: #2e7d32;
  border: 2px solid #2e7d32;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(46,125,50,0.2);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  white-space: normal;
  min-width: 280px;
  max-width: 90vw;
  text-align: center;
}
.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-error {
  color: #d32f2f;
  border-color: #d32f2f;
  box-shadow: 0 4px 12px rgba(211,47,47,0.2);
}

/* === Nearby Banner === */
.nearby-banner {
  position: fixed;
  bottom: 40vh;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #c0600a;
  color: #fff;
  padding: 16px 28px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(230,126,34,0.4);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  cursor: pointer;
  text-align: center;
  max-width: 90%;
}
.nearby-banner.nearby-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  animation: pulse-glow 1.5s ease-in-out infinite;
}
.nearby-banner.nearby-loading {
  opacity: 0.6;
  pointer-events: none;
  animation: none;
}
.nearby-banner:active {
  animation-play-state: paused;
  transform: translateX(-50%) translateY(0) scale(0.93);
}
#nearby-shop-name {
  color: #ffe0b2;
}
@keyframes pulse-glow {
  0%, 100% {
    transform: translateX(-50%) translateY(0) scale(1);
    box-shadow: 0 4px 20px rgba(192,96,10,0.4);
  }
  50% {
    transform: translateX(-50%) translateY(0) scale(1.05);
    box-shadow: 0 6px 30px rgba(192,96,10,0.7), 0 0 15px rgba(192,96,10,0.3);
  }
}

/* === Overlay & Dialog === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.overlay.overlay-visible {
  opacity: 1;
  pointer-events: auto;
}
.dialog {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.dialog-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}
.dialog-close:hover { color: #333; }
.dialog-title {
  font-size: 20px;
  color: #2c3e50;
  margin-bottom: 4px;
}
.dialog-subtitle {
  font-size: 14px;
  color: #666;
  margin-bottom: 16px;
}
/* === Trivia Section === */
.trivia-section {
  text-align: center;
}
.trivia-section-label {
  font-size: 15px;
  color: #888;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}
.trivia-image-container {
  text-align: center;
  margin-bottom: 12px;
}
.trivia-image {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.trivia-trivia-title {
  font-size: 16px;
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 6px;
}
.trivia-description {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 14px;
}
.trivia-link {
  display: inline-block;
  font-size: 14px;
  color: #fff;
  background: #2c3e50;
  padding: 8px 20px;
  border-radius: 20px;
  text-decoration: none;
  transition: background 0.2s;
}
.trivia-link:hover {
  background: #1a252f;
}

/* === Legal Pages === */
.legal-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px;
  font-size: 14px;
  line-height: 1.8;
  color: #333;
}
.legal-page h1 {
  font-size: 20px;
  color: #2c3e50;
  margin-bottom: 4px;
}
.legal-page .legal-date {
  font-size: 12px;
  color: #888;
  margin-bottom: 24px;
}
.legal-page h2 {
  font-size: 16px;
  color: #2c3e50;
  margin-top: 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
}
.legal-page h3 {
  font-size: 14px;
  color: #444;
  margin-top: 16px;
  margin-bottom: 4px;
}
.legal-page p { margin-bottom: 12px; }
.legal-page ol, .legal-page ul {
  margin-bottom: 12px;
  padding-left: 24px;
}
.legal-page li { margin-bottom: 4px; }
.legal-page hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid #ddd;
}
.legal-back {
  display: inline-block;
  margin-bottom: 16px;
  color: #2980b9;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.legal-back:hover { text-decoration: underline; }

/* === Desktop === */
@media (min-width: 769px) {
  #content {
    flex-direction: row;
  }
  #sidebar {
    width: 360px;
    min-width: 360px;
    height: auto;
    max-height: none;
    border-top: none;
    border-right: 2px solid #dee2e6;
    order: -1;
  }
  .shop-list-toggle {
    display: none;
  }
  .shop-list.shop-list-collapsed {
    display: block;
  }
  #map { flex: 1; }
}
