/* Happy Camper. Light and dark themes from the same tokens; every text colour meets WCAG 2.2 AA on its background, and
   the trees, tents, and grass marks keep 3:1 against the spots they sit on. */
:root {
  --bg: #f2f5ec; --card: #ffffff; --ink: #16231b; --muted: #4a5a4f; --line: #d6dfd0;
  --brand: #2c6a45; --brand-ink: #ffffff; --link: #215a39; --head: #1f4d3a; --head-ink: #ffffff; --head-soft: #d4ead8;
  --focus: #1d4ed8; --danger: #b42318;
  --ok-bg: #e4f3e6; --ok-ink: #14532d; --warn-bg: #fff3d4; --warn-ink: #5e4100; --err-bg: #fde8e6; --err-ink: #8a1c12;
  --tag-bg: #e9efe3; --meter: #2c6a45; --star: #8a5a00;
  /* the campsite */
  --plot: #f4f1dc; --plot-line: #b9b48f; --plot-grass: #d9ebc2; --frame: #6b5a3a;
  --leaf: #2d7a35; --leaf-hi: #64ad55; --trunk: #6b4423;
  --tent: #d2601c; --tent-shade: #a94810; --tent-door: #3d2210; --tent-line: #33261a;
  --tuft: #3b7426; --hl: #9a5c00; --hl-bg: #fff2c2; --bad: #b42318; --bad-bg: #fde3df;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101712; --card: #18221b; --ink: #eaf2ea; --muted: #b5c4b8; --line: #2e3c32;
    --brand: #8fd3a3; --brand-ink: #0d2316; --link: #9fe0b2; --head: #0b120d; --head-ink: #ffffff; --head-soft: #c8e8cf;
    --focus: #93c5fd; --danger: #ff8f80;
    --ok-bg: #143a22; --ok-ink: #c8efd2; --warn-bg: #3a2e0c; --warn-ink: #ffe3a3; --err-bg: #3d1611; --err-ink: #ffd2cb;
    --tag-bg: #223026; --meter: #8fd3a3; --star: #f5c451;
    --plot: #223024; --plot-line: #4b5d4c; --plot-grass: #2f4a2b; --frame: #4b3d27;
    --leaf: #57b65e; --leaf-hi: #9ad98a; --trunk: #b07a48;
    --tent: #f28a46; --tent-shade: #cf6a2a; --tent-door: #2a1608; --tent-line: #f6e2cf;
    --tuft: #a7dc86; --hl: #f5c451; --hl-bg: #4a3d12; --bad: #ff8f80; --bad-bg: #5a2018;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--link); text-underline-offset: 2px; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.25rem; line-height: 1.25; margin: 1.2rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 16px 0 6px; }
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
p { margin: 0 0 .8rem; }
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--card); color: var(--ink); padding: 8px 12px; z-index: 2000; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 16px; padding-bottom: 24px; }
main:focus { outline: none; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 46em; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap-row { flex-wrap: wrap; margin: 0 0 10px; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; background: var(--tag-bg); color: var(--ink); border-radius: 999px; padding: 1px 9px; vertical-align: 2px; margin-left: 4px; }

/* Header and footer */
.site-header { background: var(--head); color: var(--head-ink); }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; min-height: 56px; }
.brand { color: var(--head-ink); text-decoration: none; font-weight: 800; font-size: 1.2rem; padding: 8px 0; }
.brand span { margin-right: .3em; }
.top-nav { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.top-nav a { color: var(--head-soft); text-decoration: none; padding: 8px 0; border-bottom: 3px solid transparent; }
.top-nav a:hover, .top-nav a[aria-current] { color: var(--head-ink); border-bottom-color: var(--head-soft); }
.site-header :focus-visible { outline-color: #ffffff; }
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; padding: 16px 0 28px; color: var(--muted); font-size: .92rem; }
.site-footer a { color: var(--link); }

/* Cards, forms, buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }
.card.narrow { max-width: 600px; margin: 24px auto; }
.hero { margin: 8px 0 18px; }
.hero h1 { font-size: 2rem; }
.hero h1 span { margin-right: .3em; }
label { display: block; font-weight: 600; margin: 10px 0 4px; }
select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--muted); border-radius: 8px; padding: 8px 10px; min-height: 44px; }
fieldset.choices { border: 0; padding: 0; margin: 12px 0 4px; }
fieldset.choices legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
label.choice { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 2px 0; padding: 6px 4px; min-height: 36px; cursor: pointer; border-radius: 6px; }
label.choice:hover { background: var(--tag-bg); }
label.choice.inline { display: inline-flex; margin-right: 10px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; min-height: 32px; cursor: pointer; }
label.check input { margin-top: 3px; }
input[type=radio], input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink); border: 2px solid var(--brand);
  border-radius: 8px; padding: 8px 16px; min-height: 44px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .92rem; }
.btn.outline { background: transparent; color: var(--link); border-color: currentColor; }
.btn.ghost { background: var(--tag-bg); color: var(--link); border-color: var(--tag-bg); }
.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 14px; background: var(--tag-bg); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }
.stars { color: var(--star); letter-spacing: .08em; white-space: nowrap; }
.stars .off { color: var(--muted); }

/* The home page */
.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 820px) { .home-grid { grid-template-columns: 1fr; } }
.side .card { margin-bottom: 16px; }
.hc-resume { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.packs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pack { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 4px 4px; }
.pack:hover { border-color: var(--muted); }
.pack-link { flex: 1; display: grid; gap: 2px; padding: 10px 12px; color: var(--ink); text-decoration: none; border-radius: 8px; }
.pack-name { font-weight: 800; font-size: 1.08rem; color: var(--link); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.pack-name .tag { text-decoration: none; }
.pack-meta { font-size: .9rem; color: var(--muted); }
.pack-blurb { font-size: .95rem; }
.meter { display: block; height: 6px; border-radius: 999px; background: var(--tag-bg); overflow: hidden; margin: 6px 0 2px; box-shadow: inset 0 0 0 1px var(--line); }
.meter-fill { display: block; height: 100%; width: 0; background: var(--meter); border-radius: 999px; }
.random-form select { width: 100%; max-width: 240px; }
dl.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 10px; }
dl.stats dt { color: var(--muted); }
dl.stats dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 0 0 12px; }
.rule p { margin: 8px 0 0; }

/* The little pictures (How to play) */
.mini { margin: 0; }
.mini figcaption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mini-board { display: inline-grid; grid-template-columns: repeat(var(--cols), 34px); grid-auto-rows: 34px; border-radius: 6px; }
.mini-board .mcell { position: relative; background: var(--plot); box-shadow: inset 0 0 0 .5px var(--plot-line); }
.mini-board .mcell.grass { background: var(--plot-grass); }
.mini-board .mcell.hl { box-shadow: inset 0 0 0 3px var(--hl); background: var(--hl-bg); }
.mini-board .mclue { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink); }
.mini-board .ic { position: absolute; inset: 3px; width: 28px; height: 28px; }

/* The play page */
.crumbs { margin: 0 0 4px; }
.play-top h1 { margin-bottom: .2rem; }
.play-meta { margin: 0 0 .4rem; }
.play-done { margin: 0 0 .6rem; }
.play-grid { display: grid; grid-template-columns: minmax(0, 620px) minmax(250px, 1fr); grid-template-areas: "board panel" "help panel"; gap: 0 20px; align-items: start; margin-top: 10px; }
.board-col { grid-area: board; min-width: 0; margin-bottom: 12px; }
.play-grid > .panel { grid-area: panel; }
.play-grid > .board-help { grid-area: help; margin: 0; }
/* On a phone: the board, then the tools, then the help. */
@media (max-width: 860px) { .play-grid { grid-template-columns: 1fr; grid-template-areas: "board" "panel" "help"; } .play-grid > .board-help { margin-top: 14px; } }
.status-bar { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0 0 8px; }
.timer::before { content: '⏱ '; font-weight: 400; }
.board-wrap { max-width: 620px; width: 100%; }
.loading { padding: 40px 12px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }
.board { --n: 8; --cell: calc(100cqw / (var(--n) + .8)); container-type: inline-size; display: grid; grid-template-rows: .8fr repeat(var(--n), 1fr);
  aspect-ratio: 1; width: 100%; max-width: calc((var(--n) + .8) * 66px); margin: 0 auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pinch-zoom; }
.brow { display: grid; grid-template-columns: .8fr repeat(var(--n), minmax(0, 1fr)); min-height: 0; }
.cell { position: relative; background: var(--plot); border: solid var(--plot-line); border-width: 0 1px 1px 0; cursor: pointer; min-width: 0; min-height: 0; }
.cell.r0 { border-top-width: 1px; }
.cell.c0 { border-left-width: 1px; }
.brow:nth-child(2) .cell:first-of-type { border-top-left-radius: 6px; }
.cell.s-grass { background: var(--plot-grass); }
.cell.s-tree { cursor: default; }
.cell .ic { position: absolute; inset: 9%; width: 82%; height: 82%; pointer-events: none; }
.cell .ic-grass { inset: 18%; width: 64%; height: 64%; }
.cell:focus { outline: none; }
/* Focus: a blue ring inside a white one, so it shows on every kind of spot. */
.cell:focus-visible, .clue:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; box-shadow: inset 0 0 0 5px #ffffff; border-radius: 0; z-index: 2; }
.cell.hl { background: var(--hl-bg); box-shadow: inset 0 0 0 calc(var(--cell) * .08) var(--hl); }
.cell.bad { background: var(--bad-bg); }
.cell.wrong { box-shadow: inset 0 0 0 calc(var(--cell) * .07) var(--bad); }
.badge { position: absolute; right: 4%; top: 3%; min-width: calc(var(--cell) * .34); height: calc(var(--cell) * .34); padding: 0 2px; border-radius: 999px;
  background: var(--bad); color: var(--card); font-size: calc(var(--cell) * .26); font-weight: 800; line-height: calc(var(--cell) * .34); text-align: center; pointer-events: none; }
.clue, .corner { display: flex; align-items: center; justify-content: center; position: relative; min-width: 0; min-height: 0; }
.clue { font-weight: 800; font-size: calc(var(--cell) * .42); color: var(--ink); cursor: pointer; border-radius: 6px; }
.clue:hover { background: var(--tag-bg); }
.clue .mark { position: absolute; right: 6%; top: 2%; font-size: calc(var(--cell) * .26); line-height: 1; }
.clue.done { color: var(--muted); }
.clue.done .mark { color: var(--ok-ink); }
.clue.bad { background: var(--err-bg); color: var(--err-ink); }
.clue.hl { background: var(--hl-bg); box-shadow: inset 0 0 0 2px var(--hl); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.hint-box { border: 2px solid var(--hl); background: var(--hl-bg); border-radius: 10px; padding: 12px; margin: 0 0 12px; color: var(--ink); }
.hint-head { font-weight: 800; display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.hint-head .ic { width: 22px; height: 22px; }
.msg:empty { display: none; }
.msg { background: var(--tag-bg); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.settings { margin: 0 0 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.settings summary { font-weight: 700; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.play-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; border-top: 1px solid var(--line); padding: 10px 0 2px; margin: 0 0 8px; }
.play-nav a { padding: 6px 0; }
.stars-note { margin: 0; }
.print-rules { display: none; }
dialog.win { border: 0; border-radius: 16px; padding: 24px; max-width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.35); text-align: center; }
dialog.win::backdrop { background: rgba(10, 20, 12, .55); }
dialog.win h2 { margin-top: 0; font-size: 1.5rem; }
.win-stars { font-size: 2.4rem; line-height: 1; margin: 0 0 12px; }
dialog.win .row { justify-content: center; margin-bottom: 0; }
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: filter .12s; }
  .board.won .s-tent .ic { animation: hc-hop .6s ease-out both; }
  @keyframes hc-hop { 0% { transform: translateY(0); } 40% { transform: translateY(-14%); } 100% { transform: translateY(0); } }
}
@media (max-width: 520px) {
  main.wrap { padding-left: 8px; padding-right: 8px; }
  .play-page .site-footer .wrap { padding: 0 12px; }
}

/* A pack's page */
.levels { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.levels a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--ink); background: var(--card); font-weight: 800; font-size: 1.1rem; }
.levels a:hover { border-color: var(--muted); }
.levels a.solved { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.levels a.partway { border: 2px dashed var(--brand); }
.lvl-st { font-size: .78rem; font-weight: 600; min-height: 1.2em; }
.levels a.solved .stars, .levels a.solved .stars .off { color: var(--ok-ink); }

/* How to play */
.prose { max-width: 48em; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: 0 0 .4rem; }
.tech { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: start; margin: 14px 0 18px; }
.tech .mini { grid-row: span 2; }
.tech h3 { margin: 0; }
.tech p { margin: 0; }
@media (max-width: 520px) { .tech { grid-template-columns: 1fr; } .tech .mini { grid-row: auto; } }
kbd { font: .9em ui-monospace, Menlo, Consolas, monospace; background: var(--tag-bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* Print: the puzzle on its own, ready for a pencil (Print leaves out your marks). */
@media print {
  :root { --plot: #ffffff; --plot-line: #444444; --plot-grass: #ffffff; --ink: #000000; --muted: #333333; --bg: #ffffff; --card: #ffffff;
    --leaf: #2d7a35; --leaf-hi: #64ad55; --trunk: #6b4423; --tent: #d2601c; --tent-shade: #a94810; --tent-door: #3d2210; --tent-line: #33261a; --tuft: #3b7426; }
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .skip, .panel, .board-help, .status-bar, .crumbs, .play-done, dialog, .msg { display: none !important; }
  .play-grid { display: block; }
  .board-wrap { max-width: 16cm; margin: 0 auto; }
  .play-top { text-align: center; }
  .cell.hl, .cell.bad, .cell.wrong { box-shadow: none; background: #fff; }
  .badge, .clue .mark { display: none; }
  .clue.done, .clue.bad, .clue.hl { color: #000; background: none; box-shadow: none; }
  .print-rules { display: block; text-align: center; max-width: 16cm; margin: 14px auto 0; font-size: 10pt; }
  body.print-blank .cell.s-tent .ic, body.print-blank .cell.s-grass .ic { display: none; }
  body.print-blank .cell.s-grass { background: #fff; }
}
ul.plain-list { list-style: none; padding: 0; margin: 0; }
ul.plain-list li { padding: 4px 0; }
