/* =============================================================
   GAME: Sudoku
   ============================================================= */
.board-sudoku {
  --cell: min(calc((100vw - 76px) / 9), 52px);
  --sd-glow: #3daeff;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.sd-grid {
  display: grid; grid-template-columns: repeat(9, var(--cell)); grid-auto-rows: var(--cell); gap: 1px;
  padding: 3px; border-radius: 14px;
  background: linear-gradient(160deg, #2a5a8c, #1a3558 60%, #234d7a);
  box-shadow: 0 0 0 2px var(--sd-glow), 0 0 28px rgba(61, 174, 255, .38), 0 12px 30px rgba(0, 0, 0, .35);
}
.sd-cell {
  position: relative; border: 0; padding: 0; margin: 0; cursor: pointer; border-radius: 2px;
  background: linear-gradient(180deg, #11223a, #0d1b2c); color: #7cc6ff;
  font: 600 calc(var(--cell) * .54) / 1 var(--font-body); font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
/* grid corners follow the rounded frame */
.sd-cell:nth-child(1) { border-top-left-radius: 10px; }
.sd-cell:nth-child(9) { border-top-right-radius: 10px; }
.sd-cell:nth-child(73) { border-bottom-left-radius: 10px; }
.sd-cell:nth-child(81) { border-bottom-right-radius: 10px; }
.sd-cell.sd-bl { margin-left: 2px; }
.sd-cell.sd-bt { margin-top: 2px; }
.sd-cell:hover { background: #17304d; }
.sd-cell:focus { outline: none; }
.sd-cell:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.sd-cell.sd-given { color: #eef3ff; font-weight: 700; }
.sd-cell.sd-user { text-shadow: 0 0 10px rgba(61, 174, 255, .45); }
.sd-cell.sd-peer { background: #162d4a; }
.sd-cell.sd-same { background: #1d4170; color: #fff; }
.sd-cell.sd-same.sd-user { color: #bfe4ff; }
.sd-cell.sd-sel { background: linear-gradient(180deg, #2b6aa4, #1f5486); box-shadow: inset 0 0 0 2px var(--sd-glow), 0 0 12px rgba(61, 174, 255, .55); z-index: 1; }
.sd-cell.sd-conflict { color: var(--t-red); text-shadow: 0 0 10px rgba(255, 61, 127, .55); }
.sd-cell.sd-conflict:not(.sd-given)::after {
  content: ""; position: absolute; inset: 3px; border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(255, 61, 127, .75);
}
.sd-cell.sd-pop .sd-v { display: inline-block; animation: sdpop .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes sdpop { from { transform: scale(.4); opacity: .2; } }
.sd-cell.sd-conflict.sd-pop .sd-v { animation: sdshake .32s ease; }
@keyframes sdshake { 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }
.sd-cell.sd-flash { animation: sdflash .7s ease both; }
@keyframes sdflash { 35% { background: #3a8be0; color: #fff; box-shadow: 0 0 14px rgba(61, 174, 255, .8); } }
.sd-cell.sd-done { animation: sdwin .6s ease both; }
.sd-cell.sd-done:nth-child(9n+2), .sd-cell.sd-done:nth-child(9n+4) { animation-delay: .06s; }
.sd-cell.sd-done:nth-child(9n+6), .sd-cell.sd-done:nth-child(9n+8) { animation-delay: .12s; }
@keyframes sdwin { 50% { background: #2a72b8; color: #fff; } }
.sd-cell:disabled { cursor: default; }
.sd-loading .sd-cell { background: #0f1d2b; animation: sdload 1.2s ease-in-out infinite alternate; }
.sd-loading .sd-cell:nth-child(2n) { animation-delay: .3s; }
@keyframes sdload { to { background: #142a3a; } }
.sd-v:empty { display: none; }
.sd-notes {
  position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font: 600 calc(var(--cell) * .24) / 1 var(--font-body); color: #9fb7d6; pointer-events: none;
}
.sd-notes span { display: grid; place-items: center; visibility: hidden; border-radius: 3px; }
.sd-notes span.on { visibility: visible; }
.sd-notes span.hl { background: rgba(61, 174, 255, .3); color: #fff; }

/* number pad */
.sd-pad {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; width: calc(var(--cell) * 9 + 18px); max-width: 100%;
}
.sd-key, .sd-act {
  border: 0; cursor: pointer; border-radius: 10px; color: var(--ink);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 0 rgba(0, 0, 0, .35);
  font: 700 1.25rem/1 var(--font-body); transition: transform .1s, box-shadow .15s, background .15s;
}
.sd-key { position: relative; min-height: 46px; padding: 0; }
.sd-key small { position: absolute; right: 4px; bottom: 3px; font-size: .62rem; font-weight: 600; color: var(--muted); }
.sd-key:hover, .sd-act:hover { box-shadow: inset 0 0 0 1px var(--sd-glow); }
.sd-key:active, .sd-act:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px var(--sd-glow), 0 0 0 rgba(0, 0, 0, .35); }
.sd-key.sd-used { opacity: .35; }
.sd-notes-on .sd-key { color: #9fb7d6; font-size: .95rem; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(61, 174, 255, .5); }
.sd-act {
  grid-column: span 4; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .9rem; padding: 6px 10px;
}
.sd-notes-btn { grid-column: 1 / span 5; }
.sd-act[aria-pressed="true"] { background: linear-gradient(135deg, #1a7ad8, #135a9e); color: #fff; box-shadow: 0 0 0 1px var(--sd-glow), 0 0 16px rgba(61, 174, 255, .4); }
.sd-key:disabled, .sd-act:disabled { opacity: .4; cursor: default; transform: none; }
.sd-key:focus-visible, .sd-act:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* small drawn icons: pencil + eraser */
.sd-pencil { width: 14px; height: 4px; background: currentColor; border-radius: 1px 0 0 1px; transform: rotate(-45deg); position: relative; }
.sd-pencil::after { content: ""; position: absolute; right: -4px; top: 0; border: 2px solid transparent; border-left: 4px solid currentColor; }
.sd-eraser { width: 13px; height: 8px; border: 2px solid currentColor; border-radius: 2px; transform: rotate(-30deg); background: linear-gradient(90deg, currentColor 40%, transparent 40%); }

.sd-clock { font-variant-numeric: tabular-nums; }
.sd-tag { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: rgba(61, 174, 255, .18); color: #b5dcff; }
@media (prefers-reduced-motion: reduce) {
  .sd-cell { transition: none; }
}
