* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a5c1a 0%, #2d8a4e 50%, #1a5c1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: white;
    padding: 40px;
    max-width: 400px;
    width: 90%;
}

.loading-logo {
    display: block;
    max-width: 180px;
    max-height: 60px;
    margin: 0 auto 20px auto;
    border-radius: 10px;
    box-shadow: 0 3px 20px rgba(0, 0, 0, 0.4);
    object-fit: contain;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.85; }
}

.loading-title {
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: loadingFade 2s ease-in-out infinite;
}

@keyframes loadingFade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.loading-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffc107, #ff9800, #ffc107);
    background-size: 200% 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    animation: loadingBarShine 1s linear infinite;
}

@keyframes loadingBarShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-text {
    font-size: 16px;
    margin-bottom: 20px;
    opacity: 0.9;
    font-weight: 500;
}

.loading-tips {
    font-size: 13px;
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 16px;
    border-radius: 8px;
    display: inline-block;
    animation: loadingTipFade 3s ease-in-out infinite;
}

@keyframes loadingTipFade {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Bouncing soccer ball loader */
.loading-ball {
    display: inline-block;
    font-size: 40px;
    animation: loadingBallBounce 0.6s ease-in-out infinite alternate;
    margin-bottom: 10px;
}

@keyframes loadingBallBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-15px); }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a5c1a 0%, #2d8a4e 50%, #1a5c1a 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    background: #2e7d32;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 3px solid #1b5e20;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 15px;
    color: white;
}

.game-logo {
    display: block;
    max-width: 200px;
    max-height: 60px;
    margin: 0 auto 8px auto;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    object-fit: contain;
}

header h1 {
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

#scoreboard {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    font-size: 36px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 30px;
    border-radius: 15px;
    display: inline-flex;
    margin: 0 auto;
}

.score {
    min-width: 40px;
    text-align: center;
}

.score-divider {
    color: rgba(255, 255, 255, 0.7);
}

#timer {
    margin-top: 8px;
    font-size: 20px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 16px;
    border-radius: 10px;
    display: inline-block;
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    border-radius: 12px;
    background: #4caf50;
    cursor: none;
    border: 3px solid #1b5e20;
    width: 100%;
    max-width: 800px;
    height: auto;
    touch-action: none;
}

#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    color: white;
}

.instructions {
    font-size: 14px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
}

button {
    background: #ffc107;
    color: #1b5e20;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

button:active {
    transform: scale(0.95);
}

/* Goal overlay */
#goal-overlay,
#gameover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
    z-index: 10;
}

#goal-overlay:not(.hidden) ~ #gameover-overlay:not(.hidden) {
    display: none;
}

.hidden {
    display: none !important;
}

.goal-message,
.gameover-message {
    text-align: center;
    color: white;
    background: linear-gradient(135deg, #1b5e20, #388e3c);
    padding: 40px 60px;
    border-radius: 20px;
    border: 3px solid #ffc107;
    box-shadow: 0 0 60px rgba(255, 193, 7, 0.3);
}

.goal-message h2,
.gameover-message h2 {
    font-size: 48px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

.goal-message p,
.gameover-message p {
    font-size: 22px;
    margin-bottom: 20px;
}

.goal-message button,
.gameover-message button {
    font-size: 18px;
    padding: 12px 36px;
    background: #ffc107;
}

/* Responsive */
@media (max-width: 600px) {
    #game-container {
        padding: 10px;
        border-radius: 12px;
    }

    header h1 {
        font-size: 20px;
    }

    #scoreboard {
        font-size: 28px;
        padding: 6px 20px;
        gap: 12px;
    }

    #timer {
        font-size: 16px;
    }

    .instructions {
        font-size: 11px;
        padding: 6px 12px;
    }

    button {
        padding: 8px 16px;
        font-size: 14px;
    }

    .goal-message,
    .gameover-message {
        padding: 30px 40px;
    }

    .goal-message h2,
    .gameover-message h2 {
        font-size: 32px;
    }

    .goal-message p,
    .gameover-message p {
        font-size: 18px;
    }
}