/* ============================================================
   sudoku.css - СУДОКУ
   Версия: 1.0
   ============================================================ */

/* ============================================================
   БАЗОВЫЕ СТИЛИ
   ============================================================ */
.sudoku-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px 16px 24px;
    background-color: #0d0b09;
    color: #ede4d8;
    min-height: 85vh;
}

.sudoku-header {
    text-align: center;
    margin-bottom: 16px;
}

.sudoku-header h1 {
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 3px;
    color: #d4a853;
    margin-bottom: 4px;
}

.sudoku-header h1 .highlight {
    color: #ede4d8;
}

.sudoku-header p {
    color: #b8aa9a;
    font-size: 0.85rem;
    opacity: 0.8;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ============================================================
   ПАНЕЛЬ УПРАВЛЕНИЯ
   ============================================================ */
.sudoku-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.difficulty-group {
    display: flex;
    gap: 6px;
    flex: 1;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 8px 14px;
    border: 1px solid #2a241e;
    border-radius: 10px;
    background: transparent;
    color: #b8aa9a;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    white-space: nowrap;
    touch-action: manipulation;
}

.difficulty-btn:hover {
    border-color: #d4a853;
    color: #ede4d8;
}

.difficulty-btn.active {
    background: rgba(212, 168, 83, 0.15);
    border-color: #d4a853;
    color: #d4a853;
}

.new-game-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 10px;
    background: #d4a853;
    color: #1a1510;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    white-space: nowrap;
    touch-action: manipulation;
}

.new-game-btn:hover {
    background: #e8c878;
    transform: translateY(-1px);
}

.new-game-btn:active {
    transform: scale(0.97);
}

/* ============================================================
   ИНФО ПАНЕЛЬ
   ============================================================ */
.sudoku-info {
    display: flex;
    justify-content: space-around;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: #14110e;
    border: 1px solid #2a241e;
    border-radius: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.info-label {
    font-size: 0.65rem;
    color: #8a7a6a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1rem;
    font-weight: 700;
    color: #d4a853;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
}

/* ============================================================
   ИГРОВОЕ ПОЛЕ
   ============================================================ */
.sudoku-board-wrapper {
    position: relative;
    margin-bottom: 14px;
    display: flex;
    justify-content: center;
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
    background: #2a241e;
    border: 3px solid #d4a853;
    border-radius: 12px;
    overflow: hidden;
    gap: 1px;
    padding: 2px;
    contain: layout style paint;
}

.sudoku-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #14110e;
    font-size: 1.2rem;
    font-weight: 600;
    color: #ede4d8;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    font-family: 'Courier New', monospace;
    aspect-ratio: 1;
}

.sudoku-cell:hover {
    background: #1e1a16;
}

.sudoku-cell:active {
    transform: scale(0.95);
}

/* Толстые границы для квадратов 3×3 */
.sudoku-cell.border-right {
    border-right: 2px solid #d4a853;
}
.sudoku-cell.border-bottom {
    border-bottom: 2px solid #d4a853;
}

/* Фиксированные (начальные) клетки */
.sudoku-cell.fixed {
    color: #d4a853;
    font-weight: 800;
    cursor: default;
    background: #1a1714;
}

.sudoku-cell.fixed:hover {
    background: #1a1714;
}

.sudoku-cell.fixed:active {
    transform: none;
}

/* Выделенная клетка */
.sudoku-cell.selected {
    background: rgba(212, 168, 83, 0.25) !important;
    box-shadow: inset 0 0 0 2px #d4a853;
}

/* Подсветка строки, столбца и квадрата */
.sudoku-cell.highlighted {
    background: rgba(212, 168, 83, 0.06);
}

/* Подсветка одинаковых цифр */
.sudoku-cell.same-number {
    background: rgba(212, 168, 83, 0.12);
    color: #e8c878;
}

/* Ошибочные клетки */
.sudoku-cell.error {
    color: #ff6b6b !important;
    background: rgba(255, 107, 107, 0.12) !important;
}

.sudoku-cell.error.fixed {
    color: #d4a853 !important;
    background: #1a1714 !important;
}

/* Подсказанные клетки */
.sudoku-cell.hint {
    color: #4fc3f7;
    animation: hintPulse 0.6s ease 2;
}

@keyframes hintPulse {
    0%, 100% { background: #14110e; }
    50% { background: rgba(79, 195, 247, 0.2); }
}

/* Клетки-кандидаты (заметки) */
.sudoku-cell .candidates {
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    font-size: 0.4rem;
    color: #6a5a4a;
    pointer-events: none;
    font-weight: 400;
}

.sudoku-cell .candidates span {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Анимация появления цифры */
.sudoku-cell .value {
    animation: cellPop 0.2s ease;
}

@keyframes cellPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   ОВЕРЛЕЙ (ПОБЕДА / ПОРАЖЕНИЕ)
   ============================================================ */
.sudoku-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 11, 9, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sudoku-overlay.active {
    display: flex;
    opacity: 1;
}

.overlay-content {
    text-align: center;
    padding: 24px;
}

.overlay-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
}

.overlay-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #d4a853;
    margin-bottom: 6px;
}

.overlay-text {
    font-size: 0.9rem;
    color: #b8aa9a;
    margin-bottom: 18px;
    line-height: 1.5;
}

.overlay-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 12px;
    background: #d4a853;
    color: #1a1510;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.overlay-btn:hover {
    background: #e8c878;
    transform: translateY(-2px);
}

.overlay-btn:active {
    transform: scale(0.97);
}

/* ============================================================
   ЦИФРОВАЯ ПАНЕЛЬ
   ============================================================ */
.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 12px;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.number-btn {
    padding: 12px 4px;
    border: 1px solid #2a241e;
    border-radius: 10px;
    background: #14110e;
    color: #ede4d8;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Courier New', monospace;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.number-btn:hover {
    border-color: #d4a853;
    color: #d4a853;
    background: rgba(212, 168, 83, 0.06);
}

.number-btn:active {
    transform: scale(0.93);
}

.number-btn.completed {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.number-btn.erase-btn {
    background: rgba(255, 107, 107, 0.08);
    border-color: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

.number-btn.erase-btn:hover {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
}

/* ============================================================
   КНОПКИ ДЕЙСТВИЙ
   ============================================================ */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid #2a241e;
    border-radius: 10px;
    background: transparent;
    color: #b8aa9a;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    white-space: nowrap;
    touch-action: manipulation;
}

.action-btn:hover {
    border-color: #d4a853;
    color: #ede4d8;
}

.action-btn:active {
    transform: scale(0.96);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================
   СТАТИСТИКА
   ============================================================ */
.sudoku-stats {
    display: flex;
    justify-content: space-around;
    gap: 8px;
    padding: 12px;
    background: #14110e;
    border: 1px solid #2a241e;
    border-radius: 12px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.stat-icon {
    font-size: 1.1rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #d4a853;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
}

.stat-label {
    font-size: 0.6rem;
    color: #8a7a6a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   SEO-ТЕКСТ
   ============================================================ */
.sudoku-seo-text {
    margin-top: 24px;
    padding: 20px 24px;
    border-top: 1px solid #2a241e;
    font-size: 0.8rem;
    color: #8a7a6a;
    line-height: 1.7;
    text-align: left;
}

.sudoku-seo-text h2 {
    font-size: 1.1rem;
    color: #d4a853;
    margin-bottom: 10px;
    font-weight: 400;
}

.sudoku-seo-text h3 {
    font-size: 0.95rem;
    color: #b8aa9a;
    margin: 14px 0 8px;
    font-weight: 500;
}

.sudoku-seo-text p {
    margin-bottom: 8px;
}

.sudoku-seo-text ul {
    padding-left: 20px;
    margin-bottom: 10px;
}

.sudoku-seo-text li {
    margin-bottom: 4px;
}

.sudoku-seo-text strong {
    color: #b8aa9a;
}

.sudoku-seo-text a {
    color: #d4a853;
    text-decoration: none;
}

.sudoku-seo-text a:hover {
    text-decoration: underline;
}

/* ============================================================
   АДАПТИВНОСТЬ
   ============================================================ */
@media (max-width: 480px) {
    .sudoku-wrapper {
        padding: 8px 10px 16px;
    }

    .sudoku-header h1 {
        font-size: 1.4rem;
    }

    .sudoku-header p {
        font-size: 0.75rem;
    }

    .difficulty-btn {
        padding: 6px 10px;
        font-size: 0.65rem;
    }

    .new-game-btn {
        padding: 6px 14px;
        font-size: 0.7rem;
    }

    .sudoku-cell {
        font-size: 1rem;
    }

    .sudoku-cell .candidates {
        font-size: 0.35rem;
    }

    .number-btn {
        padding: 10px 2px;
        font-size: 1rem;
    }

    .number-pad {
        gap: 4px;
    }

    .action-btn {
        padding: 6px 12px;
        font-size: 0.65rem;
    }

    .info-value {
        font-size: 0.85rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }
}

@media (max-width: 380px) {
    .sudoku-board {
        max-width: 100%;
    }

    .sudoku-cell {
        font-size: 0.85rem;
    }

    .sudoku-cell .candidates {
        font-size: 0.3rem;
    }

    .difficulty-btn {
        padding: 5px 8px;
        font-size: 0.6rem;
    }

    .info-label {
        font-size: 0.55rem;
    }
}

@media (min-width: 1024px) {
    .sudoku-wrapper {
        max-width: 700px;
        padding: 24px 32px 40px;
    }

    .sudoku-header h1 {
        font-size: 2.2rem;
        letter-spacing: 5px;
    }

    .sudoku-header p {
        font-size: 1rem;
    }

    .sudoku-board {
        max-width: 520px;
    }

    .sudoku-cell {
        font-size: 1.5rem;
    }

    .sudoku-cell .candidates {
        font-size: 0.5rem;
    }

    .number-btn {
        padding: 16px 8px;
        font-size: 1.4rem;
    }

    .number-pad {
        max-width: 520px;
        gap: 8px;
    }

    .info-value {
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }
}

/* ============================================================
   PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .sudoku-cell,
    .number-btn,
    .difficulty-btn,
    .new-game-btn,
    .action-btn,
    .overlay-btn {
        transition: none !important;
    }

    .sudoku-cell .value {
        animation: none !important;
    }

    .sudoku-cell.hint {
        animation: none !important;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .sudoku-controls,
    .number-pad,
    .action-buttons,
    .sudoku-stats,
    .sudoku-seo-text {
        display: none !important;
    }

    .sudoku-board {
        border-color: #000;
    }

    .sudoku-cell {
        color: #000;
        background: #fff;
    }

    .sudoku-cell.fixed {
        color: #000;
        font-weight: 900;
    }
}