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

body {
    font-family: Arial, Calibri, sans-serif;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Welcome Screen */
.welcome-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 400px;
}

.welcome-content h1 {
    font-size: 3em;
    color: #4a5568;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.welcome-content p {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 30px;
}

.age-selector {
    margin-bottom: 30px;
}

.age-selector label {
    display: block;
    font-size: 1.1em;
    color: #4a5568;
    margin-bottom: 10px;
    font-weight: bold;
}

.age-dropdown {
    padding: 12px 20px;
    font-size: 1.1em;
    border: 3px solid #667eea;
    border-radius: 10px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    min-width: 200px;
}

.start-btn {
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.3em;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0,0,0,0.3);
}

/* Game Screen */
#game-screen {
    background: none;
    height: 100vh;
    padding: 5px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Removed - no longer needed */

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

.score, .level, .age-display {
    font-size: 1.2em;
    font-weight: bold;
    color: #4a5568;
}

.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 5px;
    overflow: hidden;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 180px;
}

#game-canvas {
    border: 4px solid #4a5568;
    border-radius: 10px;
    background: #1a202c;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 600px;
    height: 780px;
    object-fit: contain;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 180px;
}

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

.next-piece {
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    text-align: center;
}

.next-piece h3 {
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 1.1em;
}

#next-canvas {
    border: 2px solid #e2e8f0;
    border-radius: 5px;
    background: #f7fafc;
    width: 80px;
    height: 60px;
}

.instructions {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.instructions h4 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.1em;
    text-align: center;
}

.instructions p {
    color: #666;
    margin-bottom: 8px;
    font-size: 0.9em;
    text-align: left;
}

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

.game-buttons button {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
    font-size: 1em;
}

.game-buttons button:hover {
    transform: translateY(-1px);
}

/* Game Over Screen */
.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 400px;
}

.game-over-content h2 {
    font-size: 2.5em;
    color: #4a5568;
    margin-bottom: 20px;
}

.game-over-content p {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 15px;
}

.game-over-content button {
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    color: white;
    border: none;
    padding: 12px 25px;
    margin: 10px;
    font-size: 1.1em;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

.game-over-content button:hover {
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 900px) {
    #game-screen {
        padding: 3px;
    }
    
    .game-header {
        padding: 8px 15px;
        margin-top: 30px;
        margin-bottom: 5px;
        border-radius: 10px;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .game-container {
        flex-direction: column;
        align-items: center;
        gap: 5px;
        flex: 1;
        min-height: 0;
    }
    
    .game-layout {
        gap: 3px;
    }
    
    #game-canvas {
        width: min(95vw, 380px);
        height: min(50vh, 400px);
        flex-shrink: 0;
    }
    
    .game-info {
        width: 100%;
        max-width: 95vw;
        gap: 8px;
    }
    
    .top-controls {
        display: flex;
        flex-direction: column;
        gap: 15px;
        max-width: 250px;
        align-items: center;
    }
    
    .next-piece {
        flex: 0 0 auto;
        padding: 8px;
        min-width: 90px;
    }
    
    .game-buttons {
        flex: 1;
        gap: 8px;
        align-items: stretch;
    }
    
    .instructions {
        padding: 8px;
        order: 1;
    }
    
    .instructions p {
        margin-bottom: 3px;
        font-size: 0.75em;
    }
    
    .instructions h4 {
        font-size: 0.9em;
        margin-bottom: 8px;
    }
    
    .game-buttons {
        flex-direction: row;
        gap: 5px;
    }
    
    .game-buttons button {
        padding: 8px 12px;
        font-size: 0.8em;
    }
}

/* Mobile Touch Controls */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.control-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.control-btn {
    width: 55px;
    height: 55px;
    font-size: 22px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    flex-shrink: 0;
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

@media (max-width: 900px) {
    .mobile-controls {
        display: flex;
    }
    
    .instructions {
        display: none;
    }
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 0;
    text-align: center;
    font-size: 0.8em;
    color: #666;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.footer p {
    margin: 0;
    font-weight: 500;
}

/* Adjust body padding to account for footer */
body {
    padding-bottom: 50px;
}

@media (max-width: 600px) {
    body {
        font-size: 14px;
        padding-bottom: 50px;
    }
    
    .footer {
        font-size: 0.7em;
        padding: 6px 0;
    }
    
    #game-canvas {
        width: 95vw;
        height: 45vh;
    }
    
    .sidebar {
        flex-direction: column;
        gap: 8px;
        width: 95vw;
    }
    
    .game-buttons {
        flex-direction: row;
    }
    
    .game-header {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    
    .score, .level, .age-display {
        font-size: 1em;
    }
    
    .next-piece h3 {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .control-row {
        gap: 8px;
    }
    
    .mobile-controls {
        margin-top: 3px;
        padding: 4px;
        margin-bottom: 3px;
        flex-shrink: 0;
    }
    
    .welcome-content {
        padding: 25px;
        margin: 10px;
    }
    
    .welcome-content h1 {
        font-size: 2.2em;
    }
    
    .age-dropdown {
        font-size: 1em;
        padding: 10px 15px;
    }
    
    .start-btn {
        font-size: 1.1em;
        padding: 12px 25px;
    }
}