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

body {
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    overflow: hidden;
    background: #000;
    cursor: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Preloader Styles */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #56AFFF;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow: hidden;
}

#preloader-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        rgba(255,255,255,0.1) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.1) 75%,
        transparent 75%,
        transparent
    );
    background-size: 60px 60px;
    animation: moveBackground 3s linear infinite;
}

#preloader-content {
    text-align: center;
    color: white;
}

#preloader-logo {
    width: 200px;
    height: auto;
    margin-bottom: 30px;
    animation: logoFloat 2s ease-in-out infinite;
}

#loading-text {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: white;
}

#loading-bar {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

#loading-progress {
    height: 100%;
    background: white;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes moveBackground {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(-60px, -60px);
    }
}

@keyframes backgroundMove {
    0% {
        transform: translateX(-10%);
    }
    25% {
        transform: translateX(0%);
    }
    50% {
        transform: translateX(-5%);
    }
    75% {
        transform: translateX(-15%);
    }
    100% {
        transform: translateX(-10%);
    }
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 30%;
    max-width: 200px;
    height: auto;
    z-index: 100;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

#counter {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.9), rgba(30, 30, 30, 0.9));
    color: #fff;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 24px;
    font-weight: bold;
    z-index: 100;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

#bullet-counter {
    position: absolute;
    top: 160px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.9), rgba(160, 82, 45, 0.9));
    color: #fff;
    padding: 12px 25px;
    border-radius: 20px;
    font-size: 20px;
    font-weight: bold;
    z-index: 100;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}


#game-area {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#background {
    position: absolute;
    top: 0;
    left: 0;
    width: 120%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    animation: backgroundMove 8s ease-in-out infinite;
}

#fence {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    object-fit: cover;
    z-index: 3;
    pointer-events: none;
}

#character {
    position: absolute;
    width: 120px;
    height: 120px;
    z-index: 2;
    cursor: crosshair;
    transition: all 0.1s ease;
    animation: jumpAround 1s infinite ease-in-out;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

#character:hover {
    filter: brightness(1.2) drop-shadow(0 6px 12px rgba(86, 175, 255, 0.6));
    transform: scale(1.1);
}

@keyframes jumpAround {
    0% {
        left: 20%;
        bottom: 15%;
        transform: translateX(-50%);
    }
    25% {
        left: 80%;
        bottom: 50%;
        transform: translateX(-50%) scaleX(-1);
    }
    50% {
        left: 70%;
        bottom: 20%;
        transform: translateX(-50%) scaleX(-1);
    }
    75% {
        left: 30%;
        bottom: 45%;
        transform: translateX(-50%);
    }
    100% {
        left: 20%;
        bottom: 15%;
        transform: translateX(-50%);
    }
}

#target-cursor {
    position: fixed;
    width: 50px;
    height: 50px;
    background: url('assets/target.png') no-repeat center;
    background-size: contain;
    pointer-events: none;
    z-index: 10;
    opacity: 0.9;
    transform: translate(-50%, -50%);
    display: none;
    filter: drop-shadow(0 2px 6px rgba(255, 0, 0, 0.5));
    animation: targetPulse 1.5s ease-in-out infinite;
}

#instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.9), rgba(30, 30, 30, 0.9));
    color: white;
    padding: 15px 25px;
    border-radius: 15px;
    text-align: center;
    z-index: 100;
    font-size: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

#instructions p {
    margin: 5px 0;
}

/* Landing Page Styles */
#landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('assets/congbg.jpeg') center center / cover no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.landing-content {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

#landing-logo {
    width: 150px;
    height: auto;
    margin-bottom: 30px;
    animation: logoFloat 2s ease-in-out infinite;
}

.landing-content h1 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #333;
}

.landing-content p {
    font-size: 18px;
    margin: 15px 0;
    color: #666;
}

#play-again {
    background: linear-gradient(135deg, #56AFFF 0%, #2E5BFF 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(86, 175, 255, 0.3);
    font-weight: bold;
}

#play-again:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(86, 175, 255, 0.4);
    background: linear-gradient(135deg, #2E5BFF 0%, #56AFFF 100%);
}

.hidden {
    display: none !important;
}

/* Hit Effect */
.hit-effect {
    animation: hitFlash 0.3s ease;
}

@keyframes hitFlash {
    0% { filter: brightness(1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4)); }
    50% { filter: brightness(2) hue-rotate(90deg) drop-shadow(0 8px 16px rgba(86, 175, 255, 0.8)); }
    100% { filter: brightness(1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4)); }
}

@keyframes targetPulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
}

/* Professional Game UI Enhancements */
.score-popup {
    position: fixed;
    color: #00ff00;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
    animation: hitIndicator 1s ease-out forwards;
    text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00;
}

.miss-popup {
    position: fixed;
    color: #ff4444;
    font-size: 20px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
    animation: missIndicator 1s ease-out forwards;
    text-shadow: 0 0 10px #ff4444, 0 0 20px #ff4444;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1.5);
    }
}

@keyframes missIndicator {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(1.2);
    }
}

/* Enhanced preloader with professional loading animation */
#preloader {
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 50%, #333333 100%);
}

#loading-bar {
    position: relative;
    overflow: visible;
}

#loading-progress {
    position: relative;
    background: linear-gradient(90deg, #fff, #56AFFF, #fff);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Game title/logo glow effect */
#logo {
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% {
        filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    }
    50% {
        filter: drop-shadow(0 4px 16px rgba(86, 175, 255, 0.4)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    }
}

/* Counter enhancement with pulsing effect on hit */
#counter.hit-counter {
    animation: counterPulse 0.3s ease;
}

@keyframes counterPulse {
    0% { transform: translateX(-50%) scale(1); }
    50% { 
        transform: translateX(-50%) scale(1.1);
        box-shadow: 0 12px 40px rgba(86, 175, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.2);
        border-color: rgba(86, 175, 255, 0.8);
    }
    100% { transform: translateX(-50%) scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #preloader-logo {
        width: 150px;
    }
    
    #loading-text {
        font-size: 20px;
    }
    
    #loading-bar {
        width: 250px;
    }
    
    #logo {
        width: 50%;
        max-width: 250px;
        top: max(30px, env(safe-area-inset-top, 30px));
        left: 15px;
    }
    
    
    #counter {
        font-size: 18px;
        padding: 10px 20px;
        top: max(120px, env(safe-area-inset-top, 120px));
        border-radius: 20px;
    }
    
    #bullet-counter {
        font-size: 16px;
        padding: 8px 18px;
        top: max(170px, env(safe-area-inset-top, 170px));
        border-radius: 18px;
    }
    
    #character {
        width: 100px;
        height: 100px;
    }
    
    #target-cursor {
        width: 40px;
        height: 40px;
    }
    
    #instructions {
        font-size: 14px;
        padding: 12px 20px;
        bottom: max(80px, env(safe-area-inset-bottom, 80px));
        max-width: 90%;
        border-radius: 12px;
    }
    
    .landing-content {
        padding: 30px;
        margin: 20px;
    }
    
    #landing-logo {
        width: 120px;
    }
    
    .landing-content h1 {
        font-size: 28px;
    }
    
    .landing-content p {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #preloader-logo {
        width: 120px;
    }
    
    #loading-text {
        font-size: 18px;
    }
    
    #loading-bar {
        width: 200px;
    }
    
    #logo {
        width: 50%;
        max-width: 300px;
        top: max(40px, env(safe-area-inset-top, 40px));
        left: 10px;
    }
    
    
    #counter {
        font-size: 16px;
        padding: 8px 16px;
        top: max(130px, env(safe-area-inset-top, 130px));
        border-radius: 18px;
    }
    
    #bullet-counter {
        font-size: 14px;
        padding: 6px 14px;
        top: max(175px, env(safe-area-inset-top, 175px));
        border-radius: 16px;
    }
    
    #character {
        width: 80px;
        height: 80px;
    }
    
    #instructions {
        font-size: 12px;
        padding: 8px 12px;
        bottom: max(100px, env(safe-area-inset-bottom, 100px));
        max-width: 95%;
        line-height: 1.3;
    }
    
    .landing-content {
        padding: 20px;
        margin: 15px;
    }
    
    #landing-logo {
        width: 100px;
    }
    
    .landing-content h1 {
        font-size: 24px;
    }
    
    .landing-content p {
        font-size: 14px;
    }
}

/* iPhone specific adjustments */
@media (max-width: 430px) and (max-height: 932px) {
    #logo {
        width: 50%;
        max-width: 280px;
        top: max(50px, env(safe-area-inset-top, 50px));
        left: 8px;
    }
    
    
    #counter {
        top: max(140px, env(safe-area-inset-top, 140px));
    }
    
    #bullet-counter {
        top: max(185px, env(safe-area-inset-top, 185px));
    }
    
    #instructions {
        bottom: max(120px, env(safe-area-inset-bottom, 120px));
    }
}
