html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ========== 新佈局：頂部過濾器 + 左側列表 + 主要地圖 ========== */
.castle-map-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px); /* 減去 landing-nav 的高度 */
  overflow: hidden;
  margin-top: 0; /* 由 body padding 處理 */
}

/* 頂部過濾器區域 */
.filter-toolbar {
  background: white;
  border-bottom: 2px solid #e0e0e0;
  padding: 15px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  z-index: 1001;
}

.filter-toolbar-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-right: 20px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filter-group-label {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  white-space: nowrap;
}

.filter-toolbar .search-box {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
  margin: 0;
}

.filter-toolbar .search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.3s ease;
}

.filter-toolbar .search-box input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 過濾按鈕組 */
.filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 12px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

/* 令制國下拉選單 */
.ryoseikoku-dropdown {
  position: relative;
  min-width: 150px;
}

.ryoseikoku-dropdown-btn {
  width: 100%;
  padding: 6px 30px 6px 12px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  position: relative;
}

.ryoseikoku-dropdown-btn::after {
  content: '▼';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #666;
}

.ryoseikoku-dropdown-btn:hover {
  border-color: #667eea;
}

.ryoseikoku-dropdown-btn.active {
  border-color: #667eea;
  color: #667eea;
}

.ryoseikoku-dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1002;
  display: none;
}

.ryoseikoku-dropdown-menu.show {
  display: block;
}

.ryoseikoku-search-input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 2px solid #e0e0e0;
  font-size: 12px;
  outline: none;
}

.ryoseikoku-search-input:focus {
  border-bottom-color: #667eea;
}

.ryoseikoku-list {
  padding: 5px;
}

.ryoseikoku-item {
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.ryoseikoku-item:hover {
  background: #f5f5f5;
}

.ryoseikoku-item.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea;
  font-weight: 600;
}

/* 主要內容區域（左側列表 + 地圖） */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 左側城堡列表面板 */
.castle-list-panel {
  width: 320px;
  background: #f8f9fa;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 15px;
  background: white;
  border-bottom: 1px solid #ddd;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.panel-stats {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
}

/* 城堡列表 */
.castle-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.castle-list-item {
  background: white;
  border-radius: 8px;
  padding: 12px 15px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}

.castle-list-item.top100 {
  border-left-color: #dc4e41;
}

.castle-list-item.continued100 {
  border-left-color: #4169E1;
}

.castle-list-item:hover {
  background: #f0f0f0;
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.castle-list-item.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
}

.castle-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.castle-number {
  font-size: 12px;
  font-weight: 700;
  color: #888;
}

.castle-type-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

.castle-type-badge.badge-top100 {
  background-color: #dc4e41;
}

.castle-type-badge.badge-continued100 {
  background-color: #4169E1;
}

.castle-item-name {
  margin: 0 0 5px 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.castle-item-location {
  margin: 0;
  font-size: 12px;
  color: #666;
}

.castle-item-meta {
  margin: 5px 0 0 0;
  font-size: 11px;
}

.region-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

/* 中間地圖容器 */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* 地圖圖例 */
.map-legend {
  position: absolute;
  top: 20px;
  right: 60px;
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  font-size: 13px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 8px;
  display: inline-block;
}

.legend-marker.top100 {
  background-color: #dc4e41;
}

.legend-marker.continued100 {
  background-color: #4169E1;
}

/* 當前篩選狀態顯示 */
.filter-status {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  max-width: 300px;
}

#filter-status-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 右側城堡詳情側邊欄 */
.castle-details {
  position: fixed;
  top: 0;
  right: -450px;
  width: 400px;
  height: 100vh;
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  transition: right 0.3s ease;
  z-index: 2000;
  overflow-y: auto;
  padding: 20px;
}

.castle-details.show {
  right: 0;
}

.btn-close {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  z-index: 10;
}

.btn-close:hover {
  color: #000;
}

#castle-content {
  margin-top: 40px;
}

.castle-badge {
  margin-bottom: 10px;
}

.castle-badge span {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  color: white;
}

.badge-top100 {
  background-color: #dc4e41;
}

.badge-continued100 {
  background-color: #4169E1;
}

#castle-name {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 15px;
  color: #333;
}

.btn-locate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-locate:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
}

.btn-locate:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.btn-locate svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-view-detail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-view-detail:hover {
  background: linear-gradient(135deg, #f97316 0%, #f59e0b 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
  transform: translateY(-2px);
}

.btn-view-detail:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}

.btn-view-detail svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-checkin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-checkin:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transform: translateY(-2px);
}

.btn-checkin:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.btn-checkin svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#castle-image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 15px;
  background-color: #f0f0f0;
}

.castle-info {
  line-height: 1.8;
}

.castle-info p {
  margin-bottom: 10px;
}

.castle-info strong {
  color: #555;
}

/* 自訂標記樣式 */
.custom-marker {
  display: block !important;
  cursor: pointer !important;
  transition: width 0.2s ease, height 0.2s ease, box-shadow 0.2s ease !important;
}

.mapboxgl-marker {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  will-change: transform !important;
}

/* Mapbox 彈出視窗樣式 */
.mapboxgl-popup {
  max-width: 300px !important;
  z-index: 10 !important;
}

.mapboxgl-popup-content {
  padding: 0 !important;
  border-radius: 8px !important;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3) !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif !important;
}

.mapboxgl-popup-close-button {
  font-size: 20px !important;
  padding: 4px 8px !important;
  color: #666 !important;
}

.mapboxgl-popup-close-button:hover {
  background-color: #f0f0f0 !important;
  color: #000 !important;
}

/* 彈出視窗箭頭顏色 */
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
  border-bottom-color: white !important;
}

.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
  border-top-color: white !important;
}

.mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
  border-right-color: white !important;
}

.mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
  border-left-color: white !important;
}

/* 捲軸美化 */
.castle-list::-webkit-scrollbar,
.ryoseikoku-dropdown-menu::-webkit-scrollbar {
  width: 8px;
}

.castle-list::-webkit-scrollbar-track,
.ryoseikoku-dropdown-menu::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.castle-list::-webkit-scrollbar-thumb,
.ryoseikoku-dropdown-menu::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 4px;
}

.castle-list::-webkit-scrollbar-thumb:hover,
.ryoseikoku-dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* 響應式設計 */
@media (max-width: 1400px) {
  .filter-toolbar {
    padding: 12px 15px;
    gap: 10px;
  }
  
  .filter-toolbar-title {
    font-size: 16px;
    margin-right: 10px;
  }
}

@media (max-width: 1200px) {
  .castle-list-panel {
    width: 280px;
  }
  
  .filter-group-label {
    display: none;
  }
}

@media (max-width: 992px) {
  .filter-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
  }
  
  .filter-toolbar-title {
    margin-bottom: 5px;
  }
  
  .filter-toolbar .search-box {
    max-width: 100%;
  }
  
  .filter-group {
    width: 100%;
    flex-wrap: wrap;
  }
  
  .main-content {
    flex-direction: column;
  }
  
  .castle-list-panel {
    width: 100%;
    height: 180px;
  }
  
  .map-container {
    flex: 1;
  }
  
  .castle-details {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 768px) {
  .filter-toolbar {
    padding: 8px;
  }
  
  .filter-btn {
    font-size: 11px;
    padding: 5px 10px;
  }
  
  .castle-item-name {
    font-size: 14px;
  }
  
  .map-legend {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 11px;
  }
  
  .filter-status {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
    font-size: 11px;
    max-width: 200px;
  }
  
  .castle-list-panel {
    height: 150px;
  }
  
  .panel-header {
    padding: 10px;
  }
  
  .panel-header h2 {
    font-size: 14px;
  }
}

@media (max-width: 576px) {
  .filter-toolbar-title {
    font-size: 14px;
  }
  
  .filter-btn {
    font-size: 10px;
    padding: 4px 8px;
  }
  
  .ryoseikoku-dropdown {
    min-width: 120px;
  }
}

/* ========================================
   Enhanced Footer Styles
   ======================================== */
.site-footer {
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 60px 0 20px;
  margin-top: 80px;
  border-top: none;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section {
  /* Styling for each footer column */
}

.footer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 15px;
  color: white;
}

.footer-icon {
  font-size: 28px;
}

.footer-description {
  font-size: 14px;
  line-height: 1.8;
  color: #b0b0b0;
  margin-bottom: 20px;
}

.footer-section-title {
  font-size: 16px;
  font-weight: 700;
  color: white;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 12px;
}

.footer-links a {
  color: #b0b0b0;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s ease;
  display: inline-block;
}

.footer-links a:hover {
  color: white;
  transform: translateX(5px);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 30px;
  margin-top: 40px;
}

.footer-bottom-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-copyright {
  font-size: 14px;
  color: #888;
  margin: 0;
}

.footer-bottom-links {
  display: flex;
  align-items: center;
  gap: 15px;
}

.footer-bottom-links a {
  color: #b0b0b0;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s ease;
}

.footer-bottom-links a:hover {
  color: white;
}

.footer-divider {
  color: #555;
}

/* Footer Responsive Design */
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  
  .footer-bottom-content {
    flex-direction: column;
    text-align: center;
  }
  
  .site-footer {
    padding: 40px 0 20px;
    margin-top: 60px;
  }
}