.sd-game { --sd-ink:#292344; --sd-purple:#6f4dd2; --sd-line:#d9d1e5; --sd-muted:#786f88; width:100%; max-width:760px; margin-inline:auto; color:var(--sd-ink); font-family:inherit; min-width:0; }
.sd-game *, .sd-game *::before,.sd-game *::after { box-sizing:border-box; }
.sd-game button,.sd-game select { font:inherit; color:inherit; touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
.sd-game button { cursor:pointer; }
.sd-game button:disabled { opacity:.44; cursor:default; }
.sd-game button:focus-visible,.sd-game select:focus-visible,.sd-game summary:focus-visible { outline:3px solid #a58be9; outline-offset:3px; }
.sd-topline { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px; margin:0 0 12px; }
.sd-size-label { display:flex; flex-direction:column; gap:6px; font-size:.75rem; font-weight:800; color:var(--sd-muted); text-align:left; }
.sd-size-label select { max-width:100%; border:1px solid var(--sd-line); background:#fff; padding:10px 32px 10px 12px; border-radius:11px; font-weight:750; font-size:.88rem; min-height:44px; }
.sd-stats { display:flex; gap:15px; text-align:center; color:var(--sd-muted); font-size:.7rem; }
.sd-stats span { display:flex; flex-direction:column; gap:3px; }
.sd-stats strong { color:var(--sd-ink); font-weight:850; font-size:1.14rem; }
.sd-level-line { display:flex; flex-wrap:wrap; justify-content:space-between; gap:6px 12px; font-size:.74rem; color:var(--sd-muted); margin:15px 0 20px; line-height:1.5; }
.sd-layout { display:grid; grid-template-columns:minmax(0,1fr) 160px; align-items:start; gap:24px; max-width:720px; margin-inline:auto; }
.sd-board-wrap { min-width:0; }
.sd-board { display:grid; grid-template-columns:repeat(var(--sd-size),minmax(0,1fr)); width:100%; border:2px solid #76648b; border-radius:8px; overflow:hidden; background:#76648b; aspect-ratio:1; isolation:isolate; }
.sd-row { display:contents; }
.sd-cell { position:relative; border:0; border-right:1px solid var(--sd-line); border-bottom:1px solid var(--sd-line); border-radius:0; min-width:0; min-height:0; aspect-ratio:1; padding:0; display:flex; align-items:center; justify-content:center; font-size:clamp(1.1rem,3.5vw,1.65rem); font-weight:750; background:#fff; color:#6b46c3 !important; line-height:1; user-select:none; }
.sd-cell:last-child { border-right:0; }
.sd-row:last-child .sd-cell { border-bottom:0; }
.sd-cell.sd-box-right { border-right:2px solid #817093; }
.sd-cell.sd-box-bottom { border-bottom:2px solid #817093; }
.sd-cell.sd-given { background:#f9f7fc; color:#352b48 !important; font-weight:850; }
.sd-cell.sd-neighbor { background:#f1ecfa; }
.sd-cell.sd-same { background:#dfd1fa; }
.sd-cell.sd-selected { background:#d6c1fc; box-shadow:inset 0 0 0 2px #8055ca; z-index:1; }
.sd-game .sd-cell:focus-visible { outline:0; box-shadow:inset 0 0 0 3px #6540b4; }
.sd-cell.sd-conflict { background:#ffefdb; color:#9b520a !important; }
.sd-cell.sd-checked { background:#fff0e0; color:#9b520a !important; }
.sd-cell.sd-conflict.sd-selected,.sd-cell.sd-checked.sd-selected { box-shadow:inset 0 0 0 2px #b77926; }
.sd-check-mark { position:absolute; top:2px; right:3px; font-size:.5rem; line-height:1; font-weight:900; }
.sd-notes { display:grid; grid-template-columns:repeat(var(--sd-note-cols),minmax(0,1fr)); width:100%; height:100%; padding:3px; gap:0; font-size:clamp(.48rem,1.65vw,.68rem); color:#6e617f; font-weight:550; }
.sd-notes i { display:flex; align-items:center; justify-content:center; font-style:normal; min-width:0; line-height:1; }
.sd-game[data-sudoku-size="4"] .sd-cell { font-size:clamp(1.4rem,5vw,2.2rem); }
.sd-game[data-sudoku-size="4"] .sd-notes { font-size:clamp(.7rem,2.5vw,.94rem); padding:8px; }
.sd-game[data-sudoku-size="6"] .sd-notes { font-size:clamp(.6rem,2vw,.78rem); padding:5px; }
.sd-selection { font-size:.73rem; line-height:1.45; color:var(--sd-muted); text-align:center; margin:10px 0 0; min-height:21px; }
.sd-controls { min-width:0; }
.sd-keypad { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.sd-keypad button { min-width:0; min-height:51px; border:1px solid #d9cceb; border-radius:10px; background:#f7f2ff; font-size:1.25rem; font-weight:800; color:#6745af; position:relative; padding:8px 4px 12px; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:3px; }
.sd-keypad small { font-size:.45rem; font-weight:750; text-transform:uppercase; min-height:.5em; color:#8d759e; }
.sd-keypad button:hover:not(:disabled) { background:#e8dcff; }
.sd-tools { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin-top:13px; }
.sd-tools button,.sd-bottom-actions button { min-width:0; min-height:43px; border:1px solid var(--sd-line); border-radius:10px; background:#fff; font-size:.77rem; font-weight:750; padding:9px 5px; line-height:1.35; }
.sd-tools button:hover:not(:disabled),.sd-bottom-actions button:hover { background:#f3edfc; }
.sd-tools button.sd-on { border-color:var(--sd-purple); background:#ece2ff; color:#6140a9; }
.sd-tools small { font-size:.52rem; font-weight:900; display:inline-block; margin-left:2px; }
.sd-key-help { font-size:.66rem; color:var(--sd-muted); line-height:1.6; text-align:center; margin:12px 0; }
.sd-message { display:flex; align-items:center; justify-content:center; min-height:52px; padding:12px 16px; border-radius:12px; background:#f5f1fa; color:#68587f; font-size:.84rem; text-align:center; line-height:1.5; margin:20px auto 15px; }
.sd-message-warning { background:#fff1df; color:#8b5218; }
.sd-message-success { background:#eaf8f0; color:#326b51; }
.sd-bottom-actions { display:flex; justify-content:center; gap:10px; flex-wrap:wrap; }
.sd-bottom-actions button { min-height:45px; padding:12px 18px; font-size:.86rem; }
.sd-bottom-actions .sd-primary { background:var(--sd-purple); border-color:var(--sd-purple); color:#fff; }
.sd-bottom-actions .sd-primary:hover { background:#6140bf; }
.sd-rules { margin-top:23px; border-top:1px solid #e6dfed; padding-top:16px; font-size:.85rem; line-height:1.6; color:var(--sd-muted); text-align:left; }
.sd-rules summary { font-weight:800; color:#66517f; cursor:pointer; min-height:32px; }
.sd-rules p { margin:10px 0; }
.sd-celebration { display:flex; align-items:center; justify-content:center; gap:15px; border:1px solid #d4ebde; border-radius:16px; background:#effaf4; padding:18px; margin:0 0 20px; }
.sd-celebration > span { font-size:2.6rem; line-height:1; color:#65a07e; }
.sd-celebration h3 { font-size:1.18rem; margin:0 0 5px; }
.sd-celebration p { font-size:.83rem; line-height:1.4; margin:0; color:#527661; }
@media(max-width:650px) {
  .sd-layout { grid-template-columns:minmax(0,1fr); gap:13px; max-width:470px; }
  .sd-board { max-width:450px; margin-inline:auto; }
  .sd-keypad { grid-template-columns:repeat(var(--sd-key-cols),minmax(0,1fr)); gap:7px; max-width:400px; margin-inline:auto; }
  .sd-game[data-sudoku-size="6"] .sd-keypad { grid-template-columns:repeat(6,minmax(0,1fr)); }
  .sd-game[data-sudoku-size="9"] .sd-keypad { grid-template-columns:repeat(9,minmax(0,1fr)); gap:5px; }
  .sd-keypad button { min-height:46px; padding:6px 1px; border-radius:8px; font-size:1.12rem; }
  .sd-keypad small { display:none; }
  .sd-tools { grid-template-columns:repeat(3,minmax(0,1fr)); max-width:450px; margin:12px auto 0; }
  .sd-tools button { font-size:.82rem; min-height:44px; padding:10px 5px; }
  .sd-key-help { display:none; }
  .sd-selection { margin-top:8px; }
}
@media(max-width:360px) {
  .sd-topline { gap:12px; }
  .sd-size-label { width:100%; }
  .sd-stats { width:100%; justify-content:space-around; flex-direction:row; }
  .sd-stats span { flex-direction:row; align-items:baseline; gap:5px; }
  .sd-level-line { margin-top:12px; font-size:.69rem; }
  .sd-game[data-sudoku-size="9"] .sd-keypad { grid-template-columns:repeat(5,minmax(0,1fr)); gap:7px; }
  .sd-game[data-sudoku-size="6"] .sd-keypad { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .sd-notes { padding:2px; font-size:.48rem; }
  .sd-cell { font-size:1.03rem; }
  .sd-message { padding:11px 10px; font-size:.78rem; }
  .sd-celebration { padding:14px; gap:10px; }
}
@media(prefers-reduced-motion:reduce) { .sd-game * { transition:none !important; } }
