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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(26, 26, 46, 0.95);
    color: white;
    padding: 20px;
    text-align: center;
}

.screen.hidden {
    display: none;
}

.screen h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.screen p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    max-width: 300px;
    line-height: 1.5;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    margin: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
}

button:hover, button:active {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5);
}

#player-name {
    padding: 12px 20px;
    font-size: 1.2rem;
    border: 2px solid #667eea;
    border-radius: 10px;
    margin: 10px;
    text-align: center;
    width: 200px;
    background: rgba(255,255,255,0.1);
    color: white;
}

#player-name::placeholder {
    color: rgba(255,255,255,0.5);
}

#new-highscore {
    background: rgba(255, 215, 0, 0.1);
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    border: 2px solid #ffd700;
}

#new-highscore p {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.3rem;
}

#highscore-list {
    list-style: none;
    text-align: left;
    font-size: 1.1rem;
    background: rgba(255,255,255,0.05);
    padding: 20px 30px;
    border-radius: 15px;
    margin: 20px 0;
    min-width: 280px;
}

#highscore-list li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#highscore-list li:last-child {
    border-bottom: none;
}

#highscore-list .rank {
    min-width: 30px;
    color: #ffd700;
}

#highscore-list .name {
    flex: 1;
}

#highscore-list .score {
    font-weight: bold;
    color: #667eea;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 20px;
    font-size: 1.2rem;
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#score, #level, #misses {
    background: rgba(0,0,0,0.3);
    padding: 8px 15px;
    border-radius: 20px;
}

#level {
    font-size: 1rem;
}

/* Safe area for notch phones */
@supports (padding-top: env(safe-area-inset-top)) {
    #hud {
        padding-top: calc(15px + env(safe-area-inset-top));
    }
}

/* Sound button */
#sound-btn {
    position: absolute;
    top: 65px;
    right: 20px;
    width: 50px;
    height: 50px;
    padding: 0;
    font-size: 1.5rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sound-btn:hover, #sound-btn:active {
    transform: scale(1.1);
}

/* Sound message */
#sound-message {
    position: absolute;
    top: 130px;
    right: 15px;
    background: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 100;
    max-width: 200px;
    text-align: center;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

#sound-message.hidden {
    display: none;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

@supports (top: env(safe-area-inset-top)) {
    #sound-btn {
        top: calc(65px + env(safe-area-inset-top));
    }
    #sound-message {
        top: calc(130px + env(safe-area-inset-top));
    }
}
