/* Create By Asking: the sudoku game. Loaded after puzzles.css, which gives the board-and-side-panel layout. */

.sd .pz-board { justify-items: center; }
.sd .pz-head, .sd .pz-msg { width: 100%; }
.sd-board { width: min(100%, 520px, max(300px, 100vh - 330px)); aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: #1C0F3F; border-radius: 10px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14); touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; outline: none; }
.sd-board:focus-visible { box-shadow: 0 0 0 3px #FFC93C; }
.sd-box { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 1px; background: #B9AFD3; }
.sd-box:nth-child(1) { border-top-left-radius: 7px; overflow: hidden; }
.sd-box:nth-child(3) { border-top-right-radius: 7px; overflow: hidden; }
.sd-box:nth-child(7) { border-bottom-left-radius: 7px; overflow: hidden; }
.sd-box:nth-child(9) { border-bottom-right-radius: 7px; overflow: hidden; }
.sd-cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; background: #FFFDF6; color: #4A35C9; font: 600 clamp(1.05rem, 5vw, 1.8rem)/1 var(--body); cursor: pointer; transition: background 0.12s; }
.sd-cell.given { color: #1C0F3F; font-weight: 800; }
.sd-cell.hinted { color: #D6337F; }
.sd-cell.peer { background: #EEE8FB; }
.sd-cell.same { background: #FFE39A; }
.sd-cell.sel { background: #FFC93C; }
.sd-cell.wrong { color: #D7263D; background-image: linear-gradient(transparent 80%, rgba(215, 38, 61, 0.18) 80%); }
.sd-notes { position: absolute; inset: 1px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); font: 600 clamp(0.5rem, 1.8vw, 0.7rem)/1 var(--mono); color: #6A5E8C; }
.sd-notes i { display: grid; place-items: center; font-style: normal; border-radius: 3px; }
.sd-notes i.hl { background: #FFC93C; color: #1C0F3F; }
.sd-making .sd-board { opacity: 0.45; }
.sd.won .sd-cell { animation: sd-win 0.6s ease-in-out; }
.sd.won .sd-box:nth-child(2) .sd-cell, .sd.won .sd-box:nth-child(4) .sd-cell { animation-delay: 0.08s; }
.sd.won .sd-box:nth-child(3) .sd-cell, .sd.won .sd-box:nth-child(5) .sd-cell, .sd.won .sd-box:nth-child(7) .sd-cell { animation-delay: 0.16s; }
.sd.won .sd-box:nth-child(6) .sd-cell, .sd.won .sd-box:nth-child(8) .sd-cell { animation-delay: 0.24s; }
.sd.won .sd-box:nth-child(9) .sd-cell { animation-delay: 0.32s; }
@keyframes sd-win { 50% { background: #8FE3B4; } }

.sd-pad { width: min(100%, 520px); display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.sd-pad button { display: grid; place-items: center; align-content: center; gap: 3px; padding: 8px 0 6px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; font: inherit; }
.sd-pad button:hover { background: rgba(255, 255, 255, 0.18); }
.sd-pad b { font: 700 clamp(1.15rem, 4.6vw, 1.55rem)/1 var(--body); }
.sd-pad small { min-height: 0.62rem; font: 600 0.62rem/1 var(--mono); color: #A597CC; }
.sd-pad button.full { opacity: 0.3; }
.sd-pad.notes b { color: #FFC93C; font-size: clamp(0.95rem, 3.6vw, 1.15rem); }
.sd-tools { width: min(100%, 520px); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sd-tools .btn { justify-content: center; padding-inline: 4px; white-space: nowrap; }
.tool-shell .sd-tools .btn[aria-pressed="true"] { background: #FFC93C; color: #1C0F3F; }
.sd-tools .btn:disabled { opacity: 0.4; cursor: default; }
.sd .pz-side .sd-keys { margin: 0; }
@media (hover: none) and (pointer: coarse) { .sd .pz-side .sd-keys { display: none; } }

@media (max-width: 480px) {
  .sd.tool-shell { padding: 10px; }
  .sd .pz-board { padding: 10px 6px; }
  .sd-pad { gap: 4px; }
  .sd-tools .btn { font-size: 0.8rem; }
}

@media print {
  .sd-print .sd-line { display: flex; justify-content: space-between; gap: 8mm; margin: 0 0 8mm; font-size: 11pt; text-align: left; }
  .sd-sheet svg { display: block; width: 100%; max-width: 165mm; height: auto; margin: 0 auto; }
  .sd-ans svg { max-width: 120mm; }
  .sd-print .sd-from { margin-top: 8mm; font-size: 9pt; color: #555; }
}
