/* Xmas Pong - Christmas Theme */
#xmas-pong-game {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 700px;
    margin: 0 auto;
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    background: #0c1445;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* MOBILE: Full screen on mobile devices */
@media (max-width: 768px) {
    #xmas-pong-game {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
        max-height: none;
    }
}

.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    z-index: 10;
}

.game-screen.active {
    display: flex;
}

/* Winter Background with Snow */
.winter-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0c1445 0%, #1a237e 50%, #311b92 100%);
    overflow: hidden;
    z-index: -1;
}

.winter-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 64, 129, 0.3) 0%, transparent 50%);
    animation: northernLights 8s ease-in-out infinite alternate;
}

@keyframes northernLights {
    0% { opacity: 0.7; filter: hue-rotate(0deg); }
    100% { opacity: 1; filter: hue-rotate(45deg); }
}

/* Snowflakes */
.snowflake {
    position: absolute;
    top: -10px;
    color: white;
    font-size: 1em;
    animation: snowfall linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes snowfall {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* Game Title */
.game-title {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 2rem;
    text-shadow: 
        0 0 10px #00bcd4,
        0 0 20px #00bcd4,
        0 0 30px #00bcd4;
    background: linear-gradient(45deg, #4fc3f7, #e1f5fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 80%;
    max-width: 250px;
}

.menu-btn {
    padding: 1rem 1.5rem;
    font-size: 1.1em;
    font-weight: bold;
    background: linear-gradient(45deg, #d32f2f, #f44336);
    border: none;
    border-radius: 25px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 50px;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

/* MOBILE: Larger touch targets */
@media (max-width: 768px) {
    .menu-btn {
        min-height: 55px;
        font-size: 1.1em;
        padding: 1rem 1.5rem;
    }
    
    .game-title {
        font-size: 2em;
        margin-bottom: 2rem;
    }
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

.menu-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.back-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 0.8rem 1.2rem;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #4fc3f7;
    border-radius: 25px;
    color: white;
    cursor: pointer;
    z-index: 100;
}

/* MOBILE: Larger back button */
@media (max-width: 768px) {
    .back-btn {
        padding: 0.9rem 1.3rem;
        font-size: 1em;
        min-width: 70px;
    }
}

/* Game Canvas */
#xmas-game-canvas-container {
    position: relative;
    width: 100%;
    height: calc(100% - 60px);
    margin-top: 60px;
}

#xmas-game-canvas {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0c1445 0%, #1a237e 50%, #311b92 100%);
    display: block;
}

/* HUD Display - FIXED POSITIONING */
.hud {
    position: absolute;
    top: 70px; /* Move below the menu button */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    font-size: 1.1em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 0 0 10px 10px;
}

/* MOBILE: Larger HUD text */
@media (max-width: 768px) {
    .hud {
        font-size: 1.1em;
        padding: 10px 15px;
        top: 70px;
    }
}

.hud .score, .hud .lives, .hud .level {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud .score::before {
    content: "🏆";
    font-size: 1.1em;
}

.hud .lives::before {
    content: "❤️";
    font-size: 1.1em;
}

.hud .level::before {
    content: "⭐";
    font-size: 1.1em;
}

/* Game Over Screen - COMPACT DESIGN */
#xmas-game-over {
    justify-content: flex-start;
    padding: 60px 15px 20px 15px;
    overflow-y: auto;
}

/* MOBILE: Better fit for game over screen */
@media (max-width: 768px) {
    #xmas-game-over {
        padding: 50px 10px 15px 10px;
        justify-content: flex-start;
    }
}

#xmas-game-over h2 {
    font-size: 2em;
    color: #f44336;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

/* MOBILE: Smaller game over title */
@media (max-width: 768px) {
    #xmas-game-over h2 {
        font-size: 1.6em;
        margin-bottom: 0.3rem;
    }
}

.final-score, .final-level {
    font-size: 1.1em;
    margin-bottom: 0.5rem;
}

/* MOBILE: Smaller final score text */
@media (max-width: 768px) {
    .final-score, .final-level {
        font-size: 0.95em;
        margin-bottom: 0.3rem;
    }
}

/* Score Submission Form - COMPACT DESIGN */
.score-form {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 12px;
    margin: 0.3rem 0;
    width: 90%;
    max-width: 350px;
    backdrop-filter: blur(10px);
}

/* MOBILE: Better form sizing */
@media (max-width: 768px) {
    .score-form {
        width: 95%;
        padding: 0.8rem;
        margin: 0.2rem 0;
        max-width: 320px;
    }
}

.score-form h3 {
    color: #ffffff;
    margin-bottom: 0.8rem;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* MOBILE: Smaller form title */
@media (max-width: 768px) {
    .score-form h3 {
        font-size: 1em;
        margin-bottom: 0.6rem;
    }
}

.form-group {
    margin-bottom: 0.6rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: bold;
    color: #ffffff;
    font-size: 0.9em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* MOBILE: Larger form labels */
@media (max-width: 768px) {
    .form-group label {
        font-size: 0.95em;
        margin-bottom: 0.4rem;
        color: #ffffff;
        font-weight: 600;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    }
}

.form-group input {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid #4fc3f7;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    font-size: 0.9em;
    box-sizing: border-box;
}

/* MOBILE: Larger form inputs */
@media (max-width: 768px) {
    .form-group input {
        padding: 0.7rem;
        font-size: 0.95em;
        min-height: 40px;
        background: rgba(255, 255, 255, 0.98);
    }
}

.form-group input:focus {
    outline: none;
    border-color: #ffeb3b;
    box-shadow: 0 0 8px rgba(255, 235, 59, 0.5);
}

.form-group small {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.7em;
    color: #ffffff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

/* MOBILE: Better small text visibility */
@media (max-width: 768px) {
    .form-group small {
        font-size: 0.75em;
        color: #ffffff;
        text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    }
}

.form-buttons {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
}

.form-buttons .menu-btn {
    flex: 1;
    min-height: 35px;
    padding: 0.7rem 0.8rem;
    font-size: 0.9em;
}

/* MOBILE: Larger form buttons */
@media (max-width: 768px) {
    .form-buttons {
        flex-direction: column;
        gap: 0.4rem;
        margin-top: 0.8rem;
    }
    
    .form-buttons .menu-btn {
        min-height: 45px;
        font-size: 1em;
        padding: 0.8rem 0.9rem;
    }
}

.submit-btn {
    background: linear-gradient(45deg, #4caf50, #8bc34a) !important;
}

.skip-btn {
    background: linear-gradient(45deg, #757575, #9e9e9e) !important;
}

.message {
    display: none;
    padding: 0.5rem;
    margin-top: 0.6rem;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.85em;
}

/* MOBILE: Better message visibility */
@media (max-width: 768px) {
    .message {
        padding: 0.6rem;
        margin-top: 0.7rem;
        font-size: 0.9em;
    }
}

.message.success {
    background: rgba(76, 175, 80, 0.2);
    border: 2px solid #4caf50;
    color: #c8e6c9;
}

.message.error {
    background: rgba(244, 67, 54, 0.2);
    border: 2px solid #f44336;
    color: #ffcdd2;
}

/* Hall of Fame */
#xmas-hall-of-fame h2 {
    font-size: 2em;
    margin-bottom: 1rem;
    color: #4caf50;
}

.leaderboard-controls {
    margin-bottom: 1rem;
}

.refresh-btn {
    padding: 0.5rem 1rem;
    background: rgba(76, 175, 80, 0.3);
    border: 2px solid #4caf50;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    font-size: 0.9em;
}

/* MOBILE: Larger refresh button */
@media (max-width: 768px) {
    .refresh-btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.95em;
        min-height: 40px;
    }
}

.refresh-btn:hover {
    background: rgba(76, 175, 80, 0.5);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#xmas-leaderboard {
    width: 95%;
    max-width: 450px;
    margin-bottom: 2rem;
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 50px 1fr 100px 60px 80px;
    gap: 0.5rem;
    align-items: center;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border-left: 4px solid #4caf50;
}

.leaderboard-item.rank-1 {
    background: rgba(255, 215, 0, 0.2);
    border-left-color: #ffd700;
}

.leaderboard-item.rank-2 {
    background: rgba(192, 192, 192, 0.2);
    border-left-color: #c0c0c0;
}

.leaderboard-item.rank-3 {
    background: rgba(205, 127, 50, 0.2);
    border-left-color: #cd7f32;
}

.rank {
    font-weight: bold;
    color: #ffeb3b;
    text-align: center;
}

.name {
    font-weight: bold;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.score {
    font-weight: bold;
    color: #4fc3f7;
    text-align: right;
}

.level {
    color: #ff9800;
    text-align: center;
    font-size: 0.9em;
}

.date {
    color: #bdbdbd;
    font-size: 0.8em;
    text-align: center;
}

.leaderboard-loading, .leaderboard-error, .leaderboard-empty {
    padding: 2rem;
    text-align: center;
    color: #bdbdbd;
    font-style: italic;
}

/* How to Play - SCROLLABLE DESIGN */
#xmas-how-to-play {
    justify-content: flex-start;
    padding-top: 70px;
    padding-bottom: 20px;
}

#xmas-how-to-play h2 {
    font-size: 2em;
    margin-bottom: 1rem;
    color: #4fc3f7;
    position: sticky;
    top: 0;
    background: rgba(12, 20, 69, 0.9);
    padding: 10px 20px;
    border-radius: 10px;
    z-index: 10;
    width: 90%;
    max-width: 400px;
}

.instructions {
    width: 95%;
    max-width: 420px;
    max-height: 400px;
    overflow-y: auto;
    padding: 0 10px;
    margin-bottom: 1rem;
}

.instruction-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    border-radius: 10px;
    text-align: left;
    backdrop-filter: blur(5px);
}

.instruction-card h3 {
    color: #4caf50;
    margin-bottom: 0.4rem;
    border-bottom: 2px solid #4caf50;
    padding-bottom: 0.3rem;
    font-size: 1em;
}

.instruction-card p {
    margin: 0.3rem 0;
    font-size: 0.85em;
    line-height: 1.3;
}

.instruction-card strong {
    color: #ffeb3b;
}

/* MOBILE: Larger instruction text */
@media (max-width: 768px) {
    .instruction-card {
        padding: 0.9rem;
    }
    
    .instruction-card h3 {
        font-size: 1em;
    }
    
    .instruction-card p {
        font-size: 0.85em;
        line-height: 1.3;
    }
}

/* Scrollbar Styling for Instructions */
.instructions::-webkit-scrollbar {
    width: 6px;
}

.instructions::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.instructions::-webkit-scrollbar-thumb {
    background: #4fc3f7;
    border-radius: 3px;
}

.instructions::-webkit-scrollbar-thumb:hover {
    background: #29b6f6;
}

/* Scrollbar Styling */
#xmas-leaderboard::-webkit-scrollbar {
    width: 8px;
}

#xmas-leaderboard::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#xmas-leaderboard::-webkit-scrollbar-thumb {
    background: #4fc3f7;
    border-radius: 4px;
}

#xmas-leaderboard::-webkit-scrollbar-thumb:hover {
    background: #29b6f6;
}

/* Responsive fixes for laptops and desktops */
#xmas-pong-game {
    height: 80vh; /* Use viewport height instead of fixed pixels */
    max-height: 700px; /* But don't exceed the original design height */
    min-height: 500px; /* Ensure it doesn't get too small on mobile */
}

/* Adjust canvas container for better proportions */
#xmas-game-canvas-container {
    height: calc(100% - 80px); /* More balanced spacing */
    margin-top: 60px;
}

/* Media queries for different screen sizes */
@media (max-height: 800px) {
    #xmas-pong-game {
        height: 75vh;
        max-height: 600px;
    }
    
    /* Adjust How to Play for smaller screens */
    #xmas-how-to-play {
        padding-top: 60px;
    }
    
    .instructions {
        max-height: 350px;
    }
}

@media (max-height: 700px) {
    #xmas-pong-game {
        height: 70vh;
        max-height: 550px;
    }
    
    .game-title {
        font-size: 1.8em;
        margin-bottom: 1.5rem;
    }
    
    .menu-btn {
        padding: 0.8rem 1.2rem;
        min-height: 45px;
        font-size: 1em;
    }
    
    .hud {
        top: 65px;
        font-size: 1em;
        padding: 8px 15px;
    }
    
    /* Compact game-over for smaller screens */
    #xmas-game-over h2 {
        font-size: 1.8em;
    }
    
    .final-score, .final-level {
        font-size: 1em;
    }
    
    .score-form {
        padding: 0.9rem;
    }
    
    .score-form h3 {
        font-size: 1em;
    }
    
    /* Adjust How to Play for smaller screens */
    #xmas-how-to-play {
        padding-top: 50px;
    }
    
    .instructions {
        max-height: 300px;
    }
    
    .instruction-card {
        padding: 0.7rem;
        margin-bottom: 0.6rem;
    }
    
    .instruction-card h3 {
        font-size: 0.95em;
    }
    
    .instruction-card p {
        font-size: 0.8em;
    }
}

@media (max-height: 600px) {
    #xmas-pong-game {
        height: 65vh;
        max-height: 500px;
    }
    
    .game-title {
        font-size: 1.6em;
        margin-bottom: 1rem;
    }
    
    .hud {
        top: 60px;
        font-size: 0.9em;
        padding: 6px 12px;
    }
    
    .back-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9em;
    }
    
    /* Ultra-compact game-over for very small screens */
    #xmas-game-over {
        padding: 40px 10px 15px 10px;
    }
    
    #xmas-game-over h2 {
        font-size: 1.6em;
        margin-bottom: 0.3rem;
    }
    
    .final-score, .final-level {
        font-size: 0.9em;
        margin-bottom: 0.3rem;
    }
    
    .score-form {
        padding: 0.7rem;
        margin: 0.2rem 0;
    }
    
    .score-form h3 {
        font-size: 0.9em;
        margin-bottom: 0.6rem;
    }
    
    .form-group {
        margin-bottom: 0.5rem;
    }
    
    .form-group input {
        padding: 0.5rem;
        font-size: 0.85em;
    }
    
    .form-buttons {
        margin-top: 0.7rem;
        gap: 0.4rem;
    }
    
    .form-buttons .menu-btn {
        min-height: 32px;
        padding: 0.5rem 0.7rem;
        font-size: 0.85em;
    }
    
    /* Ultra-compact How to Play for very small screens */
    #xmas-how-to-play {
        padding-top: 40px;
        padding-bottom: 10px;
    }
    
    #xmas-how-to-play h2 {
        font-size: 1.6em;
        padding: 8px 15px;
    }
    
    .instructions {
        max-height: 250px;
        padding: 0 5px;
    }
    
    .instruction-card {
        padding: 0.6rem;
        margin-bottom: 0.5rem;
    }
    
    .instruction-card h3 {
        font-size: 0.9em;
        margin-bottom: 0.3rem;
    }
    
    .instruction-card p {
        font-size: 0.75em;
        margin: 0.2rem 0;
    }
}

/* For very tall screens */
@media (min-height: 900px) {
    #xmas-pong-game {
        height: 70vh; /* Don't make it too tall on large screens */
    }
    
    .instructions {
        max-height: 450px;
    }
}

/* Ensure game screens stack properly on all devices */
.game-screen {
    padding: 20px 15px;
    box-sizing: border-box;
}

/* Make leaderboard scrollable on smaller screens */
#xmas-leaderboard {
    max-height: 40vh;
    overflow-y: auto;
}

/* MOBILE: Extra small screen optimizations */
@media (max-height: 500px) {
    #xmas-pong-game {
        height: 100vh;
        min-height: 400px;
    }
    
    #xmas-game-over {
        padding: 30px 8px 10px 8px;
    }
    
    .score-form {
        padding: 0.6rem;
        margin: 0.1rem 0;
    }
    
    .form-buttons {
        margin-top: 0.5rem;
    }
    
    .form-buttons .menu-btn {
        min-height: 30px;
        padding: 0.4rem 0.6rem;
    }
}