/* CSS Custom Variables for curated, premium palette */
:root {
    --primary: #f9d423; /* Bright Banana Yellow */
    --primary-glow: rgba(249, 212, 35, 0.4);
    --secondary: #ff4e50; /* Red Tomato/Coconut danger */
    --accent: #2ecc71; /* Jungle Green */
    --accent-dark: #27ae60;
    --dark-bg: #1e272e; /* Dark wood charcoal */
    --light-glass: rgba(255, 255, 255, 0.15);
    --border-glass: rgba(255, 255, 255, 0.25);
    --text-light: #ffffff;
    --text-dark: #2f3640;
    --text-yellow: #f1c40f;
    --font-playful: 'Fredoka', system-ui, -apple-system, sans-serif;
}

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

body {
    background: linear-gradient(135deg, #11998e, #38ef7d); /* Tropical forest gradient */
    font-family: var(--font-playful);
    color: var(--text-light);
    height: 100vh;
    height: 100dvh; /* Dynamic Viewport Height for mobile browsers */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Outer layout wrapper */
#game-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 600px;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Full screen wrapper on iPad and iPhone */
@media (max-width: 1024px) {
    #game-wrapper {
        padding: 0;
        max-width: none;
        max-height: none;
    }
}

/* Core game container */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    background-color: var(--dark-bg);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3),
                0 0 0 10px rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid var(--border-glass);
}

/* Full screen container overrides on iPad and iPhone */
@media (max-width: 1024px) {
    #game-container {
        aspect-ratio: auto;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
}

/* Game Canvas */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1d2b64, #f8cdda); /* Jungle sunset gradient */
}

/* HUD Overlay */
#game-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--light-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Elements inside HUD that need pointer events */
#sound-btn {
    pointer-events: auto;
}

.hud-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.score-container {
    align-items: flex-start;
}

.hud-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hud-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    display: inline-block;
    transition: transform 0.1s ease;
}

/* Bouncing anim when score changes */
.score-pop {
    animation: pop 0.15s ease-out;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Lives representation (hearts) */
.lives-container {
    align-items: flex-end;
}

#lives-display {
    display: flex;
    gap: 6px;
}

.heart-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: heartBeat 1.5s infinite alternate;
}

/* Powerup container (Banana Rush progress bar) */
.active-powerup-container {
    flex-grow: 1;
    max-width: 250px;
    margin: 0 20px;
    align-items: center;
}

.powerup-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: pulseBorder 1.5s infinite;
}

.powerup-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #f9d423, #ff4e50);
    border-radius: 4px;
    box-shadow: 0 0 8px var(--primary-glow);
    transition: width 0.1s linear;
}

/* Sound control */
.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-light);
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Fullscreen Screens overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85); /* Premium deep dark wash */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Dialog Card container */
.overlay-card {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid var(--border-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 32px;
    padding: 30px 40px;
    width: 85%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5),
                inset 0 1px 1px rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Title text */
.game-title {
    font-size: 46px;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -1px;
    color: var(--text-light);
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
    animation: titleBounce 2s ease-in-out infinite alternate;
}

.game-title .highlight {
    font-size: 54px;
    background: linear-gradient(135deg, #f9d423, #ff4e50);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.welcome-msg {
    font-size: 16px;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 20px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Rules / Instructions list */
.instructions {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 16px;
    text-align: left;
    width: 100%;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.instructions h3 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.instructions p {
    font-size: 12.5px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 6px;
}

.instructions p:last-child {
    margin-bottom: 0;
}

/* Play/Restart Action Buttons */
.action-btn {
    font-family: var(--font-playful);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-light);
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    border-radius: 20px;
    padding: 14px 40px;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--accent-dark),
                0 12px 20px rgba(46, 204, 113, 0.3);
    transition: all 0.15s ease-out;
    transform: translateY(0);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 var(--accent-dark),
                0 16px 24px rgba(46, 204, 113, 0.4);
    filter: brightness(1.1);
}

.action-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--accent-dark),
                0 4px 6px rgba(46, 204, 113, 0.2);
}

/* Game Over Card overrides */
.game-over-card {
    border-color: rgba(255, 78, 80, 0.4);
    box-shadow: 0 30px 60px rgba(255, 78, 80, 0.15),
                0 30px 60px rgba(0, 0, 0, 0.5);
}

.game-over-title {
    font-size: 40px;
    background: linear-gradient(135deg, #ff4e50, #f9d423);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    text-transform: uppercase;
}

/* Score displays in Game Over */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.game-over-msg {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 28px;
    line-height: 1.5;
}

.restart-btn {
    background: linear-gradient(135deg, #ff9f43, #ff6b6b);
    box-shadow: 0 6px 0 #ee5253,
                0 12px 20px rgba(255, 107, 107, 0.3);
}

.restart-btn:hover {
    box-shadow: 0 8px 0 #ee5253,
                0 16px 24px rgba(255, 107, 107, 0.4);
}

.restart-btn:active {
    box-shadow: 0 2px 0 #ee5253,
                0 4px 6px rgba(255, 107, 107, 0.2);
}

/* Helper Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes titleBounce {
    from { transform: translateY(0) rotate(-2deg); }
    to { transform: translateY(-8px) rotate(2deg); }
}

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

@keyframes pulseBorder {
    0% { filter: drop-shadow(0 0 2px rgba(249, 212, 35, 0.4)); }
    50% { filter: drop-shadow(0 0 10px rgba(249, 212, 35, 0.8)); }
    100% { filter: drop-shadow(0 0 2px rgba(249, 212, 35, 0.4)); }
}

/* Neon banana rush border classes added dynamically to game-container */
.banana-rush-active {
    animation: neonGlow 0.4s infinite alternate;
}

@keyframes neonGlow {
    from {
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4),
                    0 0 15px rgba(249, 212, 35, 0.6),
                    inset 0 0 15px rgba(249, 212, 35, 0.4);
        border-color: rgba(249, 212, 35, 0.8);
    }
    to {
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4),
                    0 0 25px rgba(249, 212, 35, 0.9),
                    inset 0 0 25px rgba(249, 212, 35, 0.6);
        border-color: rgba(255, 255, 255, 1);
    }
}

/* Small screen adjustments (Mobile viewports) */
@media (max-width: 600px) or (max-height: 600px) {
    #game-hud {
        top: 10px;
        left: 10px;
        right: 10px;
        height: 48px;
        padding: 0 12px;
        border-radius: 12px;
    }
    .hud-value {
        font-size: 20px;
    }
    .hud-label {
        font-size: 9px;
        letter-spacing: 1px;
    }
    .heart-icon {
        font-size: 18px;
    }
    .active-powerup-container {
        margin: 0 8px;
    }
    .powerup-label {
        font-size: 8px;
        letter-spacing: 0.5px;
    }
    .progress-track {
        height: 6px;
    }
    .icon-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .overlay-card {
        padding: 20px;
        border-radius: 24px;
        width: 90%;
        max-width: 380px;
    }
    .game-title {
        font-size: 28px;
        margin-bottom: 4px;
    }
    .game-title .highlight {
        font-size: 32px;
    }
    .welcome-msg {
        font-size: 13px;
        margin-bottom: 12px;
    }
    .instructions {
        padding: 10px 14px;
        margin-bottom: 15px;
        max-height: 120px;
        overflow-y: auto;
    }
    .instructions h3 {
        font-size: 12px;
        margin-bottom: 4px;
    }
    .instructions p {
        font-size: 11px;
        line-height: 1.4;
        margin-bottom: 4px;
    }
    .action-btn {
        font-size: 16px;
        padding: 10px 28px;
        border-radius: 14px;
    }
    .game-over-title {
        font-size: 26px;
        margin-bottom: 12px;
    }
    .stats-grid {
        gap: 10px;
        margin-bottom: 12px;
    }
    .stat-card {
        padding: 8px;
        border-radius: 12px;
    }
    .stat-value {
        font-size: 22px;
    }
    .stat-label {
        font-size: 9px;
    }
    .game-over-msg {
        font-size: 12px;
        margin-bottom: 16px;
    }
    
    /* Style the scrollbar for instructions inside the overlay */
    .instructions::-webkit-scrollbar {
        width: 6px;
    }
    .instructions::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 3px;
    }
    .instructions::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
    }
    .instructions::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.4);
    }
}

/* Language Button Styling */
.lang-toggle-container {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-bottom: -10px; /* Offset spacing to overlay cleanly */
}
.lang-toggle-btn {
    font-family: var(--font-playful);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.lang-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}
.lang-toggle-btn:active {
    transform: scale(0.95);
}
