:root {
  --paper: #0b1322;
  --paper-warm: #101b2f;
  --ink: #f4f7ff;
  --panel: #101a2b;
  --panel-raised: #17243a;
  --panel-line: #283a56;
  --text: #f4f7ff;
  --muted: #98a8c1;
  --brand-blue: #58b8ff;
  --brand-pink: #ff5b9d;
  --green: #66edae;
  --green-dark: #174937;
  --amber: #e9ad4d;
  --red: #de625d;
  --header-height: 70px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: "Trebuchet MS", Arial, sans-serif; font-size: 14px; line-height: 1.45; }
button, input { font: inherit; }
button { cursor: pointer; }
small { font-size: 12px; }

.site-header { position: relative; z-index: 1000; height: var(--header-height); padding: 0 22px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid #263854; background: rgba(11,19,34,.96); backdrop-filter: blur(16px); }
.wordmark { color: var(--brand-blue); text-decoration: none; font-family: "Arial Rounded MT Bold", "Trebuchet MS", Arial, sans-serif; font-size: 22px; font-weight: 900; letter-spacing: -.075em; }
.wordmark span { color: var(--brand-pink); }
.forecast-controls { justify-self: center; display: flex; align-items: center; gap: 10px; }
.forecast-days-toggle { display: flex; padding: 3px; border: 1px solid #354a6a; border-radius: 999px; background: #15233a; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.forecast-days-toggle button { min-width: 56px; padding: 4px 8px; border: 0; border-radius: 999px; color: #91a3bd; background: transparent; font-size: 12px; font-weight: 800; white-space: nowrap; }
.forecast-days-toggle button:hover { color: #fff; }
.forecast-days-toggle button.active { color: #071421; background: var(--brand-blue); }
.week-label { margin: 0; color: #91a3bd; font-size: 12px; white-space: nowrap; }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.temperature-button { padding: 9px 14px; border: 1px solid #354a6a; border-radius: 999px; color: var(--ink); background: #15233a; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.temperature-button:hover { border-color: var(--brand-blue); }
.night-preference-icon { display: inline-block; margin-left: 6px; font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif; font-size: 12px; line-height: 1; vertical-align: -1px; }
.about-button { width: 34px; height: 34px; border: 1px solid #4b4164; border-radius: 50%; color: var(--brand-pink); background: transparent; font-size: 16px; font-weight: 800; }
.about-button:hover { color: #fff; border-color: var(--brand-pink); background: rgba(255,91,157,.1); }

.app-shell { height: calc(100vh - var(--header-height)); display: grid; grid-template-columns: minmax(0, 1fr) 470px; }
.map-stage { position: relative; min-width: 0; overflow: hidden; background: #091414; }
.map { width: 100%; height: 100%; background: #091414; }
.map-intro { position: absolute; z-index: 500; top: 24px; left: 24px; width: min(430px, calc(100% - 48px)); padding: 19px 21px 18px; border: 1px solid rgba(96,139,190,.38); border-radius: 16px; color: var(--text); background: rgba(11,20,36,.91); box-shadow: 0 12px 35px rgba(0,0,0,.32); backdrop-filter: blur(14px); transition: padding .18s ease, width .18s ease, background .18s ease, border-radius .18s ease; }
.map-intro.collapsed { width: min(285px,calc(100% - 48px)); padding: 11px 13px; border-radius: 999px; background: rgba(11,20,36,.96); }
.map-intro-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.map-intro-toggle { padding: 4px 9px; border: 1px solid #3b5375; border-radius: 999px; color: #a8b8cf; background: rgba(21,35,58,.8); font-size: 12px; font-weight: 700; white-space: nowrap; }
.map-intro-toggle:hover, .map-intro-toggle:focus-visible { color: #fff; border-color: var(--brand-blue); outline: none; }
.map-intro-content { max-height: 420px; overflow: hidden; opacity: 1; visibility: visible; transition: max-height .22s ease, opacity .14s ease; }
.map-intro.collapsed .map-intro-content { max-height: 0; opacity: 0; visibility: hidden; }
.eyebrow { margin: 0; color: var(--brand-blue); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.map-intro h1, .leaderboard h2, dialog h2 { margin: 8px 0 0; font-family: "Trebuchet MS", Arial, sans-serif; font-weight: 800; letter-spacing: -.05em; line-height: 1.02; }
.map-intro h1 { max-width: 390px; font-size: clamp(35px, 3.6vw, 54px); }
.map-intro-copy { margin: 10px 0 0; color: #9db0ab; font-size: 12px; }
.global-forecast { margin-top: 17px; padding-top: 14px; border-top: 1px solid #29413e; }
.global-score { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.global-score > span { color: #a9bbb6; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.global-score strong { color: var(--global-color,var(--muted)); font-size: 12px; font-weight: 700; white-space: nowrap; }
.global-score b { font-size: 25px; font-weight: 800; letter-spacing: -.05em; }
.global-track { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #263b39; }
.global-track i { display: block; width: var(--global-score); height: 100%; border-radius: inherit; background: var(--global-color,var(--muted)); transition: width .35s ease; }
.global-forecast.best { --global-color: var(--green); }
.global-forecast.fair { --global-color: var(--amber); }
.global-forecast.poor { --global-color: var(--red); }
.global-forecast p { margin: 7px 0 0; color: #9db0ab; font-size: 12px; }
.map-legend { position: absolute; z-index: 500; left: 24px; bottom: 24px; display: flex; gap: 6px; padding: 7px; border: 1px solid rgba(96,139,190,.32); border-radius: 999px; background: rgba(11,20,36,.93); box-shadow: 0 8px 25px rgba(0,0,0,.28); backdrop-filter: blur(12px); }
.map-legend span { padding: 5px 8px; color: #a9bbb6; font-size: 12px; white-space: nowrap; }
.map-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
.map-legend .best { background: #2ab57d; }
.map-legend .fair { background: var(--amber); }
.map-legend .poor { background: var(--red); }
.map-message { position: absolute; z-index: 550; inset: 0; display: grid; place-content: center; justify-items: center; color: #9fb1ac; background: rgba(7,18,18,.9); transition: opacity .2s; }
.map-message[hidden] { display: none; }
.map-message p { margin: 12px 0 0; }
.loader { width: 26px; height: 26px; border: 2px solid #31445f; border-top-color: var(--brand-blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.leaflet-container { font-family: "Trebuchet MS", Arial, sans-serif; background: #091414; }
.leaflet-tile-pane { filter: grayscale(1) invert(.91) brightness(1.05) contrast(1.08); }
.leaflet-control-zoom { overflow: hidden; border: 1px solid #314947 !important; border-radius: 11px !important; box-shadow: 0 8px 25px rgba(0,0,0,.28) !important; }
.leaflet-control-zoom a { color: #dcebe6 !important; background: rgba(10,27,26,.94) !important; border-color: #304644 !important; }
.leaflet-control-attribution { color: #839994 !important; background: rgba(7,20,19,.84) !important; font-size: 12px !important; }
.leaflet-control-attribution a { color: #aec1bc !important; }
.weather-div-icon { border: 0; background: transparent; }
.weather-marker { position: relative; width: 12px; height: 12px; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.92); border-radius: 50%; color: white; background: var(--red); box-shadow: 0 2px 7px rgba(13,25,22,.3); transform: translate(-1px,-1px); transition: transform .15s, box-shadow .15s; }
.weather-marker:after { content: ""; position: absolute; inset: -4px; z-index: -1; border-radius: 50%; background: currentColor; opacity: .14; }
.weather-marker.best { color: #2ab57d; background: #2ab57d; }
.weather-marker.fair { color: var(--amber); background: var(--amber); }
.weather-marker.poor { color: var(--red); background: var(--red); }
.weather-marker.ranked { width: 29px; height: 29px; border-width: 3px; color: #1b332b; background: var(--green); font-size: 12px; font-weight: 800; box-shadow: 0 3px 12px rgba(11,40,29,.35); }
.weather-marker.ranked:after { inset: -10px; color: var(--green); opacity: .24; }
.weather-marker:hover, .weather-marker.selected, .weather-marker.highlighted { transform: translate(-1px,-1px) scale(1.75); box-shadow: 0 0 0 5px rgba(255,255,255,.18), 0 5px 20px rgba(0,0,0,.55); }
.weather-marker.ranked:hover, .weather-marker.ranked.selected, .weather-marker.ranked.highlighted { transform: translate(-1px,-1px) scale(1.28); }
.weather-marker.selected:after, .weather-marker.highlighted:after { inset: -9px; opacity: .3; }
.city-name-label { padding: 5px 8px !important; border: 1px solid #385277 !important; border-radius: 6px !important; color: #edf4ff !important; background: rgba(12,23,41,.96) !important; box-shadow: 0 2px 8px rgba(0,0,0,.3) !important; font-size: 12px !important; font-weight: 700 !important; }
.city-name-label:before { display: none; }
.leaflet-popup-content-wrapper { border: 1px solid #385170; border-radius: 14px; color: var(--text); background: #101d31; box-shadow: 0 14px 40px rgba(0,0,0,.45); }
.leaflet-popup-content { width: 300px !important; margin: 16px 17px; }
.leaflet-popup-tip { background: #101d31; }
.popup-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.popup-top strong { display: block; font-size: 21px; font-weight: 800; letter-spacing: -.04em; }
.popup-top span { display: block; color: #91a6a0; font-size: 12px; }
.popup-score { font-size: 12px !important; font-weight: 800; white-space: nowrap; }
.popup-score.best { color: var(--green) !important; }
.popup-score.fair { color: var(--amber) !important; }
.popup-score.poor { color: var(--red) !important; }
.popup-week { display: grid; grid-template-columns: repeat(var(--forecast-days,7),1fr); gap: 3px; margin-top: 15px; padding-top: 12px; border-top: 1px solid #29413e; }
.popup-week span { min-width: 0; text-align: center; }
.popup-week b { display: block; font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif; font-size: 17px; font-weight: 400; line-height: 1.15; }
.popup-week small { display: block; margin-top: 3px; color: #eef8f4; font-size: 12px; font-weight: 700; }
.popup-week em { display: block; margin-top: 3px; color: #819a94; font-size: 12px; font-style: normal; line-height: 1.2; white-space: nowrap; }
.popup-copy { margin: 12px 0 0; color: #a8bbb5; font-size: 12px; }

.leaderboard { min-width: 0; overflow-y: auto; color: var(--text); background: var(--panel); scrollbar-color: #355051 transparent; }
.leaderboard-heading { position: sticky; z-index: 4; top: 0; padding: 26px 26px 20px; border-bottom: 1px solid var(--panel-line); background: rgba(16,26,43,.96); backdrop-filter: blur(16px); }
.leaderboard .eyebrow { color: var(--brand-blue); }
.leaderboard h2 { font-size: 34px; }
.leaderboard-heading > p:not(.eyebrow) { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.leaderboard-heading .leaderboard-caption { color: #718b86; font-size: 12px; }
.rank-score.best { color: var(--green); }
.rank-score.fair { color: var(--amber); }
.rank-score.poor { color: var(--red); }
.ranking { margin: 0; padding: 0; list-style: none; }
.ranking > li { margin: 0; padding: 0; }
.ranking-error { padding: 20px 26px; color: var(--muted); font-size: 12px; }
.rank-card { position: relative; width: 100%; margin: 0; padding: 18px 26px 19px 67px; border: 0; border-bottom: 1px solid var(--panel-line); color: inherit; background: transparent; text-align: left; cursor: pointer; transition: background .15s; }
.rank-card:hover { background: rgba(103,237,174,.045); }
.rank-card.active { background: rgba(103,237,174,.07); }
.ranking > li:first-child .rank-card { padding-top: 23px; padding-bottom: 23px; border-bottom-color: #376250; border-radius: 0; background: linear-gradient(100deg,rgba(102,237,174,.12),rgba(102,237,174,.025)); box-shadow: inset 3px 0 var(--green); }
.rank-number { position: absolute; top: 19px; left: 26px; width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid #3a5152; border-radius: 50%; color: var(--muted); font-size: 12px; }
.ranking > li:first-child .rank-number { top: 23px; color: #092218; border-color: var(--green); background: var(--green); font-weight: 800; }
.rank-heading { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.rank-winner { display: block; margin-bottom: 4px; color: var(--green); font-size: 12px; font-style: normal; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.rank-place strong { display: block; overflow: hidden; color: var(--text); font-size: 22px; font-weight: 800; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.rank-card.winner .rank-place strong { font-size: 25px; }
.rank-place span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.rank-score { font-size: 13px; font-weight: 800; white-space: nowrap; }
.rank-card.winner .rank-score { font-size: 17px; }
.rank-reason { margin: 11px 0 14px; color: #b4c7c2; font-size: 12px; }
.forecast-strip { display: grid; grid-template-columns: repeat(var(--forecast-days,7),1fr); gap: 4px; }
.forecast-day { min-width: 0; padding: 6px 2px 7px; border: 1px solid #2c4445; border-radius: 8px; text-align: center; background: rgba(5,18,19,.28); }
.forecast-day span { display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.forecast-day b { display: block; margin: 4px 0 3px; font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif; font-size: 18px; font-weight: 400; line-height: 1; }
.forecast-day small { display: block; color: #eef8f4; font-size: 12px; font-weight: 700; }
.forecast-day em { display: block; overflow: hidden; margin-top: 3px; color: #78918b; font-size: 12px; font-style: normal; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.show-more { width: calc(100% - 36px); margin: 14px 18px 4px; padding: 11px; border: 1px solid #385477; border-radius: 10px; color: #a9c9e8; background: transparent; font-size: 12px; font-weight: 700; }
.show-more:hover { border-color: var(--brand-blue); color: #fff; }
.ranking > li.ranking-loading { height: 148px; margin: 16px 20px 0; overflow: hidden; border: 1px solid #263a56; border-radius: 12px; background: radial-gradient(circle,#2b3f5d 0 13px,transparent 14px) 15px 15px / 28px 28px no-repeat, linear-gradient(#2b3f5d,#2b3f5d) 55px 18px / 38% 13px no-repeat, linear-gradient(#21334e,#21334e) 55px 39px / 22% 7px no-repeat, linear-gradient(#263a56,#263a56) right 20px top 19px / 46px 10px no-repeat, linear-gradient(#21334e,#21334e) 20px 70px / 70% 8px no-repeat, linear-gradient(#1b2b43,#1b2b43) 20px 96px / calc(100% - 40px) 35px no-repeat, #121f33; animation: skeleton-pulse 1.35s ease-in-out infinite alternate; }
.ranking > li.ranking-loading:last-child { margin-bottom: 16px; }
@keyframes skeleton-pulse { from { opacity: .62; } to { opacity: 1; } }
.data-note { padding: 22px 26px 28px; color: #718b86; font-size: 12px; }
.data-note p { margin: 0 0 6px; }
.data-note a, .data-note span { display: block; color: #7f92af; margin-top: 4px; }
.data-note a:hover { color: var(--brand-blue); }

dialog { width: min(560px,calc(100vw - 28px)); padding: 28px; border: 1px solid #385170; border-radius: 18px; color: var(--text); background: #101d31; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(2,9,9,.76); backdrop-filter: blur(5px); }
.dialog-close { float: right; padding: 7px 11px; border: 1px solid #3b5350; border-radius: 999px; color: #a8bbb5; background: transparent; font-size: 12px; }
dialog h2 { clear: left; max-width: 460px; font-size: 39px; }
dialog > p:not(.eyebrow) { max-width: 470px; color: #a5b8b2; }
.temperature-readout { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 28px 0 4px; font-size: 27px; font-weight: 800; letter-spacing: -.05em; }
.temperature-readout span { min-width: 0; }
.temperature-readout span:nth-child(2) { text-align: center; }
.temperature-readout span:last-child { text-align: right; }
.temperature-readout small { display: block; margin-bottom: 2px; color: var(--muted); font-family: "Trebuchet MS", Arial, sans-serif; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: lowercase; }
.range-triple { position: relative; height: 38px; margin-top: 10px; }
.range-track { position: absolute; top: 18px; left: 1px; right: 1px; height: 4px; border-radius: 4px; background: #314744; }
.range-fill { position: absolute; height: 100%; border-radius: inherit; background: var(--green); }
.range-triple input { position: absolute; top: 6px; left: 0; width: 100%; height: 28px; margin: 0; appearance: none; pointer-events: none; background: transparent; }
.range-triple input:focus { z-index: 4; outline: none; }
.range-triple input::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.range-triple input::-webkit-slider-thumb { width: 19px; height: 19px; margin-top: -8px; border: 3px solid #0d201f; border-radius: 50%; background: var(--green); box-shadow: 0 1px 5px rgba(0,0,0,.35); appearance: none; pointer-events: auto; }
.range-triple input::-moz-range-track { height: 4px; background: transparent; }
.range-triple input::-moz-range-thumb { width: 15px; height: 15px; border: 3px solid #0d201f; border-radius: 50%; background: var(--green); pointer-events: auto; }
.range-triple #tempIdeal { --ideal-thumb: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l2.55 6.95h7.25l-5.7 4.35 2.15 7.05L12 15.8l-6.25 4.05 2.15-7.05-5.7-4.35h7.25z' fill='%2366edae' stroke='%230d201f' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.range-triple #tempIdeal::-webkit-slider-thumb { width: 31px; height: 31px; margin-top: -14px; border: 0; border-radius: 0; background: var(--ideal-thumb) center / contain no-repeat; box-shadow: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.range-triple #tempIdeal::-moz-range-thumb { width: 31px; height: 31px; border: 0; border-radius: 0; background: var(--ideal-thumb) center / contain no-repeat; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.temperature-scale { display: flex; justify-content: space-between; color: #839994; font-size: 12px; }
.weather-option { display: flex; align-items: flex-start; gap: 11px; margin-top: 24px; padding: 14px 15px; border: 1px solid #2e4542; border-radius: 12px; color: #dcebe7; background: rgba(5,18,19,.3); cursor: pointer; }
.weather-option input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--green); }
.weather-option span { display: grid; gap: 3px; }
.weather-option strong { font-size: 12px; }
.weather-option small { color: #879d97; font-size: 12px; line-height: 1.45; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 30px; padding-top: 18px; border-top: 1px solid #2e4542; }
.reset-temperature { border: 0; padding: 0; color: var(--brand-blue); background: transparent; text-decoration: underline; text-underline-offset: 3px; font-size: 12px; font-weight: 700; }
.unit-toggle { display: flex; padding: 3px; border: 1px solid #3a5350; border-radius: 999px; }
.unit-toggle button { padding: 6px 9px; border: 0; border-radius: 999px; color: #93a8a2; background: transparent; font-size: 12px; }
.unit-toggle button.active { color: #071421; background: var(--brand-blue); }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: minmax(0,1fr) 420px; }
  .map-intro { width: 380px; }
  .map-intro h1 { font-size: 42px; }
}

@media (max-width: 820px) {
  :root { --header-height: 64px; }
  .site-header { grid-template-columns: auto auto minmax(0,1fr); padding: 0 15px; }
  .week-label { display: none; }
  .forecast-controls { margin-left: 10px; }
  .header-actions { min-width: 0; }
  .temperature-button { padding: 8px 11px; font-size: 12px; }
  .app-shell { height: auto; display: block; }
  .map-stage { height: 62vh; min-height: 480px; }
  .leaderboard { overflow: visible; }
  .leaderboard-heading { position: static; }
  .map-intro { top: 16px; left: 16px; width: calc(100% - 32px); padding: 16px 17px; }
  .map-intro h1 { max-width: 340px; font-size: 37px; }
  .map-legend { left: 16px; bottom: 16px; max-width: calc(100% - 32px); overflow-x: auto; }
}

@media (max-width: 480px) {
  :root { --header-height: 104px; }
  .site-header { grid-template-areas: "brand actions" "forecast forecast"; grid-template-columns: 1fr auto; grid-template-rows: 54px 50px; padding: 0 12px; }
  .wordmark { grid-area: brand; font-size: 20px; }
  .forecast-controls { grid-area: forecast; justify-self: center; margin-left: 0; }
  .forecast-days-toggle button { min-width: 58px; padding: 5px 7px; font-size: 12px; }
  .about-button { display: none; }
  .header-actions { grid-area: actions; width: 100%; }
  .temperature-button { width: 100%; max-width: 218px; margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .map-stage { height: 68vh; min-height: 520px; }
  .map-intro h1 { font-size: 34px; }
  .map-intro > p:last-child { max-width: 280px; }
  .map-legend { width: calc(100% - 32px); justify-content: space-between; gap: 0; }
  .map-legend span { padding: 5px 7px; font-size: 12px; }
  .leaderboard-heading { padding: 25px 20px 18px; }
  .leaderboard h2 { font-size: 32px; }
  .ranking { padding: 0 12px; }
  .ranking > li.ranking-loading { margin-right: 6px; margin-left: 6px; }
  .rank-card { padding-left: 45px; }
  .rank-card:first-child { padding-left: 51px; }
  .forecast-day b { font-size: 17px; }
  dialog { padding: 22px 19px; }
  dialog h2 { font-size: 34px; }
  .dialog-actions { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
