@font-face { font-family:DM; src:url('/fonts/dm-sans-latin.woff2'); font-display:swap; }
@font-face { font-family:Barlow; src:url('/fonts/barlow-condensed-800-latin.woff2'); font-weight:800; font-display:swap; }

* { box-sizing:border-box; }
:root {
  color-scheme:light;
  --paper:#f3edf7; --panel:#fffaf2; --ink:#261c33; --muted:#65566e;
  --line:#c5b4d1; --purple:#6d378a; --button-text:#fff;
  --gold:#e4a846; --gold-ink:#67420e; --red:#a32338; --green:#275c38;
  --route:#2e1c40; --route-ink:#fff6ed; --route-muted:#dfcbe9; --rung:#8d729f;
  --accent:var(--purple); --bg:var(--paper);
}
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#20192c; --panel:#2c2238; --ink:#fff4ef; --muted:#d0bed8;
  --line:#5e4b70; --purple:#dbb2f8; --button-text:#281934;
  --gold:#e6b66a; --gold-ink:#f2ca90; --red:#ff9fa7; --green:#b7ebbe;
  --route:#342246; --rung:#a084b3;
}

[hidden] { display:none !important; }
body { margin:0; background:var(--paper); color:var(--ink); font:16px/1.45 DM,system-ui,sans-serif; }
main { max-width:1050px; margin:auto; padding:22px clamp(16px,4vw,38px) 36px; }
header,.stats,.meter-label,.actions { display:flex; align-items:center; justify-content:space-between; gap:12px; }
header { padding-bottom:12px; border-bottom:1px solid var(--line); }
.brand { color:var(--purple); font-weight:900; letter-spacing:.1em; text-decoration:none; }
.header-actions { display:flex; gap:6px; }
.header-actions button { padding-inline:10px; }
.intro { padding:22px 0 20px; }
.title-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.intro p { margin:7px 0 0; color:var(--muted); }
h1 { margin:0; font:800 clamp(48px,8.2vw,92px)/.92 Barlow,DM,sans-serif; text-transform:uppercase; letter-spacing:-.02em; }
.beta-label {
  align-self:flex-start; margin-top:7px; padding:3px 8px;
  color:var(--purple); border:1px solid currentColor;
  font-size:12px; font-weight:800;
}
h2 { margin:14px 0 4px; font-size:clamp(21px,4vw,32px); line-height:1.14; }
.ladder-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(230px,29%); align-items:start; gap:16px; }
.panel { min-width:0; padding:clamp(16px,3vw,28px); background:var(--panel); border:1px solid var(--line); border-top:4px solid var(--purple); }
label { display:block; font-weight:800; margin-bottom:5px; }
button,input,select {
  font:inherit; color:inherit; background:var(--panel); border:1px solid var(--line);
  padding:8px 12px; min-height:44px; border-radius:3px;
}
button { cursor:pointer; font-weight:700; }
.primary { color:var(--button-text); background:var(--purple); border-color:var(--purple); }
.primary:hover { filter:brightness(.93); }
select { width:100%; }
:focus-visible { outline:3px solid var(--purple); outline-offset:3px; }

.part-picker { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding:0; margin:0; border:0; }
.part-picker legend { font-weight:800; padding:0; margin-bottom:8px; }
.part-picker label { display:flex; gap:8px; align-items:center; margin:0; padding:12px; border:1px solid var(--line); cursor:pointer; }
.part-picker label:has(:checked) { border-color:var(--purple); box-shadow:inset 0 -3px var(--purple); background:var(--paper); }
.part-picker input { flex:none; min-height:0; margin:0; accent-color:var(--purple); }
.part-picker small { display:block; color:var(--muted); font-weight:400; }
.run-rules { color:var(--muted); margin:16px 0; }
.run-rules strong { color:var(--ink); }
.start-button { display:inline-flex; align-items:center; gap:20px; padding-inline:16px; }
.start-button span { font-size:19px; }

.climb-board { background:var(--route); color:var(--route-ink); padding:18px 20px 20px; border-top:4px solid var(--gold); }
.climb-board h2 { font-size:15px; margin:0 0 13px; }
#climb-route { position:relative; margin:0; padding:0; list-style:none; }
#climb-route::before {
  content:""; position:absolute; inset:0 auto 0 3px; width:35px;
  border-inline:2px solid var(--rung); pointer-events:none;
}
#climb-route li {
  position:relative; display:grid; grid-template-columns:45px minmax(0,1fr); align-items:center; gap:10px;
  min-height:52px; padding:6px 8px 6px 0;
}
#climb-route li + li { margin-top:3px; }
#climb-route li::before {
  content:""; position:absolute; top:50%; left:3px; width:35px;
  border-top:2px solid var(--rung); pointer-events:none;
}
#climb-route li:is([data-step="active"],[data-step="start"]) {
  background:color-mix(in srgb,var(--gold) 12%,transparent);
}
.route-marker {
  position:relative; display:grid; place-items:center; justify-self:center;
  width:25px; height:25px; border:1px solid var(--rung); border-radius:50%;
  background:var(--route); color:var(--route-ink); font-size:14px;
}
[data-step="cleared"] .route-marker { background:#35604c; color:#efffec; border-color:#81b89a; }
:is([data-step="start"],[data-step="active"],[data-step="reached"]) .route-marker {
  color:#35210c; border-color:var(--gold); background:var(--gold);
}
.route-details strong,.route-details small { display:block; }
.route-details strong { font-size:15px; }
.route-details small { margin-top:1px; color:var(--route-muted); font-size:13px; }

.stats { flex-wrap:wrap; justify-content:flex-start; font-weight:700; font-variant-numeric:tabular-nums; }
.stats > strong {
  color:var(--gold-ink); background:color-mix(in srgb,var(--gold) 22%,var(--panel));
  padding:4px 9px; border-bottom:2px solid var(--gold);
}
.stats > :last-child { margin-left:auto; color:var(--muted); }
#timer.urgent { color:var(--red); }
#rule { color:var(--muted); margin:6px 0 14px; }
.meter-label label { margin:0; }
.meter-label strong { color:var(--purple); font-variant-numeric:tabular-nums; }
progress { display:block; width:100%; height:10px; margin:6px 0 12px; accent-color:var(--purple); }
#time-track { height:5px; margin:8px 0 0; accent-color:var(--gold-ink); }
.input-row { display:flex; gap:8px; }
input { flex:1; min-width:0; }
input[aria-invalid="true"] { border-color:var(--red); box-shadow:inset 0 0 0 1px var(--red); }
#feedback { min-height:1.45em; margin:6px 0; overflow-wrap:anywhere; }
.error { color:var(--red); font-weight:800; }
.good { color:var(--green); font-weight:700; }
.next-flight { margin:5px 0 8px; font-size:13px; color:var(--muted); }
#answers { list-style:none; display:flex; flex-wrap:wrap; gap:6px; padding:0; margin:0; }
#answers li { padding:4px 8px; background:var(--paper); border-bottom:2px solid var(--purple); }
main:has(#play:not([hidden])) .intro { padding:10px 0; }
main:has(#play:not([hidden])) h1 { font-size:clamp(29px,5vw,47px); }
main:has(#play:not([hidden])) .intro :is(.beta-label,p) { display:none; }

#share-status:empty { display:none; }
#share-text { box-sizing:border-box; width:100%; padding:8px; font:inherit; color:inherit; background:var(--paper); }
.actions { justify-content:flex-start; flex-wrap:wrap; gap:8px; }
.result-summary { margin-bottom:14px; padding:10px 12px; border-left:3px solid var(--gold); background:var(--paper); }
.result-summary h2 { margin:0 0 6px; }
.result-summary p { margin:4px 0 0; }
#score { font-weight:800; }
#best { color:var(--muted); }
#best:empty { display:none; }
#result h3 { margin:17px 0 4px; font-size:15px; }
.recap { list-style:none; padding:0; }
.recap li { border-bottom:1px solid var(--line); }
.recap summary { cursor:pointer; min-height:44px; padding:12px 0; font-weight:700; }
.recap p { margin:0 0 10px; overflow-wrap:anywhere; }

#feedback-dialog { width:min(480px,calc(100% - 24px)); max-height:calc(100dvh - 24px); overflow:auto; padding:18px; border:1px solid var(--line); border-top:4px solid var(--purple); background:var(--panel); color:var(--ink); }
#feedback-dialog::backdrop { background:#19151fc7; }
#feedback-dialog .close { float:right; min-width:44px; }
#feedback-dialog h2 { margin:0 50px 8px 0; }
#feedback-form { clear:both; display:grid; gap:6px; margin-top:12px; }
#feedback-form :is(input,textarea,select) { width:100%; font:inherit; color:inherit; border:1px solid var(--line); background:var(--paper); }
#feedback-form textarea { resize:vertical; min-height:90px; padding:8px; }
#feedback-form .fine-print,#feedback-status,#feedback-confirmation { color:var(--muted); font-size:14px; }
#feedback-status:empty,#feedback-confirmation:empty { display:none; }
.feedback-trap { position:absolute; left:-10000px; width:1px; height:1px; overflow:hidden; }

@media(max-width:680px) {
  .ladder-layout { grid-template-columns:minmax(0,1fr); gap:12px; }
  .climb-board { padding:12px; }
  .climb-board h2 { margin-bottom:8px; }
  #climb-route { display:flex; flex-direction:row-reverse; justify-content:flex-end; }
  #climb-route::before { display:none; }
  #climb-route li {
    flex:0 1 33.33%; min-width:0; display:grid; grid-template-columns:minmax(0,1fr);
    justify-items:center; align-content:start; gap:4px; padding:5px 3px;
    text-align:center;
  }
  #climb-route li + li { margin:0; }
  #climb-route li::before { top:17px; left:0; width:100%; }
  #climb-route li:nth-last-child(1 of :not([hidden]))::before { left:50%; width:50%; }
  #climb-route li:nth-child(1 of :not([hidden]))::before { width:50%; }
  #climb-route li:nth-child(1 of :not([hidden])):nth-last-child(1 of :not([hidden]))::before { display:none; }
  .route-details strong,.route-details small { font-size:12px; }
}
@media(max-width:500px) {
  main { padding:12px; }
  .intro { padding:17px 0 14px; }
  .brand,.header-actions button { font-size:13px; }
  .part-picker label { padding:9px; }
  .panel { padding:13px; }
  .stats { gap:7px; font-size:14px; }
  #play h2 { margin-top:10px; }
  #play #rule { margin-bottom:9px; }
}
@media(max-height:430px) and (orientation:landscape) {
  main:has(#play:not([hidden])) { padding-top:8px; }
  main:has(#play:not([hidden])) header { padding-bottom:6px; }
  main:has(#play:not([hidden])) .intro { padding:7px 0; }
  #play { padding:12px; }
  main:has(#play:not([hidden])) .climb-board { display:none; }
  #play h2 { margin-top:8px; }
}

#climb-route .route-review { background:transparent; color:inherit; border:0; min-height:0; padding:0; font:inherit; text-decoration:underline; }
.route-review::after { content:""; position:absolute; inset:0; }
