/* 8848 · climbing ropes, newsprint and cut rock. */
:root {
  --ridge-art:url('assets/ridge-night.webp');
  --summit-sky:url('assets/sky-print.webp');
  color-scheme:light;
  --paper:#F4F1EA; --ink:#161413; --muted:#514d49; --line:#aba49c;
  --accent:#ffe324; --forest:#12554f; --red:#e60025;
}
body {
  background-color:var(--paper);
  background-image:radial-gradient(circle, #d9d3c9 .8px, transparent 1px);
  background-size:7px 7px;
}
.masthead {
  height:68px; max-width:none; background:var(--red); color:white;
  border-bottom:3px solid var(--ink); margin-bottom:15px;
  padding-inline:max(18px, calc((100vw - 1156px) / 2));
}
.masthead .brand-name { color:white; border-color:#ff9da2; }
.brand b { text-shadow:2px 2px #151212; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline:3px solid #126c84; outline-offset:2px; }
.brand-icon { background:var(--accent); transform:skewX(-9deg); }
.brand b { font-style:italic; }
nav .text-button { border:2px solid var(--ink); background:var(--paper); color:var(--ink); border-radius:1px; transform:skew(-6deg); }
nav .text-button:hover { background:var(--accent); }
.board { border:3px solid #0b0a09; border-radius:0; box-shadow:7px 7px #e62a35; background:#121111; }
.mountain { background:#EAE6DF; border-right:3px solid #080707; }
.scene-art { background-image:var(--ridge-art),var(--summit-sky); background-position:var(--peak-x) var(--peak-y);
  background-color:#EAE6DF; }
.scene-shade, .scene-fog {
  mask:var(--ridge-art) var(--peak-x) var(--peak-y) / cover no-repeat;
}
.scene-shade { background:linear-gradient(0deg,#090806cf 0%, transparent 31%); }
.scene-fog { background:radial-gradient(ellipse at 36% 56%,#fff5e866,transparent 42%); }
.scene-head, .stage-tag { border:2px solid #131010; border-radius:0; background:#151111; color:#fff9ec; transform:skewX(-6deg); }
.scene-head { box-shadow:3px 3px var(--red); font-style:italic; }
.scene-ruler { font-weight:800; text-shadow:-1px 0 #080808,1px 0 #080808,0 -1px #080808,0 1px #080808; }
.scene-ruler span:nth-child(-n+2) { color:#151311; text-shadow:-1px 0 #eae6df,1px 0 #eae6df,0 -1px #eae6df,0 1px #eae6df; }
.scene-ruler span:nth-child(-n+2):after { background:#191612; box-shadow:0 1px #eae6df; }
.scene-ruler span:after { background:#fff9ec; box-shadow:0 1px #080808; }
.altitude-readout {
  display:grid; grid-template-columns:auto auto; align-items:baseline; gap:0 4px;
  padding:5px 15px 6px 10px; background:#000; border-left:4px solid var(--red);
  clip-path:polygon(0 0,100% 0,calc(100% - 8px) 100%,0 100%); color:white;
}
.altitude-readout > span:first-child {
  grid-column:1 / -1; position:static; font-size:12px; line-height:1.15;
  letter-spacing:.04em; font-weight:750; color:#fff9ec;
}
.altitude-readout strong { font-size:clamp(27px,3.4vw,48px); line-height:1.04; }
.altitude-readout .unit { font-size:14px; }
#trail { stroke:white; stroke-width:2; }
#trail-progress { stroke:var(--accent); stroke-width:3; }
.summit {
  left:var(--peak-x); top:var(--peak-y); width:12px; height:12px; border:1.5px solid #241b13;
  transform:translate(-50%,-50%) rotate(45deg); background:var(--accent); box-shadow:0 0 2px #29200e;
}
.scene-ruler { top:0; bottom:0; display:block; }
.scene-ruler span { position:absolute; right:0; transform:translateY(-50%); }
.stage-tag { right:68px; }
@media(max-width:760px) { .stage-tag { right:50px; } }
.mountain-guide {
  display:none; position:absolute; right:5%; bottom:10%; width:42%;
  max-height:56%; object-fit:contain; object-position:center bottom;
  filter:drop-shadow(2px 0 #fff4dd) drop-shadow(-2px 0 #fff4dd) drop-shadow(3px 4px #0c0a09);
  pointer-events:none;
}
body[data-phase="landing"] .mountain-guide, body[data-phase="result"] .mountain-guide { display:block; }
.panel {
  position:relative; background:var(--paper);
  background-image:linear-gradient(134deg,transparent 0 52%,var(--red) 53% 77%,var(--ink) 78% 84%,transparent 85%),
    linear-gradient(165deg,transparent 72%,#e9e4d9 72.2% 80%,transparent 80.2%);
  background-position:top right,center; background-size:44px 44px,100% 100%; background-repeat:no-repeat;
}
.wordmark { font-style:italic; transform:skewX(-5deg); color:var(--ink); text-shadow:3px 3px var(--paper), 7px 7px var(--red); }
.wordmark span { color:var(--ink); text-shadow:none; }
.headline,.result-title { font-style:italic; font-weight:1000; letter-spacing:-.055em; }
.headline { display:table; background:var(--red); color:white; padding:2px 18px 4px 9px; clip-path:polygon(4% 0,100% 0,95% 100%,0 100%); }
.subtitle, .question-rule { color:var(--muted); }
.primary, .secondary, #dialog-body .secondary { border-radius:0; border:2px solid #0c0a08; }
.primary { box-shadow:4px 4px #e62a35; background:var(--accent); color:#17120b; transform:skewX(-5deg); }
.primary:hover:not(:disabled) { background:#fff270; }
.primary:active:not(:disabled) { transform:skewX(-5deg) translate(2px,2px); box-shadow:2px 2px var(--red); }
.secondary, #dialog-body .secondary { background:#fff6e4; color:#1c1612; }
.secondary:hover, #dialog-body .secondary:hover { background:#ffdfa5; }
.progress { gap:4px; }
.progress i { height:8px; border:1px solid #6b645c; border-radius:0; transform:skew(-28deg); background:#ded8ce; }
.progress .done { background:var(--red); }
.progress .current { background:var(--accent); }
.prompt { color:#161311; background:white; border:2px solid var(--ink); padding:12px 15px; transform:rotate(-.7deg); box-shadow:4px 4px var(--red); }
input { background:#fdf5e9; color:#191511; border:2px solid #1b1714; border-radius:0; }
input::placeholder { color:#706862; }
.choices button, dialog { background:var(--paper); color:var(--ink); border-color:var(--ink); }
.choices button:hover { background:var(--accent); }
.feedback { color:#961735; }
#answer-form .text-button { color:var(--muted); }
.answer-clock { --watch-case:#cec0a8; --watch-ink:#f4edda; --watch-face:#242321; }
.answer-clock.urgent { --watch-case:#ff534b; --watch-face:#6b201f; --watch-ink:white; }
.reveal { background:white; border:2px solid var(--ink); border-left:6px solid var(--red); border-radius:0; }
.gain { color:#bb1032; font-style:italic; }
.result-height { margin-top:0; color:var(--accent); -webkit-text-stroke:3px var(--ink); paint-order:stroke fill; text-shadow:3px 3px #151111,5px 5px var(--red); transform:skewX(-7deg); }
.result-highlight { color:var(--muted); font-size:14px; line-height:1.55; overflow-wrap:anywhere; }
.result-highlight b { color:var(--ink); }
.distribution { border:2px solid var(--ink); border-radius:0; background:#fffdf8; box-shadow:3px 3px var(--ink); }
.distribution-bars i { background:#8a837a; border-radius:0; }
.distribution-bars .player-bin {
  background:var(--accent); box-shadow:0 0 6px #ffe32a99;
  outline:1px solid #5b490d; outline-offset:-1px; min-height:2px;
}
.distribution-plot { background:repeating-linear-gradient(to top,transparent 0 21px,#d4cec3 21px 22px); border-color:#857969; }
.distribution-marker { box-shadow:1px 0 #785d18; }
.distribution-marker strong { border-radius:0; border:1px solid var(--ink); }
.footer { padding-top:20px; }
@media(max-width:760px) {
  .masthead {height:55px; margin-bottom:9px;}
  .board { border-width:2px; box-shadow:4px 4px var(--red); }
  .mountain { border-right:0; border-bottom:3px solid #100d0b; }
  .mountain-guide { width:39%; bottom:13%; right:7%; }
  body[data-phase="question"] .mountain,body[data-phase="reveal"] .mountain {height:clamp(156px,43vw,220px);}
  body[data-phase="result"] .mountain {height:clamp(175px,49vw,244px);}
  .panel { padding:20px 19px 24px; }
  .progress { margin:8px 0 15px; }
}

/* A quiet watch by the question index leaves the input area clear. */
.question-meta { justify-content: space-between; }
.question-meta .answer-clock {
  --watch-case: #928b81;
  --watch-ink: #5e5851;
  --watch-face: #ede9e0;
  margin: 0;
  gap: 0;
}
.question-meta .answer-clock.urgent {
  --watch-case: #c06258;
  --watch-ink: #942b30;
  --watch-face: #f9e1d8;
}
.question-meta .answer-clock-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 3px;
  width: 47px;
  height: 23px;
  border: 1px solid var(--watch-case);
  border-radius: 7px;
  box-shadow: none;
}
.question-meta .answer-clock-face::before { display: none; }
.question-meta .answer-clock-face::after {
  top: 7px; right: -3px; width: 2px; height: 6px;
}
.question-meta .answer-clock-face strong {
  margin: 0;
  font: 600 14px/1 ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.question-meta .answer-clock-face span { font-size: 10px; }
.question-meta .answer-warning {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.finish-quote { margin:10px 0; color:var(--ink); font-weight:750; line-height:1.45; }
body[data-phase="result"][data-mood="sigh"] .scene-art { filter:saturate(.28); }
body[data-phase="result"][data-mood="sigh"] .result-height { color:#e0d8c8; text-shadow:3px 3px #171514; }

.result-actions .secondary { min-width:0; padding-inline:4px; }
.best-record { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:3px 10px; border-block:1px solid #b8afa2; padding:3px 0; font-size:14px; }
.best-record b { color:#9d1027; font-variant-numeric:tabular-nums; }
.best-record button { font-size:13px; text-decoration:underline; }
.retry-note,.seal-note { margin:9px 0; font-size:13px; color:var(--muted); }
.seal-note { border-left:3px solid var(--red); padding-left:7px; }
.attempt-scores li { padding:5px; border-bottom:1px solid var(--line); }
#confirm-reveal { margin-top:9px; text-align:center; }
.result-actions { display:grid; grid-template-columns:1.35fr 1fr 1fr; }
.result-actions .secondary { font-size:clamp(13px,3.6vw,16px); }
.diary h3 { margin:10px 0 8px; font-size:15px; }
.diary-entry { width:100%; min-height:42px; display:grid; grid-template-columns:auto 1fr auto; align-items:center; text-align:left; gap:10px; padding:7px 9px; color:var(--ink); background:#fffdf7; border:1px solid #c9c3b8; border-left:4px solid #b5aa98; }
.diary-entry + .diary-entry { margin-top:4px; }
.diary-entry:first-of-type { border-left-color:var(--red); }
.diary-entry small { color:var(--muted); }
.diary-entry span { font-size:12px; font-weight:750; }
.diary-entry:hover { background:#ffed8c; }
#diary-form { margin-top:15px; }
#diary-form label { font-weight:800; font-size:14px; }
#diary-form div { margin-top:5px; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px; }
#diary-form input { min-width:0; font-size:15px; }
#diary-form .secondary { margin:0; padding:8px; font-size:14px; }
#review:first-child:nth-last-child(2) { grid-column:span 2; }
#dialog:has(.diary) {
  padding:0; border:2px solid var(--ink); border-radius:0; box-shadow:5px 5px var(--ink);
}
#dialog:has(.diary) .dialog-head {
  background:var(--red); color:white; padding:10px 14px; border-bottom:3px solid var(--ink);
}
#dialog:has(.diary) #close-dialog { color:var(--ink); background:var(--paper); border:2px solid var(--ink); border-radius:0; }
.diary { padding:6px 14px 14px; }
.diary-entry[aria-current="date"] { border-color:var(--ink); border-left-color:var(--red); }
.diary-entry:first-of-type small { justify-self:start; color:var(--ink); background:var(--accent); padding:1px 5px; }

/* On the scorecard, the result panel already holds the altitude and stage. */
body[data-phase="result"] .mountain :is(.scene-head,.scene-ruler,.trail,.summit,.climber,.altitude-readout,.stage-tag) { display:none; }
@media (max-width:760px) {
  .masthead { padding-inline:12px; gap:5px; }
  .masthead nav { gap:5px; }
  .masthead nav .text-button { min-height:42px; padding:5px 8px; white-space:nowrap; }
  .masthead #sound { min-width:42px; padding-inline:4px; }
  body[data-phase="result"] .mountain { display:none; }
  body[data-phase="result"] .panel { padding:15px 16px; }
  .result-actions { grid-template-columns:repeat(auto-fit,minmax(76px,1fr)); }
  .result-title { font-size:clamp(28px,8vw,38px); margin:8px 0 4px; }
  .finish-quote, .result-highlight { margin:6px 0; }
  .distribution { margin:10px 0 12px; }
  body[data-phase="result"] .footer { display:none; }
}
@media (max-width:400px) {
  .masthead .brand-name { display:none; }
}
@media (max-width:760px) and (max-height:740px) {
  .masthead { height:50px; margin-bottom:6px; }
  .panel, body[data-phase="result"] .panel { padding:12px 14px 14px; }
  body[data-phase="landing"] .mountain { height:clamp(145px,28dvh,205px); }
  body[data-phase="question"] .mountain, body[data-phase="reveal"] .mountain { height:clamp(97px,18dvh,135px); }
  .mountain .altitude-readout { bottom:5px; padding:4px 10px 4px 7px; }
  .mountain .altitude-readout strong { font-size:25px; }
  .mountain .scene-head { top:6px; left:8px; padding:3px 6px; font-size:12px; }
  .wordmark { font-size:clamp(61px,17vw,80px); margin-top:8px; }
  .panel .guide-intro { margin:10px 0 14px; }
  .progress { margin:6px 0 10px; }
  .prompt { font-size:clamp(20px,5.5vw,25px); padding:7px 9px; margin-bottom:9px; }
  .panel .guide-brief { margin:7px 0; }
  .result-height { font-size:clamp(43px,12vw,53px); margin-bottom:4px; }
  .distribution-plot { height:67px; }
  .primary, .secondary { min-height:42px; padding-block:8px; }
  .result-record { margin-top:4px; }
  .footer { display:none; }
}
@media (orientation:landscape) and (max-height:520px) and (min-width:550px) {
  .masthead { height:46px; margin-bottom:5px; }
  .board { width:calc(100% - 24px); max-width:none; grid-template-columns:32% minmax(0,1fr); min-height:0; }
  .board .mountain,body[data-phase] .board .mountain { height:auto; min-height:0; align-self:stretch; border-bottom:0; border-right:2px solid var(--ink); }
  .board .panel { padding:10px 14px; }
  body[data-phase="result"] .board { display:block; }
  body[data-phase="result"] .mountain { display:none; }
  body[data-phase="result"] #screen { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); column-gap:22px; align-items:start; }
  body[data-phase="result"] #screen > * { grid-column:1; }
  body[data-phase="result"] #screen > .distribution { grid-column:2 / 3; grid-row:1 / 5; margin-top:0; }
  body[data-phase="result"] #share { grid-column:2; grid-row:5; }
  body[data-phase="result"] #screen > .result-actions { grid-column:2; grid-row:6; }
  body[data-phase="result"] #screen > :is(.retry-note,.seal-note) { grid-column:2; grid-row:7; }
  .footer { display:none; }
}
@media (max-width:760px) and (max-height:600px) and (orientation:portrait) {
  body[data-phase="question"] .mountain, body[data-phase="reveal"] .mountain { height:64px; }
  body[data-phase="question"] .scene-head, body[data-phase="reveal"] .scene-head { display:none; }
  body[data-phase="result"] .result-title, body[data-phase="result"] .result-height {
    display:inline-block; vertical-align:baseline; margin:5px 8px 3px 0;
  }
  body[data-phase="result"] .result-title { font-size:24px; }
  body[data-phase="result"] .result-height { font-size:36px; }
  body[data-phase="result"] .distribution { padding-block:6px; margin-block:7px; }
  body[data-phase="result"] .distribution-plot { height:57px; }
  body[data-phase="result"] .result-record { margin-top:0; }
  body[data-phase="question"] .panel, body[data-phase="result"] .panel { padding-bottom:7px; }
  #answer-form .primary { margin-top:6px; }
}
@media (orientation:landscape) and (max-height:520px) and (min-width:550px) {
  body:is([data-phase="question"],[data-phase="reveal"]) .mountain { display:none; }
  body:is([data-phase="question"],[data-phase="reveal"]) .board { display:block; }
  body:is([data-phase="question"],[data-phase="reveal"]) #screen {
    display:grid; grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);
    grid-template-rows:auto auto auto auto; gap:4px 20px; align-items:start;
  }
  body:is([data-phase="question"],[data-phase="reveal"]) #screen > * { grid-column:1; }
  body:is([data-phase="question"],[data-phase="reveal"]) .prompt { font-size:22px; margin:0; padding:6px 9px; }
  body:is([data-phase="question"],[data-phase="reveal"]) .progress { margin:1px 0 5px; }
  body[data-phase="question"] #screen #answer-form { grid-column:2;grid-row:1 / span 4;align-self:center; }
  body[data-phase="reveal"] #screen .reveal { grid-column:2;grid-row:1 / span 2;margin:0; }
  body[data-phase="reveal"] #screen .rr-reaction { grid-column:2;grid-row:3;margin:0; }
  body[data-phase="reveal"] #screen #next { grid-column:2;grid-row:4; }
  body:is([data-phase="question"],[data-phase="reveal"]) .panel .guide-brief { margin:2px 0; }
  body[data-phase="landing"] .wordmark { font-size:75px; margin-top:8px; }
  body[data-phase="landing"] .headline { font-size:30px; margin-block:8px; }
  body[data-phase="landing"] .panel .guide-intro { margin:8px 0 12px; }
  body[data-phase="result"] .result-title { margin:5px 0 2px; font-size:30px; }
  body[data-phase="result"] .result-height { font-size:42px; margin:0; }
  body[data-phase="result"] .distribution { margin-bottom:8px; }
  body[data-phase="result"] #screen > .result-record { grid-column:1; grid-row:7; margin:0; }
  body[data-phase="result"] #screen:has(.result-record[open]) > .result-record { grid-column:1 / -1; grid-row:8; }
  body[data-phase="result"] .finish-quote, body[data-phase="result"] .result-highlight { margin:4px 0; }
}
@media (max-width:760px) and (max-height:600px) and (orientation:portrait) {
  body[data-phase="result"] .result-highlight { display:none; }
  body[data-phase="result"] .best-record .text-button { padding-block:5px; }
}
