* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background: #111;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 500px;
    background: #222;
    border: 4px solid #444;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #333;
}

#ui {
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

#score-board {
    color: white;
    font-size: 24px;
    font-weight: 900;
    text-shadow: 2px 2px 0px #000;
    opacity: 0.5;
}

#countdown-banner {
    font-size: 24px;
    color: #ffcc00;
    margin-top: 10px;
    font-weight: 900;
    text-shadow: 3px 3px 0px #000;
    text-align: center;
    min-height: 40px;
    letter-spacing: 1px;
}

#alarm-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    box-shadow: inset 0 0 0px #ff0000;
    pointer-events: none;
    z-index: 5;
    transition: box-shadow 0.2s ease;
}

.panic-mode #alarm-overlay {
    box-shadow: inset 0 0 50px #ff0000;
    animation: flash 0.5s infinite alternate;
}

@keyframes flash {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

#menu {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.93);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    color: white;
    padding: 20px;
    text-align: center;
}

#menu h1 {
    color: #ff4500;
    font-size: 38px;
    font-weight: 900;
    margin-bottom: 5px;
    text-shadow: 3px 3px 0px #000;
}

#menu p {
    font-size: 14px;
    color: #aaa;
    font-weight: 500;
    margin-bottom: 15px;
}

/* NEU: Styling für die Namens- und Farbauswahl */
#setup-box {
    width: 80%;
    margin-bottom: 15px;
}

#username {
    width: 100%;
    padding: 10px;
    font-size: 18px;
    font-weight: 700;
    border: 3px solid #444;
    border-radius: 8px;
    background: #222;
    color: white;
    text-align: center;
    outline: none;
}

#username:focus {
    border-color: #ff4500;
}

#color-picker {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 12px;
}

.color-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    box-shadow: none !important;
    padding: 0 !important;
}

.color-btn.active {
    border-color: white;
    transform: scale(1.1);
}

button {
    font-family: inherit;
    font-weight: 900;
    padding: 12px 25px;
    font-size: 20px;
    background: #ff4500;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 5px 0 #b33000;
}

button:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #b33000;
}

/* NEU: Highscore-Box */
/* Erweitert für die 100er-Liste */
#highscore-box {
    margin-top: 15px;
    width: 85%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 10px;
    padding: 10px;
}

#highscore-box h3 {
    font-size: 14px;
    color: #ffcc00;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

/* NEU: Begrenzt die Höhe und schaltet den Scrollbalken ein */
#highscore-list {
    max-height: 140px; /* Zeigt ca. 4-5 Einträge gleichzeitig an */
    overflow-y: auto;  /* Aktiviert das Scrollen, sobald mehr Einträge da sind */
    padding-right: 5px;
}

/* Optional: Macht den Scrollbalken schmaler und dunkler für einen coolen Arcade-Look */
#highscore-list::-webkit-scrollbar {
    width: 6px;
}
#highscore-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}
#highscore-list::-webkit-scrollbar-thumb {
    background: #ff4500;
    border-radius: 10px;
}

.highscore-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1px solid #222;
}

.highscore-row:last-child {
    border-bottom: none;
}

.hs-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hs-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.hs-level {
    color: #ff4500;
}


#joystick-zone {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 15;
    display: none; 
}

#joystick-base {
    position: absolute;
    width: 100px; height: 100px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: none; 
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#joystick-stick {
    position: absolute;
    top: 50%; left: 50%; width: 45px; height: 45px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

@media (pointer: coarse) {
    #joystick-zone { display: block; }
}
