* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #1a1a2e;
    overflow: hidden;
    user-select: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#gameContainer {
    width: 375px;
    height: 667px;
    margin: 0;
    position: relative;
    background: #0b1430 url('assets/bg.png') center/cover no-repeat;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
}

.screen.active {
    display: flex;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.banner {
    position: absolute;
    top: -64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    transform-origin: 50% 0%;
    animation: bannerSway 2.6s ease-in-out infinite alternate;
    will-change: transform;
}

.banner::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 8px;
    background: #2c3e50;
    border-radius: 2px;
}

.banner::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: #34495e;
    border-radius: 1px;
    margin-left: 8px;
}

.banner-img { display: block; width: 320px; height: auto; }

@keyframes bannerSway {
    0%   { transform: translateX(-50%) rotate(-0.8deg); }
    100% { transform: translateX(-50%) rotate(0.8deg); }
}

.divider { display: none; }

.banner-content h2 { display: none; }

.character { position: relative; margin: 40px 0; }

.character-face { display: none; }

.eyes {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
}

.eye {
    width: 12px;
    height: 12px;
    background: black;
    border-radius: 50%;
    position: relative;
}

.eye::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
}

.mouth {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
}

.mouth.open {
    width: 30px;
    height: 30px;
    background: #FF6B6B;
    border-radius: 50%;
    border: 2px solid #E74C3C;
}

.mouth.open::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 15px;
    background: white;
    border-radius: 50%;
}

.mouth.smile {
    width: 25px;
    height: 12px;
    border: 3px solid #2C3E50;
    border-top: none;
    border-radius: 0 0 25px 25px;
}

.character-body { display: none; }

.start-character .character-face {
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.start-button {
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease;
    margin-bottom: 20px;
}

.start-button:hover {
    transform: translateY(-2px);
}

.start-button:active {
    transform: translateY(0);
}


/* Start screen character image */
.start-char-img {
    width: 200px;
    height: auto;
    margin: auto auto 10px auto;
    display: block;
    order: 1;
    margin-top: auto;
    transform: translateY(-200px);
    text-align: center;
    position: relative;
    z-index: 5;
}

/* Rules box styling */
.rules-box {
    width: 300px;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -20%);
    z-index: 10;
    opacity: 1;
    animation: rulesPulse 3s ease-in-out infinite;
}

/* Desktop rules - show on larger screens */
.rules-desktop {
    display: block;
}

.rules-mobile {
    display: none;
}

/* Mobile rules - show on smaller screens */
@media (max-width: 768px) {
    .rules-desktop {
        display: none;
    }
    
    .rules-mobile {
        display: block;
        width: 280px; /* Slightly smaller for mobile */
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    .rules-mobile {
        width: 250px; /* Even smaller for very small screens */
    }
}

@keyframes rulesPulse {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -20%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -20%) scale(1.02);
    }
}


.start-image {
    width: 280px;
    height: auto;
    display: block;
    background: url('assets/start.png') center/contain no-repeat;
    border: none;
    padding: 0;
    position: relative;
    aspect-ratio: 3.86 / 1;
    transition: transform 0.2s ease;
    cursor: pointer;
    order: 3;
}

.start-image:hover {
    transform: scale(0.95);
}

.start-image:active {
    transform: scale(0.9);
}

.start-image .start-img {
    display: none;
}

/* Play Again button styling */
.playagain-image {
    width: 280px;
    height: auto;
    display: block;
    background: url('assets/playagain.png') center/contain no-repeat;
    border: none;
    padding: 0;
    position: relative;
    aspect-ratio: 3.86 / 1;
    transition: transform 0.2s ease;
    cursor: pointer;
    order: 2;
}

.playagain-image:hover {
    transform: scale(0.95);
}

.playagain-image:active {
    transform: scale(0.9);
}

.playagain-image .playagain-img {
    display: none;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFD700 0%, #FFA500 100%);
    width: 100%;
    transition: width 0.1s linear;
}

#gameCanvas {
    background: transparent;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
}

.instructions {
    color: white;
    font-size: 16px;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.control-btn:active {
    transform: scale(0.95);
    background: rgba(255,255,255,0.3);
}

.control-btn.left, .control-btn.right {
    font-size: 14px;
}

.control-btn.center {
    font-size: 20px;
}

/* Mobile responsiveness */
@media (max-width: 400px) { }

/* Game elements */
.laddoo {
    position: absolute;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #FFD700, #FFA500);
    border-radius: 50%;
    box-shadow: 
        inset -5px -5px 10px rgba(0,0,0,0.3),
        0 2px 5px rgba(0,0,0,0.2);
    animation: laddooGlow 2s infinite alternate;
}

@keyframes laddooGlow {
    0% {
        box-shadow: 
            inset -5px -5px 10px rgba(0,0,0,0.3),
            0 2px 5px rgba(0,0,0,0.2),
            0 0 10px rgba(255,215,0,0.3);
    }
    100% {
        box-shadow: 
            inset -5px -5px 10px rgba(0,0,0,0.3),
            0 2px 5px rgba(0,0,0,0.2),
            0 0 20px rgba(255,215,0,0.6);
    }
}

.catcher {
    position: absolute;
    width: 60px;
    height: 60px;
    background: #20B2AA;
    border-radius: 50%;
    border: 3px solid #1E9B94;
    transition: all 0.1s ease;
}

.catcher::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: #D4A574;
    border-radius: 50%;
    border: 2px solid #B8956A;
}

.catcher::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: black;
    border-radius: 50%;
}

.catcher.catching {
    animation: catchPulse 0.3s ease;
}

@keyframes catchPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Timer Bar */
.timer-container {
    position: fixed;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    z-index: 1000;
}

/* Mobile timer positioning - below laddoo counter */
@media (max-width: 768px) {
    .timer-container {
        position: absolute; /* Change from fixed to absolute */
        top: 220px; /* Position below the laddoo eaten counter + 100px total */
        left: 50%;
        transform: translateX(-50%);
        width: 280px; /* Slightly narrower for mobile */
        padding: 0 10px; /* Add some padding */
        z-index: 1000;
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    .timer-container {
        top: 210px; /* Adjust for smaller screens + 100px total */
        width: 260px; /* Narrower for small screens */
        padding: 0 15px; /* More padding for very small screens */
    }
}

.timer-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 1s linear;
    border-radius: 2px;
}

.timer-text {
    text-align: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
    margin-top: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

/* Mobile timer text */
@media (max-width: 768px) {
    .timer-text {
        font-size: 16px; /* Slightly smaller for mobile */
        margin-top: 8px; /* More space from bar */
    }
}

@media (max-width: 480px) {
    .timer-text {
        font-size: 14px; /* Even smaller for very small screens */
        margin-top: 10px; /* More space for readability */
    }
}

/* Win/Lose Messages */
.win-message, .lose-message {
    text-align: center;
    color: white;
    margin: 20px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

.win-message h2, .lose-message h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #4CAF50;
}

.lose-message h2 {
    color: #f44336;
}

.win-message p, .lose-message p {
    font-size: 16px;
    line-height: 1.4;
}

/* Win Screen Styling */
.win-screen {
    background: url('assets/won bg.png') center/cover no-repeat;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Lose Screen Styling */
.lose-screen {
    background: url('assets/lost bg.png') center/cover no-repeat;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Win Screen Elements */
.won-image {
    width: 200px;
    height: auto;
    margin: 0 !important;
    z-index: 5 !important;
    position: absolute !important;
    top: calc(50% - 80px) !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: none !important;
}

.win-screen .playagain-image {
    margin-top: 0 !important;
    z-index: 10 !important;
    position: absolute !important;
    top: calc(50% + 150px) !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: auto !important;
    transition: transform 0.2s ease !important;
    cursor: pointer !important;
}

.win-screen .playagain-image:hover {
    transform: translate(-50%, -50%) scale(0.95) !important;
}

.win-screen .playagain-image:active {
    transform: translate(-50%, -50%) scale(0.9) !important;
}

#trophyCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicks to pass through */
    z-index: 2; /* Below images, above background */
}

.confetti-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: none; /* Allows clicks to pass through */
    z-index: 4; /* Above trophies, below images */
    overflow: hidden;
}

/* Cache bust - updated positioning */
.lost-image {
    width: 200px;
    height: auto;
    margin: 0 !important;
    z-index: 5 !important;
    position: absolute !important;
    top: calc(50% - 80px) !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: none !important;
}

.lose-screen .playagain-image {
    margin-top: 0 !important;
    z-index: 10 !important;
    position: absolute !important;
    top: calc(50% + 150px) !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: auto !important;
    transition: transform 0.2s ease !important;
    cursor: pointer !important;
}

.lose-screen .playagain-image:hover {
    transform: translate(-50%, -50%) scale(0.95) !important;
}

.lose-screen .playagain-image:active {
    transform: translate(-50%, -50%) scale(0.9) !important;
}

#cryingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Countdown Screen Styling */
.countdown-screen {
    background: url('assets/bg.png') center/cover no-repeat;
    justify-content: center;
    align-items: center;
    position: relative;
}

.countdown-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.countdown-number {
    font-size: 120px;
    font-weight: bold;
    color: white;
    font-family: 'Arial', sans-serif;
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
