/* Sudoku Game CSS v2.8 */

.sudoku-wrapper,
.sudoku-wrapper * {
    box-sizing: border-box;
}

.sudoku-wrapper {
    max-width: 950px;
    margin: 0 auto;
    color: #1e293b;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.sudoku-container {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 4px 8px rgba(15,23,42,.04), 0 18px 45px rgba(15,23,42,.08);
    padding: 16px;
    margin-top: 10px;
    border: 1px solid #e5e7eb;
}

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

.sudoku-header h1 {
    color: #0f172a;
    margin: 0 0 5px;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.sudoku-header p {
    color: #64748b;
    font-size: .95rem;
    margin: 0;
    font-weight: 500;
}

.sudoku-controls-top {
    margin-bottom: 14px;
}

.diff-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
    background: #f8fafc;
    padding: 5px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.sudoku-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    font-family: inherit;
    transition: all .2s ease;
    box-shadow: 0 2px 6px rgba(37,99,235,.18);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sudoku-btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37,99,235,.22);
}

.sudoku-btn:disabled {
    opacity: .62;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.diff-btn {
    background: transparent;
    color: #475569;
    box-shadow: none;
    flex: 1;
    min-width: 60px;
    padding: 9px 6px;
    font-size: 12px;
    border: 1px solid transparent;
}

.diff-btn:hover:not(:disabled) {
    background: #e2e8f0;
    color: #0f172a;
    box-shadow: none;
    transform: none;
}

.diff-btn.active {
    background: #fff;
    color: #0f172a;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(15,23,42,.08);
}

#btn-extreme.active {
    color: #dc2626;
    background: #fff1f2;
    border-color: #fecdd3;
}

#btn-daily.active {
    color: #ea580c;
    background: #fff7ed;
    border-color: #fed7aa;
}

.sudoku-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    gap: 8px;
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #334155;
    white-space: nowrap;
}

.stat-error span {
    color: #ef4444;
}

.stat-success span {
    color: #10b981;
}

#timer {
    font-variant-numeric: tabular-nums;
}

#btn-pause {
    background: #e2e8f0;
    border: none;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.sudoku-game-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

.sudoku-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.sudoku-controls-side {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 14px;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background-color: #cbd5e1;
    border: 2px solid #0f172a;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    box-shadow: 0 10px 26px rgba(15,23,42,.12);
    touch-action: manipulation;
    overflow: hidden;
}

.sudoku-cell {
    width: 100%;
    height: 100%;
    min-width: 0;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(16px, 5vw, 24px);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background-color .12s ease, color .12s ease, box-shadow .12s ease;
    position: relative;
    font-family: Arial, Helvetica, sans-serif;
    color: #334155;
    touch-action: manipulation;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.sudoku-cell:nth-child(3n) {
    border-right: 2px solid #0f172a;
}

.sudoku-cell:nth-child(9n) {
    border-right: none;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #0f172a;
}

.sudoku-cell:hover {
    background: #f1f5f9;
}

.sudoku-cell.highlighted {
    background: #e2e8f0;
}

.sudoku-cell.same-number {
    background: #dbeafe;
}

.sudoku-cell.selected {
    background: #93c5fd;
    box-shadow: inset 0 0 0 2px #2563eb;
    z-index: 2;
}

.sudoku-cell.prefilled {
    color: #0f172a;
    font-weight: 800;
    pointer-events: none;
}

.sudoku-cell.correct {
    color: #2563eb;
    font-weight: 700;
}

.sudoku-cell.error {
    color: #ef4444;
    background: #fef2f2;
    font-weight: 800;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 1px;
}

.note-val {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(8px, 2.5vw, 11px);
    color: #64748b;
    line-height: 1;
    font-weight: 600;
}

.pause-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 10px;
    text-align: center;
    padding: 20px;
}

.pause-overlay h2 {
    margin: 0 0 6px;
    color: #0f172a;
    font-size: 1.5rem;
    font-weight: 800;
}

.pause-overlay p {
    margin: 0 0 20px;
    color: #64748b;
}

.action-toolbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid transparent;
    padding: 10px 4px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    touch-action: manipulation;
}

.toolbar-btn .icon {
    font-size: 17px;
    line-height: 1;
}

.toolbar-btn:hover,
.toolbar-btn.active-notes {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
}

.number-btn {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 700;
    font-size: 22px;
    transition: all .15s ease;
    font-family: Arial, Helvetica, sans-serif;
    box-shadow: 0 3px 8px rgba(15,23,42,.06);
    touch-action: manipulation;
}

.number-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.keyboard-hint {
    text-align: center;
    color: #94a3b8;
    margin-top: 3px;
    font-style: italic;
    font-size: 12px;
    display: none;
}

.leaderboard-section {
    margin-top: 34px;
}

.leaderboard-header h3 {
    text-align: left;
    color: #0f172a;
    font-size: 1.15rem;
    margin: 0 0 12px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 9px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.leaderboard-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(15,23,42,.06);
}

.sudoku-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.sudoku-leaderboard-table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .05em;
    padding: 12px 14px;
    border-bottom: 2px solid #e2e8f0;
}

.sudoku-leaderboard-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.rank-1 {
    background: #fffbeb;
}

.rank-2 {
    background: #f8fafc;
}

.rank-3 {
    background: #fdf4ff;
}

.rank-cell {
    width: 60px;
    text-align: center;
}

.medal {
    font-size: 22px;
    line-height: 1;
}

.rank-number {
    font-weight: 800;
    color: #94a3b8;
}

.player-cell strong {
    color: #334155;
    font-weight: 700;
}

.time-cell {
    font-family: "Courier New", Courier, monospace;
    font-weight: 800;
    color: #2563eb;
    font-variant-numeric: tabular-nums;
}


.empty-state {
    text-align: center;
    padding: 26px 18px;
    color: #64748b;
    font-style: italic;
}

/* Modal fixed to viewport */

body.sudoku-modal-open {
    overflow: hidden !important;
}

body > #game-over-modal.sudoku-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    margin: 0 !important;
    background: rgba(15,23,42,.72) !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 2147483647 !important;
    overflow: hidden !important;
}

body > #game-over-modal.sudoku-modal[style*="display: flex"] {
    display: flex !important;
}

body > #game-over-modal .sudoku-modal-content {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: min(420px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 32px) !important;
    overflow-y: auto !important;
    margin: 0 !important;
    background: #fff !important;
    border-radius: 18px !important;
    padding: 26px 22px !important;
    text-align: center !important;
    box-shadow: 0 24px 70px rgba(15,23,42,.28) !important;
    border: 1px solid #e2e8f0 !important;
}

.sudoku-modal-content h2 {
    color: #0f172a;
    margin: 0 0 7px;
    font-size: 1.45rem;
    font-weight: 800;
}

.time-display {
    font-size: 1rem;
    color: #475569;
    margin: 0 0 18px;
}

.time-display strong {
    color: #2563eb;
    font-variant-numeric: tabular-nums;
}

.modal-subtext,
#sudoku-login-save-notice {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 12px 0 14px;
    font-size: 14px;
    line-height: 1.5;
}

#btn-submit-score {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    width: 100%;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    width: 100%;
    box-shadow: none;
}

.modal-footer {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #f1f5f9;
}

@media (min-width: 768px) {
    .sudoku-container {
        padding: 30px;
        margin-top: 20px;
    }

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

    .sudoku-game-area {
        flex-direction: row;
        align-items: flex-start;
        gap: 30px;
    }

    .sudoku-board {
        flex: 2;
        max-width: 500px;
    }

    .sudoku-grid {
        border: 3px solid #0f172a;
    }

    .sudoku-controls-side {
        flex: 1;
        max-width: 300px;
        gap: 20px;
    }

    .diff-btn {
        padding: 10px 15px;
        font-size: 14px;
    }

    .sudoku-stats-bar {
        font-size: 16px;
        padding: 15px 25px;
    }

    .action-toolbar {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .number-pad {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .number-btn {
        height: 60px;
        font-size: 24px;
    }

    .keyboard-hint {
        display: block;
    }
}

@media (max-width: 480px) {
    .sudoku-container {
        border-radius: 14px;
        padding: 12px;
    }

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

    .sudoku-stats-bar {
        padding: 9px 8px;
        font-size: 12px;
    }

    .diff-btn {
        min-width: 54px;
        padding: 8px 4px;
        font-size: 11px;
    }

    .number-btn {
        height: 48px;
        font-size: 21px;
    }

    .sudoku-leaderboard-table th,
    .sudoku-leaderboard-table td {
        padding: 10px 9px;
        font-size: 13px;
    }

    body > #game-over-modal .sudoku-modal-content {
        width: calc(100vw - 24px) !important;
        max-height: calc(100vh - 24px) !important;
        padding: 22px 16px !important;
        border-radius: 16px !important;
    }
}


/* Beautiful login confirm popup */

.sudoku-login-confirm-popup {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 2147483647 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
}

.sudoku-login-confirm-box {
    width: min(420px, calc(100vw - 32px));
    background: #ffffff;
    border-radius: 20px;
    padding: 26px 22px;
    text-align: center;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
    border: 1px solid #e2e8f0;
    animation: sudokuLoginPopupIn 0.22s ease-out;
}

@keyframes sudokuLoginPopupIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.sudoku-login-confirm-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.sudoku-login-confirm-box h3 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sudoku-login-confirm-box p {
    margin: 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.55;
}

.sudoku-login-confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
}

.sudoku-login-confirm-actions button {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 13px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s ease;
}

.sudoku-login-confirm-cancel {
    background: #f1f5f9;
    color: #475569;
}

.sudoku-login-confirm-cancel:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.sudoku-login-confirm-login {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
}

.sudoku-login-confirm-login:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
}

@media (max-width: 480px) {
    .sudoku-login-confirm-box {
        width: calc(100vw - 24px);
        padding: 22px 16px;
        border-radius: 18px;
    }

    .sudoku-login-confirm-actions {
        flex-direction: column;
    }

    .sudoku-login-confirm-actions button {
        width: 100%;
    }
}
