/* Sudoku styling — reuses the theme variables defined in line_escape.css
   (:root for dark, html[data-theme="light"] for light). */

.sk-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 12px 20px;
  color: var(--text);
}

.sk-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.sk-topbar a.back {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  background: var(--btn);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 6px 12px;
}
.sk-topbar a.back:active { transform: translateY(1px); }
.sk-title { font-size: 20px; font-weight: 700; letter-spacing: 0.3px; }

/* difficulty picker */
.sk-diffs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sk-diff-btn, .sk-daily {
  background: var(--btn);
  color: var(--muted);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sk-diff-btn.active { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.sk-daily { margin-left: auto; color: var(--accent); }

/* HUD */
.sk-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
}
.sk-hud .lbl { color: var(--muted2); font-weight: 500; font-size: 12px; }
#sk-time { color: var(--text); font-variant-numeric: tabular-nums; }
#sk-mistakes { color: var(--accent); }
#sk-diff { color: var(--text); }

/* the board */
#sk-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1 / 1;
  width: min(100%, 52vh);
  margin: 0 auto;
  background: var(--board);
  border: 2px solid var(--line2);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}
.sk-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 6vw, 30px);
  font-weight: 600;
  color: var(--accent);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  aspect-ratio: 1 / 1;
}
.sk-cell.bl { border-left: 2px solid var(--line2); }
.sk-cell.bt { border-top: 2px solid var(--line2); }
.sk-cell.br { border-right: 2px solid var(--line2); }
.sk-cell.bb { border-bottom: 2px solid var(--line2); }
/* 3x3 box separators */
.sk-cell[data-i]:nth-child(3n) { border-right: 2px solid var(--line2); }
#sk-board > .sk-cell:nth-child(n+19):nth-child(-n+27),
#sk-board > .sk-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid var(--line2);
}

.sk-cell.given { color: var(--text); font-weight: 700; }
.sk-cell.peer { background: var(--pad); }
.sk-cell.same { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.sk-cell.sel { background: color-mix(in srgb, var(--accent) 38%, transparent); outline: 2px solid var(--accent); outline-offset: -2px; z-index: 2; }
.sk-cell.bad { color: #ff6b6b; }
.sk-cell.flash { animation: skflash 0.5s ease; }
.sk-cell.win { animation: skwin 0.8s ease; }
@keyframes skflash {
  0%, 100% { background: transparent; }
  40% { background: rgba(255,80,80,0.35); }
}
@keyframes skwin {
  0% { background: transparent; }
  50% { background: color-mix(in srgb, var(--good) 40%, transparent); }
  100% { background: transparent; }
}

/* pencil marks */
.sk-cell.notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-size: clamp(7px, 2.1vw, 11px);
  color: var(--muted2);
  font-weight: 500;
  padding: 1px;
}
.sk-cell.notes span {
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* number pad */
.sk-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  margin-top: 8px;
}
.sk-num {
  background: var(--btn);
  color: var(--accent);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 8px 0;
  font-size: clamp(16px, 5vw, 22px);
  font-weight: 700;
  cursor: pointer;
}
.sk-num.used { opacity: 0.28; }
.sk-num:active { transform: translateY(1px); }

/* action row */
.sk-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.sk-act {
  flex: 1 1 0;
  min-width: 52px;
  background: var(--btn);
  color: var(--muted);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 7px 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.sk-act.on { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.sk-act small { display: block; font-size: 14px; }
.sk-hidden { display: none !important; }
/* admin-only reveal button stands out a little */
#sk-solution { color: var(--accent); border-color: var(--accent); }

/* leaderboard panel */
#sk-board-panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
#sk-board-panel h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.sk-lb { width: 100%; border-collapse: collapse; font-size: 14px; }
.sk-lb td { padding: 4px 6px; border-bottom: 1px solid var(--line); color: var(--muted); }
.sk-lb td:first-child { width: 34px; color: var(--muted2); }
.sk-lb td:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.sk-lb tr.me td { color: var(--accent); font-weight: 700; }
.sk-lb .flag { width: 16px; height: 12px; vertical-align: middle; border-radius: 2px; }
.sk-empty { color: var(--muted2); font-size: 13px; margin: 4px 0; }
.sk-me-line { margin-top: 8px; font-size: 13px; color: var(--accent); font-weight: 600; }

/* overlay */
#sk-overlay {
  position: fixed; inset: 0;
  background: var(--backdrop2);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
#sk-overlay.hidden { display: none; }
.sk-ov-card {
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 26px 28px;
  text-align: center;
  max-width: 340px;
  width: 100%;
}
#sk-ov-title { font-size: 24px; font-weight: 800; margin-bottom: 10px; color: var(--text); }
.sk-ov-time { font-size: 34px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.sk-ov-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.sk-ov-card .btnrow { display: flex; gap: 8px; margin-top: 18px; }
.sk-ov-card button {
  flex: 1; background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 8px; padding: 11px; font-weight: 700;
  font-size: 15px; cursor: pointer;
}
.sk-ov-card button.ghost { background: var(--btn); color: var(--muted); border: 1px solid var(--line2); }

/* toast */
#sk-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line2); border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60;
}
#sk-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sk-guest-note {
  margin-top: 14px; text-align: center; font-size: 13px; color: var(--muted2);
}
.sk-guest-note a { color: var(--accent); }

/* level browser */
#sk-levels {
  position: fixed; inset: 0;
  background: var(--backdrop2);
  display: flex; align-items: center; justify-content: center;
  z-index: 55; padding: 18px;
}
#sk-levels.hidden { display: none; }
.sk-levels-card {
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 460px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.sk-levels-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 17px; font-weight: 700; color: var(--text);
}
.sk-levels-head button {
  background: var(--btn); color: var(--muted); border: 1px solid var(--line2);
  border-radius: 8px; width: 32px; height: 32px; font-size: 15px; cursor: pointer;
}
.sk-levels-hint { color: var(--muted2); font-size: 12px; margin: 6px 0 12px; }
.sk-levels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}
.sk-lvl {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--btn);
  border: 1px solid var(--line2);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 2px;
}
.sk-lvl .n { font-size: 17px; line-height: 1.1; }
.sk-lvl .t { font-size: 10px; color: var(--muted2); font-weight: 600; margin-top: 2px; }
.sk-lvl.done { border-color: var(--good-line); }
.sk-lvl.done .n { color: var(--good); }
.sk-lvl.locked {
  color: var(--muted3); background: transparent; cursor: default; opacity: 0.6;
}
.sk-lvl:not(.locked):active { transform: translateY(1px); }

/*  V1015 — THE ACTION ROW FITS ITS LABELS ON A PHONE.

    Measured in Chromium at 390px, before: six buttons share one row at 55px
    each, and "Challenge" needs 62px of text for a 45px content box — so it
    overran by 17px and crossed into Notes. Every other label fits; this is one
    word that is longer than a sixth of a phone.

    WHY NOT JUST A BIGGER `min-width`. Tried and measured: at 72px the row wraps,
    but flex then stretches whatever lands on the second row to fill it — Hint
    and New came out 176px each beside four 85px buttons, which is a worse screen
    than the one being fixed.

    THREE PER ROW, AND THEY STAY EQUAL. `flex: 1 1 30%` makes the basis a third
    of the row, so six buttons fall into two rows of three and every button on a
    row is the same width: 115px at 390px, 105px at 360px, worst label clearing
    its box by 33px. `min-width: 0` is what lets the 30% basis win over the 52px
    floor the one-row layout needs.

    PHONE ONLY. Above 430px the row has the width for one line and nothing here
    applies, so the laptop screen he approved is untouched. */
@media (max-width: 430px) {
  .sk-act { flex: 1 1 30%; min-width: 0; }
}
