/* Safe Pick: five small boards dealt one at a time. Builds on style.css tokens
   and the bevel system; nothing here is rounded or shadowed. */

.sp-wrap { --sp-cell: 60px; --sp-size: 5; max-width: 1240px; margin: 0 auto; }

.sp-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: fit-content;
  max-width: 100%;
}
/* Heading as on the homepage: mono, left-aligned over the game. */
.sp-intro { align-self: stretch; }
.sp-lede { margin: 2px 0 0; font-size: 13px; line-height: 1.45; color: var(--text-dark-muted); }

/* Status bar: three LED counters and the start button. */
.sp-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 8px 12px;
}
.sp-stat { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sp-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}
.sp-bar .counter { font-size: 22px; min-width: 4ch; }
.sp-stage > .sp-bar { align-self: stretch; justify-content: space-between; box-sizing: border-box; }

.sp-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
}
.sp-btn.raised { color: var(--ink); }
.sp-btn:active { border-style: solid; filter: brightness(0.92); }
.sp-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }


/* The deal: one board on show at a time. */
.sp-cards { display: flex; justify-content: center; width: 100%; }
.sp-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
}
.sp-card-head, .sp-card-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink);
}
.sp-tag { color: var(--ink-faint); font-weight: 600; }
.sp-card-foot {
  justify-content: center;
  min-height: 1.4em;
  white-space: pre;
  color: var(--ink-muted);
}

.sp-well { background: var(--board-well); padding: 3px; align-self: center; }
.sp-board .cell {
  --cell-size: var(--sp-cell);
  padding: 0;
  font-size: calc(var(--sp-cell) * 0.6);
  box-sizing: border-box;
}
.sp-board button.cell { appearance: none; color: inherit; }
.sp-board button.cell:hover:not(:disabled) { background: #cfcfcf; }
.sp-board button.cell:focus-visible { outline: 3px solid #d43b1e; outline-offset: -3px; z-index: 2; }
.sp-board button.cell:disabled { cursor: default; }

/* Face-down card: a blank sunken panel the size of a board. */
.sp-cover {
  width: calc(var(--sp-size) * var(--sp-cell) + (var(--sp-size) - 1) * 1px + 6px);
  height: calc(var(--sp-size) * var(--sp-cell) + (var(--sp-size) - 1) * 1px + 6px);
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,0.06) 6px 12px),
    var(--board-well);
}

/* After the pick: the answer tile is outlined, and the picked tile says what
   it was. Words in the card footer carry the result, not colour alone. */
.sp-board .cell.sp-answer {
  outline: 3px solid #007a00;
  outline-offset: -3px;
  z-index: 1;
}
.sp-board .cell.sp-answer::after {
  content: "";
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: #007a00;
}
.sp-board .cell.revealed.mine-hit { border: 1px solid var(--mine-cell-border); }
.sp-board .cell.revealed:has(.mine):not(.mine-hit) { background: var(--face); border: 1px solid var(--grid-line); }

.sp-card.is-safe .sp-card-foot { color: #007a00; }
.sp-card.is-mine .sp-card-foot { color: var(--mine-cell); }

/* These set display, which would otherwise beat the hidden attribute. */
.sp-card[hidden], .sp-bar[hidden], .sp-cards[hidden], .sp-btn[hidden], .sp-link[hidden], .sp-options-sep[hidden] { display: none; }

@keyframes sp-enter {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sp-card.sp-enter { animation: sp-enter 0.16s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .sp-card.sp-enter { animation: none; }
}

/* Start card: the button sits on the face-down board. */
.sp-start-card .sp-cover { display: flex; align-items: center; justify-content: center; }
.sp-btn-big { font-size: 16px; min-height: 56px; padding: 0 32px; }

/* Countdown on the start card. */
.sp-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: calc(var(--sp-cell) * 1.8);
  color: var(--navy);
  animation: sp-count 0.6s ease-out;
}
@keyframes sp-count {
  from { transform: scale(1.5); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}

/* A miss: the clock flashes as the penalty lands. */
.counter.sp-penalty { animation: sp-penalty 0.7s ease-out; }
@keyframes sp-penalty {
  0%, 40% { background: var(--mine-cell); color: #fff; }
  100% { background: var(--led-bg); color: var(--led-red); }
}
@media (prefers-reduced-motion: reduce) {
  .sp-count, .counter.sp-penalty { animation: none; }
}

/* Reasoning marks: the number being read, and the safe tile. */
.sp-board .cell.sp-why {
  outline: 3px solid var(--navy);
  outline-offset: -3px;
  background: #fff4b8;
  z-index: 1;
}
.sp-board .cell.sp-why[data-step]::after {
  content: attr(data-step);
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: max(9px, calc(var(--sp-cell) * 0.22));
  line-height: 1;
  color: var(--navy);
}
.sp-board .cell .flag { pointer-events: none; }
/* The demo's tap: a ring that closes in on the tile. */
.sp-board .cell.sp-tap { z-index: 2; }
.sp-board .cell.sp-tap::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 3px solid var(--navy);
  border-radius: 50%;
  animation: sp-tap 0.7s ease-in forwards;
}
@keyframes sp-tap {
  from { transform: scale(1.4); opacity: 0; }
  to { transform: scale(0.6); opacity: 1; }
}
/* Proven safe but not dug yet. */
.sp-board .cell.sp-hint {
  outline: 3px dashed #007a00;
  outline-offset: -4px;
  z-index: 1;
}
@media (prefers-reduced-motion: reduce) {
  .sp-board .cell.sp-tap::before { animation: none; }
}

/* Walkthrough and practice. */
.sp-tut { width: min(100%, calc(var(--sp-size) * (var(--sp-cell) + 1px) + 120px)); box-sizing: border-box; }
.sp-tut-caption {
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  min-height: 4.4em;
  padding: 2px 4px;
}
.sp-why-list { margin: 6px 0 0; padding-left: 20px; }
.sp-why-list li { margin: 2px 0; }
.sp-tut-actions { justify-content: flex-end; }
.sp-tut-skip { align-self: center; color: var(--ink-muted); }

/* Small text links: How to play, the layout switch, skip. */
.sp-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dark-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.sp-link:hover:not(:disabled) { color: var(--text-dark); }
.sp-link:disabled { cursor: default; opacity: 0.5; }
.sp-link:focus-visible { outline: 2px solid var(--text-dark); outline-offset: 2px; }
.sp-tut .sp-link { color: var(--ink-muted); }
.sp-tut .sp-link:hover { color: var(--ink); }
.sp-link[aria-pressed="true"] { color: var(--text-dark); text-decoration: none; font-weight: 700; }
.sp-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dark-muted);
}
.sp-options-group { display: inline-flex; align-items: center; gap: 4px; }

/* Results dialog: reuses the site's .dialog / .win-dialog chrome. */
dialog.sp-done {
  margin: auto;
  width: calc(100% - 32px);
  max-width: 380px;
  box-sizing: border-box;
}
dialog.sp-done::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog.sp-done[open] { animation: sp-pop 0.18s ease-out; }
@keyframes sp-pop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.sp-done[open] { animation: none; }
}
.sp-done-headline {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
}
.sp-done .sp-breakdown { margin-top: 12px; text-align: left; }
.sp-done .sp-best { text-align: left; margin: 8px 0 0; }
/* The daily handoff in the results dialog, like the homepage's. */
.sp-daily-handoff {
  display: block;
  margin: 0 12px 4px;
  padding: 10px 12px;
  background: var(--chip-surface);
  border: 1px solid var(--chip-border);
  color: var(--text-dark);
  text-decoration: none;
}
.sp-daily-handoff[hidden] { display: none; }
.sp-daily-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.sp-daily-text { display: block; font-size: 13px; color: var(--text-dark-muted); }
.sp-daily-handoff:hover .sp-daily-text { color: var(--text-dark); text-decoration: underline; }
.sp-modes-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-wrap .modes { max-width: 720px; }
.site-nav .home-footer-btn { text-transform: uppercase; } /* match .site-nav a */

.sp-share-status { margin: 0 16px; min-height: 1.2em; font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); text-align: center; }
.sp-done .dialog-actions .sp-again { min-height: 46px; font-size: 16px; }
.sp-actions-row { display: flex; gap: 6px; }
.sp-actions-row button { flex: 1; min-height: 40px; }

.sp-breakdown { margin: 0; font-family: var(--font-mono); font-size: 14px; color: var(--ink); }
.sp-breakdown div { display: flex; justify-content: space-between; gap: 24px; padding: 3px 0; }
.sp-breakdown dt, .sp-breakdown dd { margin: 0; }
.sp-breakdown .sp-total { border-top: 1px solid var(--divider); margin-top: 4px; padding-top: 6px; font-weight: 700; font-size: 16px; }
.sp-best { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); margin: 10px 0; }
.sp-actions { display: flex; gap: 10px; flex-wrap: wrap; }


/* The fuse over each board, and the blast. */
.sp-fuse { height: 10px; background: var(--led-bg); padding: 0; position: relative; }
.sp-fuse-burn {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: repeating-linear-gradient(90deg, #c8a060 0 4px, #8a6a38 4px 6px);
}
/* The spark: a square that flickers at the burning end. */
.sp-fuse-burn::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -3px;
  width: 10px;
  height: 10px;
  background: #ffd23a;
  outline: 2px solid #ff6a00;
  animation: sp-spark 0.16s steps(2) infinite;
}
@keyframes sp-spark {
  from { background: #ffd23a; outline-color: #ff6a00; }
  to { background: #fff6c8; outline-color: #d43b1e; }
}
.sp-card.is-hot .sp-fuse-burn { background: repeating-linear-gradient(90deg, #d43b1e 0 4px, #8a1e0c 4px 6px); }
.sp-card.is-done .sp-fuse-burn::after { display: none; }
.counter.sp-hot { animation: sp-hot 0.5s steps(2) infinite; }
@keyframes sp-hot {
  from { background: var(--mine-cell); color: #fff; }
  to { background: var(--led-bg); color: var(--led-red); }
}

/* Pattern boards: a tile opened by a lucky guess keeps a dashed outline, and
   when the board ends, safe tiles nothing proved are opened but dimmed. */
.sp-board .cell.sp-lucky { outline: 2px dashed #b07a00; outline-offset: -4px; z-index: 1; }
.sp-board .cell.sp-unproven { opacity: 0.55; }

.sp-well { position: relative; }
.sp-fire {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 3;
}
.sp-scorched .sp-board { filter: sepia(0.6) saturate(1.5) brightness(0.8); transition: filter 1.2s steps(4); }
.sp-card.sp-shake { animation: sp-shake 0.36s steps(6); }
@keyframes sp-shake {
  0% { transform: translate(0, 0); }
  17% { transform: translate(-6px, 3px); }
  33% { transform: translate(5px, -4px); }
  50% { transform: translate(-4px, -2px); }
  67% { transform: translate(3px, 3px); }
  83% { transform: translate(-2px, -1px); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .sp-fuse-burn::after, .counter.sp-hot, .sp-card.sp-shake { animation: none; }
  .sp-scorched .sp-board { transition: none; }
}

/* Phones: tiles shrink just enough to fit, staying well above tap size. */
@media (max-width: 640px) {
  .sp-modes-list { grid-template-columns: 1fr; }
  .sp-wrap { --sp-cell: 56px; padding-left: 16px; padding-right: 16px; }
  .sp-bar { gap: 8px; padding: 6px 8px; width: 100%; box-sizing: border-box; justify-content: space-between; }
  .sp-bar .counter { font-size: 18px; padding: 2px 6px; }
  .sp-btn { padding: 0 10px; }
}
@media (max-width: 360px) {
  .sp-wrap { --sp-cell: 50px; }
}

/* The explanation under "More ways to play". */
.sp-info { margin-top: 8px; }
.sp-info-list { margin: 0 0 10px; padding-left: 20px; color: #d8d8d8; font-size: 14px; line-height: 1.6; }
.sp-info-list li { margin: 0 0 6px; }
.sp-info .diag-figure figcaption { color: var(--text-dark-muted); }
