/* Climb. The look of his reference (DitherFX): black, thin 1 px rules, 12 px corners, a white pill for the selected
   tab, acid lime only where it matters. Every surface is a raster (public/img/ui/v2-*, drawn by tools/plates.py)
   used as a border-image; no CSS boxes stand in for objects. One type system: Archivo for words, Geist Mono for
   numbers and the contract. */
@font-face { font-family: "Archivo"; src: url("/fonts/archivo.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geistmono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #000000;
  --bone: #f2f2ee;
  --ash: #7c7c78;
  --ash2: #b0b0aa;
  --rule: #1f1f1f;
  --lime: #d4f53c;
  --lime-dim: #7c911e;
  --red: #ff4a2e;
  --amber: #ffb43c;
  --ground: 64px;
  --col: 368px;
  --text: "Archivo", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--bone); }
body { font: 400 15px/1.5 var(--text); font-synthesis: none; -webkit-font-smoothing: antialiased; overflow: hidden; }
img { display: block; }
a { color: var(--lime); }
kbd { font: 600 0.85em var(--mono); color: var(--bone); padding: 0 0.3em; border-bottom: 1px solid var(--lime-dim); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
[hidden] { display: none !important; }

#world { position: fixed; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; will-change: transform; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* ---------- surfaces and type roles ---------- */
.panel { border-style: solid; border-width: 12px; border-image: url("/img/ui/v2-panel.png") 24 fill / 12px stretch; }
.label, .panel-title, dt { font: 700 10.5px/1.2 var(--text); font-stretch: 112%; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ash); }
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 0 12px 2px;
  border-style: solid; border-width: 9px; border-image: url("/img/ui/v2-key-line.png") 18 fill / 9px stretch;
  font: 700 12.5px/1 var(--text); font-stretch: 112%; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none;
  color: var(--bone); background: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.key:hover:not([disabled]):not([aria-disabled="true"]) { border-image-source: url("/img/ui/v2-key-line-hover.png"); }
.key:active:not([disabled]):not([aria-disabled="true"]) { transform: translateY(1px); }
.key-lime { border-width: 10px; border-image: url("/img/ui/v2-key-lime.png") 20 fill / 10px stretch; color: var(--ink); }
.key-lime:hover:not([disabled]) { border-image-source: url("/img/ui/v2-key-lime-hover.png"); }
.key-lime:active:not([disabled]) { border-image-source: url("/img/ui/v2-key-lime-down.png"); transform: translateY(2px); }
.key[disabled], .key[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.key img { width: 20px; height: 20px; image-rendering: pixelated; }

/* ---------- the intro column, in the sky over the foot ---------- */
.mast { position: absolute; top: 30px; left: 32px; width: var(--col); }
.wordmark { margin: 0; display: flex; align-items: flex-end; gap: 12px; font-size: 0; }
.wordmark img { width: 196px; height: auto; }
.tick { font: 600 12px/1 var(--mono); color: var(--lime); letter-spacing: 0.08em; padding-bottom: 5px; }
.lede { margin: 22px 0 0; font: 500 18px/1.42 var(--text); color: var(--bone); max-width: 30ch; text-wrap: pretty; }
.sub { margin: 8px 0 0; font-size: 15px; color: var(--ash2); max-width: 34ch; text-wrap: pretty; }
.cta { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 22px 0 0; }
.cta .key { min-height: 50px; padding: 0 22px 3px; font-size: 14px; }
.keys { margin: 0; font-size: 12.5px; color: var(--ash); }

.run { margin-top: 24px; padding: 2px 6px 0; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 10px; }
.panel-title .state { color: var(--lime); letter-spacing: 0.1em; }
.panel-title .state.practice { color: var(--amber); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; margin: 0; }
.facts div { padding: 9px 0; border-top: 1px solid var(--rule); min-width: 0; }
.facts dt { margin: 0 0 4px; }
.facts dd { margin: 0; font: 500 14px/1.3 var(--mono); color: var(--bone); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts dd.lime { color: var(--lime); }
.facts dd small { font: inherit; color: var(--ash); }
.run-note { margin: 0; padding: 9px 0 6px; border-top: 1px solid var(--rule); font-size: 12.5px; line-height: 1.45; color: var(--ash); }
.run-note:empty { display: none; }
.run-note .warn { color: var(--amber); }
.gap { display: none; }

/* ---------- the trailhead board on its post, at the foot of the mountain ---------- */
.trailhead { position: absolute; left: 32px; bottom: calc(var(--ground) + 28px); width: var(--col); }
.board { padding: 4px 4px 2px; position: relative; z-index: 1; }
.pole { position: absolute; left: 34px; top: 100%; height: calc(28px + 22px); width: 6px; background: url("/img/ui/v2-pole.png") repeat-y; background-size: 6px 16px; image-rendering: pixelated; }
.pole::after { content: ""; position: absolute; left: 24px; top: 0; bottom: 0; width: 6px; background: inherit; }
.ca-row { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 10px; padding: 0 2px 12px; }
.ca-row .label { grid-column: 1; margin: 0 0 6px; }
.ca { grid-column: 1; grid-row: 2; margin: 0; font: 500 12.5px/1.4 var(--mono); color: var(--bone); word-break: break-all; user-select: all; }
.ca.empty { color: var(--ash); user-select: none; font-family: var(--text); font-size: 13.5px; }
.ibtn { grid-column: 2; grid-row: 1 / span 2; align-self: center; width: 42px; height: 42px; display: grid; place-items: center; padding: 0; background: none; cursor: pointer;
  border-style: solid; border-width: 9px; border-image: url("/img/ui/v2-key-line.png") 18 fill / 9px stretch; }
.ibtn:hover:not([disabled]) { border-image-source: url("/img/ui/v2-key-line-hover.png"); }
.ibtn img { width: 18px; height: 18px; image-rendering: pixelated; }
.ibtn[disabled] { opacity: 0.35; cursor: not-allowed; }
.links { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.lrow {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 6px; margin: 2px -2px 0;
  border: 8px solid transparent; border-image: none; color: var(--bone); text-decoration: none; cursor: pointer;
  font: 600 14.5px/1.2 var(--text); font-stretch: 104%;
}
.lrow + .lrow { margin-top: 0; }
.lrow:hover:not([aria-disabled="true"]) { border-image: url("/img/ui/v2-row-hover.png") 16 fill / 8px stretch; }
.lrow .mark { width: 20px; height: 20px; object-fit: contain; flex: none; }
.lrow .mark-x { width: 16px; height: 16px; margin: 0 2px; }
.lrow .lt { flex: 1; }
.lrow-buy .lt { color: var(--lime); }
.lrow .la { flex: none; display: flex; align-items: center; font-size: 12px; color: var(--ash); }
.lrow .la img { width: 16px; height: 16px; image-rendering: pixelated; }
.lrow[aria-disabled="true"] { cursor: not-allowed; }
.lrow[aria-disabled="true"] .lt { color: var(--ash2); }
.lrow[aria-disabled="true"] .mark { opacity: 0.45; }
.pages { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 0 2px; border-top: 1px solid var(--rule); margin-top: 2px; }
.ptab { display: flex; align-items: center; justify-content: center; min-height: 38px; text-decoration: none; color: var(--ash2);
  border-style: solid; border-width: 8px; border-image: url("/img/ui/v2-tab-off.png") 16 fill / 8px stretch;
  font: 700 11.5px/1 var(--text); font-stretch: 112%; letter-spacing: 0.1em; text-transform: uppercase; }
.ptab:hover { border-image-source: url("/img/ui/v2-tab-on.png"); color: var(--ink); }

/* ---------- climbing HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-run { position: absolute; top: 14px; left: 14px; padding: 2px 6px; border-image-source: url("/img/ui/v2-panel-glass.png"); font: 500 12.5px/1.65 var(--mono); color: var(--ash2); max-width: 300px; }
.hud-run p { margin: 0; }
.hud-run b { color: var(--bone); font-weight: 600; }
.hud-run .lime { color: var(--lime); }
.hud-run .warn { color: var(--amber); }
.hud-keys { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 340px); }
.ikey { min-height: 42px; font-size: 11.5px; padding: 0 10px 2px; background-color: transparent; }
.help { position: absolute; left: 50%; top: 76px; transform: translateX(-50%); width: min(540px, calc(100% - 28px)); font-size: 14px; color: var(--ash2); text-align: center; cursor: pointer; border-image-source: url("/img/ui/v2-panel-glass.png"); }
.help p { margin: 2px 0; }
.result { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); width: min(440px, calc(100% - 28px)); text-align: center; border-image-source: url("/img/ui/v2-panel-glass.png"); }
.result-title { margin: 6px 0 6px; font: 800 20px/1.15 var(--text); font-stretch: 118%; text-transform: uppercase; letter-spacing: 0.02em; color: var(--lime); }
.result-title.miss { color: var(--amber); }
.result p { margin: 0 0 10px; color: var(--ash2); }
.result-keys { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

.pad { position: absolute; left: 0; right: 0; bottom: 0; height: 0; }
.padkey { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); width: 72px; height: 76px; border: 0; padding: 0 0 6px; background: url("/img/ui/pad.png") no-repeat center / 72px 76px; display: grid; place-items: center; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.padkey img { width: 30px; height: 30px; image-rendering: pixelated; }
.padkey.down { transform: translateY(4px); filter: brightness(1.3); }
#pl { left: 16px; }
#pr { left: 100px; }
.padjump { right: 18px; width: 96px; height: 101px; background-image: url("/img/ui/pad-jump.png"); background-size: 96px 101px; color: var(--ink); font: 800 11px/1 var(--text); letter-spacing: 0.08em; text-transform: uppercase; gap: 0; align-content: center; }
.padjump img { width: 34px; height: 34px; }

.tip { position: absolute; z-index: 5; pointer-events: none; padding: 1px 4px; font: 500 12px/1.55 var(--mono); color: var(--ash2); border-image-source: url("/img/ui/v2-panel-glass.png"); max-width: 270px; }
.tip b { color: var(--bone); font-weight: 600; }
.tip .up { color: var(--lime); }
.tip .down { color: var(--red); }
.toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); max-width: min(520px, calc(100% - 28px)); padding: 1px 8px; border-style: solid; border-width: 12px; border-image: url("/img/ui/v2-panel.png") 24 fill / 12px stretch; font: 500 14px/1.4 var(--text); text-align: center; }
body.climb .toast { top: 70px; }

/* ---------- pages (dialogs over the live mountain) ---------- */
dialog.page { width: min(820px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; background: none; color: var(--bone); overflow: visible; }
dialog.page.small { width: min(520px, calc(100% - 24px)); }
dialog.page:focus, dialog.page:focus-visible { outline: none; }
dialog.page::backdrop { background: rgba(0, 0, 0, 0.66); }
.page-in { max-height: calc(100dvh - 32px); overflow: auto; padding: 6px 12px 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; position: sticky; top: -6px; background: #070707; padding: 6px 0; z-index: 2; }
.page h2 { margin: 0; font: 800 22px/1 var(--text); font-stretch: 118%; text-transform: uppercase; letter-spacing: 0.02em; }
.close { min-height: 38px; font-size: 11.5px; padding: 0 10px 2px; }
.close img { width: 16px; height: 16px; }
.rules h3 { margin: 22px 0 6px; font: 700 11.5px/1 var(--text); font-stretch: 112%; letter-spacing: 0.14em; text-transform: uppercase; color: var(--lime); }
.rules p, .rules li { color: var(--ash2); max-width: 70ch; }
.rules ul { padding-left: 20px; }
.rules b { color: var(--bone); font-weight: 600; }
.risk { margin-top: 24px; font-size: 12.5px; color: var(--ash) !important; }
.purses { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.purse { border-style: solid; border-width: 9px; border-image: url("/img/ui/v2-well.png") 18 fill / 9px stretch; padding: 2px 5px 3px; }
.purse span { display: block; font: 700 10px/1.4 var(--text); font-stretch: 112%; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ash); }
.purse b { font: 500 17px/1.35 var(--mono); color: var(--bone); }
.purse b.lime { color: var(--lime); }
.purse small { display: block; font-size: 12px; line-height: 1.35; color: var(--ash); }
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; }
.tab { min-height: 38px; padding: 0 14px 1px; border-style: solid; border-width: 8px; border-image: url("/img/ui/v2-tab-off.png") 16 fill / 8px stretch; background: none; color: var(--ash2); font: 700 11.5px/1 var(--text); font-stretch: 112%; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; }
.tab[aria-selected="true"] { border-image-source: url("/img/ui/v2-tab-on.png"); color: var(--ink); }
.daypick { margin-left: auto; font: 700 10.5px var(--text); color: var(--ash); display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: 0.12em; }
.daypick select { font: 500 13px var(--mono); color: var(--bone); background: #0a0a0a; border: 1px solid #2e2e2e; border-radius: 8px; padding: 7px 8px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 74px 1fr auto; gap: 4px 12px; align-items: baseline; padding: 10px 2px; border-bottom: 1px solid var(--rule); font: 500 13.5px/1.4 var(--mono); }
.rows li .when { color: var(--ash); }
.rows li .who b { color: var(--bone); font-weight: 600; }
.rows li .who small { color: var(--ash); margin-left: 6px; }
.rows li .what { text-align: right; color: var(--lime); }
.rows li .what.dim { color: var(--ash); }
.rows li .why { grid-column: 2 / -1; color: var(--ash); font-size: 12px; }
.rows li a { color: var(--lime); }
.empty-note { color: var(--ash); padding: 10px 2px; margin: 0; }
.fallcard { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.fallcard canvas { width: 300px; height: auto; max-width: 100%; image-rendering: pixelated; }
.walletlist { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.walletlist .key { justify-content: flex-start; }
.walletlist .key img { width: 22px; height: 22px; image-rendering: auto; border-radius: 4px; }
.note { font-size: 13px; color: var(--ash); margin: 6px 0 0; }
.note.ok { color: var(--lime); }
.note.bad { color: var(--amber); }
.clipview { display: grid; place-items: center; min-height: 240px; }
.clipview img { width: min(360px, 100%); height: auto; image-rendering: pixelated; }
.clipview p { color: var(--ash); }

/* ---------- climbing mode ---------- */
body.climb .mast, body.climb .trailhead { display: none; }

/* ---------- short desktop screens: lines fold away until the column clears the board (ui.fitColumn) ---------- */
@media (max-height: 860px) and (min-width: 761px) {
  .mast { top: 24px; }
  .lede { margin-top: 16px; font-size: 16.5px; }
  .cta { margin-top: 16px; flex-direction: row; align-items: center; gap: 14px; }
  .keys { max-width: 16ch; line-height: 1.35; }
  .run { margin-top: 16px; }
  .trailhead { bottom: calc(var(--ground) + 16px); }
  .pole { height: calc(16px + 22px); }
  .lrow { min-height: 40px; }
  .ca-row { padding-bottom: 8px; }
}
body.t1 .run-note { display: none; }
body.t2 .facts div:nth-child(n+3) { display: none; }
body.t3 .panel-title { display: none; }
body.t4 .sub { display: none; }
body.t3 .run { margin-top: 12px; }
body.t3 .lede { font-size: 15.5px; margin-top: 12px; }
body.t3 .cta { margin-top: 12px; }

/* ---------- narrow screens: the foot is the bottom of the page ---------- */
@media (max-width: 760px) {
  :root { --col: auto; }
  body.overview #ui { position: absolute; inset: 0 0 auto 0; min-height: 100dvh; display: flex; flex-direction: column; }
  body.overview { overflow-y: auto; }
  .mast { position: relative; top: 0; left: 0; width: auto; padding: 18px 16px 0; }
  .wordmark img { width: 150px; }
  .lede { margin-top: 14px; font-size: 16px; max-width: none; }
  .sub { font-size: 14px; max-width: none; }
  .cta { margin-top: 14px; }
  .cta .key { width: 100%; min-height: 50px; }
  .keys { display: none; }
  .run { margin-top: 14px; }
  .facts div:nth-child(n+3) { display: none; }
  .run-note { font-size: 12px; }
  .gap { display: block; flex: 1 1 auto; min-height: 250px; }
  .trailhead { position: relative; left: 0; bottom: 0; width: auto; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
  .pole { display: none; }
  .hud-run { font-size: 11.5px; max-width: 190px; top: 8px; left: 8px; }
  .hud-keys { top: 8px; right: 8px; gap: 6px; flex-direction: column; max-width: none; }
  .ikey span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ikey { min-height: 42px; padding: 0 6px 2px; }
  .help { top: 232px; font-size: 13px; }
  .result { top: auto; bottom: 150px; }
  .rows li { grid-template-columns: 56px 1fr auto; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) { .key { transition: none; } }
@media (max-width: 760px) and (max-height: 700px) {
  .run-note { display: none; }
  .lede { font-size: 15px; margin-top: 12px; }
  .sub { font-size: 13px; }
  .cta { margin-top: 12px; }
  .run { margin-top: 12px; }
}
