/* Numtrail tokens: dark mode only changes these values. */
:root {
  --g-trail: #8a5cd6;
  --trail-cell: #ffffff;
  --trail-line: #dcdcd8;
  --trail-path: #8a5cd6;
  --trail-visited: #f1ebfb;
  --trail-number-bg: #1b1b1b;
  --trail-number-ink: #ffffff;
  --trail-wall: #1b1b1b;
}
:root[data-theme='dark'] {
  --g-trail: #a983eb;
  --trail-cell: #1a1a1a;
  --trail-line: var(--board-grid);
  --trail-path: #a983eb;
  --trail-visited: #2a2238;
  --trail-number-bg: #f2f2f2;
  --trail-number-ink: #121212;
  --trail-wall: #f2f2f2;
}

.trail-shell {
  --game-accent: var(--g-trail);
}
.trail-shell .shell-stage {
  gap: var(--space-3);
  padding: 0 var(--space-4);
}
.trail-shell .shell-board-area {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.trail-board-wrap {
  width: min(
    calc(520px * max(1, var(--cols) / var(--rows))),
    calc(100vw - 32px),
    calc((100dvh - 260px) * var(--cols) / var(--rows))
  );
  margin: 0 auto;
}
.trail-board {
  position: relative;
  display: grid;
  overflow: hidden;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  aspect-ratio: var(--cols) / var(--rows);
  border: 2px solid var(--trail-wall);
  border-radius: 12px;
  background: var(--trail-cell);
  /* Drawing must not scroll or zoom the page. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.trail-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--trail-line);
  border-bottom: 1px solid var(--trail-line);
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.trail-cell.on {
  background: var(--trail-visited);
}
.trail-cell.hint-context {
  box-shadow: inset 0 0 0 3px var(--hint-context);
}
.trail-cell.hint-target {
  box-shadow: inset 0 0 0 3px var(--hint-target);
}
.trail-cell:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 3px var(--text);
}
/* Numbers sit above the path so they stay readable where the line passes through. */
.trail-number {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--trail-number-bg);
  color: var(--trail-number-ink);
  font: 800 clamp(13px, 4.2vw, 22px) / 1 var(--font-app);
  font-variant-numeric: tabular-nums;
}
.trail-number.reached {
  background: var(--trail-path);
  color: #ffffff;
}
.trail-layer {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.trail-path {
  fill: none;
  stroke: var(--trail-path);
  stroke-width: 0.34;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trail-head {
  fill: #ffffff;
  stroke: var(--trail-path);
  stroke-width: 0.06;
}
.trail-walls line {
  stroke: var(--trail-wall);
  stroke-width: 0.1;
  stroke-linecap: round;
}
.trail-hint-edges line {
  stroke-width: 0.12;
  stroke-linecap: round;
}
.trail-hint-edges .on {
  stroke: var(--hint-target);
  stroke-dasharray: 0.15 0.12;
}
.trail-hint-edges .off {
  stroke: var(--danger);
  stroke-dasharray: 0.06 0.1;
  opacity: 0.8;
}
.trail-board.solved .trail-path {
  animation: trail-glow 900ms ease-out;
}
@keyframes trail-glow {
  50% {
    stroke-width: 0.5;
  }
}
@media (prefers-reduced-motion: reduce) {
  .trail-board.solved .trail-path {
    animation: none;
  }
}
.trail-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}
.trail-status b {
  color: var(--text);
}

/* Picture rules: the 3 × 3 demo board fills its stage. */
.trail-demo-board {
  width: 100%;
  overflow: visible;
}
.trail-demo-board .trail-number {
  font-size: 22px;
}
