/* --- Basis-Container (div.game) --- */
/* --- Das Grundgerüst (Flexibel) --- */
.game {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid #141c2c;
    width: 100%;
    /* Keine feste Höhe mehr! Das Spiel wächst mit dem Inhalt */
    min-height: 600px; 
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center; /* Zentriert alle Kinder (Score, Ruppel, Shop) horizontal */
    height: 100%;
    width: 100%;
    padding: 20px;
    gap: 20px;
    box-sizing: border-box;
}

/* --- 1. Score-Bereich (Oben) --- */
.score-board {
    width: 100%; /* Nimmt volle Breite ein, damit text-align: center greift */
    text-align: center;
}

#score-display {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin: 0;
    color: var(--text);
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#points-per-click {
    color: var(--muted);
    font-size: 1rem;
    margin-top: 4px;
}

/* --- 2. Ruppel-Bereich (Mitte - Dynamisch) --- */
.cookie-section {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; /* Wichtig für die Zentrierung im Flex-Layout */
    padding: 20px 0;
}

#main-cookie {
    display: block; /* Verhält sich stabiler beim Zentrieren */
    margin: 0 auto; /* Zusätzliche Sicherheit für die horizontale Mitte */
    width: 100%;
    max-width: 350px; 
    height: auto;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.05s ease;
    filter: drop-shadow(0 8px 15px rgba(0,0,0,0.4));
}

#main-cookie:active {
    transform: scale(0.94);
}

/* --- 3. Shop-Bereich (Unten) --- */
.shop-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    width: 100%; /* Damit der Shop die volle Breite des Game-Containers nutzt */
    max-width: 800px; /* Optional: Damit der Shop am PC nicht zu breit läuft */
}

.upgrade-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--muted);
    border-radius: 10px;
    padding: 10px 5px;
    width: 110px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upgrade-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
    border-color: var(--text);
}

.upgrade-item img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    margin-bottom: 6px;
}

.upgrade-info {
    text-align: center;
    width: 100%;
}

.upgrade-info p {
    font-size: 0.7rem;
    margin: 0 0 5px 0;
    color: var(--muted);
    line-height: 1.1;
    min-height: 28px; /* Hält Boxen gleich hoch */
    display: flex;
    align-items: center;
    justify-content: center;
}

.upgrade-info span {
    font-weight: 800;
    color: #fbbf24; /* Gelb für Preise */
    font-size: 0.9rem;
    display: block;
}

/* --- Popup & Floating Text --- */
.popup-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.popup-overlay.hidden { display: none; }

.floating-text {
    position: fixed;
    color: #fff;
    font-weight: 900;
    pointer-events: none;
    font-size: 1.5rem;
    z-index: 1000;
    animation: floatUp 0.8s ease-out forwards;
}

/* --- Popup System (Absolut zentriert) --- */
.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 12, 0.95); /* Fast schwarz für Fokus */
    display: flex;
    align-items: center; /* Vertikal zentrieren */
    justify-content: center; /* Horizontal zentrieren */
    z-index: 9999; /* Über allem anderen */
    backdrop-filter: blur(8px);
}

.popup-overlay.hidden {
    display: none;
}

.popup-content {
    background: var(--panel);
    border: 2px solid #ef4444;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 85%; /* Flexibel für Mobile */
    max-width: 400px; /* Begrenzung für Desktop */
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.3);
    animation: popupPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popupPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.popup-content h2 {
    color: #ef4444;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

#popup-text {
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

#popup-btn {
    padding: 12px 25px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

#popup-btn:hover {
    transform: scale(1.05);
    background: #d9363e;
}

@keyframes floatUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100px); opacity: 0; }
}

/* --- Mobile Fixes --- */
@media (max-width: 700px) {
#main-cookie {
        max-width: 280px; /* Ruppel bleibt auf dem Handy schön groß */
    }

    .shop-section {
        /* Handy: 2 Spalten nebeneinander sieht bei Scrollen am besten aus */
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px;
    }

    .upgrade-item {
        width: 100%; /* Nutzt die Grid-Zelle voll aus */
        padding: 15px 5px;
    }

    .upgrade-item img {
        width: 50px; /* Icons bleiben groß und erkennbar */
        height: 50px;
    }
}