/* ===== Plants vs Zombies Clone - Styles v3 (Mobile) ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    background: #1a1a2e;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; font-family: 'Segoe UI', Arial, sans-serif;
    flex-direction: column; overflow-y: auto;
    overflow-x: hidden; touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
}
#game-container {
    position: relative; width: 100%; max-width: 1000px;
    aspect-ratio: 1000/600;
    background: linear-gradient(180deg, #2d5016 0%, #1a300e 100%);
    border: 3px solid #6b8c42; border-radius: 12px;
    box-shadow: 0 0 40px rgba(0,0,0,0.7), 0 0 80px rgba(76,175,80,0.15);
    overflow: hidden; margin-top: 2px;
}
canvas { display: block; cursor: crosshair; width: 100% !important; height: auto !important; }

/* ===== TOP BAR ===== */
#top-bar {
    position: absolute; top: 0; left: 0; right: 0; height: 9%;
    background: linear-gradient(180deg, rgba(60,30,10,0.95), rgba(40,20,5,0.95));
    display: flex; align-items: center; padding: 0 1.2%;
    border-bottom: 2px solid #8B6914; z-index: 10; gap: 0.5%;
}
.stat-box {
    background: rgba(0,0,0,0.5); border: 1px solid #6b8c42;
    border-radius: 6px; padding: 2px 8px; color: #fff;
    font-size: clamp(10px, 1.4vw, 14px); font-weight: bold;
    display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.stat-box .icon { font-size: clamp(14px, 2vw, 20px); }
#sun-count { color: #FFD700; min-width: 24px; text-align: center; }
#level-name { color: #8BC34A; font-size: clamp(10px, 1.3vw, 13px); flex: 1; text-align: center; }

/* ===== PLANT BAR ===== */
#plant-bar {
    position: absolute; bottom: 1.5%; left: 1%; right: 1%;
    height: 12%; background: rgba(30,15,5,0.92);
    border: 2px solid #6b8c42; border-radius: 10px;
    display: flex; align-items: center; padding: 2px 8px;
    gap: 4px; z-index: 10; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.plant-card {
    position: relative; min-width: clamp(42px, 5.6vw, 56px); width: clamp(42px, 5.6vw, 56px);
    height: 88%; flex-shrink: 0;
    background: linear-gradient(180deg, #4a3520, #2a1a0a);
    border: 2px solid #5a4a30; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; cursor: pointer;
    transition: all 0.15s; overflow: hidden;
    user-select: none; padding: 1px;
}
.plant-card:hover { border-color: #FFD700; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255,215,0,0.2); }
.plant-card.selected { border-color: #4CAF50; box-shadow: 0 0 12px rgba(76,175,80,0.4); background: #2a4a20; }
.plant-card.disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(50%); }
.plant-card .card-icon { font-size: clamp(20px, 3vw, 30px); line-height: 1; }
.plant-card .card-cost {
    font-size: clamp(7px, 1vw, 10px); font-weight: bold; color: #FFD700;
    background: rgba(0,0,0,0.6); padding: 1px 5px; border-radius: 4px; margin-top: 1px;
}
.cooldown-overlay {
    position: absolute; top: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.55);
    pointer-events: none; transition: height 0.3s; height: 0; border-radius: 6px;
}
.key-hint {
    position: absolute; top: 1px; right: 3px;
    font-size: clamp(6px, 0.9vw, 9px); color: rgba(255,255,255,0.5); font-weight: bold;
}
#shovel-btn {
    min-width: clamp(36px, 4.8vw, 48px); width: clamp(36px, 4.8vw, 48px);
    height: 88%; flex-shrink: 0;
    background: linear-gradient(180deg, #5a4030, #3a2010);
    border: 2px solid #7a5a40; border-radius: 8px;
    font-size: clamp(20px, 2.8vw, 28px); cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center; user-select: none;
}
#shovel-btn:hover { border-color: #FFD700; transform: translateY(-2px); }
#shovel-btn.active { border-color: #f44336; box-shadow: 0 0 12px rgba(244,67,54,0.4); background: #4a2020; }

/* ===== LEVEL SELECT ===== */
#level-select {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 100;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 15px;
    backdrop-filter: blur(5px);
}
#level-select h1 {
    font-size: clamp(24px, 5vw, 42px); color: #4CAF50; margin-bottom: 4px;
    text-shadow: 0 0 20px rgba(76,175,80,0.6), 2px 2px 0 #1a3a10; letter-spacing: 1px;
}
.subtitle { color: #aaa; font-size: clamp(10px, 1.4vw, 14px); margin-bottom: 15px; }
#level-grid {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: clamp(6px, 1vw, 10px); max-width: 550px; width: 100%; padding: 0 5px;
}
.level-btn {
    background: linear-gradient(180deg, #3a5a25, #1a3a10);
    border: 2px solid #5a7a3a; border-radius: 10px;
    padding: clamp(10px, 1.6vw, 16px) clamp(4px, 0.8vw, 8px);
    color: #fff; cursor: pointer; font-size: clamp(11px, 1.4vw, 14px);
    font-weight: bold; text-align: center;
    transition: all 0.2s; user-select: none;
}
.level-btn:hover:not(.locked) {
    border-color: #FFD700; transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(255,215,0,0.25);
}
.level-btn.locked { opacity: 0.35; cursor: not-allowed; filter: grayscale(60%); }
.lvl-num { font-size: clamp(16px, 2.2vw, 22px); display: block; }
.lvl-name { font-size: clamp(7px, 1vw, 10px); color: #aacf88; display: block; margin-top: 3px; }

/* ===== OVERLAYS ===== */
.overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.82); z-index: 200;
    display: none; flex-direction: column; align-items: center;
    justify-content: center; backdrop-filter: blur(4px);
}
.overlay.show { display: flex; }
.overlay h2 { font-size: clamp(28px, 5vw, 48px); margin-bottom: 8px; text-shadow: 0 0 30px currentColor; }
#game-over h2 { color: #f44336; }
#win-screen h2 { color: #4CAF50; animation: pulse 1s infinite; }
.overlay p { color: #ddd; font-size: clamp(12px, 1.6vw, 16px); margin-bottom: 15px; text-align: center; }
.btn {
    background: linear-gradient(180deg, #6b8c42, #3a5a20);
    border: 2px solid #8bc34a; color: #fff;
    padding: clamp(8px, 1.2vw, 12px) clamp(20px, 3vw, 30px);
    font-size: clamp(14px, 1.8vw, 18px); font-weight: bold;
    border-radius: 8px; cursor: pointer; transition: all 0.2s;
    margin: 4px; user-select: none;
}
.btn:hover { background: #8bc34a; transform: scale(1.05); box-shadow: 0 4px 20px rgba(139,195,74,0.4); }
.btn.red { background: linear-gradient(180deg, #c62828, #8b0000); border-color: #f44336; }
.btn.red:hover { background: #f44336; box-shadow: 0 4px 20px rgba(244,67,54,0.4); }

@keyframes pulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
.footer-info {
    color: #555; font-size: clamp(8px, 1.1vw, 11px); margin-top: 4px;
    text-align: center; padding: 0 10px;
}
.footer-info span { color: #8bc34a; }

/* ===== MOBILE ADJUSTMENTS ===== */
@media (max-width: 600px) {
    #game-container {
        border-radius: 6px;
        border-width: 2px;
        margin-top: 0;
    }
    #plant-bar {
        border-radius: 6px;
        padding: 1px 4px;
        gap: 2px;
    }
    .plant-card {
        border-radius: 5px;
        border-width: 1.5px;
    }
    .btn {
        margin: 3px;
        border-radius: 6px;
    }
    .footer-info {
        font-size: 8px;
    }
}

@media (max-height: 500px) {
    #plant-bar { height: 14%; }
    #top-bar { height: 11%; }
}