/* ===== GENERAL STYLING ===== */

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #181825;
    color: #fff;
}

/* ===== WELCOME SCREEN ONLY ===== */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(ellipse at center, #23243a 0%, #181825 70%, #120532 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    gap: 32px;
    box-shadow: 0 0 60px 10px #4cc9f0a0;
    overflow: hidden;
    animation: welcomeFadeIn 0.8s ease-out;
}

@keyframes welcomeFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.welcome-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.18;
    background-image:
        repeating-linear-gradient(0deg, #4cc9f0 0px, #4cc9f0 6px, transparent 6px, transparent 64px),
        repeating-linear-gradient(90deg, #f72585 0px, #f72585 6px, transparent 6px, transparent 64px);
    background-size: 64px 64px, 64px 64px;
    background-repeat: repeat;
    animation: gridColorMove 8s linear infinite;
    pointer-events: none;
    box-shadow: 0 0 32px 8px #4cc9f0, 0 0 48px 16px #f72585;
    background-blend-mode: lighten;
}

@keyframes gridColorMove {
    0% {
        background-position: 0 0, 0 0;
        filter: hue-rotate(0deg);
    }
    50% {
        background-position: 32px 32px, 32px 32px;
        filter: hue-rotate(60deg);
    }
    100% {
        background-position: 64px 64px, 64px 64px;
        filter: hue-rotate(0deg);
    }
}

.welcome-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 60%, #181825 100%);
    opacity: 0.6;
    animation: none;
}

.welcome-screen h2 {
    font-size: 2.7rem;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 0 0 18px #4cc9f0, 0 0 32px #f72585;
    animation: titleBounce 1.5s infinite alternate;
    letter-spacing: 2px;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    position: relative;
    z-index: 1;
}

@keyframes titleBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

.welcome-screen h2 .pong-emoji {
    text-shadow: none !important;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    color: inherit;
    filter: none;
    font-size: 3.2rem;
    margin: 0 10px;
    vertical-align: middle;
    animation: emojiWobble 0.8s infinite alternate;
    transition: transform 0.2s;
    z-index: 1;
}

@keyframes emojiWobble {
    0%   { transform: rotate(-10deg) scale(1); }
    50%  { transform: rotate(10deg) scale(1.15); }
    100% { transform: rotate(-10deg) scale(1); }
}

.avatar-select-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    z-index: 2;
}

.avatar-select-label {
    font-size: 1.1rem;
    color: #4cc9f0;
    margin-bottom: 4px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px #23243a;
}

.avatar-options {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.avatar-option {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #23243a;
    border: 2.5px solid #4cc9f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 0 12px #4cc9f040;
    position: relative;
    user-select: none;
}

.avatar-option.selected,
.avatar-option:hover {
    border-color: #f72585;
    box-shadow: 0 0 18px #f7258580;
    transform: scale(1.18) rotate(-8deg);
}

.avatar-option::after {
    content: '';
    display: block;
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 0 #f72585;
    transition: box-shadow 0.2s;
}

.avatar-option.selected::after {
    box-shadow: 0 0 12px 4px #f7258580;
}

.profile-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 18px 0 0 0;
    font-size: 1.3rem;
    background: rgba(44, 45, 70, 0.7);
    border-radius: 12px;
    padding: 10px 22px;
    box-shadow: 0 0 12px #4cc9f0;
    color: #fff;
    z-index: 2;
    transition: all 0.3s;
}

.profile-avatar {
    font-size: 2.2rem;
    border-radius: 50%;
    background: #23243a;
    border: 2px solid #f72585;
    padding: 6px;
    box-shadow: 0 0 8px #f72585;
}

.profile-name {
    font-weight: bold;
    letter-spacing: 1px;
    font-size: 1.2rem;
}

#playerNameInput {
    padding: 14px 24px;
    width: 320px;
    border: 2px solid #4cc9f0;
    border-radius: 12px;
    background: rgba(44, 45, 70, 0.85);
    color: #fff;
    font-size: 1.1rem;
    text-align: center;
    box-shadow: 0 0 8px #4cc9f0;
    transition: all 0.3s ease;
    z-index: 1;
}

#playerNameInput:focus {
    outline: none;
    border-color: #f72585;
    box-shadow: 0 0 14px #f72585;
    background: rgba(44, 45, 70, 0.95);
}

.welcome-screen button {
    padding: 14px 36px;
    font-size: 1.2rem;
    background: linear-gradient(90deg, #4cc9f0 40%, #f72585 100%);
    color: #fff;
    border-radius: 30px;
    box-shadow: 0 0 12px #4cc9f0, 0 0 6px #f72585 inset;
    border: none;
    animation: buttonPulse 2s infinite;
    transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: bold;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 0 12px #4cc9f0, 0 0 6px #f72585 inset; }
    50% { box-shadow: 0 0 24px #f72585, 0 0 12px #4cc9f0 inset; }
}

.welcome-screen button:hover {
    background: linear-gradient(90deg, #4895ef 40%, #b5179e 100%);
    box-shadow: 0 0 18px #f72585, 0 0 8px #4cc9f0 inset;
    transform: scale(1.07) rotate(-2deg);
}

/* Hide elements utility */
.hidden {
    display: none !important;
}

/* ===== MAIN GAME PAGE STYLES ===== */
.main-game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding-top: 0; /* Remove extra top padding */
    margin-top: 18px; /* Small margin for breathing room */
    z-index: 1;
}

.main-game-container h1 {
    font-size: 2.2rem;
    margin-bottom: 18px;
    color: #fff;
    text-shadow: 0 0 8px #4cc9f0;
}

.score {
    font-size: 1.2rem;
    color: #fff;
    margin: 10px 0;
    text-align: center;
    letter-spacing: 1px;
    text-shadow: 0 0 8px #4cc9f0;
}

.game-controls {
    display: flex;
    gap: 18px;
    justify-content: center;
    margin: 18px 0;
}

canvas#gameCanvas {
    background: linear-gradient(135deg, #181825 60%, #23243a 100%);
    border: 3px solid #4cc9f0;
    border-radius: 18px;
    box-shadow: 0 0 32px #4cc9f0, 0 0 24px #f72585 inset;
    margin-bottom: 18px;
    transition: box-shadow 0.3s;
}

/* Modal Styles (How to Play) */
.modal-content {
    background: linear-gradient(135deg, #23243a 60%, #4cc9f0 100%);
    padding: 32px;
    border-radius: 18px;
    max-width: 500px;
    width: 92%;
    box-shadow: 0 0 40px #4cc9f0, 0 0 80px #f72585;
    border: 2.5px solid #f72585;
    position: relative;
    transform: translateY(-50px) scale(0.92);
    transition: transform 0.5s ease;
    color: #fff;
    overflow: hidden;
}

.modal.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-content h3 {
    font-size: 2rem;
    margin-bottom: 18px;
    color: #fff;
    text-align: center;
    text-shadow: 0 0 18px #4cc9f0, 0 0 32px #f72585;
    letter-spacing: 2px;
}

.modal-content ul {
    margin: 20px 0;
    padding-left: 0;
    list-style: none;
}

.modal-content li {
    margin-bottom: 16px;
    line-height: 1.7;
    padding: 12px 18px;
    border-radius: 10px;
    background: rgba(44, 45, 70, 0.85);
    border-left: 6px solid #f72585;
    font-size: 1.1rem;
    box-shadow: 0 0 8px #4cc9f0;
    transition: all 0.3s ease;
    position: relative;
}

.modal-content li::before {
    content: "🎮";
    margin-right: 10px;
    font-size: 1.2rem;
    vertical-align: middle;
}

.modal-content li:hover {
    transform: translateX(8px) scale(1.04);
    border-left: 6px solid #4cc9f0;
    background: rgba(76, 201, 240, 0.15);
}

#closeHowToPlayBtn, #closeHowToPlay {
    display: block;
    margin: 24px auto 0;
    padding: 12px 32px;
    background: linear-gradient(90deg, #4cc9f0, #f72585);
    border-radius: 30px;
    color: #fff;
    font-weight: bold;
    font-size: 1.1rem;
    border: none;
    box-shadow: 0 0 12px #4cc9f0;
    cursor: pointer;
    transition: background 0.3s, box-shadow 0.3s;
}

#closeHowToPlayBtn:hover, #closeHowToPlay:hover {
    background: linear-gradient(90deg, #4895ef, #b5179e);
    box-shadow: 0 0 18px #f72585;
    transform: scale(1.07);
}

.scoreboard {
    display: flex;
    justify-content: center;
    gap: 60px;
    margin: 0 0 16px 0; /* No top margin, less bottom margin */
    font-size: 1.3rem;
    background: rgba(44, 45, 70, 0.92);
    border-radius: 16px;
    box-shadow: 0 0 18px #4cc9f0;
    padding: 18px 40px;
    position: relative;
    top: 0;
}

.score-player, .score-ai {
    display: flex;
    align-items: center;
    gap: 14px;
}

.score-avatar {
    font-size: 2.1rem;
    border-radius: 50%;
    background: #23243a;
    border: 2px solid #f72585;
    padding: 4px 8px;
    box-shadow: 0 0 8px #f72585;
}

.score-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: #4cc9f0;
    letter-spacing: 1px;
    text-shadow: 0 0 8px #23243a;
}

.score-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    margin-left: 8px;
    text-shadow: 0 0 8px #f72585;
}

/* Interactive select dropdowns */
.game-controls select,
#difficulty,
#themeSelector {
    padding: 10px 18px;
    font-size: 1.05rem;
    border-radius: 18px;
    border: 2px solid #4cc9f0;
    background: linear-gradient(90deg, #23243a 60%, #4cc9f0 100%);
    color: #fff;
    font-weight: bold;
    box-shadow: 0 0 8px #4cc9f0;
    margin: 0 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.game-controls select:focus,
#difficulty:focus,
#themeSelector:focus {
    border-color: #f72585;
    box-shadow: 0 0 14px #f72585;
    outline: none;
}

/* Nicer buttons */
.game-controls button,
#pauseButton, #restartButton, #fullscreenButton {
    padding: 12px 28px;
    font-size: 1.1rem;
    background: linear-gradient(90deg, #4cc9f0 40%, #f72585 100%);
    color: #fff;
    border-radius: 24px;
    border: none;
    box-shadow: 0 0 12px #4cc9f0, 0 0 6px #f72585 inset;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    margin: 0 6px;
    transition: 
        background 0.3s, 
        box-shadow 0.3s, 
        transform 0.2s,
        filter 0.2s;
    position: relative;
    overflow: hidden;
}

.game-controls button:active,
#pauseButton:active, #restartButton:active, #fullscreenButton:active {
    filter: brightness(1.2) drop-shadow(0 0 8px #f72585);
    transform: scale(0.97);
}

.game-controls button:hover,
#pauseButton:hover, #restartButton:hover, #fullscreenButton:hover {
    background: linear-gradient(90deg, #4895ef 40%, #b5179e 100%);
    box-shadow: 0 0 18px #f72585, 0 0 8px #4cc9f0 inset;
    transform: scale(1.07) rotate(-2deg);
}

/* Game Over Screen - show winner/loser differently */
.game-over-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(44,45,70,0.95);
    z-index: 200;
    animation: fadeIn 0.6s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#gameOverMessage {
    font-size: 2.2rem;
    margin-bottom: 28px;
    color: #fff;
    text-align: center;
    text-shadow: 0 0 18px #4cc9f0, 0 0 32px #f72585;
    letter-spacing: 2px;
    padding: 18px 36px;
    border-radius: 16px;
    background: linear-gradient(90deg, #23243a 60%, #f72585 100%);
    box-shadow: 0 0 24px #f72585;
    border: 2px solid #4cc9f0;
}

.game-over-screen.winner #gameOverMessage {
    background: linear-gradient(90deg, #23243a 60%, #4cc9f0 100%);
    color: #4cc9f0;
    border-color: #f72585;
    box-shadow: 0 0 32px #4cc9f0;
}

.game-over-screen.loser #gameOverMessage {
    background: linear-gradient(90deg, #23243a 60%, #f72585 100%);
    color: #f72585;
    border-color: #4cc9f0;
    box-shadow: 0 0 32px #f72585;
}

/* Make Play Again button more vibrant and animated */
#playAgainButton {
    padding: 16px 40px;
    font-size: 1.25rem;
    background: linear-gradient(90deg, #f72585 40%, #4cc9f0 100%);
    color: #fff;
    border-radius: 32px;
    border: none;
    box-shadow: 0 0 18px #f72585, 0 0 10px #4cc9f0 inset;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    margin: 0 6px;
    transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
    position: relative;
    overflow: hidden;
    animation: buttonPulse 1.5s infinite;
}

#playAgainButton:hover {
    background: linear-gradient(90deg, #4895ef 40%, #b5179e 100%);
    box-shadow: 0 0 24px #4cc9f0, 0 0 14px #f72585 inset;
    transform: scale(1.09) rotate(-2deg);
}

/* Make Difficulty and Theme labels stylish */
.game-controls label[for="difficulty"],
.game-controls label[for="themeSelector"],
label[for="difficulty"],
label[for="themeSelector"] {
    font-size: 1.15rem;
    color: #4cc9f0;
    font-weight: bold;
    letter-spacing: 1px;
    margin-right: 10px;
    text-shadow: 0 0 10px #23243a, 0 0 8px #f72585;
    background: linear-gradient(90deg, #4cc9f0 60%, #f72585 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
    transition: text-shadow 0.3s;
    border-radius: 8px;
    padding: 2px 8px;
    display: inline-block;
}

.game-controls label[for="difficulty"]:hover,
.game-controls label[for="themeSelector"]:hover,
label[for="difficulty"]:hover,
label[for="themeSelector"]:hover {
    text-shadow: 0 0 18px #f72585, 0 0 12px #4cc9f0;
    background: linear-gradient(90deg, #f72585 60%, #4cc9f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

/* Ping pong ball and paddle SVG animation for welcome screen */
.welcome-screen .pong-animation {
    position: absolute;
    bottom: 40px;
    right: 60px;
    width: 120px;
    height: 80px;
    z-index: 2;
    pointer-events: none;
}

.welcome-screen .pong-ball {
    position: absolute;
    left: 70px;
    top: 18px;
    width: 28px;
    height: 28px;
    animation: pongBallBounce 1.2s cubic-bezier(.5,1.5,.5,1) infinite;
}

.welcome-screen .pong-paddle {
    position: absolute;
    left: 10px;
    top: 38px;
    width: 80px;
    height: 28px;
    animation: pongPaddleMove 1.2s cubic-bezier(.5,1.5,.5,1) infinite;
}

@keyframes pongBallBounce {
    0%   { transform: translateY(0) scale(1); }
    40%  { transform: translateY(-32px) scale(1.1); }
    60%  { transform: translateY(-32px) scale(1.1); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes pongPaddleMove {
    0%   { transform: rotate(-8deg) scale(1); }
    40%  { transform: rotate(8deg) scale(1.05); }
    60%  { transform: rotate(8deg) scale(1.05); }
    100% { transform: rotate(-8deg) scale(1); }
}

/* Add any other needed styles below... */