/* =============== CSS Variables =============== */
:root {
  /* Color Palette - Modern and Accessible */
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  
  /* Grayscale */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Semantic Colors */
  --bg-primary: var(--white);
  --bg-secondary: var(--gray-50);
  --bg-card: var(--white);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  
  /* Forecast Window Colors */
  --hour-12: #0891b2;
  --hour-24: #d97706;
  --hour-48: #059669;
  --hour-72: #7c3aed;
  
  /* Synopsis Severity Colors */
  --dry-bg: #dbeafe;
  --dry-border: #60a5fa;
  --dry-text: #1e40af;
  
  --light-bg: #e0f2fe;
  --light-border: #38bdf8;
  --light-text: #0369a1;
  
  --wet-bg: #fed7aa;
  --wet-border: #fb923c;
  --wet-text: #c2410c;
  
  --soak-bg: #fecaca;
  --soak-border: #f87171;
  --soak-text: #b91c1c;
  
  /* Layout */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-strong: #475569;
    
    --dry-bg: #1e3a8a20;
    --light-bg: #0284c720;
    --wet-bg: #c2410c20;
    --soak-bg: #b91c1c20;
  }
}

/* =============== Base Styles =============== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* =============== Sponsor Banner (Optional) =============== */
#sponsor-banner {
  background: linear-gradient(90deg, #1f2937, #374151);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.sponsor-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  max-width: 1200px;
  margin: 0 auto;
}

.sponsor-label {
  color: var(--white);
  font-size: 0.875rem;
  opacity: 0.9;
}

.sponsor-logo {
  height: 40px;
  width: 120px;
  max-width: 150px;
  object-fit: contain; /* Maintains aspect ratio */
}

@media (max-width: 480px) {
  .sponsor-logo {
    height: 30px;
    width: 90px;
    max-width: 120px;
  }
}

.sponsor-link {
  color: var(--white);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.sponsor-link:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* =============== Header =============== */
header {
  text-align: center;
  padding: var(--space-lg) var(--space-md) var(--space-md);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: var(--white);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin: 0 -16px;
}

.app-icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.subtitle {
  font-size: 0.875rem;
  opacity: 0.95;
  font-weight: 400;
}

/* =============== Search Container =============== */
.search-container {
  padding: var(--space-md);
  background: var(--bg-card);
  margin: var(--space-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.search-wrapper {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  min-width: 0; /* Prevent flex items from overflowing */
}

#search {
  flex: 1 1 auto;
  min-width: 0; /* Allow shrinking below content size */
  padding: 14px 16px;
  font-size: 16px; /* Prevents zoom on iOS */
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

#search:focus {
  outline: none;
  border-color: var(--primary-light);
}

.gps-btn, .map-picker-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.gps-btn:active, .map-picker-btn:active {
  transform: scale(0.95);
}

.gps-btn svg, .map-picker-btn svg {
  width: 20px;
  height: 20px;
}

.search-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.search-btn:active {
  transform: scale(0.98);
  background: var(--primary-dark);
}

/* =============== Location Status =============== */
.location-status {
  text-align: center;
  padding: 0 var(--space-md) var(--space-md);
}

.location-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

.location-name strong {
  color: var(--primary);
  font-weight: 700;
}

.location-name small {
  display: block;
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.timestamp small {
  font-size: 0.7rem;
  opacity: 0.9;
}

/* =============== Loading State =============== */
.loading-container {
  text-align: center;
  padding: var(--space-xl);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-md);
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-container {
  margin-top: var(--space-md);
  width: 100%;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.loading-quote {
  margin-top: var(--space-lg);
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  opacity: 0.8;
}

/* =============== Summary Card =============== */
.summary-card {
  margin: 0 var(--space-md) var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border);
  position: relative;
  overflow: hidden;
}

.summary-card.syn-dry {
  background: var(--dry-bg);
  border-color: var(--dry-border);
  color: var(--dry-text);
}

.summary-card.syn-light {
  background: var(--light-bg);
  border-color: var(--light-border);
  color: var(--light-text);
}

.summary-card.syn-wet {
  background: var(--wet-bg);
  border-color: var(--wet-border);
  color: var(--wet-text);
}

.summary-card.syn-soak {
  background: var(--soak-bg);
  border-color: var(--soak-border);
  color: var(--soak-text);
}

.summary-header {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.summary-icon {
  font-size: 2rem;
  line-height: 1;
}

.summary-content {
  flex: 1;
}

.summary-content h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
  opacity: 0.8;
}

.summary-main {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.summary-details {
  font-size: 0.875rem;
  padding-top: var(--space-sm);
  border-top: 1px solid currentColor;
  opacity: 0.9;
}

/* =============== Forecast Section =============== */
#results-section {
  padding: 0 var(--space-md);
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.forecast-grid {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  align-items: start;
}

/* =============== Forecast Cards =============== */
.forecast-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: var(--space-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.forecast-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gray-400);
}

.forecast-card.h12::before { background: var(--hour-12); }
.forecast-card.h24::before { background: var(--hour-24); }
.forecast-card.h48::before { background: var(--hour-48); }
.forecast-card.h72::before { background: var(--hour-72); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hour-badge {
  padding: 4px 10px;
  background: var(--gray-100);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.forecast-card.h12 .hour-badge { background: var(--hour-12); color: var(--white); }
.forecast-card.h24 .hour-badge { background: var(--hour-24); color: var(--white); }
.forecast-card.h48 .hour-badge { background: var(--hour-48); color: var(--white); }
.forecast-card.h72 .hour-badge { background: var(--hour-72); color: var(--white); }

.time-window {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* Rain Odds Synopsis - New Enhanced Section */
.rain-odds-synopsis {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
  border-left: 3px solid var(--primary);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  min-height: 240px;
}

.rain-odds-synopsis strong {
  color: var(--text-primary);
  font-weight: 600;
}

.forecast-card.h12 .rain-odds-synopsis {
  border-left-color: var(--hour-12);
}

.forecast-card.h24 .rain-odds-synopsis {
  border-left-color: var(--hour-24);
}

.forecast-card.h48 .rain-odds-synopsis {
  border-left-color: var(--hour-48);
}

.forecast-card.h72 .rain-odds-synopsis {
  border-left-color: var(--hour-72);
}

/* Main Values Display - Updated */
.amounts-container {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.amount-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-sm) 0;
  gap: var(--space-md);
}

.amount-row.cumulative {
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-sm);
}

.amount-row.incremental {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.amount-row.incremental .amount-label {
  hyphens: auto;
  word-break: break-word;
  line-height: 1.2;
}

.amount-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  flex-shrink: 0;
  line-height: 1.3;
  max-width: 140px;
}

.amount-row.cumulative .amount-label {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 600;
}

.amount-value {
  text-align: right;
  flex: 1;
  line-height: 1.4;
}

.amount-value strong {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1em;
}

.amount-value .likely-range {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
  display: block;
}

.most-likely-amount {
  color: white;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.1em;
  display: inline-block;
}

.amount-mm {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
}

/* Enhanced Range Visual */
.range-visual {
  margin-bottom: var(--space-md);
}

.range-header {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.range-container {
  position: relative;
  padding: 45px 0 25px;
}

.range-bar {
  height: 40px;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  overflow: visible;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.scale-tick {
  position: absolute;
  width: 1px;
  height: 100%;
  background: var(--border-strong);
  opacity: 0.7;
}

.range-fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 24px;
  border-radius: var(--radius-sm);
  opacity: 0.8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Range Points with Labels */
.range-point {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.range-point.p10 {
  z-index: 10;
}

.range-point.p90 {
  z-index: 11;
}

.range-point.p50 {
  z-index: 12; /* P50 on top */
}

.point-marker {
  width: 16px;
  height: 16px;
  background: var(--white);
  border: 3px solid var(--primary);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  margin: 0 auto;
}

.range-point.p10 .point-marker {
  border-color: #10b981;
  background: #ecfdf5;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.range-point.p50 .point-marker {
  border-color: var(--primary);
  background: var(--white);
  width: 20px;
  height: 20px;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.range-point.p90 .point-marker {
  border-color: #1e40af;
  background: #dbeafe;
  box-shadow: 0 2px 6px rgba(30, 64, 175, 0.3);
}

.point-label {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
  background: var(--bg-card);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.point-label small {
  display: block;
  font-size: 0.55rem;
  color: var(--text-muted);
  font-weight: 400;
}

.range-point.p50 .point-label {
  font-weight: 800;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

.range-point.p50 .point-label small {
  color: rgba(255, 255, 255, 0.9);
}

/* Label positioning - above and below bar */
.point-label.above {
  top: -40px;
}

.point-label.below {
  top: 25px;
}

/* Scale Labels */
.scale-labels-container {
  position: relative;
  height: 20px;
  margin-top: 4px;
}

.scale-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Range Description */
.range-description {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.range-desc-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Confidence Indicator */
.confidence-indicator {
  margin-top: var(--space-md);
}

.confidence-box {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}

.confidence-level {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.confidence-description {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid;
}

.dot.p10 {
  background: #dbeafe;
  border-color: #60a5fa;
}

.dot.p50 {
  background: var(--white);
  border-color: var(--primary);
}

.dot.p90 {
  background: #dbeafe;
  border-color: #1e40af;
}

/* Probability Section */
.probability-section {
  margin-bottom: var(--space-md);
}

.prob-header {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prob-timeframe {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-sm);
  font-style: italic;
}

/* Probability Pills */
.probability-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.prob-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  text-align: center;
  border: 1px solid var(--border);
}

.prob-chance {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.prob-threshold {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.2;
}

.prob-threshold small {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Map Button */
.map-btn {
  width: 100%;
  padding: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.map-btn:active {
  transform: scale(0.98);
  background: var(--border);
}

/* =============== Info Section =============== */
.info-section {
  padding: 0 var(--space-md) var(--space-lg);
}

.info-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.info-card summary {
  padding: var(--space-md);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.info-card summary::-webkit-details-marker {
  display: none;
}

.info-card summary::after {
  content: '▼';
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.info-card[open] summary::after {
  transform: rotate(180deg);
}

.info-content {
  padding: 0 var(--space-md) var(--space-md);
  border-top: 1px solid var(--border);
}

.info-item {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.info-item:last-child {
  border-bottom: none;
}

.info-item strong {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.info-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.disclaimer {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--border);
}

.disclaimer p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* =============== Map Overlay =============== */
.map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
}

.map-overlay.open {
  display: block;
}

.map-panel {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.map-controls {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  right: var(--space-md);
  z-index: 10001;
  display: flex;
  justify-content: space-between;
}

.map-close {
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.map-close svg {
  width: 20px;
  height: 20px;
}

.map-legend-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-md);
  height: 44px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
}

.map-legend-btn svg {
  width: 18px;
  height: 18px;
}

.legend-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-lg);
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  z-index: 10002;
  display: none;
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.legendClose {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.legend-popup img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  background: var(--white);
}

.map-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.map-slice {
  flex: 1;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.map-slice:last-child {
  border-bottom: none;
}

.slice-title {
  position: absolute;
  top: var(--space-sm);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: var(--white);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1000;
  pointer-events: none;
}

.slice-map {
  position: absolute;
  inset: 0;
}

/* =============== Location Picker Overlay =============== */
.location-picker-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 10000;
  display: none;
  flex-direction: column;
}

.location-picker-overlay.open {
  display: flex;
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow-md);
}

.picker-header h3 {
  margin: 0;
  font-size: 1.125rem;
  color: var(--text-primary);
}

.picker-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  cursor: pointer;
}

.picker-close svg {
  width: 20px;
  height: 20px;
}

.picker-instructions {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.picker-instructions p {
  margin: 0 0 var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.picker-coords {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.picker-map {
  flex: 1;
  position: relative;
  background: var(--gray-100);
}

.picker-footer {
  padding: var(--space-md);
  background: var(--bg-card);
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.use-location-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.use-location-btn:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  opacity: 0.6;
}

.use-location-btn:not(:disabled):active {
  transform: scale(0.98);
  background: var(--primary-dark);
}

/* Custom marker for picked location */
.picker-marker-icon {
  width: 40px;
  height: 40px;
  margin-left: -20px;
  margin-top: -40px;
}

/* =============== Footer =============== */
footer {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =============== Mobile Adjustments =============== */
@media (max-width: 480px) {
  /* Adjust search wrapper to prevent overflow */
  .search-wrapper {
    gap: 6px;
  }
  
  #search {
    min-width: 0;
    flex: 1 1 auto;
  }
  
  .gps-btn, .map-picker-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  
  .range-point .point-label {
    font-size: 0.55rem;
    padding: 1px 4px;
  }

  .range-point .point-label.above {
    top: -35px;
  }

  .range-point .point-label.below {
    top: 20px;
  }
  
  .range-point .point-label small {
    font-size: 0.5rem;
  }
  
  .range-container {
    padding: 40px 0 25px;
  }
  
  .range-description {
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-sm);
  }
  
  .scale-label {
    font-size: 0.65rem;
  }
  
  .amounts-container {
    padding: var(--space-sm);
  }
  
  .amount-row.cumulative {
    font-size: 0.9rem;
  }
  
  .amount-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .amount-label {
    max-width: none;
    font-size: 0.8rem;
  }
  
  .amount-value {
    text-align: left;
  }
  
  .rain-odds-synopsis {
    font-size: 0.8rem;
    padding: var(--space-sm);
  }
}

/* Extra small screens (iPhone SE, etc) */
@media (max-width: 375px) {
  .search-container {
    padding: var(--space-sm);
  }
  
  .search-wrapper {
    gap: 4px;
  }
  
  #search {
    font-size: 15px; /* Slightly smaller on very small screens */
    padding: 12px 10px;
  }
  
  .gps-btn, .map-picker-btn {
    width: 42px;
    height: 42px;
  }
  
  .gps-btn svg, .map-picker-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* =============== Tablet and Desktop =============== */
@media (min-width: 768px) {
  body {
    max-width: 768px;
    margin: 0 auto;
  }
  
  header {
    margin: var(--space-md);
    border-radius: var(--radius-lg);
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }

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

  .probability-list {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .map-stack {
    flex-direction: row;
  }
  
  .map-slice {
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
}

@media (min-width: 1024px) {
  body {
    max-width: 1024px;
  }

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

/* =============== Utilities =============== */
.hidden {
  display: none !important;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Touch feedback */
button:active,
.clickable:active {
  opacity: 0.8;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible {
  outline-offset: 0;
}

/* =============== Vertical Bar Chart =============== */
.bar-chart-section {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.bar-chart-header {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bar-chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  height: 120px;
  padding: 0 var(--space-md);
}

.bar {
  position: relative;
  width: 40px;
  min-height: 10px;
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: all 0.3s ease;
}


.bar-value {
  position: absolute;
  top: -40px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  background: var(--bg-card);
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  text-align: center;
  line-height: 1.2;
}

.bar-value small {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: normal;
}

.bar-labels {
  display: flex;
  gap: var(--space-lg);
}

.bar-label {
  width: 40px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.2;
  font-weight: 500;
}

/* Mobile responsive for bar chart */
@media (max-width: 640px) {
  .bar-chart {
    gap: var(--space-md);
    height: 100px;
  }

  .bar {
    width: 32px;
  }

  .bar-labels {
    gap: var(--space-md);
  }

  .bar-label {
    width: 32px;
    font-size: 0.7rem;
  }

  .bar-value {
    font-size: 0.7rem;
    top: -35px;
  }

  .bar-value small {
    font-size: 0.6rem;
  }
}

/* Label positioning for overlapping P values */
.label-above {
  transform: translateY(-8px);
}

.label-below {
  transform: translateY(8px);
}

.label-center {
  transform: translateY(0);
}