:root {
    --bg-dark: #1a1a2e;
    --bg-light: #16213e;
    --text-main: #ffffff;
    --primary: #ff477e;
    --secondary: #6a4c93;
    --accent: #ffca3a;
    --board-bg: #0a0a1a;

    /* 21 Ball Colors */
    --color-1: #FF4444;   /* Kırmızı */
    --color-2: #44CC44;   /* Yeşil */
    --color-3: #4488FF;   /* Mavi */
    --color-4: #FFD700;   /* Sarı */
    --color-5: #AA44FF;   /* Mor */
    --color-6: #FF8833;   /* Turuncu */
    --color-7: #FF69B4;   /* Pembe */
    --color-8: #00CED1;   /* Turkuaz */
    --color-9: #AAFF00;   /* Lime */
    --color-10: #CC2222;  /* Bordo */
    --color-11: #3355AA;  /* Lacivert */
    --color-12: #8B4513;  /* Kahverengi */
    --color-13: #FF6F61;  /* Mercan */
    --color-14: #6B8E23;  /* Zeytin */
    --color-15: #C8A2C8;  /* Leylak */
    --color-16: #00DDDD;  /* Camgöbeği */
    --color-17: #DAA520;  /* Altın */
    --color-18: #FF007F;  /* Gül */
    --color-19: #2E8B57;  /* Deniz Yeşili */
    --color-20: #7B68EE;  /* Lavanta */
    --color-21: #FFAA55;  /* Açık Turuncu */
}

* { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    height: 100dvh; /* dynamic viewport height */
    background-color: var(--bg-dark);
    font-family: 'Outfit', Arial, Helvetica, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* disables pull-to-refresh & browser scrolling */
}

#parallax-container {
    position: fixed;
    top: -10%; left: -10%;
    width: 120%; height: 120%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    will-change: transform;
    pointer-events: none;
    transition: transform 0.1s linear;
}

#parallax-bg {
    background: url('../images/menu_bg.png') no-repeat center center;
    background-size: cover;
}

#parallax-lights {
    background: radial-gradient(circle at 20% 30%, rgba(72, 202, 228, 0.1) 0%, transparent 40%),
                radial-gradient(circle at 80% 60%, rgba(255, 71, 126, 0.12) 0%, transparent 50%),
                radial-gradient(circle at 50% 10%, rgba(255, 202, 58, 0.08) 0%, transparent 40%);
}

#parallax-bubbles {
    background-image: 
        radial-gradient(circle at 15% 25%, transparent 25px, rgba(255,255,255,0.2) 28px, transparent 30px),
        radial-gradient(circle at 75% 15%, transparent 15px, rgba(255,255,255,0.12) 18px, transparent 20px),
        radial-gradient(circle at 45% 75%, transparent 20px, rgba(255,255,255,0.15) 23px, transparent 25px),
        radial-gradient(circle at 85% 85%, transparent 10px, rgba(255,255,255,0.25) 12px, transparent 14px);
    background-size: 350px 350px;
    opacity: 0.8;
}

#parallax-dust {
    background-image: 
        radial-gradient(circle at 30% 40%, rgba(255,255,255,0.2) 0%, transparent 3px),
        radial-gradient(circle at 70% 60%, rgba(255,255,255,0.3) 0%, transparent 2px),
        radial-gradient(circle at 10% 80%, rgba(255,255,255,0.15) 0%, transparent 4px);
    background-size: 150px 150px;
    opacity: 0.6;
}

#game-container {
    width: 100%; height: 100%; height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    background: rgba(10, 10, 26, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    position: relative;
    z-index: 10;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
}

.screen {
    width: 100%; height: 100%;
    position: absolute;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    padding: 20px;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Canvas Overlays */
#particles-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 50;
}

#lang-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10000;
}
.lang-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 5px 10px;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
}
.lang-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* --- Menü --- */
.logo-text {
    font-size: clamp(2rem, 8vw, 3.5rem);
    text-align: center;
    margin-top: 2vh;
    margin-bottom: 5px;
    text-shadow: 0 0 10px rgba(255,71,126,0.6), 0 0 20px rgba(255,71,126,0.4), 0 5px 15px rgba(0,0,0,0.8);
    line-height: 1.1;
    background: -webkit-linear-gradient(#fff, #ffca3a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 5px 5px rgba(0,0,0,0.5));
}
.accent-text { color: var(--primary); }
.subtitle { font-family: 'Inter', sans-serif; font-size: min(4vw, 1.1rem); margin-bottom: 20px; opacity: 0.8; margin-top:0; }

.menu-buttons {
    display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 250px;
}

.tutorial-box {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 18px;
    border-radius: 20px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-family: 'Inter', sans-serif;
    width: 90%;
}
.tutorial-box h3 { margin-top: 0; font-family: 'Outfit', sans-serif; color: var(--accent); }
.tutorial-box ul { padding-left: 20px; margin: 0; line-height: 1.6; font-size: 0.95rem; }

/* Butonlar */
.btn {
    padding: 15px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    font-size: 1.2rem;
    font-family: 'Outfit', sans-serif;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-transform: uppercase;
    box-shadow: 0 8px 15px rgba(0,0,0,0.3), inset 0 2px 5px rgba(255,255,255,0.2);
    backdrop-filter: blur(5px);
}

.btn:active {
    transform: translateY(4px) scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    filter: brightness(1.2);
}

.btn.primary { background: linear-gradient(135deg, #ff477e, #ff0a54); }
.btn.secondary { background: linear-gradient(135deg, #6a4c93, #432874); }
.btn.tertiary { background: linear-gradient(135deg, #48cae4, #0096c7); }
.btn.icon-btn {
    width: 45px; height: 45px;
    border-radius: 50%;
    padding: 0;
    display: flex; justify-content: center; align-items: center;
    background: rgba(255,255,255,0.2);
    box-shadow: none; font-size: 1.2rem;
}
.btn.icon-btn:active { background: rgba(255,255,255,0.3); transform: scale(0.9); }

/* --- Top Bar --- */
#top-bar {
    width: 100%;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.level-info {
    font-size: 1.3rem; color: var(--accent); text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.level-desc {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    opacity: 0.7;
    margin-left: 8px;
}
.moves-container {
    background: rgba(0,0,0,0.4);
    padding: 5px 15px; border-radius: 20px;
    display: flex; flex-direction: column; align-items: center;
    border: 2px solid var(--primary);
}
.moves-label { font-size: 0.8rem; opacity: 0.8; font-family: 'Inter', sans-serif; text-transform: uppercase; font-weight: bold; }
#moves-left { font-size: 1.8rem; color: #fff; }

/* --- Oyun Alanı (Grid) --- */
#board-container {
    flex-grow: 1; width: 100%;
    display: flex; justify-content: center; align-items: center;
    overflow: hidden; /* Avoid clipping */
    box-sizing: border-box;
    position: relative;
}





#game-board {
    display: grid;
    gap: 2px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.6), 0 10px 40px rgba(0,0,0,0.4);
}

/* --- Ball (Cell) Base --- */
.cell {
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, opacity 0.25s ease;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.2rem;
}

.cell:not(.empty):hover {
    transform: scale(1.15);
    z-index: 10;
}

/* Ball 3D effect - generated per color */
.color-1  { background: radial-gradient(circle at 35% 35%, #ff8888, var(--color-1) 50%, #aa0000); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-2  { background: radial-gradient(circle at 35% 35%, #88ff88, var(--color-2) 50%, #228822); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-3  { background: radial-gradient(circle at 35% 35%, #88bbff, var(--color-3) 50%, #224488); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-4  { background: radial-gradient(circle at 35% 35%, #ffee88, var(--color-4) 50%, #bb9900); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-5  { background: radial-gradient(circle at 35% 35%, #cc88ff, var(--color-5) 50%, #662299); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-6  { background: radial-gradient(circle at 35% 35%, #ffbb77, var(--color-6) 50%, #aa5500); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-7  { background: radial-gradient(circle at 35% 35%, #ffaadd, var(--color-7) 50%, #cc3388); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-8  { background: radial-gradient(circle at 35% 35%, #77eeee, var(--color-8) 50%, #008888); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-9  { background: radial-gradient(circle at 35% 35%, #ccff77, var(--color-9) 50%, #669900); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-10 { background: radial-gradient(circle at 35% 35%, #ee6666, var(--color-10) 50%, #880000); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-11 { background: radial-gradient(circle at 35% 35%, #7799cc, var(--color-11) 50%, #112266); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-12 { background: radial-gradient(circle at 35% 35%, #bb8855, var(--color-12) 50%, #553300); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-13 { background: radial-gradient(circle at 35% 35%, #ffaa99, var(--color-13) 50%, #cc3322); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-14 { background: radial-gradient(circle at 35% 35%, #99bb55, var(--color-14) 50%, #445500); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-15 { background: radial-gradient(circle at 35% 35%, #ddccdd, var(--color-15) 50%, #886688); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-16 { background: radial-gradient(circle at 35% 35%, #77ffff, var(--color-16) 50%, #009999); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-17 { background: radial-gradient(circle at 35% 35%, #eebb66, var(--color-17) 50%, #886600); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-18 { background: radial-gradient(circle at 35% 35%, #ff77bb, var(--color-18) 50%, #aa0044); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-19 { background: radial-gradient(circle at 35% 35%, #66bb88, var(--color-19) 50%, #1a5533); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-20 { background: radial-gradient(circle at 35% 35%, #aa99ff, var(--color-20) 50%, #4433aa); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }
.color-21 { background: radial-gradient(circle at 35% 35%, #ffcc88, var(--color-21) 50%, #cc7722); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.3); }

/* Shine effect on every ball */
.cell:not(.empty):not(.bomb)::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 30%;
    height: 25%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.55) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* Frozen and Rainbow Cells */
.cell.frozen::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: rgba(255, 255, 255, 0.4);
    border: 3px solid rgba(170, 238, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(170, 238, 255, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 5;
    transition: all 0.2s ease;
}

.cell.rainbow {
    background: conic-gradient(from 0deg, #ff0000, #ff8000, #ffff00, #00ff00, #00ffff, #0000ff, #8000ff, #ff00ff, #ff0000);
    box-shadow: 0 0 15px rgba(255,255,255,0.8), inset 0 0 10px rgba(255,255,255,0.5);
    animation: rainbow-spin 3s linear infinite;
}

@keyframes rainbow-spin { 
    to { transform: rotate(360deg); } 
}

.cell.rainbow::after {
    content: '⭐';
    font-size: 1.2rem;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    width: auto; height: auto;
    border-radius: 0;
    pointer-events: none;
}

/* Bomba Sınıfı */
.bomb { 
    background: radial-gradient(circle at 35% 35%, #888, #444 50%, #111);
    box-shadow: inset 0 -3px 6px rgba(0,0,0,0.4), 0 0 12px rgba(255, 10, 84, 0.6);
    animation: pulse-bomb 1s infinite alternate;
}
.bomb::after {
    content: '💣';
    font-size: 1rem;
    position: static;
    background: none;
    width: auto; height: auto;
    border-radius: 0;
}

.cell.empty {
    background: transparent;
    box-shadow: none;
    pointer-events: none;
}

.cell:active:not(.empty) { transform: scale(0.85); }

/* Patlama Efekti (Popping out) */
.cell.pop-out {
    animation: squash-stretch-pop 0.3s ease-in-out forwards;
}

@keyframes squash-stretch-pop {
    0% { transform: scale(1); opacity: 1; }
    33% { transform: scale(1.25, 0.85); opacity: 1; }
    66% { transform: scale(0.85, 1.25); opacity: 0.9; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes light-shake {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 1px); }
    50% { transform: translate(2px, -1px); }
    75% { transform: translate(-1px, 2px); }
    100% { transform: translate(0, 0); }
}

.cell.animate-fall {
    animation: fall-down 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes fall-down {
    0% { transform: translateY(calc(-100% * var(--drop-dist, 1))); }
    100% { transform: translateY(0); }
}

.shake {
    animation: light-shake 0.15s ease-in-out;
}

/* Highlight connected group on hover */
.cell.highlight {
    filter: brightness(1.3);
    transform: scale(1.1);
}

/* --- Overlay --- */
#overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 200;
}
#overlay-content {
    background: linear-gradient(145deg, #202442, #16213e);
    padding: 35px; border-radius: 25px;
    text-align: center;
    border: 2px solid rgba(255,255,255,0.1);
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
    transform: scale(1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%; width: 350px;
}
#overlay.hidden { display: none; }
#overlay.hidden #overlay-content { transform: scale(0.5); }
.btn.hidden { display: none !important; }
#overlay-title { font-size: 2rem; margin: 0 0 10px; color: var(--accent); }
#overlay-stars { font-size: 2.5rem; margin-bottom: 20px; letter-spacing: 5px; }
#overlay-message { font-family: 'Inter', sans-serif; font-size: 1.1rem; margin-bottom: 20px; opacity: 0.9; }
.overlay-buttons { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }

/* --- Seviye Gridi --- */
#levels-screen {
    overflow-y: auto;
}
.header {
    display: flex; align-items: center; gap: 15px; width: 100%; margin-bottom: 10px;
}
#levels-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px;
    width: 100%; padding: 10px 0; overflow-y: auto; max-height: 80vh;
}
.level-btn {
    aspect-ratio: 1; border-radius: 15px; border:none;
    font-family: 'Outfit', sans-serif; font-size: 1.5rem;
    background: rgba(255,255,255,0.1); color: white;
    cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    transition: transform 0.1s;
}
.level-btn .level-emoji { font-size: 1.2rem; line-height: 1; }
.level-btn .level-num { font-size: 1.3rem; line-height: 1; }
.level-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.level-btn:not(.locked):hover { 
    animation: pulse-breathe 1.5s infinite alternate ease-in-out; 
    z-index: 2; 
}
.level-btn.completed { background: linear-gradient(135deg, #44CC44, #228822); }
.level-btn.next { 
    background: linear-gradient(135deg, var(--accent), #eebb66); 
    color: #111; 
    box-shadow: 0 0 15px rgba(255, 202, 58, 0.6); 
    animation: glow-pulse-mini 1.5s infinite alternate ease-in-out;
}
.level-btn.locked { 
    background: linear-gradient(135deg, rgba(30,30,50,0.6), rgba(10,10,20,0.8));
    color: #888; 
    border: 1px dashed rgba(255,255,255,0.2);
    pointer-events: none; 
}

/* Animasyonlar */
@keyframes glow-pulse-mini {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 202, 58, 0.3); }
    100% { transform: scale(1.05); box-shadow: 0 0 20px rgba(255, 202, 58, 0.8); }
}
@keyframes pulse-breathe {
    0% { transform: scale(1.05); box-shadow: 0 4px 15px rgba(255,255,255,0.2); }
    100% { transform: scale(1.15); box-shadow: 0 8px 25px rgba(255,255,255,0.4); }
}

@keyframes glow-pulse {
    0% { box-shadow: 0 0 10px rgba(255, 71, 126, 0.4), inset 0 2px 5px rgba(255,255,255,0.2); }
    100% { box-shadow: 0 0 25px rgba(255, 71, 126, 0.9), inset 0 2px 5px rgba(255,255,255,0.2); transform: scale(1.05); }
}

.btn-glow {
    animation: glow-pulse 1.5s infinite alternate ease-in-out !important;
}

@keyframes star-drop-pop {
    0% { opacity: 0; transform: translateY(-50px) scale(3) rotate(-20deg); }
    60% { opacity: 1; transform: translateY(10px) scale(0.9) rotate(10deg); }
    100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

.anim-star {
    display: inline-block;
    opacity: 0;
    animation: star-drop-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.bounce { animation: bounce 2s ease-in-out infinite; }

@keyframes pulse-bomb { 0% { box-shadow: inset 0 -3px 6px rgba(0,0,0,0.4), 0 0 5px rgba(255,10,84,0.4); } 100% { box-shadow: inset 0 -3px 6px rgba(0,0,0,0.4), 0 0 18px rgba(255,10,84,0.8); transform: scale(1.05); } }
.bounce-text { animation: scale-bounce 0.3s; }
@keyframes scale-bounce { 0% { transform: scale(1); } 50% { transform: scale(1.5); color: var(--primary); } 100% { transform: scale(1); } }

/* Shape preview pulse */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Floating Combo Text */
.floating-combo-text {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font-size: 2rem;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0,0,0,0.6);
    background: -webkit-linear-gradient(45deg, #ffca3a, #ff477e, #48cae4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    z-index: 300;
    animation: float-up-fade 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes float-up-fade {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; filter: brightness(1); }
    15% { transform: translate(-50%, -100%) scale(1.3); opacity: 1; filter: brightness(1.5); }
    80% { transform: translate(-50%, -150%) scale(1); opacity: 1; filter: brightness(1.2); }
    100% { transform: translate(-50%, -200%) scale(0.8); opacity: 0; filter: brightness(1); }
}

/* --- Gallery System --- */
#gallery-container {
    width: 100%; display: flex; justify-content: center; align-items: center; margin-top: 20px;
}
.gallery-image-wrapper {
    position: relative;
    width: 320px; height: 320px;
    border: 4px solid var(--accent);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    background: #000;
}
#gallery-image {
    width: 100%; height: 100%;
    object-fit: cover;
    filter: blur(15px);
    transition: filter 1s ease;
}
#gallery-grid {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: grid;
    /* dynamically set by JS */
}
.puzzle-piece {
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.8s ease, opacity 0.8s ease;
}
.puzzle-piece.unlocked {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

/* --- Card Collection System --- */
.cards-stats {
    display: flex; gap: 15px; margin-bottom: 20px; justify-content: center; width: 100%;
}
.card-stat {
    padding: 8px 15px; border-radius: 20px; font-size: 0.9rem;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(5px);
}
.card-stat.common { border: 2px solid #aaa; color: #aaa; }
.card-stat.rare { border: 2px solid #48cae4; color: #48cae4; text-shadow: 0 0 5px #48cae4; }
.card-stat.epic { border: 2px solid #ff477e; color: #ff477e; text-shadow: 0 0 5px #ff477e; }

#cards-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px;
    width: 100%; padding: 10px; overflow-y: auto; max-height: 65vh;
}
.collection-card {
    aspect-ratio: 2/3;
    border-radius: 10px;
    background: linear-gradient(135deg, #222, #111);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    position: relative; overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 2px solid #555;
    transition: transform 0.2s;
}
.collection-card:hover { transform: translateY(-5px) scale(1.05); }
.collection-card.rare { border-color: #48cae4; box-shadow: 0 5px 20px rgba(72,202,228,0.4); }
.collection-card.epic { border-color: #ff477e; box-shadow: 0 5px 20px rgba(255,71,126,0.4); }

.card-icon { font-size: 2.5rem; margin-bottom: 10px; text-shadow: 0 0 10px rgba(255,255,255,0.5); }
.card-name { font-size: 0.8rem; text-align: center; padding: 0 5px; }

/* In-game card drop animation */
.flying-card {
    position: absolute;
    width: 40px; height: 60px;
    background: #fff; border-radius: 4px;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.5rem;
    z-index: 400;
    pointer-events: none;
    box-shadow: 0 0 30px rgba(255,255,255,1);
    animation: card-fly 1.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
.flying-card.rare { background: linear-gradient(135deg, #fff, #48cae4); box-shadow: 0 0 30px #48cae4; }
.flying-card.epic { background: linear-gradient(135deg, #fff, #ff477e); box-shadow: 0 0 30px #ff477e; }

@keyframes card-fly {
    0% { transform: scale(0.5) rotate(0deg); opacity: 0; }
    20% { transform: scale(1.8) rotate(15deg); opacity: 1; }
    80% { transform: translate(150px, -200px) scale(1.2) rotate(180deg); opacity: 1; }
    100% { transform: translate(150px, -400px) scale(0) rotate(360deg); opacity: 0; }
}

/* --- Daily Challenge --- */
.daily-panel {
    margin-top: 10px; width: 90%; max-width: 300px;
    background: linear-gradient(135deg, rgba(255, 202, 58, 0.2), rgba(255, 71, 126, 0.2));
    border: 2px solid var(--accent); border-radius: 15px;
    padding: 12px; text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}
.daily-panel h4 { margin: 0 0 5px; color: var(--accent); font-family: 'Outfit', sans-serif; text-shadow:0 2px 4px rgba(0,0,0,0.5); }
#daily-desc { margin: 0 0 8px; font-size: 0.9rem; font-family:'Inter',sans-serif; }
.progress-bar-wrapper {
    width: 100%; height: 12px;
    background: rgba(0,0,0,0.5); border-radius: 6px; overflow: hidden;
    margin-bottom: 5px;
}
.progress-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #ff477e, #ffca3a);
    transition: width 0.3s ease;
}
.reward-text { font-size: 0.85rem; color: #48cae4; font-weight: bold; margin:0; }
.daily-panel.completed {
    border-color: #44CC44;
    background: linear-gradient(135deg, rgba(68, 204, 68, 0.2), rgba(34, 136, 34, 0.2));
}
.daily-panel.completed .progress-bar-fill { background: linear-gradient(90deg, #44CC44, #AAFF00); }

/* --- Energy Bar & Frenzy Mode --- */
.energy-container {
    width: 150px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.energy-label {
    font-size: 0.75rem; color: #ffca3a; font-family: 'Outfit', sans-serif; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    letter-spacing: 2px; margin: 0;
}
.energy-bar {
    width: 100%; height: 12px;
    background: rgba(0,0,0,0.6); border: 2px solid #ffca3a;
    border-radius: 6px; overflow: hidden; box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}
#energy-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #ffca3a, #ff477e, #48cae4);
    background-size: 200% 200%;
    transition: width 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.frenzy-active {
    animation: frenzy-bg 0.5s infinite alternate;
}
.frenzy-active #energy-fill {
    animation: gradient-shift 0.5s infinite linear;
    width: 100% !important;
}
.frenzy-active #game-board {
    box-shadow: 0 0 50px rgba(255, 71, 126, 0.8), inset 0 0 30px rgba(255, 202, 58, 0.6);
    border-color: #ffca3a;
}
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}
@keyframes frenzy-bg {
    0% { filter: hue-rotate(0deg) contrast(1.1); }
    100% { filter: hue-rotate(90deg) contrast(1.4); }
}

/* --- Ghost Score --- */
#ghost-score-indicator {
    position: absolute;
    right: 15px; top: 75px;
    background: rgba(255,255,255,0.15);
    border: 1px dashed rgba(255,255,255,0.4);
    padding: 4px 8px; border-radius: 20px;
    backdrop-filter: blur(4px);
    display: flex; align-items: center; gap: 8px;
    opacity: 0.8; pointer-events: none;
    z-index: 100;
    font-family: 'Outfit', sans-serif;
    color: #fff;
}
#ghost-score-indicator.hidden { display: none; }
.ghost-icon { font-size: 1.2rem; animation: ghost-float 2s ease-in-out infinite; }
@keyframes ghost-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* --- THEMES (Stil Atölyesi) --- */

/* GLASS THEME */
body.theme-glass .cell:not(.empty):not(.bomb) {
    box-shadow: inset 0 0 10px rgba(255,255,255,0.8), 0 5px 15px rgba(0,0,0,0.3) !important;
    background-image: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 50%) !important;
    border: 1px solid rgba(255,255,255,0.6) !important;
    backdrop-filter: blur(6px);
}

/* NEON THEME */
body.theme-neon { background-color: #050510 !important; }
body.theme-neon .cell:not(.empty):not(.bomb) {
    background: transparent !important;
    border: 3px solid currentColor !important;
    box-shadow: 0 0 15px currentColor, inset 0 0 15px currentColor !important;
}

/* METAL THEME */
body.theme-metal .cell:not(.empty):not(.bomb) {
    box-shadow: inset 0px -5px 10px rgba(0,0,0,0.8), inset 0px 5px 15px rgba(255,255,255,0.9), 0 5px 10px rgba(0,0,0,0.6) !important;
    border: 1px solid #444 !important;
    filter: contrast(1.2) grayscale(0.2);
}

/* WATERCOLOR THEME */
body.theme-watercolor .cell:not(.empty):not(.bomb) {
    box-shadow: none !important;
    border-radius: 50% 40% 60% 40% / 40% 60% 50% 50% !important; /* Organik sekil */
    filter: contrast(0.8) sepia(0.2) opacity(0.85);
    border: none !important;
}

/* GAMIFICATION HOOKS STYLES */

/* The 90% Rule Progress Bar */
.level-progress-bar {
    width: 90%; height: 8px; background: rgba(0,0,0,0.5);
    border-radius: 4px; margin: 0 auto 10px; overflow: hidden;
    position: relative; z-index: 100;
}
.level-progress-fill {
    height: 100%; width: 0%; background: linear-gradient(90deg, #ffca3a, #ff477e);
    transition: width 0.3s ease;
}
.level-progress-fill.vibrating {
    animation: light-shake 0.1s infinite; background: #ff477e;
}
.level-progress-fill.exploding {
    background: #44CC44; box-shadow: 0 0 20px #44CC44;
}

/* Mystery Chest */
.mystery-panel {
    margin-top: 10px; width: 90%; max-width: 300px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.2), rgba(75, 0, 130, 0.2));
    border: 2px solid #8A2BE2; border-radius: 15px; padding: 12px; text-align: center;
}
.mystery-panel.hidden { display: none; }
.mystery-panel h4 { margin: 0 0 5px; color: #E6E6FA; }
.chest-icon { font-size: 3rem; margin: 10px 0; }
.chest-icon.shaking { animation: light-shake 0.5s infinite; filter: drop-shadow(0 0 15px #FFD700); }

/* Max Chain Container */
.max-chain-container {
    position: absolute; top: 120px; left: 10px;
    background: rgba(0,0,0,0.5); padding: 5px 10px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2); text-align: center;
    z-index: 100;
}
#max-chain-warning { color: #ffca3a; font-size: 0.75rem; animation: pulse-breathe 1s infinite alternate; }

/* Next Level Preview */
.next-level-preview {
    background: rgba(0,0,0,0.3); border-radius: 15px; padding: 10px; margin-bottom: 15px;
    display: flex; align-items: center; justify-content: space-around;
    border: 1px dashed var(--accent);
}
.next-level-preview.hidden { display: none; }
.next-level-preview .preview-bg {
    width: 60px; height: 40px; background: url('../images/bg.png');
    background-size: cover; filter: blur(3px); border-radius: 5px; border: 1px solid #fff;
}
.next-level-preview .preview-icon { font-size: 2rem; filter: brightness(0) invert(1); opacity: 0.8; }

/* Modals & Toasts */
.modal {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.8); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--bg-light); padding: 30px; border-radius: 20px;
    text-align: center; border: 2px solid var(--primary); width: 80%; max-width: 400px;
}
.modal-buttons { display: flex; gap: 15px; justify-content: center; margin-top: 20px; }
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(255, 202, 58, 0.9); color: #000; padding: 15px 25px;
    border-radius: 30px; font-family: 'Nunito', sans-serif; font-weight: bold;
    z-index: 1000; box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    transition: opacity 0.5s, bottom 0.5s;
}
.toast.hidden { opacity: 0; bottom: -50px; pointer-events: none; }
.vibrating-border {
    animation: red-vibrate 0.3s infinite !important; border: 2px solid #ff4444 !important;
}
@keyframes red-vibrate {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -1px); }
    100% { transform: translate(1px, -1px); }
}

/* Skill Tree */
.skills-container {
    display: flex; flex-direction: column; align-items: center; gap: 30px; margin-top: 20px;
    width: 100%;
}
.skill-row { display: flex; gap: 40px; justify-content: center; position: relative; }
.skill-node {
    background: #333; padding: 15px; border-radius: 50%; width: 70px; height: 70px;
    display: flex; justify-content: center; align-items: center; font-size: 1.5rem;
    border: 3px solid #555; cursor: pointer; position: relative; z-index: 5;
    transition: all 0.3s;
}
.skill-node.unlocked { background: var(--primary); border-color: #fff; box-shadow: 0 0 20px var(--primary); }
.skill-node.available { border-color: var(--accent); animation: glow-pulse-mini 1.5s infinite alternate; }
.skill-node.locked { opacity: 0.5; filter: grayscale(1); pointer-events: none; }
.skill-path {
    position: absolute; background: #555; transition: background 0.3s; z-index: 1;
}
.skill-path.vertical { width: 4px; height: 30px; left: 50%; transform: translateX(-50%); top: -30px; }
.skill-path.unlocked { background: #fff; box-shadow: 0 0 10px #fff; }

/* PHASE 2: SOCIAL & CLOUD UI */

.glass-modal {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37) !important;
}
.glass-input {
    width: 100%; padding: 12px; margin-bottom: 15px;
    background: rgba(255,255,255,0.2) !important; border: 1px solid rgba(255,255,255,0.4) !important;
    border-radius: 10px; color: #fff; font-family: 'Fredoka One', cursive;
    font-size: 1.1rem; text-align: center;
}
.glass-input::placeholder { color: rgba(255,255,255,0.6); }

.glow-text {
    text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 40px var(--primary);
    color: #fff;
}
.glow-border {
    border: 2px solid var(--accent) !important;
    box-shadow: 0 0 30px rgba(255, 202, 58, 0.4), inset 0 0 20px rgba(255, 71, 126, 0.3) !important;
    animation: glow-pulse 2s infinite alternate;
}

/* Leaderboard */
.leaderboard-list {
    width: 100%; flex-grow: 1; overflow-y: auto; padding-bottom: 120px; /* space for sticky bottom */
}
.lb-row {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.4); padding: 10px 15px; margin-bottom: 5px;
    border-radius: 10px; border-left: 3px solid #555; width: 100%;
}
.lb-row.is-me {
    background: rgba(72, 202, 228, 0.3); border-left: 5px solid var(--accent);
    box-shadow: 0 0 15px rgba(72, 202, 228, 0.2);
}
.lb-rank { width: 40px; font-size: 1.2rem; text-align: center; }
.lb-name { flex-grow: 1; margin-left:10px; font-family:'Nunito',sans-serif; text-align: left; }
.lb-score { font-family:'Fredoka One',cursive; color:var(--accent); }

.leaderboard-sticky {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: linear-gradient(0deg, var(--bg-dark) 60%, transparent 100%);
    padding: 15px; padding-top: 30px; z-index: 10;
}

/* Next Target Widget */
.next-target-widget {
    background: rgba(255, 71, 126, 0.2); padding: 10px; border-radius: 15px;
    border: 1px solid var(--primary); margin-bottom: 15px; width: 100%;
}

/* Profile / Avatar */
.avatar-container {
    width: 80px; height: 80px; margin: 0 auto 10px;
    border-radius: 50%; display: flex; justify-content: center; align-items: center;
    font-size: 2.5rem; background: rgba(0,0,0,0.5); border: 2px solid #555;
    position: relative;
}
.avatar-container.legendary {
    border: 2px solid #ffca3a; box-shadow: 0 0 20px #ffca3a, inset 0 0 15px #ffca3a;
    animation: glow-pulse-mini 1s infinite alternate;
}
.avatar-selector-item {
    font-size: 2rem; cursor: pointer; padding: 10px; border-radius: 10px;
    background: rgba(0,0,0,0.3); transition: background 0.2s; border: 2px solid transparent;
}
.avatar-selector-item:hover { background: rgba(255,255,255,0.2); }
.avatar-selector-item.locked { opacity: 0.3; filter: grayscale(1); pointer-events: none; border-color: #f00; }

.friends-list {
    max-height: 150px; overflow-y: auto; text-align: left;
    background: rgba(0,0,0,0.3); border-radius: 10px; padding: 5px; margin-top: 10px;
}
.sync-icon { display:inline-block; }
.syncing .sync-icon { animation: roll-spin 1s infinite linear; }
@keyframes roll-spin { 100% { transform: rotate(360deg); } }
