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

:root {
  --bg-dark: #1b2a1f;
  --bg-card: #2a3d2a;
  --bg-card-hover: #334a33;
  --accent-gold: #e8a84c;
  --accent-red: #c45a3a;
  --text-heading: #d4c4a0;
  --text-muted: #7a9a6a;
  --text-dim: #5a7a5a;
  --border-subtle: #3a5a3a;
  --color-easy: #6abf5c;
  --color-moderate: #e8a84c;
  --color-hard: #c45a3a;
  --header-height: 60px;
  --legend-height: 90px;
  --sheet-max-height: 70vh;
}

html, body { height: 100%; overflow: hidden; background: var(--bg-dark); color: var(--text-heading); font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }

.header { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: var(--header-height); background: var(--bg-dark); border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.header-title h1 { font-size: 16px; font-weight: 800; color: var(--text-heading); letter-spacing: -0.5px; text-transform: uppercase; }
.header-subtitle { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; }

.month-filter { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.month-filter::-webkit-scrollbar { display: none; }
.month-pill { flex-shrink: 0; height: 44px; padding: 0 16px; border: none; border-radius: 22px; background: var(--bg-card); color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s, color 0.2s; -webkit-tap-highlight-color: transparent; }
.month-pill.active { background: var(--accent-gold); color: var(--bg-dark); }
.month-pill:hover { background: var(--bg-card-hover); }
.month-pill.active:hover { background: var(--accent-gold); }

.main { position: fixed; top: var(--header-height); left: 0; right: 0; bottom: var(--legend-height); }
.map { width: 100%; height: 100%; }
.leaflet-container { background: var(--bg-dark); }

.legend-strip { position: fixed; bottom: 0; left: 0; right: 0; height: var(--legend-height); background: var(--bg-dark); border-top: 1px solid var(--border-subtle); display: flex; align-items: center; gap: 10px; padding: 0 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; z-index: 1000; }
.legend-strip::-webkit-scrollbar { display: none; }
.legend-card { flex-shrink: 0; width: 200px; background: var(--bg-card); border-radius: 8px; padding: 10px 12px; border-left: 3px solid var(--accent-gold); cursor: pointer; transition: background 0.2s, opacity 0.3s; -webkit-tap-highlight-color: transparent; }
.legend-card:hover { background: var(--bg-card-hover); }
.legend-card.active { outline: 2px solid var(--accent-gold); outline-offset: -2px; }
.legend-card.dimmed { opacity: 0.3; pointer-events: none; }
.legend-card[data-difficulty="easy"] { border-left-color: var(--color-easy); }
.legend-card[data-difficulty="moderate"] { border-left-color: var(--color-moderate); }
.legend-card[data-difficulty="hard"] { border-left-color: var(--color-hard); }
.legend-card-name { font-size: 12px; font-weight: 700; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-card-stats { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1500; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.sheet-overlay.visible { opacity: 1; pointer-events: auto; }
.detail-sheet { position: fixed; bottom: 0; left: 0; right: 0; max-height: var(--sheet-max-height); background: var(--bg-dark); border-top: 2px solid var(--accent-gold); border-radius: 16px 16px 0 0; z-index: 2000; transform: translateY(100%); transition: transform 0.3s ease-out; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.detail-sheet.open { transform: translateY(0); }
.sheet-drag-handle { width: 40px; height: 4px; background: var(--border-subtle); border-radius: 2px; margin: 10px auto; }
.sheet-content { padding: 0 20px 24px; }
.sheet-trail-name { font-size: 20px; font-weight: 800; color: var(--text-heading); }
.sheet-area { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.sheet-stats { display: flex; gap: 10px; margin-top: 14px; }
.sheet-stat { background: var(--bg-card); padding: 8px 12px; border-radius: 6px; text-align: center; }
.sheet-stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.sheet-stat-value { font-size: 15px; font-weight: 700; color: var(--text-heading); margin-top: 2px; }
.sheet-section { margin-top: 14px; }
.sheet-section-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.sheet-section-text { font-size: 14px; color: var(--text-muted); line-height: 1.5; }
.sheet-links { display: flex; gap: 10px; margin-top: 18px; }
.sheet-link { flex: 1; display: flex; align-items: center; justify-content: center; height: 44px; background: var(--bg-card); color: var(--text-heading); border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; transition: background 0.2s; }
.sheet-link:hover { background: var(--bg-card-hover); }

@media (max-width: 767px) {
  .header { height: auto; flex-direction: column; align-items: flex-start; padding: 10px 12px; gap: 8px; }
  .header-title h1 { font-size: 14px; }
  .month-filter { width: 100%; }
  :root { --header-height: 90px; --legend-height: 100px; }
  .legend-card { width: 160px; padding: 12px 14px; }
  .sheet-trail-name { font-size: 18px; }
  .sheet-stats { flex-wrap: wrap; }
}

/* -- Map Markers -- */
.trail-marker { background: transparent; border: none; }
.trail-marker-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3); transition: transform 0.2s; cursor: pointer; }

/* -- Tooltips -- */
.trail-tooltip { background: var(--bg-dark) !important; color: var(--text-heading) !important; border: 1px solid var(--border-subtle) !important; border-radius: 6px !important; padding: 8px 12px !important; font-size: 12px !important; line-height: 1.4 !important; box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important; }
.trail-tooltip strong { color: var(--text-heading); }
.leaflet-tooltip-top::before { border-top-color: var(--border-subtle) !important; }

/* -- Touch refinements -- */
@media (pointer: coarse) {
  .trail-marker-dot { width: 30px; height: 30px; }
  .legend-card { min-height: 60px; }
  .month-pill { min-width: 52px; }
  .sheet-drag-handle { width: 48px; height: 5px; margin: 12px auto; }
}

body { overscroll-behavior: none; }
