html {
    height: -webkit-fill-available;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

body.game-active {
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    background: #000;
}

/* Game container */
#snake-game-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

/* Safe area handling */
@supports (padding: max(0px)) {
    #snake-game-wrapper {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 15px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    color: white;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Input styles */
.game-input {
    width: 100%;
    max-width: 200px;
    padding: 12px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-align: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.game-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.game-input#player-pin {
    letter-spacing: 5px;
    font-family: monospace;
    -webkit-text-security: disc;
}

/* Hide number input arrows */
.game-input#player-pin::-webkit-inner-spin-button,
.game-input#player-pin::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.game-input#player-pin {
    -moz-appearance: textfield;
}

.input-help {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 5px 0 15px;
}

/* Button styles */
.game-button {
    padding: 15px 30px;
    font-size: 18px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.game-button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.game-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Game screen styles - Updated for better mobile layout */
.game-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: #000;
}

.game-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    box-sizing: border-box;
}

/* Game board positioning - moved to top */
#game-board {
    margin-top: 150px;
    flex-shrink: 0;
    position: relative;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Score display - fixed at top */
#score {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 90vw;
    box-sizing: border-box;
    white-space: nowrap;
}

/* Timer displays - positioned below score */
#invincibility-timer, #freeze-timer {
    position: fixed;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 22px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
}

#freeze-timer {
    top: 80px; /* Stack below invincibility timer if both are active */
}

/* Leaderboard styles */
#leaderboard {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 20px;
    border-radius: 10px;
    color: white;
    z-index: 1000;
    min-width: 300px;
    display: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#leaderboard.visible {
    display: block;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

/* Special effects */
#collision-flash {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: red;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    animation: flash 0.2s ease-out;
}

@keyframes flash {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.3; }
}

.floating-score {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 40px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 101;
}

@keyframes floatUp {
    0% { 
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-30px);
        opacity: 0;
    }
}

/* Touch feedback */
.touch-feedback {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    animation: touchRipple 0.6s ease-out forwards;
}

@keyframes touchRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.fire-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 110;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 3px solid #B8860B;
    color: #000;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.fire-btn.visible {
    display: flex;
}

.fire-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Pulse animation when bullets available */
@keyframes bulletPulse {
    0%, 100% { 
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
        transform: scale(1.05);
    }
}

.fire-btn.has-bullets {
    animation: bulletPulse 2s infinite;
}

/* Debug panel */
#debug-panel {
    position: fixed;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10001;
}

/* Hide elements */
.hidden {
    display: none !important;
}

/* Game over screen */
#game-over .modal-content {
    animation: modalBounce 0.5s cubic-bezier(0.36, 0, 0.66, 1.54) forwards;
}

@keyframes modalBounce {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Powerup effects */
.powerup::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        to right,
        transparent,
        rgba(255, 255, 255, 0.8),
        transparent
    );
    transform: rotate(45deg);
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

/* Mystery box styles */
#mystery-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.box-container {
    width: 100px;
    height: 100px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: 4px solid #000;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 0.5s infinite alternate;
}

.number-display {
    font-size: 48px;
    font-weight: bold;
    color: #000;
    text-shadow: 2px 2px 0 #FFF;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* Login page leaderboard */
.login-leaderboard {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.login-leaderboard h3 {
    color: #FFD700;
    margin: 0 0 15px 0;
    font-size: 18px;
    text-align: center;
}

#login-leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
}

.login-leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 3px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    font-size: 14px;
}

.login-leaderboard-entry .rank {
    color: #FFD700;
    font-weight: bold;
    min-width: 25px;
}

.login-leaderboard-entry .name {
    flex: 1;
    color: white;
    text-align: left;
    margin-left: 10px;
}

.login-leaderboard-entry .score {
    color: #4CAF50;
    font-weight: bold;
}

.loading-scores {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    #score {
        font-size: 12px;
        padding: 6px 12px;
        top: 5px;
    }
    
    #invincibility-timer, #freeze-timer {
        top: 45px;
        font-size: 18px;
        padding: 3px 10px;
    }
    
    #freeze-timer {
        top: 65px;
    }
    
    #game-board {
        margin-top: 90px;
    }
    
    .fire-btn {
        width: 50px;
        height: 50px;
        font-size: 14px;
        bottom: 15px;
        left: 15px;
    }

    .modal-content {
        padding: 20px;
        width: 90%;
        margin: 10px;
    }

    .game-button {
        padding: 12px 24px;
        font-size: 16px;
    }
}

/* Activity notifications modal styles */
.activity-notifications {
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.activity-notifications h3 {
    color: #FFD700;
    margin: 0 0 15px 0;
    font-size: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* This is the missing CSS for the scrollable activities */
.scrollable-activities {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    flex: 1;
    margin-bottom: 15px;
}

/* Activity item styles */
.activity-item {
    margin: 8px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid #4CAF50;
    transition: background 0.2s ease;
}

.activity-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Scroll hint for activities */
.scroll-hint {
    text-align: center;
    color: #888;
    font-size: 12px;
    margin: 5px 0 10px 0;
    animation: pulse 2s infinite;
    font-style: italic;
    flex-shrink: 0;
}

/* Custom scrollbar for activity modal */
.scrollable-activities::-webkit-scrollbar {
    width: 6px;
}

.scrollable-activities::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.scrollable-activities::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.scrollable-activities::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Make sure the modal content can handle the flexible layout */
#activity-modal .modal-content {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Mobile adjustments for activity modal */
@media (max-width: 768px) {
    .scrollable-activities {
        max-height: 300px;
        padding: 8px;
    }
    
    .activity-item {
        padding: 10px;
        margin: 6px 0;
    }
    
    .activity-notifications h3 {
        font-size: 16px;
    }
    
    #activity-modal .modal-content {
        max-height: 90vh;
        padding: 20px;
    }
}

/* Powerup slot button */
.powerup-slot-btn {
    position: fixed;
    bottom: 20px;
    left: 90px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFFFFF, #4B0082);
    border: 3px solid #DDA0DD;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    z-index: 110;
}

.powerup-slot-btn.visible {
    display: flex;
}

.powerup-slot-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.powerup-slot-btn.has-powerup {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    animation: powerupPulse 2s infinite;
}

@keyframes powerupPulse {
    0%, 100% { 
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
        transform: scale(1.05);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .powerup-slot-btn {
        width: 89;
        height: 80px;
        font-size: 22px;
        bottom: 15px;
        left: 95px;
    }
}

