/* ========================================
   ENDLESS RUNNER GAME - STYLES
   ======================================== */

* {
    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, #1a1a2e 0%, #16213e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: 20px;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
    border: 6px solid rgba(52, 152, 219, 0.2);
    border-top: 6px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h2 {
    color: #3498db;
    font-size: 32px;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.loading-bar {
    width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin: 0 auto 15px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #3498db 0%, #2ecc71 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
}

.loading-content p {
    color: #bdc3c7;
    font-size: 16px;
    margin-top: 10px;
}

/* ========================================
   BODY & GENERAL STYLES
   ======================================== */

body {
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
}

/* ========================================
   GAME CONTAINER
   ======================================== */

#game-container {
    position: relative;
    width: 100%;
    max-width: 1400px;
    height: 700px;
    margin: 0 auto;
    overflow: hidden;
    border: 4px solid #16213e;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* ========================================
   SCROLLING BACKGROUND
   ======================================== */

#background {
    position: absolute;
    width: 200%;
    height: 100%;
    background-image: url('assets/bg.jpg');
    background-size: 50% 100%;
    background-repeat: repeat-x;
    animation: scrollBackground 10s linear infinite;
    z-index: 0;
}

@keyframes scrollBackground {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Pause background animation when game is paused */
#background.paused {
    animation-play-state: paused;
}

/* ========================================
   PLAYER CHARACTER
   ======================================== */

#player {
    position: absolute;
    width: 120px;
    height: 160px;
    left: 120px;
    bottom: 90px;
    z-index: 10;
    transition: transform 0.1s;
}

#player img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Player jump animation */
#player.jumping {
    transform: rotate(-5deg);
}

/* ========================================
   OBSTACLES (CSS ONLY - NO IMAGES)
   ======================================== */

.obstacle {
    position: absolute;
    bottom: 90px;
    z-index: 5;
}

/* Spike obstacle */
.obstacle.spike {
    width: 80px;
    height: 100px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

/* Box obstacle */
.obstacle.box {
    width: 90px;
    height: 90px;
    background: linear-gradient(145deg, #8e44ad 0%, #6c3483 100%);
    border: 3px solid #5b2c6f;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(142, 68, 173, 0.4);
}

/* Tall barrier obstacle */
.obstacle.barrier {
    width: 50px;
    height: 140px;
    background: linear-gradient(180deg, #e67e22 0%, #d35400 100%);
    border-radius: 5px 5px 0 0;
    box-shadow: 0 5px 15px rgba(230, 126, 34, 0.4);
}

.obstacle.barrier::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Double spike obstacle */
.obstacle.double-spike {
    width: 120px;
    height: 80px;
    background: transparent;
}

.obstacle.double-spike::before,
.obstacle.double-spike::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 80px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.obstacle.double-spike::before {
    left: 0;
}

.obstacle.double-spike::after {
    right: 0;
}

/* ========================================
   COLLECTIBLE ITEMS
   ======================================== */

.collectible {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 5;
    animation: float 1s ease-in-out infinite;
}

.collectible img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Collected animation */
.collectible.collected {
    animation: collect 0.3s ease-out forwards;
}

@keyframes collect {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ========================================
   SCORE DISPLAY
   ======================================== */

#score-display {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    z-index: 100;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

#score-display span {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border-radius: 20px;
}

/* ========================================
   GAME OVER SCREEN
   ======================================== */

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#game-over.hidden {
    display: none;
}

#sad-image {
    width: 200px;
    height: 200px;
    object-fit: contain;
    margin-bottom: 15px;
}

#game-over h1 {
    color: #e74c3c;
    font-size: 42px;
    margin-bottom: 15px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

#game-over p {
    color: #fff;
    font-size: 20px;
    margin-bottom: 10px;
}

#game-over .all-time-record {
    color: #f39c12;
    font-weight: bold;
    font-size: 22px;
    margin-top: 15px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#replay-btn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(145deg, #27ae60 0%, #1e8449 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 20px rgba(39, 174, 96, 0.4);
}

#replay-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.6);
}

/* Social Buttons Container */
.social-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

/* WhatsApp Share Button */
#share-whatsapp-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(145deg, #25D366 0%, #128C7E 100%);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

#share-whatsapp-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
}

/* Contact Moosa Button */
#contact-moosa-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(145deg, #9b59b6 0%, #8e44ad 100%);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.4);
}

#contact-moosa-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.6);
}

/* ========================================
   START SCREEN
   ======================================== */

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#start-screen.hidden {
    display: none;
}

#start-screen h1 {
    color: #3498db;
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

#start-screen p {
    color: #fff;
    font-size: 18px;
    margin-bottom: 10px;
}

#start-btn {
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(145deg, #3498db 0%, #2980b9 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 20px rgba(52, 152, 219, 0.4);
}

#start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.6);
}

/* ========================================
   GROUND LINE
   ======================================== */

#game-container::after {
    content: '';
    position: absolute;
    bottom: 88px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 50%, #2c3e50 100%);
    z-index: 1;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablets and smaller laptops */
@media screen and (max-width: 1440px) {
    #game-container {
        max-width: 1200px;
        height: 600px;
    }
}

/* Tablets */
@media screen and (max-width: 1024px) {
    #game-container {
        max-width: 900px;
        height: 450px;
    }
    
    #player {
        width: 90px;
        height: 120px;
        left: 90px;
        bottom: 67px;
    }
    
    .obstacle.spike {
        width: 60px;
        height: 75px;
    }
    
    .obstacle.box {
        width: 68px;
        height: 68px;
    }
    
    .obstacle.barrier {
        width: 38px;
        height: 105px;
    }
    
    .obstacle.double-spike {
        width: 90px;
        height: 60px;
    }
    
    .obstacle.double-spike::before,
    .obstacle.double-spike::after {
        width: 38px;
        height: 60px;
    }
    
    .collectible {
        width: 60px;
        height: 60px;
    }
    
    .obstacle {
        bottom: 67px;
    }
    
    #game-container::after {
        bottom: 66px;
    }
    
    #score-display {
        font-size: 16px;
    }
    
    #game-over h1, #start-screen h1 {
        font-size: 38px;
    }
    
    #sad-image {
        width: 150px;
        height: 150px;
    }
}

/* Mobile devices (landscape) */
@media screen and (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    #game-container {
        max-width: 100%;
        height: 400px;
        border-radius: 5px;
        border-width: 3px;
    }
    
    #player {
        width: 70px;
        height: 90px;
        left: 60px;
        bottom: 50px;
    }
    
    .obstacle.spike {
        width: 45px;
        height: 56px;
    }
    
    .obstacle.box {
        width: 50px;
        height: 50px;
    }
    
    .obstacle.barrier {
        width: 28px;
        height: 78px;
    }
    
    .obstacle.double-spike {
        width: 68px;
        height: 45px;
    }
    
    .obstacle.double-spike::before,
    .obstacle.double-spike::after {
        width: 28px;
        height: 45px;
    }
    
    .collectible {
        width: 45px;
        height: 45px;
    }
    
    .obstacle {
        bottom: 50px;
    }
    
    #game-container::after {
        bottom: 49px;
        height: 3px;
    }
    
    #score-display {
        font-size: 14px;
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    #score-display span {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    #game-over h1 {
        font-size: 32px;
        margin-bottom: 10px;
    }
    
    #game-over p {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    #replay-btn {
        padding: 12px 30px;
        font-size: 18px;
        margin-top: 15px;
    }
    
    #sad-image {
        width: 120px;
        height: 120px;
        margin-bottom: 10px;
    }
    
    .social-buttons {
        flex-direction: column;
        gap: 10px;
        margin-top: 12px;
    }
    
    #share-whatsapp-btn,
    #contact-moosa-btn {
        padding: 10px 25px;
        font-size: 14px;
        width: 100%;
        max-width: 280px;
    }
    
    #start-screen h1 {
        font-size: 36px;
        margin-bottom: 15px;
    }
    
    #start-screen p {
        font-size: 15px;
        margin-bottom: 8px;
        padding: 0 20px;
    }
    
    #start-btn {
        padding: 12px 35px;
        font-size: 20px;
        margin-top: 20px;
    }
}

/* Mobile devices (portrait) */
@media screen and (max-width: 480px) {
    #game-container {
        height: 350px;
    }
    
    #player {
        width: 55px;
        height: 70px;
        left: 50px;
        bottom: 40px;
    }
    
    .obstacle.spike {
        width: 35px;
        height: 44px;
    }
    
    .obstacle.box {
        width: 40px;
        height: 40px;
    }
    
    .obstacle.barrier {
        width: 22px;
        height: 62px;
    }
    
    .obstacle.double-spike {
        width: 54px;
        height: 36px;
    }
    
    .obstacle.double-spike::before,
    .obstacle.double-spike::after {
        width: 22px;
        height: 36px;
    }
    
    .collectible {
        width: 36px;
        height: 36px;
    }
    
    .obstacle {
        bottom: 40px;
    }
    
    #game-container::after {
        bottom: 39px;
    }
    
    #score-display {
        font-size: 12px;
        top: 8px;
        left: 8px;
        right: 8px;
    }
    
    #score-display span {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    #game-over h1 {
        font-size: 28px;
    }
    
    #game-over p {
        font-size: 14px;
    }
    
    #replay-btn {
        padding: 10px 25px;
        font-size: 16px;
    }
    
    #sad-image {
        width: 90px;
        height: 90px;
    }
    
    #share-whatsapp-btn,
    #contact-moosa-btn {
        padding: 9px 20px;
        font-size: 13px;
    }
    
    #start-screen h1 {
        font-size: 30px;
    }
    
    #start-screen p {
        font-size: 13px;
    }
    
    #start-btn {
        padding: 10px 30px;
        font-size: 18px;
    }
}

/* Very small mobile devices */
@media screen and (max-width: 360px) {
    #game-container {
        height: 300px;
    }
    
    #game-over h1 {
        font-size: 24px;
    }
    
    #start-screen h1 {
        font-size: 26px;
    }
}
