:root {
  --bg: #0b1220;
  --card: #121b2d;
  --card2: #18233a;
  --line: #24314d;
  --text: #e8eef9;
  --muted: #93a3bf;
  --ice: #5cc8ff;
  --blue: #2f6bff;
  --green: #2fbf71;
  --amber: #f5a524;
  --red: #ef4444;
  --purple: #a78bfa;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding-bottom: var(--safe-bottom);
}
a { color: var(--ice); }
h1, h2, h3, .num { font-family: 'Barlow Condensed', Inter, sans-serif; letter-spacing: .3px; }
h2 { margin: 0 0 10px; font-size: 21px; font-weight: 700; }
h3 { margin: 14px 0 8px; font-size: 17px; font-weight: 600; color: var(--muted); }
input, select, textarea, button { font: inherit; }
input, select, textarea { font-size: 16px; } /* stops iOS zoom on focus */

.top {
  position: sticky; top: 0; z-index: 1100;
  background: rgba(11, 18, 32, .94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + var(--safe-top)) 12px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; flex: 0 0 auto; }
.brand > div { flex: 1 1 auto; min-width: 0; }
.brand h1 { margin: 0; font-size: 22px; line-height: 1.1; }
.brand .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); font-size: 20px; cursor: pointer;
}
.iconbtn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: 0 0 auto; text-decoration: none; color: var(--text); font-size: 13px; font-weight: 500;
  padding: 5px 11px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line);
}

/* Grid: minmax(0,1fr) so wide children (maps, scrollers) can never push a column off-screen. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px; max-width: 1180px; margin: 0 auto; }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .span2 { grid-column: 1 / -1; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.skeleton { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: #fca5a5; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

/* Alerts banner */
.alert-banner {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; border: 1px solid;
  background: #3a1414; border-color: #7f1d1d; color: #fee2e2;
}
.alert-banner.Moderate, .alert-banner.Minor { background: #3a2a0c; border-color: #92400e; color: #fef3c7; }
.alert-banner strong { display: block; font-size: 16px; }
.alert-banner span { font-size: 13px; opacity: .9; }

/* Beanie */
.beanie { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.beanie .emoji { font-size: 26px; }
.beanie.active { background: linear-gradient(90deg, #3b1d6e, #1d3b6e); border-color: var(--purple); }
.beanie .txt { flex: 1 1 auto; min-width: 0; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.tile .label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .num { font-size: 30px; font-weight: 700; line-height: 1.05; }
.tile .num small { font-size: 15px; font-weight: 600; color: var(--muted); }
.tile .detail { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 14px; margin-top: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.lens { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--card2); border-left: 4px solid var(--ice); }
.lens.low { border-left-color: var(--amber); }
.lens.bright { border-left-color: #fde047; }

/* Lifts */
.lifts { list-style: none; margin: 0; padding: 0; }
.lifts li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lifts li:last-child { border-bottom: 0; }
.lifts .name { flex: 1 1 auto; min-width: 0; }
.lifts .wait { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pill { flex: 0 0 auto; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #2a3550; color: #c7d2e8; white-space: nowrap; }
.pill.open { background: rgba(47, 191, 113, .18); color: #7ee2a8; }
.pill.hold, .pill.wind_hold, .pill.on_hold { background: rgba(245, 165, 36, .18); color: #fcd27b; }
.pill.closed, .pill.closed_for_season { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.pill.expected, .pill.scheduled { background: rgba(47, 107, 255, .2); color: #a9c1ff; }

/* Message */
.message p { margin: 0 0 10px; }
.message strong { color: var(--ice); }

/* Forecast */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 420px) { .two { grid-template-columns: minmax(0, 1fr); } }
.period { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.period .when { font-weight: 600; }
.period .t { font-family: 'Barlow Condensed', sans-serif; font-size: 26px; font-weight: 700; }
.fc5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 520px) { .fc5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fcday { background: var(--card2); border-radius: 12px; padding: 8px; text-align: center; min-width: 0; border: 1px solid var(--line); }
.fcday .d { font-weight: 600; font-size: 13px; }
.fcday .s { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 700; color: var(--ice); }
.fcday .x { font-size: 11.5px; color: var(--muted); }
details { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-top: 8px; }
details summary { cursor: pointer; font-weight: 600; }
details pre, .pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: #cbd5e1; margin: 8px 0 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  color: var(--text); text-decoration: none; cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: white; }
.btn.danger { background: transparent; border-color: #7f1d1d; color: #fca5a5; }
.btn:disabled { opacity: .5; }

/* 12-day */
.hscroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.outday { flex: 0 0 74px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; scroll-snap-align: start; }
.outday .d { font-size: 12px; font-weight: 600; }
.outday .ic { font-size: 22px; }
.bar { height: 70px; display: flex; align-items: flex-end; justify-content: center; margin: 4px 0; }
.bar i { display: block; width: 22px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #9be3ff, var(--ice)); min-height: 2px; }
.outday .sn { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 700; color: var(--ice); }
.outday .x { font-size: 11.5px; color: var(--muted); }

/* Season */
.season-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.season-top .num { font-size: 44px; font-weight: 700; }
.cmp { margin-top: 10px; }
.cmp .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.cmp .track { position: relative; height: 12px; background: #0d1526; border-radius: 999px; overflow: hidden; margin-top: 4px; border: 1px solid var(--line); }
.cmp .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--blue), var(--ice)); border-radius: 999px; }
.cmp .pct { font-weight: 700; }
.cmp .pct.up { color: #7ee2a8; }
.cmp .pct.down { color: #fca5a5; }

/* Cameras */
.cams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 700px) { .cams { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cam { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-width: 0; display: flex; flex-direction: column; }
.cam button.thumb { display: block; padding: 0; border: 0; background: #000; cursor: zoom-in; width: 100%; }
.cam img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #05080f; }
.cam .cap { padding: 6px 8px; font-size: 12.5px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.cam .placeholder { aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--ice); background: linear-gradient(135deg, #10203d, #0b1220); text-decoration: none; }
.roadcam { flex: 0 0 220px; scroll-snap-align: start; }
.roadcam.exit { border-color: var(--ice); box-shadow: 0 0 0 1px var(--ice) inset; }

/* Roads */
.seg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.seg:last-child { border-bottom: 0; }
.seg .dot { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; background: var(--green); }
.seg .dot.unknown { background: #64748b; }
.seg .dot.R1 { background: #facc15; }
.seg .dot.R2 { background: var(--amber); }
.seg .dot.R3 { background: #f97316; }
.seg .dot.closed { background: var(--red); }
.seg .body { flex: 1 1 auto; min-width: 0; }
.seg .title { font-weight: 600; }
.mapwrap { width: 100%; min-width: 0; margin-top: 10px; }
#roadMap { width: 100%; height: 300px; border-radius: 12px; border: 1px solid var(--line); background: #0d1526; }
.leaflet-container { font: inherit; }

/* Other resorts */
.resorts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 760px) { .resorts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.resort { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.resort h3 { margin: 0 0 6px; color: var(--text); font-size: 19px; }

/* Push settings */
.toggles { display: grid; gap: 8px; margin: 10px 0; }
.toggle { display: flex; align-items: center; gap: 10px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--blue); }
.toggle span { flex: 1 1 auto; }

/* Overlay */
.overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, .72); display: flex; align-items: flex-end; justify-content: center; }
.overlay[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 900px; max-height: calc(100vh - 40px - var(--safe-top)); max-height: calc(100dvh - 40px - var(--safe-top));
  background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
}
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { margin: 0; flex: 1 1 auto; min-width: 0; color: var(--text); }
.sheet-body { padding: 12px 14px 18px; overflow: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.sheet-body img { display: block; width: 100%; height: auto; border-radius: 10px; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 16px 12px 28px; }
.foot .credits { margin-top: 6px; }
