/* ---------------------------------------------------------
   GLOBAL
--------------------------------------------------------- */

* {
    box-sizing: border-box;
}

body {
    background: radial-gradient(circle at top, #1b2a44, #050810 70%);
    color: #fff;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-align: center;
    margin: 0;
    padding: 10px;
    overflow-x: hidden;
}

#game-container {
    max-width: 480px;
    margin: 0 auto;
}

/* ---------------------------------------------------------
   TITLE AREA
--------------------------------------------------------- */

#title-area h1 {
    margin: 5px 0;
    font-size: 26px;
    font-weight: 600;
    text-shadow: 0 0 12px rgba(255,255,255,0.4);
}

#title-area p {
    margin: 0 0 12px;
    font-size: 14px;
    opacity: 0.85;
}

/* ---------------------------------------------------------
   HUD
--------------------------------------------------------- */

#game {
    position: relative;
    margin: 0 auto;
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    padding: 0 4px;
}

#health-bar-container {
    flex: 1;
    margin: 0 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    overflow: hidden;
    height: 14px;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(3px);
}

#health-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
    transition: width 0.2s linear;
}

/* ---------------------------------------------------------
   TREE AREA
--------------------------------------------------------- */

#tree {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    padding-top: 10px;
}

#tree-img {
    width: 100%;
    display: block;
    animation: subtle-sway 6s ease-in-out infinite;
    transform-origin: 50% 100%;
    filter: drop-shadow(0 12px 22px rgba(0,0,0,0.7));
}

@keyframes subtle-sway {
    0%   { transform: scale(1) rotate(0deg); }
    50%  { transform: scale(1.01) rotate(0.4deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* ---------------------------------------------------------
   LAMPS
--------------------------------------------------------- */

.lamp {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: transform 0.1s, box-shadow 0.2s, opacity 0.3s;
    touch-action: none;

    /* schönerer Lampen-Look */
    background: radial-gradient(circle at 30% 30%, #fff 0%, currentColor 40%, currentColor 100%);
    border: 1px solid rgba(255,255,255,0.3);
}

.lamp.warning {
    animation: blink 0.5s infinite alternate;
}

.lamp.off {
    background: #222;
    box-shadow: none;
    opacity: 0.6;
}

.lamp.repair-flash {
    box-shadow: 0 0 22px 10px rgba(255,255,255,0.95);
    transform: translate(-50%, -50%) scale(1.15);
}

.lamp.on-glow {
    animation: lamp-glow 1.4s ease-in-out infinite alternate;
}

@keyframes blink {
    from { opacity: 1; }
    to   { opacity: 0.3; }
}

@keyframes lamp-glow {
    from { box-shadow: 0 0 14px 6px rgba(255,255,200,0.7); }
    to   { box-shadow: 0 0 22px 10px rgba(255,255,240,1); }
}

/* ---------------------------------------------------------
   SPARKS (Funken)
--------------------------------------------------------- */

.spark {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 0 12px rgba(255,255,255,1);
    pointer-events: none;
    animation: spark-pop 0.45s ease-out forwards;
}

@keyframes spark-pop {
    0%   { transform: scale(0.2); opacity: 1; }
    100% { transform: scale(1.6) translateY(-12px); opacity: 0; }
}

/* ---------------------------------------------------------
   COMBO DISPLAY
--------------------------------------------------------- */

#combo {
    position: absolute;
    top: 12%;
    right: 4%;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    text-shadow: 0 0 8px rgba(255,255,255,0.9);
    font-weight: 600;
}

#combo.visible {
    opacity: 1;
    transform: translateY(-4px);
}

/* ---------------------------------------------------------
   OVERLAY / MENU
--------------------------------------------------------- */

#overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#overlay.hidden {
    display: none;
}

#menu {
    max-width: 320px;
    width: 100%;
    background: rgba(25,25,35,0.92);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 0 22px rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}

#overlay-title {
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255,255,255,0.4);
}

#overlay-text {
    font-size: 14px;
    margin-bottom: 12px;
    opacity: 0.9;
}

#overlay-score {
    font-size: 15px;
    font-weight: bold;
    margin: 8px 0;
}

#menu-input {
    margin: 10px 0;
    font-size: 14px;
    text-align: left;
}

#menu-input label {
    display: block;
    margin-bottom: 4px;
}

#player-name {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.5);
    color: #fff;
}

/* Buttons */

button {
    margin-top: 12px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(180deg, #2ecc71, #27ae60);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 0 12px rgba(0,0,0,0.4);
}

button:hover {
    background: linear-gradient(180deg, #3eea85, #2ecc71);
}

button.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%   { transform: scale(1); box-shadow: 0 0 0 rgba(46,204,113,0.6); }
    50%  { transform: scale(1.04); box-shadow: 0 0 14px rgba(46,204,113,0.9); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(46,204,113,0.6); }
}

/* ---------------------------------------------------------
   HIGHSCORES
--------------------------------------------------------- */

#highscore-section {
    margin-top: 14px;
    text-align: left;
}

#highscore-section h3 {
    margin: 4px 0;
    font-size: 15px;
}

#highscore-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    max-height: 130px;
    overflow-y: auto;
    font-size: 14px;
}

#highscore-list li {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ---------------------------------------------------------
   SNOWFALL
--------------------------------------------------------- */

.snow-layer {
    pointer-events: none;
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -10%;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    animation: snowfall linear infinite;
    opacity: 0.9;
    filter: blur(0.5px);
}

.snowflake:nth-child(1) { left: 10%; animation-duration: 6s;  animation-delay: 0s; }
.snowflake:nth-child(2) { left: 30%; animation-duration: 7s;  animation-delay: 1s; }
.snowflake:nth-child(3) { left: 50%; animation-duration: 5s;  animation-delay: 2s; }
.snowflake:nth-child(4) { left: 70%; animation-duration: 8s;  animation-delay: 0.5s; }
.snowflake:nth-child(5) { left: 85%; animation-duration: 6.5s;animation-delay: 1.5s; }
.snowflake:nth-child(6) { left: 20%; animation-duration: 9s;  animation-delay: 2.5s; }

@keyframes snowfall {
    0%   { transform: translateY(0) translateX(0); opacity: 0.9; }
    100% { transform: translateY(120%) translateX(12px); opacity: 0; }
}

/* ---------------------------------------------------------
   MOBILE
--------------------------------------------------------- */

@media (max-width: 480px) {

    #title-area h1 {
        font-size: 22px;
    }

    #tree {
        max-width: 320px;
    }

    .lamp {
        width: 26px;
        height: 26px;
    }
}
