/* ===== CSS VARIABLES & DESIGN TOKENS ===== */
:root {
    /* Colors - Warm Sunset Palette */
    --primary: #FF6B35;
    --primary-dark: #E85A2A;
    --primary-light: #FF8F5C;
    --secondary: #2EC4B6;
    --secondary-dark: #25A99D;
    --accent: #FFD166;
    --accent-dark: #F0C14B;

    /* Background Gradients */
    --bg-gradient: linear-gradient(180deg, #87CEEB 0%, #98D8C8 30%, #F7DC6F 70%, #FF6B35 100%);
    --bg-menu: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --bg-game: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-dark: #1a1a2e;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Font */
    --font-family: 'Fredoka', sans-serif;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background: var(--bg-menu);
    color: var(--text-primary);
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

/* ===== GLASS PANEL ===== */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

/* ===== MAIN MENU ===== */
#menu-screen {
    background: url('assets/menu_bg.png') center center / cover no-repeat;
    overflow: hidden;
    position: relative;
}

#menu-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg,
            rgba(0, 0, 0, 0.3) 0%,
            rgba(0, 0, 0, 0.1) 30%,
            rgba(0, 0, 0, 0.2) 70%,
            rgba(0, 0, 0, 0.6) 100%);
    z-index: 1;
}

.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xl);
    z-index: 10;
    padding: var(--spacing-lg);
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.game-logo {
    text-align: center;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.title-main {
    font-size: 4.5rem;
    font-weight: 700;
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 50%, #FF6B35 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    letter-spacing: 6px;
    margin-bottom: -5px;
    text-transform: uppercase;
}

.title-sub {
    font-size: 3.2rem;
    font-weight: 700;
    background: linear-gradient(180deg, #FFFFFF 0%, #E0E0E0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
    letter-spacing: 4px;
    text-transform: uppercase;
}

.title-emoji {
    font-size: 4rem;
    margin-top: var(--spacing-lg);
    animation: emojiPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

@keyframes emojiPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* Floating Characters */
.floating-capybara,
.floating-lion {
    position: absolute;
    font-size: 5rem;
    opacity: 0.9;
    animation: float 5s ease-in-out infinite;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
}

.capy-1 {
    top: 12%;
    left: 8%;
    animation-delay: 0s;
}

.capy-2 {
    bottom: 15%;
    right: 10%;
    animation-delay: 2s;
}

.lion-1 {
    top: 20%;
    right: 8%;
    animation-delay: 1s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }

    50% {
        transform: translateY(-25px) rotate(3deg);
    }
}

/* ===== BUTTONS ===== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    font-family: var(--font-family);
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 220px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left var(--transition-normal);
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-primary);
    box-shadow:
        0 4px 0 var(--primary-dark),
        0 6px 20px rgba(255, 107, 53, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 0 var(--primary-dark),
        0 10px 30px rgba(255, 107, 53, 0.5);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 var(--primary-dark),
        0 3px 10px rgba(255, 107, 53, 0.4);
}

.btn-secondary {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 2px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.btn-icon {
    font-size: 1.4rem;
}

.btn-icon-only {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.pulse-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 4px 0 var(--primary-dark), 0 6px 20px rgba(255, 107, 53, 0.4);
    }

    50% {
        box-shadow: 0 4px 0 var(--primary-dark), 0 6px 40px rgba(255, 107, 53, 0.7);
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.menu-footer {
    margin-top: var(--spacing-lg);
    opacity: 0.7;
    font-size: 0.9rem;
}

/* ===== TUTORIAL SCREEN ===== */
#tutorial-screen {
    background: var(--bg-menu);
}

.tutorial-container {
    max-width: 400px;
    width: 90%;
    padding: var(--spacing-xl);
    text-align: center;
}

.tutorial-container h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-lg);
    color: var(--accent);
}

.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.tutorial-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    text-align: left;
    padding: var(--spacing-sm);
}

.tutorial-icon {
    font-size: 2rem;
    min-width: 50px;
    text-align: center;
}

.tutorial-item p {
    font-size: 1rem;
    line-height: 1.4;
}

/* ===== GAME SCREEN ===== */
#game-screen {
    background: var(--bg-game);
    padding: 0;
}

#game-canvas {
    width: 100%;
    flex: 1;
    display: block;
}

/* Game HUD */
#game-hud {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    z-index: 100;
}

.hud-left,
.hud-center,
.hud-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.coin-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 1.3rem;
    font-weight: 600;
}

.coin-icon {
    font-size: 1.5rem;
    animation: coinSpin 3s linear infinite;
}

@keyframes coinSpin {

    0%,
    100% {
        transform: rotateY(0);
    }

    50% {
        transform: rotateY(180deg);
    }
}

.wave-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 600;
}

.wave-display span:first-child {
    font-size: 0.7rem;
    opacity: 0.8;
    letter-spacing: 2px;
}

.wave-display span:last-child {
    font-size: 1.5rem;
    color: var(--accent);
}

/* Deploy Bar */
#deploy-bar {
    position: absolute;
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    right: var(--spacing-md);
    padding: var(--spacing-sm);
    z-index: 100;
}

.deploy-units {
    display: flex;
    justify-content: space-around;
    gap: var(--spacing-xs);
}

.unit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 60px;
    font-family: var(--font-family);
    position: relative;
    /* Base for overlay */
    overflow: hidden;
}

.cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    /* Will be controlled by JS */
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    transition: height 0.1s linear;
}

.unit-btn:disabled .cooldown-overlay {
    background: rgba(0, 0, 0, 0.3);
}

.unit-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--accent);
    transform: translateY(-4px);
}

.unit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.unit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.unit-btn.affordable {
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(46, 196, 182, 0.4);
}

.unit-icon {
    font-size: 1.8rem;
}

.unit-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.unit-cost {
    font-size: 0.6rem;
    color: var(--accent);
    font-weight: 500;
}

/* ===== OVERLAYS ===== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--transition-normal);
}

.overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.overlay-content {
    padding: var(--spacing-xl);
    text-align: center;
    min-width: 280px;
    animation: slideUp var(--transition-normal);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.overlay-content h2 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-lg);
}

.overlay-content .btn {
    margin-top: var(--spacing-md);
    width: 100%;
}

/* Victory Screen */
.victory h2 {
    color: var(--accent);
    text-shadow: 0 0 20px rgba(255, 209, 102, 0.5);
}

.victory-stars {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    animation: starsAppear 0.5s ease-out;
}

@keyframes starsAppear {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

.victory-message,
.defeat-message {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: var(--spacing-lg);
}

.victory-stats,
.defeat-stats {
    margin-bottom: var(--spacing-md);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

/* Defeat Screen */
.defeat h2 {
    color: #ff6b6b;
}

.defeat-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    animation: heartBreak 0.5s ease-out;
}

@keyframes heartBreak {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .title-main {
        font-size: 2.8rem;
    }

    .title-sub {
        font-size: 2rem;
    }

    .title-emoji {
        font-size: 2.2rem;
    }

    .btn {
        min-width: 180px;
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 1rem;
    }

    .unit-btn {
        min-width: 50px;
        padding: var(--spacing-xs);
    }

    .unit-icon {
        font-size: 1.5rem;
    }

    .unit-name {
        font-size: 0.55rem;
    }

    .unit-cost {
        font-size: 0.5rem;
    }

    .floating-capybara,
    .floating-lion {
        font-size: 2.5rem;
    }
}

@media (min-width: 768px) {
    .title-main {
        font-size: 5rem;
    }

    .title-sub {
        font-size: 3.5rem;
    }

    #deploy-bar {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }

    #game-hud {
        max-width: 700px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }
}

/* ===== ANIMATIONS FOR GAME ELEMENTS ===== */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.pop {
    animation: pop 0.3s ease-out;
}

@keyframes pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}