:root {
  --bg: #f4f5f2;
  --sheet: #ffffff;
  --ink: #1d1f22;
  --ink2: #474b51;
  --line: #c9ccc4;
  --soft: #e7e9e3;
  --accent: #b8361d;
  --accent-ink: #ffffff;
  --focus: #1f5fbf;
  --warn-bg: #fff4d6;
  --warn-ink: #5c4300;
  --map-ink: #1d1f22;
  --map-num-bg: #ffffff;
  --radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --sheet: #202327;
    --ink: #ecebe6;
    --ink2: #bfc2c7;
    --line: #444950;
    --soft: #2a2e33;
    --accent: #ff8f72;
    --accent-ink: #1a1a1a;
    --focus: #8fb7ff;
    --warn-bg: #3a3016;
    --warn-ink: #f6dd9b;
    --map-ink: #a3a8b0;
    --map-num-bg: #f4f5f2;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.5; }
a { color: var(--accent); }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--sheet); padding: 8px 12px; z-index: 5; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; font-size: 18px; }
.mark { width: 26px; height: 26px; }
.m-a { fill: var(--accent); }
.m-b { fill: var(--ink); }
.m-c { stroke: var(--bg); stroke-width: 1.5; }

.intro { padding: 22px 0 6px; }
h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.08; margin: 0 0 8px; letter-spacing: -0.025em; font-weight: 850; }
.lede { margin: 0; max-width: 62ch; color: var(--ink2); }
h2 { font-size: 22px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -0.01em; }
h3 { font-size: 18px; margin: 18px 0 4px; }

/* setup */
.setup { margin: 16px 0 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .lab, label { font-weight: 650; font-size: 16px; display: block; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { margin: 0; position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--sheet); font-weight: 650; cursor: pointer; white-space: nowrap; }
.chip.phz span { border-style: dashed; }
.chip input:checked + span { background: var(--ink); color: var(--bg); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.row3 { display: grid; grid-template-columns: auto 1fr; gap: 14px 14px; margin-top: 16px; align-items: end; }
.row3 .field:nth-child(2) { grid-column: 2; }
.row3 .field:nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 720px) { .row3 { grid-template-columns: auto minmax(200px, 300px) minmax(180px, 260px); justify-content: start; gap: 14px 20px; } .row3 .field:nth-child(3) { grid-column: auto; } }
.field { min-width: 0; }
select, input[type="text"] { font: inherit; font-size: 17px; width: 100%; min-height: 46px; padding: 8px 10px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--sheet); color: var(--ink); }
select:focus, input[type="text"]:focus { border-color: var(--ink); }
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
.stepper output { min-width: 2.2ch; text-align: center; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.step { font: inherit; font-size: 22px; line-height: 1; width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); cursor: pointer; border-radius: var(--radius); }
.step:disabled { color: var(--line); cursor: default; }
.step:not(:disabled):hover { background: var(--soft); }
.custom { display: grid; grid-template-columns: 1fr 1fr 90px; gap: 10px; margin-top: 12px; max-width: 460px; }
.err { color: var(--accent); font-weight: 600; margin: 8px 0 0; }

/* answer */
.answer { position: relative; margin: 20px 0 0; padding: 18px 18px 14px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.answer::after { content: ""; position: absolute; top: -1px; right: -1px; width: 26px; height: 26px; background: linear-gradient(225deg, var(--bg) 50%, var(--soft) 50%); border-bottom-left-radius: 2px; }
.big { font-size: clamp(24px, 5vw, 32px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin: 0 30px 6px 0; }
.big .num { color: var(--accent); }
.sub { margin: 0 0 12px; color: var(--ink2); }
.per { border-collapse: collapse; width: 100%; max-width: 520px; font-variant-numeric: tabular-nums; }
.per th, .per td { text-align: left; padding: 7px 10px 7px 0; border-top: 1px solid var(--soft); vertical-align: middle; }
.per thead th { border-top: 0; font-size: 16px; color: var(--ink2); font-weight: 600; }
.per tbody th { font-weight: 650; overflow-wrap: break-word; }
.cn { display: inline-flex; align-items: center; }
.cn .sw { flex: none; }
.per .left { color: var(--ink2); font-weight: 400; }
.sw { display: inline-block; width: 18px; height: 18px; border-radius: 3px; border: 1.5px solid var(--map-ink); vertical-align: -3px; margin-right: 8px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rule { margin: 12px 0 0; font-weight: 600; }
.warn { margin: 10px 0 0; padding: 8px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); }
.note { margin: 12px 0 0; padding: 8px 12px; background: var(--soft); border-radius: var(--radius); }

/* map */
.mapbox, .progress, .plans { margin-top: 32px; }
.head-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.head-row h2 { margin: 0; }
.hint { color: var(--ink2); margin: 6px 0 12px; max-width: 70ch; }
.halves { display: grid; grid-template-columns: 1fr; gap: 12px; justify-items: center; }
@media (min-width: 640px) { .halves { grid-template-columns: 1fr 1fr; } }
.halves figure { margin: 0; width: 100%; max-width: 440px; }
.halves figcaption { text-align: center; color: var(--ink2); font-size: 16px; }
.halves figure.cube { grid-column: 1 / -1; max-width: 420px; }
svg.half, .cube svg { width: 100%; height: auto; display: block; }
svg .ink { stroke: var(--map-ink); }
svg .nums text { fill: #1d1f22; text-anchor: middle; dominant-baseline: central; font-weight: 700; paint-order: stroke; stroke: var(--map-num-bg); stroke-width: 3px; stroke-linejoin: round; font-family: inherit; }
svg .face { stroke: var(--map-ink); stroke-width: 1.4; stroke-linejoin: round; }
svg .cnums circle { fill: #ffffff; stroke: #1d1f22; stroke-width: 1.5; }
svg .own circle { fill: #ffffff; stroke: #1d1f22; stroke-width: 1.6; }
svg .cnums text { stroke-width: 0; }

/* progress */
.fold { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; max-width: 560px; }
.fold li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 8px; padding: 4px 0; border-bottom: 1px solid var(--soft); }
.fold .sw { margin: 0; }
.fname { font-weight: 650; overflow-wrap: anywhere; }
.fcount { grid-column: 2; grid-row: 2; color: var(--ink2); font-variant-numeric: tabular-nums; }
.fcount b { color: var(--ink); }
.fbtns { grid-column: 3; grid-row: 1 / span 2; display: flex; gap: 6px; }
.fbtns .step { border: 2px solid var(--line); background: var(--sheet); }
@media (min-width: 560px) { .fold li { grid-template-columns: auto minmax(90px, 1fr) auto auto; } .fcount { grid-column: 3; grid-row: 1; } .fbtns { grid-column: 4; grid-row: 1; } }
.steps-d { border-top: 2px solid var(--ink); margin-top: 8px; }
.steps-d summary { cursor: pointer; font-weight: 700; padding: 12px 0; min-height: 44px; }
.steps { list-style: none; padding: 0; margin: 0 0 8px; }
@media (min-width: 900px) { .steps { columns: 2; column-gap: 32px; } }
.steps li { break-inside: avoid; }
.steps label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; padding: 8px 0; min-height: 44px; cursor: pointer; border-bottom: 1px solid var(--soft); }
.steps input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.steps .dots { white-space: nowrap; }
.steps .dots .sw { width: 13px; height: 13px; margin: 0 2px 0 0; vertical-align: -1px; }
.steps input:checked + .st { color: var(--ink2); text-decoration: line-through; text-decoration-color: var(--line); }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn { font: inherit; font-size: 16px; font-weight: 650; min-height: 44px; padding: 8px 16px; border-radius: var(--radius); border: 2px solid var(--ink); background: var(--sheet); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: var(--line); }
.btn.danger { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 40px; padding: 6px 12px; }
.done-msg { margin: 10px 0 0; overflow-wrap: anywhere; }
.confirm { margin-top: 12px; padding: 12px 14px; border: 2px solid var(--accent); border-radius: var(--radius); background: var(--sheet); }
.confirm p { margin: 0; font-weight: 600; }

.more { margin-top: 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.more summary { cursor: pointer; font-weight: 700; padding: 12px 0; }
.more-body { padding-bottom: 16px; }
.narrow { max-width: 220px; }
.names { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-width: 420px; }
.names li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; }
.cpick { width: 52px; height: 46px; padding: 2px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
.plans-list { list-style: none; padding: 0; margin: 0; }
.plans-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--soft); }

.explain { margin: 40px 0 0; padding-top: 24px; border-top: 2px solid var(--ink); max-width: 72ch; }
.explain h2 { margin-top: 18px; }
.faq h3 { margin-top: 18px; }
.faq p { margin: 0; }
.sources { margin-top: 24px; color: var(--ink2); }

.foot { margin-top: 48px; padding: 24px 0 96px; border-top: 1px solid var(--line); color: var(--ink2); }
.sb-footer p { margin: 0 0 10px; }
.sb-more { line-height: 1.8; }
.undo-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; background: var(--ink); color: var(--bg); border-radius: var(--radius); z-index: 10; max-width: calc(100% - 32px); }
.undo-bar .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }
#print-root { display: none; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

@media print {
  @page { margin: 13mm 12mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root h1 { font-size: 17pt; margin: 0 0 4pt; letter-spacing: 0; }
  #print-root h2 { font-size: 13pt; margin: 10pt 0 4pt; break-after: avoid; }
  .p-head p { margin: 0 0 3pt; }
  .p-per { border-collapse: collapse; width: 100%; margin: 8pt 0; font-size: 10pt; }
  .p-per th, .p-per td { border-bottom: 0.6pt solid #888; padding: 3pt 6pt 3pt 0; text-align: left; vertical-align: top; }
  .p-per td:nth-child(2), .p-per td:nth-child(3), .p-per th:nth-child(2), .p-per th:nth-child(3) { width: 12%; }
  .p-per tr { break-inside: avoid; }
  .p-per td:first-child { white-space: nowrap; width: 1%; padding-right: 14pt; }
  .boxes { display: flex; flex-wrap: wrap; gap: 2pt; }
  .boxes i { display: inline-block; width: 8pt; height: 8pt; border: 0.7pt solid #000; }
  .sw { border-color: #000; }
  .p-map { display: flex; justify-content: center; gap: 14pt; break-inside: avoid; margin: 6pt 0; }
  .p-map figure { margin: 0; width: 42%; }
  .p-map figure.cube { width: 60%; }
  .p-map.big { display: block; break-inside: auto; }
  .p-map.big figure { width: 100%; break-inside: avoid; margin: 0 0 8pt; }
  .p-map.big svg { max-height: 135mm; }
  .p-map.big.dense svg { max-height: 150mm; }
  .p-map figcaption { text-align: center; font-size: 9.5pt; }
  .p-map svg { width: 100%; height: auto; display: block; }
  .p-map svg .ink { stroke: #000; }
  .p-map svg .nums text { fill: #000; stroke: #fff; }
  .p-map svg path, .p-map svg rect { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-map svg .face { stroke: #000; }
  .p-map svg .cnums circle { fill: #fff; stroke: #000; }
  .p-map svg .own circle { fill: #fff; stroke: #000; }
  .p-steps { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 18pt; font-size: 9.5pt; }
  .p-steps.many { columns: 3; font-size: 8.5pt; }
  .p-steps.many li { padding: 0.6pt 0; }
  .p-steps li { display: flex; gap: 5pt; break-inside: avoid; padding: 1.5pt 0; }
  .pbox { flex: none; display: inline-block; width: 9pt; height: 9pt; border: 0.7pt solid #000; font-size: 8pt; line-height: 9pt; text-align: center; margin-top: 1pt; }
}
/* long colour names wrap instead of widening the page */
.per { table-layout: fixed; }
.per th:first-child { width: 40%; }
.per thead th:nth-child(2) { width: 18%; }
.per { max-width: 560px; }
.per tbody th { overflow-wrap: anywhere; }
.cn > span:last-child { min-width: 0; }
.st, .rule, .plans-list span, .names input, .p-steps li span { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 420px) { .per th:first-child { width: 36%; } .per thead th:nth-child(2) { width: 21%; } }
.share-ask { margin: 12px 0 0; padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--sheet); }
.share-ask p { margin: 0; overflow-wrap: anywhere; }
