/* =====================================================================
   SUDOKA — стили игры «Судоку»
   ===================================================================== */

.sudoku-page { max-width: 720px; margin-inline: auto; }

.sudoku-head { text-align: center; margin-bottom: 1rem; }
.sudoku-head h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.sudoku-head p { color: var(--ink-muted); max-width: 46ch; margin: .35rem auto 0; }

/* ---------- Панель управления ---------- */
.sudoku-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .75rem; margin-bottom: .9rem;
}
.difficulty { display: inline-flex; background: var(--bg-alt); border-radius: 999px; padding: .25rem; gap: .15rem; }
.diff-btn {
    border: 0; background: transparent; color: var(--ink-muted); font-weight: 800; font-size: .9rem;
    padding: .4rem .85rem; border-radius: 999px; transition: background .15s, color .15s;
}
.diff-btn:hover { color: var(--terracotta-d); }
.diff-btn.active { background: var(--terracotta); color: #fff; box-shadow: var(--shadow-sm); }
.sudoku-actions { display: inline-flex; gap: .5rem; }

/* ---------- Статистика ---------- */
.sudoku-stats {
    display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap;
    color: var(--ink-muted); font-weight: 700; font-size: .95rem; margin-bottom: .75rem;
}
.sudoku-stats b { color: var(--ink); }

/* ---------- Игровое поле ---------- */
.sudoku-wrap { position: relative; }

.sudoku_board {
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background: var(--ink);
    border: 3px solid var(--ink);
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cell {
    background: var(--card);
    position: relative;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.cell .val {
    font-size: clamp(1.1rem, 4.6vw, 1.7rem);
    font-weight: 700;
    color: var(--terracotta-d);
    line-height: 1;
}
.cell.fix { background: var(--bg-alt); }
.cell.fix .val { color: var(--ink); }

/* Толстые разделители блоков 3×3 */
.cell.border_h { box-shadow: inset 0 -2px 0 0 var(--ink); }
.cell.border_v { box-shadow: inset -2px 0 0 0 var(--ink); }
.cell.border_h.border_v { box-shadow: inset 0 -2px 0 0 var(--ink), inset -2px 0 0 0 var(--ink); }

/* Подсветка выбора */
.cell.selected { background: var(--terracotta-l); }
.cell.group { background: #F5E1D9; }
.cell.current { background: var(--terracotta); }
.cell.current .val { color: #fff; }
.cell .val.samevalue { color: var(--terracotta-d); text-decoration: underline; text-decoration-thickness: 2px; }
.cell.current .val.samevalue { color: #fff; }

/* Заметки-карандаш (сетка 3×3 внутри ячейки) */
.cell .notes {
    position: absolute; inset: 0;
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
    pointer-events: none;
}
.cell .notes i {
    display: none; align-items: center; justify-content: center;
    font-style: normal; font-size: clamp(.5rem, 1.8vw, .72rem); font-weight: 700;
    color: var(--ink-muted);
}
.cell .notes i.on { display: flex; }
.cell.fix .notes { display: none; }

/* Ошибки */
.cell.notvalid { background: var(--danger-l); }
.cell.notvalid .val { color: var(--danger); }
.cell.wrong { background: var(--danger-l); box-shadow: inset 0 0 0 2px var(--danger); }
.cell.wrong .val { color: var(--danger); }

/* ---------- Панель цифр ---------- */
.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: .4rem;
    max-width: 520px;
    margin: .9rem auto 0;
}
.numpad .num {
    aspect-ratio: 1 / 1;
    display: flex; align-items: center; justify-content: center;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: clamp(1rem, 4vw, 1.4rem); font-weight: 800; color: var(--terracotta-d);
    box-shadow: var(--shadow-sm);
    transition: transform .06s ease, background .15s ease;
}
.numpad .num:hover { background: var(--terracotta-l); }
.numpad .num:active { transform: translateY(1px); }
.numpad .num.note.active,
.num.note[aria-pressed="true"] { background: var(--sage-l); color: var(--sage-d); border-color: var(--sage); }

.numpad-extra { display: flex; gap: .4rem; max-width: 520px; margin: .5rem auto 0; }
.numpad-extra .num {
    flex: 1; aspect-ratio: auto; padding: .6rem; height: auto;
    font-size: .95rem; color: var(--ink-muted);
}

/* ---------- Окончание игры ---------- */
.gameover_container {
    position: absolute; inset: 0;
    background: rgba(58, 46, 42, 0.55);
    backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center;
    border-radius: 12px;
    z-index: 5;
}
.gameover_container.show { display: flex; animation: fadeIn .25s ease; }
.gameover {
    background: var(--card); border-radius: var(--radius);
    padding: 1.6rem 1.8rem; text-align: center; box-shadow: var(--shadow-lg);
    max-width: 320px;
}
.gameover h2 { color: var(--sage-d); margin-bottom: .25rem; }
.gameover p { color: var(--ink-muted); margin-bottom: 1rem; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Подсказка по управлению ---------- */
.sudoku-help {
    margin-top: 1.2rem; text-align: center; color: var(--ink-muted); font-size: .88rem;
}
.sudoku-help kbd {
    background: var(--bg-alt); border: 1px solid var(--border); border-bottom-width: 2px;
    border-radius: 6px; padding: .05rem .4rem; font-size: .8rem; font-family: ui-monospace, monospace;
}

/* ---------- Адаптив ---------- */
@media (max-width: 480px) {
    .sudoku-toolbar { justify-content: center; }
}
