/* styles.css */

/* Global Styles */
body {
    background-color: #1a1a2e;
    color: #fff;
    text-align: center;
    font-family: 'Press Start 2P', cursive;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Game Title with Glowing Animation */
h1 {
    font-size: 48px;
    margin: 20px 0;
    text-shadow: 2px 2px #0f3460;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 5px #fff,
                     0 0 10px #fff,
                     0 0 15px #e94560,
                     0 0 20px #e94560,
                     0 0 35px #e94560,
                     0 0 40px #e94560,
                     0 0 50px #e94560;
    }
    to {
        text-shadow: 0 0 10px #fff,
                     0 0 20px #fff,
                     0 0 30px #e94560,
                     0 0 40px #e94560,
                     0 0 70px #e94560,
                     0 0 80px #e94560,
                     0 0 100px #e94560;
    }
}

/* Main Game Area Layout */
#gameArea {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

/* Scoreboard Styling */
#scoreboard {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    max-width: 800px;
    text-align: center;
    padding: 10px 0;
    box-sizing: border-box;
    position: relative;
    flex-wrap: wrap;
    background-color: transparent;
    margin-bottom: 10px;
}

.score-item {
    flex: 1;
    min-width: 80px;
    margin: 5px 0;
}

.score-item h3 {
    margin: 0;
    color: #e94560;
    font-size: 16px;
}

.score-item p {
    margin: 5px 0 0 0;
    font-size: 14px;
}

/* Controls Instructions Styling */
#controlsContainer {
    margin: 20px;
    text-align: left;
    font-size: 14px;
    border: 4px solid #0f3460;
    padding: 20px;
    border-radius: 10px;
    background-color: #16213e;
    box-shadow: 0 0 20px rgba(15, 52, 96, 0.5);
    max-width: 300px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* Main Container: Game and Controls */
#mainContainer {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    flex: 1;
}

/* Game Container */
#gameContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex: 1 1 auto;
    margin: 0 auto;
    width: 100%;
    max-width: 800px;
    height: 100%;
}

/* Canvas Styling */
canvas {
    background-color: #16213e;
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    height: auto;
    touch-action: none; /* Prevent default touch behaviors */
}

/* Start/Restart Button Styling */
#startButton {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 10px 20px;
    background-color: #e94560;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    z-index: 5;
}

#startButton:hover {
    background-color: #ff6b6b;
}

/* Pause/Restart Button for Mobile */
#mobilePauseButton {
    display: none; /* Hidden by default, shown on mobile */
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 8px 16px;
    background-color: #e94560;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    z-index: 10;
}

#mobilePauseButton:hover {
    background-color: #ff6b6b;
}

/* Message Overlays Styling */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(26, 26, 46, 0.95);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(15, 52, 96, 0.7);
    z-index: 10;
    display: none; /* Hidden by default */
    text-align: center;
}

.overlay h2 {
    color: #e94560;
    margin-bottom: 20px;
    font-size: 16px;
}

.overlay button {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 8px 16px;
    background-color: #e94560;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.overlay button:hover {
    background-color: #ff6b6b;
}

/* Pause Overlay Styling */
#pauseOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 26, 46, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 0;
    display: none; /* Hidden by default */
    z-index: 10;
}

#pauseOverlay h2 {
    color: #e94560;
    margin-bottom: 20px;
    font-size: 16px;
}

/* Welcome Screen Styling */
#welcomeScreen {
    display: none; /* Hidden by default, will be shown only on mobile */
    text-align: center;
    padding: 20px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh; /* Full viewport height */
}

/* Ensure JimPong in the welcome screen has the same styling as the main header */
#welcomeScreen .gameTitle {
    font-size: 48px; /* Match the h1 font size */
    text-shadow: 2px 2px #0f3460; /* Match the glow effect shadow */
    animation: glow 2s ease-in-out infinite alternate; /* Apply the glow animation */
    color: #fff; /* Set text color to white, same as h1 */
}

/* Update Play button in the welcome screen to match the other buttons */
#welcomeScreen button {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 10px 20px;
    background-color: #e94560;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

/* Add hover effect for the Play button */
#welcomeScreen button:hover {
    background-color: #ff6b6b;
}


/* Mobile Specific Styles */
@media (max-width: 768px) {
    /* Show welcome screen on mobile */
    #welcomeScreen {
        display: flex;
    }

    /* Hide main game area and title initially on mobile */
    #gameArea,
    h1 {
        display: none;
    }

    /* Adjust h1 font size */
    h1 {
        font-size: 32px;
    }

    /* Hide controls instructions on all mobile devices */
    #controlsContainer {
        display: none !important; /* Use !important to ensure it's hidden on all mobile views */
    }

    /* Adjust scoreboard font sizes */
    .score-item h3 {
        font-size: 12px;
    }

    .score-item p {
        font-size: 10px;
    }

    /* Center the game area */
    #gameArea {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 100vh;
        width: 100%;
    }

    #mainContainer {
        justify-content: center;
        width: 100%;
    }

    #gameContainer {
        max-width: 100%;
        height: auto;
        aspect-ratio: 4 / 3; /* Maintain the aspect ratio of the game */
    }

    canvas {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* Show mobile pause button */
    #mobilePauseButton {
        display: block;
    }
}

/* Mobile Landscape Mode Styles */
@media (max-width: 768px) and (orientation: landscape) {
    /* Show main game area and title in landscape mode */
    #gameArea,
    h1 {
        display: flex;
    }

    /* Hide welcome screen in landscape mode */
    #welcomeScreen {
        display: none;
    }

    /* Adjust layout for landscape */
    #gameArea {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        height: 100vh;
    }

    #scoreboard {
        flex-direction: column;
        width: auto;
        height: 100%;
        justify-content: center;
        margin-right: 10px;
    }

    #mainContainer {
        flex: 0 1 auto;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #gameContainer {
        height: 100%;
        width: auto;
        max-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* Ensure the canvas maintains its aspect ratio */
    canvas {
        max-height: 100%;
        width: auto;
        height: auto;
    }

    /* Adjust mobile pause button position */
    #mobilePauseButton {
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
    }
}