* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: auto;  /* Remove this line or change to 'auto' */
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    max-height: 100vh;
    margin: 0 auto;
    background-image: url('images/background.webp');
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    overflow: hidden;
    touch-action: pan-y; /* Allow vertical scrolling */
}

/* Fullscreen styles */
.game-container:fullscreen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    background-size: cover;
    background-position: center top; /* Allow top to be clipped */
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-container:-webkit-full-screen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    background-size: cover;
    background-position: center top;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-container:-moz-full-screen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    background-size: cover;
    background-position: center top;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-container:-ms-fullscreen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    background-size: cover;
    background-position: center top;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    background: transparent;
    border: 3px solid #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    touch-action: none; /* Prevent touch on canvas itself */
}

.game-container:fullscreen #gameCanvas,
.game-container:-webkit-full-screen #gameCanvas,
.game-container:-moz-full-screen #gameCanvas,
.game-container:-ms-fullscreen #gameCanvas {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    border-radius: 0;
    display: block;
}

.ui-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
    gap: 10px;
}

.lives-container, .score-container {
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.exit-fullscreen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: auto;
    transition: all 0.2s;
}

.exit-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.exit-fullscreen-btn:active {
    transform: scale(0.9);
}

.hearts {
    display: flex;
    gap: 5px;
}

.heart {
    font-size: 24px;
    color: #ff6b6b;
}

.mobile-controls {
    display: none;
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none;
    justify-content: center;
    gap: 40px;
    padding: 0 20px;
}

.arrow-btn {
    width: 60px;
    height: 60px;
    font-size: 30px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #333;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: all 0.1s;
    pointer-events: auto;
    position: relative;
    z-index: 1001;
    flex-shrink: 0;
}

.arrow-btn:active {
    transform: scale(0.9);
    background: rgba(200, 200, 200, 0.9);
}

.game-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    z-index: 20;
    min-width: 300px;
}

#startScreen {
    background: rgba(0, 0, 0, 0.7);
}

.game-screen h1 {
    margin-bottom: 20px;
    font-size: 2.5em;
    color: #ffd700;
}

.game-screen p {
    margin: 10px 0;
    font-size: 1.1em;
    line-height: 1.6;
}

.game-screen p.emphasized {
    color: #ffd700;
    font-size: 1.2em;
}

.start-btn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 1.2em;
    background: #2B6445;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

.start-btn.mobile-only {
    display: block;
    margin: 10px auto 0;
}

.start-btn:hover {
    background: #1f4a33;
}

.start-btn:active {
    transform: scale(0.95);
}

.fullscreen-btn {
    margin: 10px auto 0;
    padding: 12px 30px;
    font-size: 1em;
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    border: 2px solid #ffd700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    display: block;
}

.fullscreen-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffed4e;
}

.fullscreen-btn:active {
    transform: scale(0.95);
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
}

/* Game Info Section */
.game-info-section {
    transition: opacity 0.3s ease, max-height 0.3s ease;
    overflow: hidden;
}

/* High Scores Section */
.high-scores-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

/* External High Scores Section (outside game container) */
.high-scores-section.external {
    margin-top: 20px;
    padding: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    background: rgb(45 68 106);
    border-radius: 10px;
    border-top: none;
    margin-top: 20px;
}

.scores-toggle {
    font-size: 1.5em;
    color: #ffd700;
    margin-bottom: 15px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.scores-toggle:hover {
    color: #ffed4e;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.scores-container {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: scroll;
}

.scores-list {
    min-height: 60px;
    max-height: 300px;
    overflow-y: auto;
    margin: 0 auto;
    text-align: left;
}

.scores-list-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 5px 0;
    background: rgb(64 98 137);
    border-radius: 8px;
    border-left: 3px solid #ffd700;
    transition: background 0.2s;
    gap: 10px;
}

.score-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.score-rank {
    font-weight: bold;
    color: #ffd700;
    min-width: 30px;
    font-size: 1.1em;
}

.score-name {
    flex: 1;
    font-weight: bold;
    color: #ffd700;
    font-size: 1em;
    text-align: left;
    min-width: 100px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-value {
    flex: 1;
    text-align: center;
    font-weight: bold;
    font-size: 1.2em;
    color: #fff;
}

.score-date {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    min-width: 100px;
    text-align: right;
}

.loading-scores,
.no-scores,
.scores-error {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.scores-error {
    color: #ff6b6b;
}

#message {
    color: #fff;
    font-style: italic;
    text-align: center;
}

.name-entry-form {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.player-name-input {
    width: 100%;
    max-width: 300px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    font-size: 1em;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

.player-name-input::placeholder {
    color: #666;
    opacity: 0.7;
}

.player-name-input:focus {
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.4);
    background: rgba(255, 255, 255, 1);
}

.player-contact-input {
    width: 100%;
    max-width: 300px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    font-size: 1em;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

.player-contact-input::placeholder {
    color: #666;
    opacity: 0.7;
}

.player-contact-input:focus {
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.4);
    background: rgba(255, 255, 255, 1);
}

.contact-privacy-note {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    font-style: italic;
    text-align: center;
}

.submit-name-btn {
    padding: 10px 30px;
    font-size: 1em;
    background: #2B6445;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: bold;
}

.submit-name-btn:hover {
    background: #1f4a33;
}

.submit-name-btn:active {
    transform: scale(0.95);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
    }
    
    /* Portrait mode on mobile */
    @media (orientation: portrait) {
        .mobile-controls {
            bottom: 20px;
            top: auto;
            left: 0;
            right: 0;
            justify-content: center;
            gap: 40px;
            transform: none;
        }
    }
    
    /* Landscape mode on mobile */
    @media (orientation: landscape) {
        .mobile-controls {
            top: auto !important;
            bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
            left: 0 !important;
            right: 0 !important;
            justify-content: flex-start !important;
            padding: 0 !important;
            transform: none !important;
            position: fixed !important;
            gap: 0 !important;
        }
        
        .mobile-controls .left-arrow {
            position: fixed !important;
            left: max(20px, env(safe-area-inset-left, 20px)) !important;
            bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
            right: auto !important;
            z-index: 1001 !important;
            margin: 0 !important;
        }
        
        .mobile-controls .right-arrow {
            position: fixed !important;
            right: max(20px, env(safe-area-inset-right, 20px)) !important;
            bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
            left: auto !important;
            z-index: 1001 !important;
            margin: 0 !important;
        }
    }
    
    .game-screen {
        padding: 20px 15px;
        min-width: 90vw;
        max-width: 95vw;
        width: 90vw;
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .game-screen h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .game-screen p {
        font-size: 0.85em;
        margin: 5px 0;
        line-height: 1.4;
    }
    
    .game-screen p.emphasized {
        font-size: 0.95em;
    }
    
    .game-info-section {
        padding: 0 5px;
    }
    
    .start-btn {
        margin-top: 12px;
        padding: 12px 30px;
        font-size: 1em;
    }
    
    .ui-overlay {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .high-scores-section {
        margin-top: 15px;
        padding-top: 10px;
    }
    
    .high-scores-section.external {
        margin-top: 15px;
        padding: 15px;
        max-width: 95vw;
    }
    
    .scores-toggle {
        font-size: 1.1em;
        margin-bottom: 10px;
    }
    
    .scores-list {
        max-height: 200px;
    }
    
    .score-item {
        padding: 6px 10px;
        font-size: 0.9em;
    }
    
    .score-value {
        font-size: 1em;
    }
    
    .score-date {
        font-size: 0.75em;
        min-width: 80px;
    }
    
    .player-name-input {
        font-size: 1em;
        padding: 8px 15px;
        max-width: 250px;
    }
    
    .player-contact-input {
        font-size: 0.9em;
        padding: 8px 15px;
        max-width: 250px;
    }
    
    .contact-privacy-note {
        font-size: 0.75em;
    }
    
    .score-name {
        min-width: 80px;
        max-width: 100px;
        font-size: 0.9em;
    }
    
    /* Make game over screen more compact too */
    #gameOverScreen h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    #gameOverScreen p {
        font-size: 0.9em;
        margin: 8px 0;
    }
}

/* Additional landscape mode rules for all devices - ensures buttons are at corners */
@media (orientation: landscape) and (max-height: 600px) {
    .mobile-controls {
        justify-content: flex-start !important;
        gap: 0 !important;
        padding: 0 !important;
    }
    
    .mobile-controls .left-arrow {
        position: fixed !important;
        left: max(20px, env(safe-area-inset-left, 20px)) !important;
        bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
        right: auto !important;
    }
    
    .mobile-controls .right-arrow {
        position: fixed !important;
        right: max(20px, env(safe-area-inset-right, 20px)) !important;
        bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
        left: auto !important;
    }
}

