/* ==========================================
   MERGE GUYS - Mobile-First Styling v2
   Sepet + Kombo Sistemi
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #16213e;
    --bg-card: rgba(255, 255, 255, 0.06);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --accent-primary: #6c63ff;
    --accent-secondary: #ff6584;
    --accent-glow: rgba(108, 99, 255, 0.4);
    --gold: #ffd700;
    --danger: #ff4757;
    --success: #2ed573;
    --border-glass: rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px var(--accent-glow);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --font-main: 'Outfit', sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    touch-action: none;
}

/* Grid Paper Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(108, 99, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108, 99, 255, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(108, 99, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108, 99, 255, 0.06) 1px, transparent 1px);
    background-size: 15px 15px, 15px 15px, 75px 75px, 75px 75px;
    pointer-events: none;
    z-index: 0;
}

/* Radial ambient overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 0%, rgba(108, 99, 255, 0.10) 0%, transparent 60%),
                radial-gradient(ellipse at 50% 100%, rgba(255, 101, 132, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ==========================================
   GAME WRAPPER
   ========================================== */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ==========================================
   HEADER
   ========================================== */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 6px;
    z-index: 10;
}

#score-section,
#highscore-section {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    min-width: 85px;
    text-align: center;
}

.score-label {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 1px;
}

.score-value {
    font-size: 1.15rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#game-title {
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #6c63ff, #a855f7, #ff6584);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================
   CANVAS CONTAINER
   ========================================== */
#canvas-container {
    position: relative;
    flex: 1;
    margin: 0 6px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: rgba(8, 8, 24, 0.7);
    border: 1px solid var(--border-glass);
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.3), var(--shadow-glow);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Optional overlay for mute button */
#mute-btn {
    position: absolute;
    top: 10px;
    right: 85px; /* Sola kaydırıldı, panelin üstüne binmemesi için */
    width: 36px;
    height: 36px;
    background: rgba(30, 30, 50, 0.7);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    transition: transform 0.2s, background 0.2s;
}

#mute-btn:active {
    transform: scale(0.9);
}

#mute-btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================
   ABILITIES PANEL
   ========================================== */
#abilities-panel {
    margin: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

#energy-bar-container {
    height: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#energy-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #34FFD5, #00E640);
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

#energy-bar-fill.maxed {
    background: linear-gradient(90deg, #FFD700, #FFA500);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5), 0 0 10px rgba(255, 215, 0, 0.5);
}

#energy-text {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 0;
    left: 0;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    line-height: 14px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
}

#ability-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.ability-btn {
    flex: 0 0 calc(25% - 3px);
    max-width: calc(25% - 3px);
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 6px 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

.ability-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    margin-bottom: 2px;
    transition: transform 0.2s;
}

.ability-btn .cost {
    font-size: 0.55rem;
    font-weight: 800;
    font-family: var(--font-main);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 10px;
}

.ability-btn.ready {
    color: #fff;
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.4), rgba(255, 101, 132, 0.4));
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 10px rgba(108, 99, 255, 0.3);
}

.ability-btn.ready svg {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}

.ability-btn.ready:active {
    transform: scale(0.92);
}

.ability-btn.active-ability {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a2e;
    border-color: #FFF;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    transform: scale(1.05);
}

.ability-btn.active-ability svg {
    stroke: #1a1a2e;
    animation: abilityPulse 1s infinite alternate;
}

.ability-btn.active-ability .cost {
    background: rgba(255, 255, 255, 0.3);
    color: #1a1a2e;
}

@keyframes abilityPulse {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

/* ==========================================
   EVOLUTION BAR
   ========================================== */
#evolution-bar {
    margin: 4px 6px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    overflow: hidden;
    height: 44px;
}

#evo-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ==========================================
   GAME OVER OVERLAY
   ========================================== */
#game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.4s ease;
}

#game-over-overlay.hidden {
    display: none;
}

#game-over-card {
    background: linear-gradient(145deg, rgba(30, 30, 60, 0.95), rgba(20, 20, 50, 0.98));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 36px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: cardSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 320px;
    width: 85%;
}

#game-over-title {
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-secondary), #ff8a5c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#final-score-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

#final-score {
    font-size: 2.8rem;
    font-weight: 900;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#combo-info {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 12px;
    min-height: 18px;
}

#new-highscore-badge {
    display: inline-block;
    padding: 5px 16px;
    background: linear-gradient(135deg, var(--gold), #ffaa00);
    color: #1a1a2e;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    border-radius: 20px;
    margin-bottom: 16px;
    animation: badgePop 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

#new-highscore-badge.hidden {
    display: none;
}

#restart-btn {
    display: block;
    width: 100%;
    padding: 14px 0;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 2px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
}

#restart-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 10px rgba(108, 99, 255, 0.3);
}

/* ==========================================
   START OVERLAY
   ========================================== */
#start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.5s ease;
}

#start-overlay.hidden {
    display: none;
}

#start-card {
    text-align: center;
    animation: cardSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 340px;
    width: 85%;
}

#start-title {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 6px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #6c63ff, #a855f7, #ff6584, #ffd700);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
}

#start-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
}

#start-btn {
    display: block;
    width: 100%;
    padding: 16px 0;
    border: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    color: white;
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 3px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 6px 30px rgba(108, 99, 255, 0.5);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

#start-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 60%
    );
    animation: shimmer 3s ease-in-out infinite;
}

#start-btn:active {
    transform: scale(0.96);
}

#start-instructions p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    opacity: 0.7;
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes badgePop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* ==========================================
   RESPONSIVE
   ========================================== */

/* Tüm ekranlarda mobil görünüm korunur */
@media (min-width: 481px) {
    #game-wrapper {
        max-width: 480px;
        height: 100vh;
    }
}

/* Kısa ekranlar (landscape telefon/tablet) */
@media (max-height: 600px) {
    #header {
        padding: 4px 10px 2px;
    }
    .score-value {
        font-size: 0.95rem;
    }
    #evolution-bar {
        height: 36px;
    }
}
