/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #12121f;
    color: #eee;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
}

.container {
    max-width: 440px;
    margin: 0 auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

h1 {
    margin-bottom: 12px;
    color: #f3f3f3;
    font-size: 24px;
}

/* HUD */
.hud {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    width: 100%;
    max-width: 360px;
}

.hud-item {
    flex: 1;
    background: #1e1e33;
    border-radius: 10px;
    padding: 6px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.hud-label {
    display: block;
    font-size: 10px;
    color: #9a9ac0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hud-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #f3f3f3;
}

.hud-lives .hud-value {
    font-size: 15px;
}

/* Message banner */
.message-banner {
    min-height: 26px;
    font-size: 15px;
    font-weight: bold;
    color: #ffd166;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s, transform 0.3s;
    margin-bottom: 4px;
}

.message-banner.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Game area */
.game-area {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 4px auto;
}

#game-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 360 / 520;
    background: #0a0a16;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 15, 0.85);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 10;
}

.overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.overlay-card {
    padding: 20px;
    max-width: 300px;
    text-align: center;
}

.overlay-card h2 {
    margin-bottom: 10px;
    color: #fff;
}

.overlay-card p {
    margin-bottom: 8px;
    color: #cfcfe8;
    font-size: 14px;
}

.overlay-hint {
    font-size: 12px !important;
    color: #9a9ac0 !important;
}

.gameover-score {
    font-size: 20px;
    font-weight: bold;
    color: #ff6b6b;
}

.gameover-highscore {
    color: #4ade80;
    font-weight: bold;
}

/* Buttons */
.button {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

.button:hover {
    background-color: #ff4f4f;
    transform: translateY(-2px);
}

.button:active {
    transform: translateY(0);
}

/* Steuerungswahl im Start-Overlay — nur auf Touch-Geräten sichtbar */
.control-choice {
    display: none;
    gap: 8px;
    justify-content: center;
    margin-bottom: 4px;
}

@media (pointer: coarse) {
    .control-choice {
        display: flex;
    }
}

.ctrl-opt {
    border: 1px solid #33335a;
    background: #1e1e33;
    color: #cfcfe8;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.2s;
}

.ctrl-opt.active {
    background: #4a4a80;
    border-color: #4a4a80;
    color: #fff;
}

/* Touch controls — nur auf Touch-Geräten sichtbar */
.touch-controls {
    display: none;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-bottom: env(safe-area-inset-bottom);
    width: 100%;
    max-width: 360px;
    user-select: none;
    touch-action: none;
}

@media (pointer: coarse) {
    .touch-controls {
        display: flex;
    }
}

/* Getauschte Anordnung: Joystick links, Feuer rechts */
.touch-controls.swapped {
    flex-direction: row-reverse;
}

/* Drag-Modus: klassische Touch-Controls (Joystick + Feuer) ausgeblendet */
body[data-control="drag"] .touch-controls {
    display: none;
}

.ctrl-fire {
    width: 76px;
    height: 76px;
    flex: none;
    border: none;
    border-radius: 50%;
    background: #d64545;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    touch-action: none;
    user-select: none;
}

.ctrl-fire:active {
    background: #b53535;
    transform: scale(0.94);
}

.ctrl-swap {
    width: 44px;
    height: 44px;
    flex: none;
    border: none;
    border-radius: 50%;
    background: #1e1e33;
    color: #9a9ac0;
    font-size: 20px;
    line-height: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    touch-action: none;
    user-select: none;
}

.ctrl-swap:active {
    background: #33335a;
    color: #f3f3f3;
}

/* Virtueller Joystick */
.joystick {
    position: relative;
    width: 96px;
    height: 96px;
    flex: none;
    border-radius: 50%;
    background: #1e1e33;
    box-shadow: inset 0 0 0 2px #33335a, 0 3px 8px rgba(0, 0, 0, 0.4);
    touch-action: none;
    user-select: none;
}

.joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border-radius: 50%;
    background: #4a4a80;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    will-change: transform;
}

/* Sanftes Zurückschnappen nur beim Loslassen */
.joystick-knob.centering {
    transition: transform 0.12s ease-out;
}

/* Responsive design */
@media (max-height: 720px) {
    h1 {
        font-size: 19px;
        margin-bottom: 6px;
    }

    .ctrl-fire {
        width: 64px;
        height: 64px;
        font-size: 26px;
    }

    .joystick {
        width: 84px;
        height: 84px;
    }

    .joystick-knob {
        width: 38px;
        height: 38px;
        margin: -19px 0 0 -19px;
    }
}

/* Update-Banner: Styles stehen bewusst inline in index.html — sie muessen
   auch dann greifen, wenn styles.css noch aus dem alten Cache stammt. */
