/* Sudoku: crisp 9x9 grid, number pad with counts left. */

.gm { --sd-cell: #ffffff; --sd-given: #0d1f3c; --sd-user: #1d5fc4; --sd-peer: #eaf1fd; --sd-same: #cfe0fb; --sd-sel: #ffe9a8; --sd-line: #c6d3e8; --sd-bold: #0d1f3c; }
html.dark .gm { --sd-cell: #182641; --sd-given: #e8eefa; --sd-user: #8ab4ff; --sd-peer: #1e3052; --sd-same: #284473; --sd-sel: #5b4a14; --sd-line: #2c4166; --sd-bold: #a3b3cd; }

.sd-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: clamp(1rem, 3vw, 1.75rem);
    align-items: start;
}

.sd-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: min(100%, 34rem);
    aspect-ratio: 1;
    justify-self: center;
    border: 3px solid var(--sd-bold);
    border-radius: 12px;
    overflow: hidden;
    background: var(--sd-cell);
    box-shadow: 0 18px 36px -22px rgba(13, 31, 60, 0.6);
    user-select: none;
}

.sd-cell {
    position: relative;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-right: 1px solid var(--sd-line);
    border-bottom: 1px solid var(--sd-line);
    background: var(--sd-cell);
    color: var(--sd-user);
    font: 700 clamp(1.05rem, 4.6vw, 1.75rem)/1 'Mulish', sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.sd-cell:nth-child(9n) { border-right: 0; }
.sd-cell:nth-child(n + 73) { border-bottom: 0; }
.sd-cell.b-r { border-right: 2px solid var(--sd-bold); }
.sd-cell.b-b { border-bottom: 2px solid var(--sd-bold); }
.sd-cell.is-given { color: var(--sd-given); font-weight: 800; }
.sd-cell.is-peer { background: var(--sd-peer); }
.sd-cell.is-same { background: var(--sd-same); }
.sd-cell.is-sel { background: var(--sd-sel); }
.sd-cell.is-clash .sd-val { text-decoration: underline wavy #e5484d 2px; text-underline-offset: 3px; }
.sd-cell.is-wrong { color: #e5484d; }
.sd-cell.is-shake { animation: sd-shake 0.3s ease; }
.sd-cell.is-hinted { animation: sd-glow 0.9s ease; }
.sd-cell:focus-visible { outline: 3px solid var(--sd-user); outline-offset: -3px; }

.sd-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
    box-sizing: border-box;
}
.sd-notes i {
    display: grid;
    place-items: center;
    font: 700 clamp(0.42rem, 1.6vw, 0.62rem)/1 'Mulish', sans-serif;
    font-style: normal;
    color: var(--gm-muted);
}

.sd-grid.is-done .sd-cell { animation: sd-wave 0.6s ease both; }
.sd-grid.is-done .sd-cell:nth-child(3n) { animation-delay: 0.05s; }
.sd-grid.is-done .sd-cell:nth-child(3n + 1) { animation-delay: 0.1s; }

@keyframes sd-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes sd-glow { 30% { background: #b9f6ca; } }
@keyframes sd-wave { 40% { background: #b9f6ca; } }

/* ---------- side ---------- */
.sd-side { display: grid; gap: 0.8rem; min-width: 0; }
.sd-tag {
    justify-self: start;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--gm-tint);
    color: var(--gm-blue);
    font-weight: 800;
    font-size: 0.85rem;
}
.sd-daily[aria-pressed="true"] { background: var(--gm-blue); border-color: var(--gm-blue); color: var(--gm-blue-ink); }
.sd-side .gm-stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.sd-side .gm-stat { min-width: 0; text-align: center; }

.sd-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.sd-tool {
    display: grid;
    justify-items: center;
    gap: 0.2rem;
    padding: 0.55rem 0.2rem;
    border: 1px solid var(--gm-line);
    border-radius: 0.8rem;
    background: var(--gm-card);
    color: var(--gm-ink);
    font: 700 0.78rem var(--gm-body);
    cursor: pointer;
}
.sd-tool .gm-i { width: 20px; height: 20px; }
.sd-tool[aria-pressed="true"] { background: var(--gm-blue); border-color: var(--gm-blue); color: var(--gm-blue-ink); }
.sd-tool:disabled { opacity: 0.45; cursor: not-allowed; }

.sd-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.sd-key {
    position: relative;
    min-height: 3.1rem;
    border: 1px solid var(--gm-line);
    border-radius: 0.8rem;
    background: var(--gm-card);
    color: var(--sd-user);
    font: 800 1.45rem/1 'Mulish', sans-serif;
    box-shadow: 0 3px 0 var(--gm-line);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.sd-key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gm-line); }
.sd-key small { position: absolute; right: 7px; top: 5px; font-size: 0.62rem; color: var(--gm-muted); }
.sd-key.is-done { opacity: 0.35; }

.sd-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.sd-check { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.sd-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--gm-blue); }

.gm-credit { font-size: 0.82rem; }
.gm-credit a { color: var(--gm-blue); }

@media (max-width: 860px) {
    .sd-layout { grid-template-columns: minmax(0, 1fr); }
    .sd-side { width: min(100%, 34rem); justify-self: center; }
    .sd-pad { grid-template-columns: repeat(9, 1fr); gap: 0.25rem; }
    .sd-key { min-height: 2.9rem; font-size: 1.2rem; padding: 0; }
    .sd-key small { display: none; }
}

/* full screen: the grid takes the free height */
.gm.is-full .sd-grid { width: min(100%, var(--gm-h)); }
