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

body {
    font-family: "Arial", sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    width: 500px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    max-width: 100vw;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 48px;
    font-weight: bold;
    color: #4CAF50;
    margin: 0;
}

.scores-container {
    display: flex;
    gap: 10px;
}

.score-container {
    background: #333;
    padding: 10px 20px;
    border-radius: 8px;
    color: white;
    text-align: center;
    min-width: 80px;
    border: 2px solid #4CAF50;
}

.score-label {
    font-size: 14px;
    text-transform: uppercase;
    margin-bottom: 5px;
    color: #888;
}

.score {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
}

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

.game-intro p {
    font-size: 18px;
    line-height: 1.65;
    margin-bottom: 15px;
}

.restart-button, .retry-button {
    background: #4CAF50;
    border-radius: 8px;
    padding: 12px 24px;
    color: white;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.restart-button:hover, .retry-button:hover {
    background: #45a049;
    transform: scale(1.05);
}

.game-container {
    position: relative;
    background: #222;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 20px;
    display: inline-block;
    border: 3px solid #4CAF50;
}

#gameCanvas {
    display: block;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

.game-message {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    text-align: center;
    border-radius: 12px;
    padding: 30px;
    border: 2px solid #4CAF50;
}

.game-message p {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #ff5722;
}

.game-message.game-over {
    background: rgba(255, 87, 34, 0.1);
    border-color: #ff5722;
}

.lower {
    margin-top: 20px;
}

.instructions {
    margin-top: 20px;
    line-height: 1.65;
    background: #333;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #555;
}

.instructions p {
    font-size: 14px;
    color: #ccc;
}

.instructions strong {
    color: #4CAF50;
    font-weight: bold;
}

@media (max-width: 600px) {
    .container {
        width: 100%;
        padding: 10px;
        padding-top: env(safe-area-inset-top, 10px);
        padding-bottom: env(safe-area-inset-bottom, 10px);
        padding-left: env(safe-area-inset-left, 10px);
        padding-right: env(safe-area-inset-right, 10px);
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    h1 {
        font-size: 28px;
        margin-bottom: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .scores-container {
        order: -1;
    }
    
    .game-intro {
        margin-bottom: 15px;
    }
    
    .game-intro p {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .restart-button, .retry-button {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .game-container {
        width: 100%;
        max-width: min(380px, calc(100vw - 20px));
        margin: 0 auto 15px;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
        max-width: 100%;
        display: block;
    }
    
    .score-container {
        min-width: 50px;
        padding: 6px 10px;
    }
    
    .score-label {
        font-size: 12px;
    }
    
    .score {
        font-size: 16px;
    }
    
    .game-message {
        width: 90%;
        max-width: 300px;
        padding: 20px;
    }
    
    .game-message p {
        font-size: 20px;
    }
    
    .instructions {
        display: none;
    }
}

/* iPhone specific fixes */
@supports (-webkit-touch-callout: none) {
    .container {
        height: 100vh;
        height: -webkit-fill-available;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .game-container {
        flex-shrink: 0;
    }
}
