:root {
  --bg: #0f1419; --panel: rgba(15, 20, 25, .78); --fg: #e8edf2; --muted: #93a1ae; --line: #2a333d;
  --a: #4fa3ff; --b: #ff8a3d; --accent: #4fa3ff; --input: #18202a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; }
a { color: var(--accent); }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.pickers { display: flex; align-items: center; gap: 8px; flex: 1 1 520px; min-width: 0; }
.picker { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.swatch.a { background: var(--a); } .swatch.b { background: var(--b); }
.picker input { width: 100%; min-width: 0; background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; }
.picker input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
  background: #161e27; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 20; }
#swap { background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; cursor: pointer; font-size: 15px; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); }
.tools label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; cursor: pointer; }
.tools select { background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; font: inherit; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--input); color: var(--muted); border: 0; padding: 5px 10px; cursor: pointer; font: inherit; }
.seg button.on { background: #24425f; color: var(--fg); }
main { position: relative; flex: 1 1 auto; min-height: 300px; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line); pointer-events: none; }
.panel { position: absolute; top: 10px; max-width: calc(50% - 20px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; pointer-events: none; backdrop-filter: blur(4px); }
.panel[data-side="0"] { left: 10px; border-left: 3px solid var(--a); }
.panel[data-side="1"] { left: calc(50% + 10px); border-left: 3px solid var(--b); }
.panel .title { font-weight: 650; font-size: 15px; }
.panel .title small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.stats { display: grid; grid-template-columns: auto auto; gap: 1px 12px; margin: 6px 0 0; font-size: 12.5px; }
.stats dt { color: var(--muted); } .stats dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.status { color: var(--muted); font-size: 12px; margin-top: 4px; }
.status:empty { display: none; }
#scalebar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); text-align: center; font-size: 12px; color: var(--fg); background: var(--panel); padding: 4px 10px 3px; border-radius: 8px; pointer-events: none; }
#scalebar .bar { height: 6px; border: 2px solid var(--fg); border-top: 0; margin: 0 auto 2px; }
#legend { position: absolute; right: 58px; bottom: 14px; background: var(--panel); border-radius: 8px; padding: 6px 10px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: 40%; pointer-events: none; }
#legend i { display: inline-block; width: 14px; height: 4px; outline: 1px solid rgba(255,255,255,.35); vertical-align: middle; margin-right: 4px; border-radius: 2px; }
#hint { position: absolute; left: 10px; bottom: 14px; color: var(--muted); font-size: 12px; max-width: 34%; pointer-events: none; }
footer { padding: 6px 16px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  header { padding: 8px 12px; } h1 { font-size: 14px; }
  .pickers { flex-basis: 100%; }
  .panel { max-width: calc(50% - 12px); padding: 6px 8px; } .panel[data-side="0"] { left: 4px; } .panel[data-side="1"] { left: calc(50% + 4px); }
  .stats { font-size: 11px; } .stats .x { display: none; } #hint { display: none; } #legend { max-width: 60%; bottom: 52px; }
  .panel .title { font-size: 13px; } .panel .title small { display: block; margin: 0; }
  .pop { left: 0; right: 0; min-width: 0; } .picker[data-side="1"] .pop { left: 0; }
}

/* portrait: resorts stacked top / bottom */
#stage.stacked .divider { top: 50%; bottom: auto; left: 0; right: 0; width: auto; height: 1px; }
#stage.stacked .panel { max-width: calc(100% - 64px); }
#stage.stacked .panel[data-side="0"] { left: 6px; top: 6px; }
#stage.stacked .panel[data-side="1"] { left: 6px; top: calc(50% + 6px); }
#stage.stacked #legend { bottom: auto; top: 6px; right: 6px; max-width: 34%; flex-direction: column; }
#stage.stacked #scalebar { left: auto; right: 6px; transform: none; bottom: 8px; }

.tools .slider input { width: 90px; accent-color: var(--accent); }
.tools .slider output { min-width: 2.6em; color: var(--fg); font-variant-numeric: tabular-nums; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* search popover */
.pop { display: none; position: absolute; top: calc(100% + 4px); left: 16px; right: 0; z-index: 20;
  background: #161e27; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.55); overflow: hidden; }
.picker.open .pop { display: flex; flex-direction: column; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pop-head select { background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; margin-left: 4px; }
.results { position: relative; margin: 0; padding: 4px; list-style: none; max-height: min(62vh, 560px); overflow: auto; }
.results li { padding: 5px 8px; border-radius: 6px; display: flex; justify-content: space-between; gap: 12px; }
.results li[data-k] { cursor: pointer; }
.results li .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li .m { color: var(--muted); font-size: 12px; margin-left: 4px; }
.results li .v { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.results li.act, .results li[data-k]:hover { background: #22303e; }
.results li.cur .n { color: var(--accent); font-weight: 600; }
.results li.h1 { position: sticky; top: -4px; background: #161e27; color: var(--fg); font-weight: 650; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; padding-top: 9px; z-index: 1; }
.results li.h2 { color: var(--muted); font-size: 12px; font-weight: 600; padding: 7px 8px 2px; }

.btn { background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; }
.btn:hover, .seg button:hover { color: var(--fg); }

/* lift labels + hover card */
.lift-label { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-size: 10.5px; font-weight: 600; line-height: 1; padding: 1px 3px;
  border-radius: 3px; color: #fff6d6; transform-origin: 50% 50%; pointer-events: auto; cursor: default; will-change: transform;
  text-shadow: 0 0 2px #111418, 0 0 2px #111418, 0 0 3px #111418, 0 0 4px rgba(17,20,24,.8); }
.lift-label .ico, .lift-tip .ico { width: 14px; height: 14px; filter: drop-shadow(0 0 1.5px #111418); fill: none; stroke: #ffd23f; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.lift-label .seat { text-shadow: none; font-size: 9px; font-weight: 700; color: #111418; background: #ffd23f; border-radius: 3px; padding: 1px 3px; }
.lift-label.hot { background: #ffd23f; color: #111418; text-shadow: none; z-index: 2; }
.lift-label.hot .ico { stroke: #111418; } .lift-label.hot .seat { background: #111418; color: #ffd23f; }
.lift-tip { position: absolute; left: 0; top: 0; z-index: 15; pointer-events: none; max-width: 280px; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.4;
  background: #fff4c2; color: #1d1a10; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.lift-tip .t { display: flex; align-items: center; gap: 5px; font-weight: 650; font-size: 13.5px; }
.lift-tip .ico { stroke: #1d1a10; }
.lift-tip .m { color: #5b5440; }

/* compass + zoom */
#navctl { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 6; }
#navctl button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; font-size: 18px; line-height: 1; backdrop-filter: blur(4px); display: grid; place-items: center; padding: 0; }
#navctl button:hover { background: #22303e; }
#compass svg { width: 32px; height: 32px; color: var(--fg); }
#compass .needle { transform-origin: 20px 21px; transform-box: view-box; }
#stage.stacked #navctl { top: auto; bottom: 40px; }
#stage.stacked #legend { right: 56px; }

/* collapsible resort info */
.panel { pointer-events: auto; }
.panel .title { cursor: pointer; user-select: none; display: flex; align-items: baseline; gap: 2px; flex-wrap: wrap; }
.panel .chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 8px 2px 1px; transition: transform .15s; align-self: center; }
.panel.collapsed .chev { transform: rotate(-45deg); }
.panel.collapsed .stats { display: none; }

@media (max-width: 760px) { #legend { display: none; } }

/* ---- round 4: compact header, resort cards with built-in picker ---- */
header { padding: 8px 12px; gap: 8px 16px; }
header h1 { font-size: 14px; }
.tools { flex: 1 1 auto; justify-content: flex-end; gap: 6px 14px; }
.tool-btns { display: inline-flex; gap: 6px; }
.btn.icon { width: 32px; padding: 5px 0; text-align: center; font-weight: 650; }
#swap { font-size: 15px; }

.panel { padding: 6px 8px 8px 10px; min-width: 200px; }
.panel .title { display: flex; align-items: flex-start; gap: 4px; cursor: default; }
.panel .pick { flex: 1 1 auto; min-width: 0; text-align: left; background: none; border: 0; color: var(--fg); font: inherit; padding: 3px 4px; border-radius: 6px; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 6px; }
.panel .pick:hover, .panel .pick:focus-visible { background: rgba(255,255,255,.07); outline: none; }
.panel .pick .nm { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.panel .pick .srch { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; flex: none; align-self: center; }
#reset svg { display: block; margin: 0 auto; }
.panel .pick small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .collapse { flex: none; width: 28px; height: 28px; border: 0; background: none; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.panel .collapse:hover { background: rgba(255,255,255,.07); }
.panel .chev { margin: 0; }
.panel .stats { padding-left: 4px; }

/* picker sheet: popover on desktop, full screen on phones */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(5, 8, 12, .45); }
.sheet[hidden] { display: none; }
.sheet-card { position: absolute; top: 64px; width: min(460px, calc(100vw - 24px)); max-height: calc(100% - 90px); display: flex; flex-direction: column;
  background: #161e27; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.6); overflow: hidden; }
#picker[data-side="0"] .sheet-card { left: 12px; }
#picker[data-side="1"] .sheet-card { left: calc(50% + 12px); }
.sheet-head { display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.sheet-head input { flex: 1; min-width: 0; background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 16px; }
.sheet-head input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.sheet .results { max-height: none; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet .results li { padding: 8px 10px; }
.sheet .results li.h1 { top: -4px; }
.modal .sheet-card { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 24px)); }
.about h2 { flex: 1; margin: 0; font-size: 16px; }
.about-body { padding: 4px 16px 16px; overflow: auto; font-size: 13.5px; line-height: 1.55; }
.about-body h3 { font-size: 13px; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.about-body ul { margin: 0; padding-left: 18px; }
.about-body .muted { color: var(--muted); font-size: 12.5px; }

#credit { position: absolute; left: 8px; bottom: 6px; z-index: 5; background: none; border: 0; padding: 2px 4px; font: inherit; font-size: 10.5px; color: var(--muted); opacity: .8; cursor: pointer; }
#credit:hover { color: var(--fg); text-decoration: underline; }
#scalebar { bottom: 10px; }

@media (max-width: 760px) {
  header { padding: 6px 10px; gap: 6px 10px; }
  header h1 { display: none; }
  .tools { justify-content: space-between; gap: 6px 10px; font-size: 13px; }
  .tools .slider input { width: 72px; }
  .sheet { background: #161e27; }
  .sheet-card, #picker[data-side] .sheet-card, .modal .sheet-card { inset: 0; top: 0; left: 0; transform: none; width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
  .sheet .results li { padding: 11px 12px; }
  .panel { min-width: 0; max-width: calc(100% - 64px); }
  .panel .pick .nm { font-size: 14px; }
}

/* phone search: no page scrolling behind the sheet, no zoom-on-focus, two-line rows */
html.sheet-open, html.sheet-open body { overflow: hidden; overscroll-behavior: none; }
@media (max-width: 760px) {
  .sheet { bottom: auto; height: 100%; }
  .sheet-card, #picker[data-side] .sheet-card, .modal .sheet-card { position: absolute; height: auto; }
  .sheet-head { padding: 8px 10px; }
  .sheet-head input, .pop-head select { font-size: 16px; }
  .pop-head { font-size: 13px; padding: 6px 10px; }
  .pop-head select { padding: 4px 6px; max-width: 60vw; }
  .sheet .results li[data-k] { align-items: center; padding: 9px 12px; }
  .sheet .results li .n { display: flex; flex-direction: column; white-space: normal; }
  .sheet .results li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
  .sheet .results li .m { margin: 1px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #pickClose { width: 40px; height: 40px; flex: none; }
}

/* brand */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-size: 17px; font-weight: 650; letter-spacing: .1px; white-space: nowrap; }
.brand img { display: block; }
.brand b { color: inherit; font-weight: inherit; }
@media (max-width: 760px) { .brand { font-size: 16px; gap: 6px; } .brand img { width: 26px; height: 26px; } }
.about-body h3 + .links { margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.resort-facts { color: var(--muted); }

/* official website link at the foot of the resort card */
.stats .site-row { grid-column: 1 / -1; text-align: left; margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }
.stats .site { color: var(--accent); text-decoration: none; font-size: 12.5px; pointer-events: auto; }
.stats .site:hover { text-decoration: underline; }

/* loading spinner over each side's map */
.loading { position: absolute; top: 0; bottom: 0; left: 0; width: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  pointer-events: none; z-index: 3; color: var(--muted); font-size: 12px; }
.loading[hidden] { display: none; }
.loading[data-side="1"] { left: 50%; }
#stage.stacked .loading { left: 0; width: 100%; height: 50%; bottom: auto; }
#stage.stacked .loading[data-side="1"] { top: 50%; }
.loading i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(232, 237, 242, .18); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.loading[data-side="1"] i { border-top-color: var(--b); }
.loading span { background: var(--panel); padding: 2px 8px; border-radius: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading i { animation-duration: 2.4s; } }

/* elevation toggle: two icon buttons */
.seg.elev button { padding: 4px 7px; display: grid; place-items: center; color: var(--muted); }
.seg.elev button svg { display: block; }
.seg.elev button:not(.on) svg polygon { opacity: .55; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 760px) {
  header { flex-wrap: nowrap; }
  .tools { flex: 0 1 auto; margin-left: auto; flex-wrap: nowrap; gap: 6px; }
}
.about-body .made-by { margin-top: 10px; }
@media (max-width: 400px) {
  header { padding: 6px 8px; gap: 6px; }
  .brand { font-size: 15px; gap: 5px; }
  .brand img { width: 24px; height: 24px; }
  .tools, .tool-btns { gap: 4px; }
  .seg.elev button { padding: 3px 4px; }
  .seg.elev button svg { width: 25px; height: 15px; }
  .tool-btns .btn.icon { width: 30px; }
}
.stats .site-row { display: flex; flex-wrap: wrap; gap: 2px 14px; }

/* browse tree in the resort search */
.results li.node { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--fg); padding: 7px 8px; border-radius: 6px; }
.results li.node:hover { background: #1d2833; }
.results li.node .v { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px; }
.results li.node .tw { width: 0; height: 0; border: 4.5px solid transparent; border-left: 6px solid var(--muted); border-right: 0; transition: transform .15s; flex: none; }
.results li.node.open .tw { transform: rotate(90deg); }
.results li.cont { position: sticky; top: -4px; z-index: 1; background: #161e27; font-size: 13.5px; }
.results li.ctry { padding-left: 22px; font-weight: 550; }
.results li.ctry ~ li[data-k], .results li.reg { padding-left: 36px; }
.results li.more { padding-left: 36px; color: var(--accent); font-weight: 500; font-size: 13px; }
.results li.reg { color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 8px; padding-bottom: 2px; }
.results li.reg span { font-weight: 400; opacity: .7; }
@media (max-width: 760px) { .results li.node { min-height: 44px; } }

/* single-resort mode */
#stage.single .panel[data-side="1"], #stage.single .divider, #stage.single .loading[data-side="1"] { display: none; }
#stage.single .loading[data-side="0"] { width: 100%; height: 100%; }
header:has(#elevSingle.on) #swap { opacity: .35; pointer-events: none; }
#swap svg, #infoBtn svg, #reset svg { display: block; margin: 0 auto; }

/* "show on the other side" button at the end of each search row */
.results li[data-k] { align-items: center; }
.results li .other { flex: none; margin: -6px -4px -6px 2px; width: 36px; align-self: stretch; display: grid; place-items: center; background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); cursor: pointer; border-radius: 0 6px 6px 0; }
.results li .other:hover { background: #2a3a4a; color: var(--fg); }
@media (max-width: 760px) { .results li .other { width: 46px; margin: -9px -12px -9px 4px; } }
/* distance / size column: flush right, next to the other-side button */
.results li[data-k] .v { margin-left: auto; text-align: right; }
