/* Campsite tokens: dark mode only changes these values. */
:root {
  --g-campsite: #2e8b57;
  --camp-cell: #fbfaf3;
  --camp-line: #dedbcc;
  --camp-frame: #6b8f5a;
  --camp-grass: #dcefcb;
  --camp-grass-ink: #82b866;
  --camp-leaf: #3f9a45;
  --camp-leaf-shine: #8fd17a;
  --camp-trunk: #8a5a32;
  --camp-tent: #f08a3c;
  --camp-tent-door: #7a3a12;
  --camp-clue: #3a3a32;
  --camp-clue-done: #2f8a3c;
  --camp-clue-bad: var(--danger);
  --camp-bad-bg: #fbe0dc;
}
:root[data-theme='dark'] {
  --g-campsite: #4fb07a;
  --camp-cell: #1b1d18;
  --camp-line: #3a3d33;
  --camp-frame: #6f9a5c;
  --camp-grass: #233420;
  --camp-grass-ink: #5f9a48;
  --camp-leaf: #5cb85f;
  --camp-leaf-shine: #a2e08e;
  --camp-trunk: #b07a4a;
  --camp-tent: #f39a52;
  --camp-tent-door: #5a2a0e;
  --camp-clue: #e8e8e0;
  --camp-clue-done: #7fd38a;
  --camp-bad-bg: #4a2420;
}

.campsite-shell {
  --game-accent: var(--g-campsite);
}
.campsite-shell .shell-stage {
  gap: var(--space-3);
  padding: 0 var(--space-4);
}
.campsite-shell .shell-board-area {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
/* The board is the camp plus a clue strip on the top and on the left, 0.8 cell thick. */
.camp-board-wrap {
  width: min(
    calc(540px * max(1, (var(--cols) + 0.8) / (var(--rows) + 0.8))),
    calc(100vw - 32px),
    calc((100dvh - 270px) * (var(--cols) + 0.8) / (var(--rows) + 0.8))
  );
  margin: 0 auto;
  container-type: inline-size;
}
.camp-board {
  --cell: calc(100cqw / (var(--cols) + 0.8));
  display: grid;
  grid-template-columns: calc(var(--cell) * 0.8) calc(var(--cell) * var(--cols));
  grid-template-rows: calc(var(--cell) * 0.8) calc(var(--cell) * var(--rows));
  user-select: none;
  -webkit-user-select: none;
}
.camp-col-clues,
.camp-row-clues {
  display: grid;
}
.camp-col-clues {
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
.camp-row-clues {
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
}
.camp-clue {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border-radius: 6px;
  color: var(--camp-clue);
  font: 800 calc(var(--cell) * 0.46) / 1 var(--font-app);
  font-variant-numeric: tabular-nums;
  transition: color 160ms ease;
}
.camp-clue.done {
  color: var(--camp-clue-done);
}
.camp-clue.over,
.camp-clue.short {
  color: var(--camp-clue-bad);
  text-decoration: underline wavy;
  text-underline-offset: 3px;
}
.camp-clue.hidden {
  color: var(--text-muted);
  font-weight: 600;
  opacity: 0.6;
}
.camp-clue.hint-line {
  box-shadow: inset 0 0 0 2px var(--hint-context);
}
.camp-grid {
  position: relative;
  display: grid;
  overflow: hidden;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  border: 2px solid var(--camp-frame);
  border-radius: 12px;
  background: var(--camp-cell);
  /* Painting grass must not scroll or zoom the page. */
  touch-action: none;
}
.camp-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--camp-line);
  border-bottom: 1px solid var(--camp-line);
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.camp-cell.tree {
  cursor: default;
}
.camp-cell.grass {
  background: var(--camp-grass);
}
.camp-cell.bad {
  background: var(--camp-bad-bg);
}
.camp-cell.bad .camp-tent .cloth {
  stroke: var(--danger);
  stroke-width: 1.6;
}
.camp-cell.hint-context {
  box-shadow: inset 0 0 0 3px var(--hint-context);
}
.camp-cell.hint-target {
  box-shadow: inset 0 0 0 3px var(--hint-target);
}
.camp-cell:focus-visible {
  z-index: 1;
  outline: 0;
  box-shadow: inset 0 0 0 3px var(--text);
}
.camp-icon {
  width: 78%;
  height: 78%;
  pointer-events: none;
}
.camp-tree .leaf {
  fill: var(--camp-leaf);
}
.camp-tree .shine {
  fill: var(--camp-leaf-shine);
  opacity: 0.7;
}
.camp-tree .trunk {
  fill: var(--camp-trunk);
}
.camp-tent .cloth {
  fill: var(--camp-tent);
  stroke: var(--camp-tent);
  stroke-width: 1;
  stroke-linejoin: round;
}
.camp-tent .door {
  fill: var(--camp-tent-door);
}
.camp-tent .pole {
  stroke: var(--camp-tent-door);
  stroke-width: 1.4;
  stroke-linecap: round;
}
.camp-grass {
  width: 56%;
  height: 56%;
}
.camp-grass path {
  fill: none;
  stroke: var(--camp-grass-ink);
  stroke-width: 2;
  stroke-linecap: round;
}
.camp-cell.tent .camp-tent {
  animation: camp-pop 180ms ease-out;
}
.camp-ghost {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  opacity: 0.5;
}
@keyframes camp-pop {
  from {
    transform: scale(0.6);
  }
}
.camp-board.solved .camp-cell:not(.tree) {
  animation: camp-wave 700ms ease-out both;
  animation-delay: calc(var(--i) * 30ms);
}
@keyframes camp-wave {
  40% {
    filter: brightness(1.12);
  }
}
@media (prefers-reduced-motion: reduce) {
  .camp-cell.tent .camp-tent,
  .camp-board.solved .camp-cell:not(.tree) {
    animation: none;
  }
}
.camp-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}
.camp-status b {
  color: var(--text);
}

/* Picture rules: a mini camp drawn with the real cells (and clue strips) fills the demo stage. */
.camp-demo-board {
  position: relative;
  width: 100%;
}
.camp-demo-board > .camp-grid {
  aspect-ratio: var(--cols) / var(--rows);
}
.camp-demo-board .camp-board-wrap {
  width: 100%;
}
.camp-demo-board .camp-cell {
  cursor: default;
}
/* With clue strips the ✓ / ✗ badge sits in the empty corner, clear of the clues. */
.camp-demo-board.clued .shell-demo-mark {
  top: 0;
  right: auto;
  left: 0;
}
