/* Mobile-First Sudoku Styles - Modern Dark Mode */

* {
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #1e2a44;
    --accent-primary: #7b68ee;
    --accent-secondary: #9d8df1;
    --accent-danger: #ef4444;
    --accent-success: #10b981;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-bright: #ffffff;
    --border-dark: #2a2a3e;
    --cell-original: #2a2a3e;
    --cell-player: #273654;
    --cell-selected: #374151;
    --cell-highlight: rgba(27, 64, 91, 0.9);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
}

/* Home Page */
.home-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

.home-icon {
    width: 120px;
    height: 120px;
    margin: 20px auto;
    display: block;
    filter: drop-shadow(0 0 20px rgba(123, 104, 238, 0.3));
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    min-height: 70px;
    padding: 15px;
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-bright);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: var(--shadow-sm);
}

.difficulty-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-secondary);
}

.difficulty-btn:active {
    transform: scale(0.98);
    background: var(--accent-primary);
    color: var(--text-bright);
    box-shadow: 0 0 20px rgba(123, 104, 238, 0.4);
}

.difficulty-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.difficulty-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.difficulty-btn:active .difficulty-desc {
    color: var(--text-bright);
}

.continue-btn {
    width: 100%;
    min-height: 60px;
    padding: 15px;
    border: 2px solid var(--accent-success);
    border-radius: 12px;
    background: var(--accent-success);
    color: var(--text-bright);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: var(--shadow-sm);
}

.continue-btn:hover {
    background: #059669;
}

.continue-btn:active {
    transform: scale(0.98);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

/* Game Page */
.game-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.game-container h1 {
    text-align: center;
    color: var(--accent-primary);
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(123, 104, 238, 0.5);
}

.game-info {
    display: flex;
    justify-content: space-around;
    text-align: center;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.game-info p {
    margin: 5px 0;
    color: var(--text-primary);
}

.game-info strong {
    color: var(--accent-secondary);
}

.failed-counter {
    color: var(--accent-danger);
    font-weight: bold;
}

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

.cell {
    aspect-ratio: 1;
    border: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    position: relative;
    transition: all 0.15s;
}

/* Thick borders for 3x3 boxes */
.cell:nth-child(9n+3),
.cell:nth-child(9n+6) {
    border-right: 2px solid var(--accent-primary);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--accent-primary);
}

.cell-original {
    background: #1a2338;
    color: var(--accent-primary);
    font-weight: 600;
    border: 1px solid rgba(123, 104, 238, 0.15);
    opacity: 0.8;
    cursor: pointer;
}

.cell-player {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    border: 1px solid rgba(123, 104, 238, 0.2);
}

.cell-player:hover {
    background: var(--cell-selected);
    border-color: rgba(123, 104, 238, 0.4);
}

.cell-player:active {
    background: var(--accent-primary);
    color: var(--text-bright);
}

.cell-selected {
    background: var(--cell-selected) !important;
    box-shadow: inset 0 0 0 2px var(--accent-primary);
}

.cell-highlight {
    background-color: var(--cell-highlight) !important;
}

.cell-correct {
    background: var(--accent-success) !important;
    color: var(--text-bright) !important;
    border-color: var(--accent-success) !important;
}

.cell-incorrect {
    background: var(--accent-danger) !important;
    color: var(--text-bright) !important;
    border-color: var(--accent-danger) !important;
}

.cell-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 1px;
}

.note-item {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--accent-secondary);
    font-weight: 500;
}

/* Number Pad */
.mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 12px;
}

.mode-button {
    flex: 1;
    min-height: 45px;
    font-size: 1rem;
    font-weight: bold;
    border: 2px solid var(--border-dark);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.mode-button.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-bright);
    box-shadow: 0 0 15px rgba(123, 104, 238, 0.3);
}

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

.number-button {
    min-height: 50px;
    font-size: 1.3rem;
    font-weight: bold;
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--accent-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}

.number-button:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-secondary);
}

.number-button:active {
    background: var(--accent-primary);
    color: var(--text-bright);
    transform: scale(0.95);
}

.clear-button {
    grid-column: span 2;
    background: var(--bg-tertiary);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

.clear-button:hover {
    background: var(--accent-danger);
    color: var(--text-bright);
}

.clear-button:active {
    background: #dc2626;
}

/* Actions */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.actions button {
    flex: 1;
    min-height: 50px;
    font-size: 1.1rem;
    border: 2px solid var(--border-dark);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}

.actions button:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.actions button:active {
    background: var(--accent-primary);
    color: var(--text-bright);
}

/* Victory */
.victory {
    background: var(--bg-secondary);
    border: 3px solid var(--accent-success);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.victory h2 {
    color: var(--accent-success);
    margin-bottom: 20px;
}

.victory-stats {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.victory-stats p {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.1rem;
}

.victory-stats strong {
    color: var(--accent-success);
}

.victory button {
    min-height: 50px;
    padding: 10px 30px;
    font-size: 1.1rem;
    border: 2px solid var(--accent-success);
    border-radius: 8px;
    background: var(--accent-success);
    color: var(--text-bright);
    cursor: pointer;
    transition: all 0.15s;
}

.victory button:hover {
    background: #059669;
}

/* Messages */
.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.flying-emoji {
    position: fixed;
    font-size: 5rem;
    z-index: 1000;
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.fly-animation-1 {
    animation: flyTopRight 1.5s ease-out forwards;
}

.fly-animation-2 {
    animation: flyTopLeft 1.5s ease-out forwards;
}

.fly-animation-3 {
    animation: flyBottomRight 1.5s ease-out forwards;
}

.fly-animation-4 {
    animation: flyBottomLeft 1.5s ease-out forwards;
}

@keyframes flyTopRight {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-45deg);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(100vw, -100vh) scale(0.8) rotate(45deg);
    }
}

@keyframes flyTopLeft {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(45deg);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(-200vw, -100vh) scale(0.8) rotate(-45deg);
    }
}

@keyframes flyBottomRight {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(45deg);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(100vw, 100vh) scale(0.8) rotate(-45deg);
    }
}

@keyframes flyBottomLeft {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-45deg);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(-200vw, 100vh) scale(0.8) rotate(45deg);
    }
}

.no-game {
    text-align: center;
    padding: 40px 20px;
}

.no-game p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.no-game button {
    min-height: 50px;
    padding: 10px 30px;
    font-size: 1.1rem;
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    background: var(--accent-primary);
    color: var(--text-bright);
    cursor: pointer;
    transition: all 0.15s;
}

.no-game button:hover {
    background: var(--accent-secondary);
}

/* Tablet and larger */
@media (min-width: 768px) {
    .sudoku-grid {
        max-width: 500px;
    }

    .difficulty-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .cell {
        font-size: 2rem;
    }
}
