@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --cell-border: #334155;
    --cell-bg: rgba(30, 41, 59, 0.5);
    --cell-hover: rgba(56, 189, 248, 0.1);
    --cell-selected: rgba(56, 189, 248, 0.25);
    --cell-related: rgba(255, 255, 255, 0.05);
    --cell-same-num: rgba(56, 189, 248, 0.15);
    --error-color: #ef4444;
    --success-color: #22c55e;
    --fixed-num: #f8fafc;
    --user-num: #38bdf8;
    --transition-speed: 0.2s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(56, 189, 248, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Sudoku Grid */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    background: var(--cell-border);
    border: 3px solid var(--cell-border);
    border-radius: 0.75rem;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.cell {
    aspect-ratio: 1;
    background: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
    user-select: none;
    position: relative;
    border: 0.5px solid rgba(255, 255, 255, 0.05);
}

/* Sub-grid borders */
.cell:nth-child(3n) {
    border-right: 2px solid var(--cell-border);
}

.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--cell-border);
}

.cell:hover {
    background: var(--cell-hover);
}

.cell.selected {
    background: var(--cell-selected) !important;
    box-shadow: inset 0 0 0 2px var(--accent-color);
}

.cell.related {
    background: var(--cell-related);
}

.cell.same-number {
    background: var(--cell-same-num);
}

.cell.error {
    color: var(--error-color);
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.cell.fixed {
    color: var(--fixed-num);
    background: rgba(255, 255, 255, 0.02);
    font-weight: 700;
}

.cell.user-input {
    color: var(--user-num);
}

/* Notes mode */
.notes-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
}

.note {
    font-size: 0.6rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}

.num-btn {
    aspect-ratio: 1.2;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.num-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.action-btn {
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.action-btn.new-game {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: white;
    border: none;
}

.action-btn.new-game:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

/* Settings Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--bg-color);
    padding: 2.5rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.difficulty-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 2rem 0;
}

.diff-btn {
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--card-bg);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover {
    border-color: var(--accent-color);
    background: var(--cell-selected);
}

/* Responsive */
@media (max-width: 500px) {
    .app-container {
        padding: 1rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .cell {
        font-size: 1.25rem;
    }
}