/* ==========================================
   STYLE PART 1: Grundlayout, Spielfeld & Blöcke
   ========================================== */

* {
    box-sizing: border-box;
    user-select: none;
}

body {
    background: linear-gradient(to bottom, #1d61c2, #2185de, #2497eb);
    background-attachment: fixed;
    margin: 0;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
    height: 100vh;
    overflow: hidden;
    touch-action: none;
}

body.square-ui * { border-radius: 0 !important; }

/* --- HEADER & SCORE --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 580px;
    margin-bottom: 10px;
}

.highscore {
    color: #f1c40f;
    font-size: 32px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.settings-icon {
    font-size: 40px;
    color: #a9b7d6;
    cursor: pointer;
    transition: transform 0.1s;
}

.settings-icon:active {
    transform: scale(0.9);
}

.current-score-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    min-height: 90px;
}

.combo-display {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255, 71, 87, 0.25);
    font-size: 100px;
    z-index: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.combo-display.hidden {
    opacity: 0;
    transform: scale(0.5);
}

.combo-display.pulse {
    animation: comboPopUI 0.4s ease-out;
}

@keyframes comboPopUI {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 15px rgba(255, 71, 87, 0.4)); }
    100% { transform: scale(1); }
}

.heart-icon {
    animation: heartbeat 0.8s infinite alternate;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

.current-score {
    font-size: 68px;
    font-weight: bold;
    z-index: 2;
    position: relative;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* --- SPIELFELD (BOARD) --- */
.board-wrapper {
    position: relative;
    width: 580px; 
    height: 580px;
    margin-bottom: 20px;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 70px); 
    grid-template-rows: repeat(8, 70px);
    gap: 2px;
    background-color: #212943;
    padding: 3px;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    width: 100%;
    height: 100%;
    transition: filter 0.5s ease;
}

.sweep-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; height: 0;
    background: linear-gradient(to bottom, rgba(238, 82, 83, 0.8), rgba(95, 39, 205, 0.8));
    z-index: 50;
    transition: height 3s ease-in-out;
    border-radius: 6px;
    pointer-events: none;
}

.sweep-overlay.active {
    height: 100%;
}

.cell {
    width: 70px;
    height: 70px;
    background-color: #2a3453;
    border-radius: 4px;
    transition: background-color 0.1s, opacity 0.1s;
}

/* NEU: Performance schonende Glas-Vorschau statt Bild-Vorschau */
.cell.preview {
    background-color: rgba(255, 255, 255, 0.25) !important;
    opacity: 1 !important;
    box-shadow: inset 0 0 10px rgba(255,255,255,0.8);
    transform: scale(0.95);
}

.cell.filled {
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.4), 
                inset -2px -2px 5px rgba(0, 0, 0, 0.3);
    transform: scale(1);
}

.cell.placed-effect { animation: dropAndShine 0.3s ease-out forwards; }

@keyframes dropAndShine {
    0% { transform: scale(1.1) translateY(-3px); filter: brightness(1.8); }
    50% { transform: scale(0.95) translateY(2px); filter: brightness(1.3); }
    100% { transform: scale(1) translateY(0); filter: brightness(1); }
}

.cell.will-clear { position: relative; }
.cell.will-clear::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.8), 0 0 10px rgba(255, 215, 0, 0.6);
    border-radius: 4px;
    z-index: 5;
    animation: pulseGlitter 0.5s infinite alternate;
    pointer-events: none;
}
@keyframes pulseGlitter {
    0% { opacity: 0.4; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1.05); }
}

.cell.shatter {
    animation: shatterEffect 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    pointer-events: none;
    z-index: 10;
}
@keyframes shatterEffect {
    0% { transform: scale(1); opacity: 1; filter: brightness(1.5); }
    40% { transform: scale(1.15) rotate(15deg); opacity: 1; filter: brightness(2); }
    100% { transform: scale(0) rotate(-45deg); opacity: 0; filter: brightness(0.5); }
}

.combo-popup {
    position: absolute;
    top: 40%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px; font-weight: bold; color: #f1c40f;
    text-shadow: 0 0 10px #e67e22, 0 0 20px #e74c3c;
    z-index: 200; pointer-events: none; white-space: nowrap;
    animation: comboPop 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes comboPop {
    0% { transform: translate(-50%, -30%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    80% { transform: translate(-50%, -60%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -70%) scale(0.8); opacity: 0; }
}

/* --- TRAY & FORMEN (UNTEN) --- */
.tray {
    display: flex;
    justify-content: space-evenly; align-items: center;
    width: 580px; 
    margin-top: 20px;
    height: 100px;
}

.shape-slot {
    width: 100px;
    height: 100px;
    display: flex; justify-content: center; align-items: center;
    cursor: grab; touch-action: none;
}

.shape-container {
    display: grid;
    gap: 2px;
    transition: transform 0.1s ease;
    visibility: hidden; pointer-events: none;
}

.shape-container.dragging { z-index: 1000; }

.mini-block {
    width: 20px;
    height: 20px; border-radius: 3px;
    box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.4), inset -1px -1px 3px rgba(0, 0, 0, 0.3);
}

/* --- FARBEN & EFFEKTE --- */
.color-hellblau { background-color: #00D2D3; }
.color-dunkelblau { background-color: #2E86DE; }
.color-gruen { background-color: #10AC84; }
.color-gelb { background-color: #FECA57; }
.color-orange { background-color: #FF9F43; }
.color-rot { background-color: #EE5253; }
.color-pink { background-color: #FF9FF3; }
.color-lila { background-color: #5F27CD; }
.color-transparent { background-color: transparent; box-shadow: none; }

.color-image {
    background-image: var(--ahmad-img, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #2E86DE; 
    box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.4), inset -1px -1px 3px rgba(0, 0, 0, 0.3);
}

.color-emanuel {
    background-image: var(--emanuel-img, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #10AC84; 
    box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.4), inset -1px -1px 3px rgba(0, 0, 0, 0.3);
}

.color-adrian {
    background-image: var(--adrian-img, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #FF9F43; 
    box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.4), inset -1px -1px 3px rgba(0, 0, 0, 0.3);
}

/* =========================================
   MOBILE OPTIMIERUNG (Responsive Design)
   ========================================= */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: top center;
    width: 100%;
}

@media (max-width: 650px) {
    .game-container { transform: scale(0.85); }
    #btn-back-to-ranking { font-size: 18px !important; padding: 12px 16px !important; }
}
@media (max-width: 550px) {
    .game-container { transform: scale(0.75); }
    #btn-back-to-ranking { font-size: 20px !important; padding: 14px 20px !important; }
}
@media (max-width: 450px) {
    .game-container { transform: scale(0.65); }
    #btn-back-to-ranking { font-size: 24px !important; padding: 16px 24px !important; }
}
@media (max-width: 380px) {
    .game-container { transform: scale(0.55); }
    #btn-back-to-ranking { font-size: 28px !important; padding: 18px 28px !important; }
}
