:root {
  --bg: #f4efe6;
  --bg-deep: #ebe3d4;
  --ink: #1c1917;
  --muted: #6b6258;
  --line: #e0d6c6;
  --paper: #fffdf8;
  --cell: #efe6d8;
  --cell-on: #c8efe4;
  --teal: #0f766e;
  --teal-ink: #115e59;
  --trail: #0d9488;
  --accent: #c2410c;
  --wall: #1c1917;
  --shadow: 0 18px 50px -28px rgba(28, 25, 23, 0.45);
  --radius: 22px;
  --max: 72rem;
  --sans: "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff8ec 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #dceee9 0%, transparent 50%),
    var(--bg);
  line-height: 1.6;
}

a {
  color: var(--teal-ink);
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.8rem;
  border-radius: 0.4rem;
  z-index: 20;
}

.skip:focus {
  top: 0.75rem;
}

.site-header,
.site-footer,
.play,
.prose {
  width: min(var(--max), calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0 0.4rem;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
}

.tag {
  color: var(--muted);
  font-size: 0.82rem;
}

.play {
  padding: 0.5rem 0 3rem;
}

.lede-wrap {
  max-width: 40rem;
  margin-bottom: 1.25rem;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 0.7rem;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.board-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#sizes {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-deep);
  padding: 0.22rem;
  border-radius: 999px;
}

#sizes button,
.ghost,
.primary {
  font: inherit;
  cursor: pointer;
  border: 0;
}

#sizes button {
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 650;
}

#sizes button[aria-pressed="true"] {
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.08);
}

.ghost,
.primary {
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 650;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost:disabled {
  opacity: 0.4;
  cursor: default;
}

.primary,
.primary-lg {
  background: var(--ink);
  color: #fff;
}

.primary-lg {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  cursor: pointer;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.15rem 0 0.45rem;
}

.track {
  height: 4px;
  background: var(--bg-deep);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

#progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--trail);
}

#board-wrap {
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: 4px;
  position: relative;
  z-index: 1;
}

.cell {
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 10px;
  background: var(--cell);
  color: var(--ink);
  font: inherit;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cell.on {
  background: var(--cell-on);
}

.cell.tip {
  box-shadow: inset 0 0 0 2px rgba(13, 148, 136, 0.45);
}

.num {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

#path-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

#path-layer .trail {
  fill: none;
  stroke: var(--trail);
  stroke-width: 7.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#path-layer .wall {
  stroke: var(--wall);
  stroke-width: 6;
  stroke-linecap: round;
}

#path-layer .tip-dot {
  fill: var(--teal-ink);
}

#path-layer .badge {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2.25;
}

#path-layer .badge.done {
  fill: var(--teal);
  stroke: var(--teal);
}

#path-layer .badge.soon {
  stroke: var(--accent);
}

#path-layer .badge-label {
  fill: var(--ink);
  font-weight: 800;
  font-size: 14px;
  text-anchor: middle;
  font-family: var(--sans);
}

#path-layer .badge-label.on {
  fill: #fff;
}

#status {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.win {
  margin-top: 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.win strong {
  display: block;
  font-size: 1rem;
}

.win span {
  color: var(--muted);
  font-size: 0.88rem;
}

#board-wrap.won {
  outline: 2px solid #99f6e4;
  outline-offset: 4px;
  border-radius: 12px;
}

.prose {
  padding: 0 0 3.5rem;
}

.prose section + section {
  margin-top: 2.4rem;
}

.prose h2 {
  font-family: var(--serif);
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  margin: 0 0 0.8rem;
}

.prose h3 {
  font-size: 1.05rem;
  margin: 1.15rem 0 0.35rem;
}

.prose p,
.prose li {
  color: #3f3a34;
}

.steps {
  display: grid;
  gap: 0.8rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.steps li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

.steps strong {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--ink);
}

.rules {
  margin: 0;
  padding-left: 1.15rem;
}

.faq details {
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq details p {
  margin: 0.45rem 0 0.15rem;
}

.site-footer {
  padding: 0 0 2.4rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.noscript {
  width: min(var(--max), calc(100% - 2rem));
  margin: 1rem auto;
  padding: 0.8rem 1rem;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 12px;
}

@media (min-width: 880px) {
  .stage {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    align-items: start;
  }

  .lede-wrap {
    position: sticky;
    top: 1.25rem;
    margin-bottom: 0;
  }

  .cell {
    border-radius: 12px;
  }
}

@media (max-width: 520px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }

  .toolbar {
    justify-content: space-between;
  }

  #path-layer .trail {
    stroke-width: 6;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
