/*
 * Guide pages (how to play, strategy, 404): a ruled prose column in the scorecard system.
 * Loaded after style.css. The example diagrams borrow the board's own look (Arial markers,
 * warm lines, board tokens) rather than restyling it.
 */
body.guide-page {
  --game-width: 720px;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
  text-decoration: none;
}
.header-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.header-play svg {
  width: 15px;
  height: 15px;
}
main.guide {
  display: block;
  width: 100%;
  max-width: calc(720px + var(--page-left) + var(--page-right));
  margin: 0 auto;
  padding: 24px var(--page-right) 48px var(--page-left);
  font-size: 16px;
  line-height: 1.65;
}
.guide h1 {
  display: block;
  margin: 12px 0 0;
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}
.guide .lede {
  max-width: none;
  margin: 8px 0 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink);
  color: var(--muted);
}
.guide h2 {
  margin: 44px 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.guide h3 {
  margin: 28px 0 6px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}
.guide p,
.guide li {
  max-width: 68ch;
}
.guide p {
  margin: 10px 0 0;
}
.guide a {
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}
.guide ol,
.guide ul {
  padding-left: 22px;
}
.guide li {
  margin: 6px 0;
}
.guide .meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
/* Ruled lists and tables, as on a results sheet. */
.guide .ruled {
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.guide .ruled > li {
  max-width: none;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.guide .ruled strong {
  display: block;
}
.guide .ruled li > span {
  color: var(--muted);
}
.score-table {
  width: 100%;
  margin: 16px 0 0;
  border-collapse: collapse;
  border-top: 1px solid var(--ink);
  font-size: 14px;
}
.score-table th,
.score-table td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: baseline;
}
.score-table th {
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.score-table .num {
  text-align: right;
  padding-right: 0;
  padding-left: 16px;
  white-space: nowrap;
  font-weight: 700;
}
.score-table td:first-child {
  color: var(--muted);
  width: 2.5em;
}
/* Field rows: a short label beside its value. */
.fields {
  margin: 14px 0 0;
  border-top: 1px solid var(--line);
}
.fields > div {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.fields dt {
  padding-top: 5px;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.fields dd {
  margin: 0;
  max-width: 62ch;
}
.guide kbd {
  font-size: 13px;
  white-space: nowrap;
}
.guide .cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 20px;
  padding: 11px 18px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.guide .ending {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--ink);
}
.guide-footer {
  width: min(calc(100% - var(--page-left) - var(--page-right)), var(--game-width));
}
.guide-footer a[aria-current='page'] {
  color: var(--ink);
}

/* Example diagrams: one six-cell line (.ex-line) or a full 6×6 board (.ex-grid). */
.example {
  margin: 18px 0 0;
}
.example figcaption {
  max-width: 62ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.example-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  margin: 18px 0 0;
}
.example-pair .example {
  margin: 0;
  max-width: 100%;
}
.example-pair figcaption {
  max-width: 300px;
}
.ex-line,
.ex-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 2px solid var(--board-line);
  border-radius: 5px;
  background: var(--tile);
  font-family: Arial, Helvetica, sans-serif;
  font-feature-settings: normal;
  user-select: none;
  -webkit-user-select: none;
}
.ex-line {
  width: 324px;
  max-width: 100%;
}
.ex-line.small {
  width: 168px;
  border-width: 1px;
  border-radius: 4px;
}
.ex-grid {
  width: 300px;
  max-width: 100%;
}
.ex-line > *,
.ex-grid > * {
  --cell-bg: var(--tile);
  position: relative;
  background-color: var(--cell-bg);
  aspect-ratio: 1;
  border-right: 2px solid var(--board-line);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 60%;
}
.ex-line.small > * {
  border-right-width: 1px;
}
.ex-line.small > .n,
.ex-line.small > .x {
  outline-width: 1px;
  outline-offset: -3px;
}
.ex-line > *:last-child,
.ex-grid > *:nth-child(6n) {
  border-right: 0;
}
.ex-grid > *:nth-child(-n + 30) {
  border-bottom: 2px solid var(--board-line);
}
.ex-line > .s,
.ex-grid > .s {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='32' r='23' fill='%23ffb51c' stroke='%23b96721' stroke-width='3.5'/%3E%3C/svg%3E");
}
.ex-line > .m,
.ex-grid > .m {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M31 9C44 12 52 26 48 39S30 59 17 52C13 50 10 47 8 43C20 47 32 41 35 30C38 22 35 14 31 9Z' fill='%234b8ee6' stroke='%232059a8' stroke-width='3.5' stroke-linejoin='round'/%3E%3C/svg%3E");
}
body.dark .ex-line > .m,
body.dark .ex-grid > .m {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M31 9C44 12 52 26 48 39S30 59 17 52C13 50 10 47 8 43C20 47 32 41 35 30C38 22 35 14 31 9Z' fill='%234b8ee6' stroke='%2385b7ff' stroke-width='3.5' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* f: fixed clue; e: a cell the deduction reads; n: the deduced cell; x: a rule conflict. */
.ex-line > .f,
.ex-grid > .f {
  --cell-bg: var(--fixed);
}
.ex-line > .e,
.ex-grid > .e {
  --cell-bg: var(--hint);
}
.ex-line > .n,
.ex-grid > .n {
  --cell-bg: var(--hint);
  outline: 2px dashed var(--accent);
  outline-offset: -5px;
}
.ex-line > .x,
.ex-grid > .x {
  --cell-bg: var(--error-bg);
  outline: 2px dashed var(--error);
  outline-offset: -5px;
}
/* = and × markers sit on the shared edge and cut the line under them, as on the board. */
.ex-line > [data-r]::after,
.ex-grid > [data-r]::after,
.ex-grid > [data-b]::before {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 18px;
  height: 26px;
  background: linear-gradient(var(--cell-bg), var(--cell-bg)) center / 2px 100% no-repeat;
  color: var(--board-marker);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.ex-line > [data-r]::after,
.ex-grid > [data-r]::after {
  content: attr(data-r);
  top: 50%;
  right: 1px;
  transform: translate(50%, -50%);
}
.ex-grid > [data-b]::before {
  content: attr(data-b);
  left: 50%;
  bottom: 1px;
  width: 26px;
  height: 18px;
  background-size: 100% 2px;
  transform: translate(-50%, 50%);
}
.ex-grid > [data-r]::after,
.ex-grid > [data-b]::before {
  font-size: 23px;
}
.ex-line.small > [data-r]::after {
  width: 12px;
  height: 18px;
  background-size: 1px 100%;
  font-size: 16px;
}
/* Cell numbers under a line, so the text can say "cell 3". */
.ex-line.numbered {
  margin-bottom: 22px;
  counter-reset: cell;
}
.ex-line.numbered > span {
  counter-increment: cell;
}
.ex-line.numbered > span::before {
  content: counter(cell);
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1;
  text-align: center;
}
.guide .line-set {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px 16px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.guide .line-set li {
  margin: 0;
}
@media (hover: hover) and (pointer: fine) {
  .header-play:hover {
    background: var(--button);
  }
  .guide .cta:hover {
    background: var(--ink-hover);
    border-color: var(--ink-hover);
  }
  .guide a:not(.cta):not(.wordmark):hover {
    text-decoration-color: currentColor;
  }
}
@media (max-width: 520px) {
  .wordmark {
    font-size: 20px;
  }
  main.guide {
    padding-top: 16px;
  }
  .guide h2 {
    margin-top: 36px;
    font-size: 20px;
  }
  .fields > div {
    grid-template-columns: 64px 1fr;
  }
}
@media (max-width: 350px) {
  .wordmark {
    font-size: 18px;
  }
}
@media (pointer: coarse) {
  .header-play {
    min-height: 44px;
  }
}

/* Strategy page: level badges, the level jump-nav and the "Try it" practice rows. */
.level {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: middle;
}
.level-meter {
  display: inline-flex;
  gap: 2px;
}
.level-meter i {
  width: 6px;
  height: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 1px;
}
.level[data-rank='1'] .level-meter i:nth-child(-n + 1),
.level[data-rank='2'] .level-meter i:nth-child(-n + 2),
.level[data-rank='3'] .level-meter i:nth-child(-n + 3),
.level[data-rank='4'] .level-meter i {
  border-color: var(--muted);
  background: var(--muted);
}
.guide .level-line {
  margin: 6px 0 0;
}
.level-nav ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
.guide .level-nav li {
  margin: 0;
  max-width: none;
}
.level-nav li + li {
  border-left: 1px solid var(--line);
}
.guide .level-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
  height: 100%;
  padding: 10px 12px;
  color: var(--ink);
  text-decoration: none;
}
.level-nav strong {
  font-size: 15px;
}
.level-nav span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.level-intro {
  margin-top: 6px;
  color: var(--muted);
}
.practice {
  margin: 18px 0 0;
  padding: 12px 0 14px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
.practice[hidden] {
  display: none;
}
.practice-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.guide .practice h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.practice-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.practice-status::before {
  content: '✓ ';
}
.guide .practice-prompt {
  margin: 4px 0 12px;
  font-size: 15px;
}
.practice-line > button {
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  --cell-bg: var(--tile);
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.practice-line > button.f {
  cursor: default;
}
.practice-line > button:focus-visible {
  box-shadow: inset 0 0 0 3px var(--focus);
}
.practice-line > button:focus-visible:not(.h):not(.n):not(.x) {
  outline: none;
}
.ex-line > .h {
  outline: 2px dashed var(--accent);
  outline-offset: -5px;
}
.guide .practice-feedback {
  min-height: 1.6em;
  margin: 10px 0 0;
  font-size: 15px;
}
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.practice-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.practice-button[data-action='reset'] {
  margin-left: auto;
  border-color: transparent;
  color: var(--muted);
}
@media (hover: hover) and (pointer: fine) {
  .guide .level-nav a:hover {
    background: var(--button);
  }
  .practice-button:hover {
    background: var(--button);
  }
  .practice-button[data-action='reset']:hover {
    background: transparent;
    color: var(--ink);
  }
  .practice-line > button:not(.f):not(.e):not(.n):not(.x):hover {
    background-color: #faf7f1;
  }
  body.dark .practice-line > button:not(.f):not(.e):not(.n):not(.x):hover {
    background-color: #302e29;
  }
}
@media (max-width: 560px) {
  .level-nav ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .level-nav li:nth-child(3) {
    border-left: 0;
  }
  .level-nav li:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}
