* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Verhindert das versehentliche Markieren von Text beim Spielen */
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a4d6d 0%, #0d2a3d 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    height: 100dvh;
    padding: 10px;
    overflow: hidden; /* Scrollen komplett unterbinden */
    overscroll-behavior: none;
}

.wrapper {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    background: rgba(20, 60, 80, 0.9);
    padding: 15px;
    border-radius: 10px 10px 0 0;
    border-bottom: 3px solid #00bcd4;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

h1 {
    color: #00bcd4;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-right: auto; 
}

.btn-menu {
    background: #e91e63;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
}

.hud {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.hud-item {
    background: rgba(0, 188, 212, 0.2);
    padding: 6px 10px;
    border-radius: 5px;
    border: 2px solid #00bcd4;
    display: flex;
    gap: 5px;
    align-items: center;
}

.hud-item .label { color: #00bcd4; font-weight: bold; font-size: 12px; }
.hud-item .value { color: #fff; font-weight: bold; font-size: 16px; min-width: 30px; }

.btn-restart {
    background: #ffc107;
    color: #000;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

/* --- Die Skalierung des Spielfelds --- */
#game {
    display: block;
    width: 100%;
    max-width: 100vw;
    max-height: 55dvh; /* Lässt Platz für Header und Buttons auf dem Handy */
    aspect-ratio: 16 / 9; /* Erzwingt das Breitbild-Format */
    background: linear-gradient(180deg, #1a7a8a 0%, #0d4a5a 50%, #0a3a4a 100%);
    border-radius: 0 0 10px 10px;
    border: 3px solid #00bcd4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* --- Mobile Steuerung (Touch-Buttons) --- */
#mobile-controls {
    display: none; 
    justify-content: space-between;
    width: 100%;
    margin-top: 15px;
    padding: 0 10px;
}

.touch-group {
    display: flex;
    gap: 15px;
}

.touch-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #00bcd4;
    border-radius: 50%;
    color: #00bcd4;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
}

.touch-btn:active {
    background: rgba(0, 188, 212, 0.4);
    color: #fff;
}

/* Zeigt die Buttons nur auf Geräten mit kleineren Bildschirmen */
@media (max-width: 1024px) {
    #mobile-controls {
        display: flex;
    }
}

/* --- Modal Styles (Game Over) --- */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); z-index: 1000; justify-content: center; align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: #0d2a3d; padding: 25px; border-radius: 15px; border: 3px solid #00bcd4;
    max-width: 400px; width: 90%; max-height: 90vh; overflow-y: auto; text-align: center;
}
.modal-content h2 { color: #00bcd4; margin-bottom: 15px; font-size: 24px; }
.modal-content h3 { color: #00bcd4; margin: 15px 0 10px 0; font-size: 18px; }
.modal-body p { color: #fff; margin-bottom: 15px; font-size: 16px; }

.name-input-box { margin-bottom: 15px; display: flex; flex-direction: column; gap: 5px; }
.name-input-box label { color: #00bcd4; font-weight: bold; }
.name-input-box input {
    padding: 10px; border: 2px solid #00bcd4; border-radius: 5px;
    background: rgba(0, 188, 212, 0.1); color: #fff; font-size: 16px; text-align: center; outline: none;
}
.btn-primary {
    background: #ffc107; color: #000; border: none; padding: 12px; border-radius: 5px;
    font-weight: bold; cursor: pointer; font-size: 16px; width: 100%; margin-bottom: 10px;
}
.highscore-list {
    background: rgba(0, 188, 212, 0.1); padding: 10px; border-radius: 5px;
    border: 2px solid #00bcd4; margin-bottom: 15px; max-height: 150px; overflow-y: auto;
}
.highscore-item {
    display: flex; justify-content: space-between; padding: 6px 0;
    border-bottom: 1px solid rgba(0, 188, 212, 0.3); color: #fff; font-size: 14px;
}
.highscore-rank { color: #ffc107; font-weight: bold; width: 25px; text-align: left; }
.highscore-name { flex: 1; color: #00bcd4; text-align: left; }
.highscore-score { color: #ffc107; font-weight: bold; }

/* Responsive Header-Tweaks für kleine Smartphones */
@media (max-width: 600px) {
    header { justify-content: center; padding: 10px; gap: 10px; }
    h1 { margin: 0; font-size: 20px; }
    .hud { justify-content: center; }
}