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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease-in-out;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Start Screen */
.start-container {
    text-align: center;
    background: white;
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

.logo {
    font-size: 4em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 3px;
}

.subtitle {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 40px;
}

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

.difficulty-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    background: #667eea;
    color: white;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.difficulty-btn:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

/* Game Screen */
#gameScreen {
    flex-direction: column;
    padding: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 450px;
    margin-bottom: 20px;
    background: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.timer, .level {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.header-message {
    flex: 1;
    text-align: center;
    font-weight: bold;
    font-size: 0.9em;
    color: #51cf66;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.header-message.show {
    opacity: 1;
}

.header-message.success {
    color: #51cf66;
}

.header-message.error {
    color: #ff6b6b;
}

.timer-label, .level-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

#timerDisplay, #levelDisplay {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 2px;
    background: #333;
    border: 3px solid #333;
    margin: 0 auto 20px;
    width: 450px;
    height: 450px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.cell {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.cell:hover {
    background: #f0f0f0;
}

.cell.given {
    background: #e8e8e8;
    color: #333;
    cursor: default;
}

.cell.given:hover {
    background: #e8e8e8;
}

.cell.selected {
    background: #667eea !important;
    color: white;
}

.cell.error {
    background: #ff6b6b !important;
    color: white;
}

.cell.correct {
    background: #51cf66 !important;
    color: white;
}

/* 3x3 box borders */
.cell:nth-child(3n) {
    border-right: 3px solid #333;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid #333;
}

.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.number-buttons {
    display: flex;
    gap: 0;
    justify-content: center;
    margin: 15px auto;
    width: 270px;
    max-width: 270px;
}

.number-btn {
    flex: 1;
    height: 35px;
    border: 2px solid #667eea;
    border-right: none;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-btn:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.number-btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-right: 2px solid #667eea;
}

.number-btn:hover {
    background: #667eea;
    color: white;
    z-index: 1;
    position: relative;
}

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

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.message {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    min-height: 25px;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.message.success {
    background: rgba(81, 207, 102, 0.2);
    color: #51cf66;
}

.message.error {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

/* Results Screen */
.results-container {
    text-align: center;
    background: white;
    border-radius: 20px;
    padding: 50px 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

.results-title {
    font-size: 2.5em;
    color: #51cf66;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.results-stats {
    margin-bottom: 40px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    font-size: 1.2em;
}

.stat:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
    font-weight: normal;
}

.stat span:last-child {
    font-weight: bold;
    color: #333;
}

.results-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.results-buttons button {
    padding: 15px 30px;
    font-size: 1.1em;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .logo {
        font-size: 3em;
    }
    
    .start-container, .results-container {
        padding: 40px 30px;
        margin: 20px;
    }
    
    .sudoku-grid {
        width: 300px;
        height: 300px;
    }
    
    .cell {
        font-size: 16px;
    }
    
    .game-header {
        max-width: 300px;
        padding: 10px 15px;
    }
    
    .timer-label, .level-label {
        font-size: 0.8em;
    }
    
    #timerDisplay, #levelDisplay {
        font-size: 1.2em;
    }
    
    .number-buttons {
        width: 180px;
        margin: 12px auto;
    }
    
    .number-btn {
        height: 30px;
        font-size: 14px;
    }
    
    .game-controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    button {
        padding: 10px 16px;
        font-size: 12px;
    }
    
    .difficulty-btn {
        padding: 12px 24px;
        font-size: 1em;
    }
}