/* Sudoku Printable - Beautiful Puzzle Game Styling */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3d3d3d;
    --secondary-color: #e07b91;
    --accent-color: #d9896e;
    --success-color: #7fb899;
    --warning-color: #f4b183;
    --bg-color: #b8c5d6;
    --white: #ffffff;
    --light-gray: #d4cec3;
    --dark-gray: #6b6b6b;
    --grid-line: #d9896e;
    --grid-bg: #e8a5a5;
    --cell-color: #fef5d4;
    --cell-highlight: #d4c8f0;
    --cell-selected: #ffd9a8;
    --cell-error: #ffc4c4;
    --cell-hint: #7fb899;
    --given-cell: #fffef9;
    --button-color: #e8a5a5;
    --sidebar-bg: #d4e0ec;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    color: var(--primary-color);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: var(--white);
    background: transparent;
    padding: 20px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header .subtitle {
    font-size: 1.1rem;
    color: var(--white);
    opacity: 0.95;
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    align-items: start;
}

/* Sidebar */
.sidebar {
    background: var(--sidebar-bg);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--button-color);
    color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0.95;
}

.btn:active {
    transform: translateY(0);
}

.btn-primary { background: var(--button-color); }
.btn-success { background: var(--success-color); color: white; }
.btn-warning { background: var(--warning-color); }
.btn-danger { background: var(--accent-color); color: white; }

select.btn {
    padding: 10px 15px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

/* Game Info */
.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--bg-color);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
}

.info-label {
    font-weight: 600;
    color: var(--dark-gray);
}

.info-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Sudoku Grid Container */
.game-container {
    background: var(--grid-bg);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Sudoku Grid */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    background: var(--grid-line);
    border: 3px solid var(--grid-line);
    border-radius: 12px;
    overflow: hidden;
}

.sudoku-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell-color);
    border: 1px solid var(--grid-line);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

/* 3x3 box borders */
.sudoku-cell:nth-child(9n+3),
.sudoku-cell:nth-child(9n+6) {
    border-right: 3px solid var(--grid-line);
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid var(--grid-line);
}

/* Cell states */
.sudoku-cell.given {
    background: var(--given-cell);
    color: var(--secondary-color);
    font-weight: 700;
    cursor: default;
}

.sudoku-cell.user-input {
    color: var(--primary-color);
}

.sudoku-cell.hint {
    background: var(--cell-hint);
    color: var(--white);
    font-weight: 700;
    animation: hintPulse 0.6s ease-in-out;
    box-shadow: inset 0 0 0 3px #4a8a6a;
}

@keyframes hintPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.sudoku-cell.selected {
    background: var(--cell-selected);
    box-shadow: inset 0 0 0 2px var(--accent-color);
}

.sudoku-cell.highlighted {
    background: var(--cell-highlight);
}

.sudoku-cell.error {
    background: var(--cell-error);
    color: var(--accent-color);
}

.sudoku-cell:not(.given):hover {
    background: var(--cell-highlight);
}

/* Pencil marks (candidate numbers) */
.sudoku-cell .pencil-marks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    position: absolute;
    inset: 2px;
    font-size: 0.6rem;
    color: var(--dark-gray);
}

.sudoku-cell .pencil-mark {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Number pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 20px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.number-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-color);
    color: var(--primary-color);
    border: none;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.number-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0.95;
}

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

.number-btn.erase {
    background: var(--accent-color);
    color: white;
}

.number-btn.pencil {
    background: var(--warning-color);
    color: white;
}

/* Timer */
.timer {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    color: var(--secondary-color);
    font-variant-numeric: tabular-nums;
}

/* Victory Modal */
.victory-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.victory-modal.show {
    display: flex;
}

.victory-content {
    background: var(--white);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.victory-content h2 {
    color: var(--success-color);
    font-size: 2rem;
    margin-bottom: 20px;
}

.victory-stats {
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 10px;
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 20px;
    }

    .header {
        box-shadow: none;
        border: 1px solid #e0e0e0;
    }

    .header h1 {
        color: var(--primary-color);
    }

    .sidebar,
    .number-pad,
    .btn,
    .victory-modal {
        display: none !important;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .game-container {
        box-shadow: none;
        border: 2px solid var(--grid-line);
    }

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

    @page {
        margin: 1cm;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-width: 540px;
        margin: 0 auto 20px;
    }

    .game-container {
        margin-bottom: 20px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .game-container {
        padding: 15px;
    }

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

    .number-pad {
        gap: 5px;
    }

    .number-btn {
        font-size: 1.2rem;
    }
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--primary-color);
    background: var(--white);
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.loading-spinner {
    border: 4px solid rgba(52, 152, 219, 0.2);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
