* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Nunito', 'Arial', sans-serif;
    background: #0a0a0a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* Ensure touch events work */
    touch-action: none; /* Prevent default touch behaviors */
}

#gameCanvas {
    background: #1a1a2e;
    cursor: none;
    display: block;
    touch-action: none; /* Prevent default touch behaviors like scrolling */
    -webkit-touch-callout: none; /* Disable callout on iOS */
    z-index: 1; /* Lower than pause menu and death screen */
    position: relative;
    -webkit-user-select: none; /* Disable text selection */
    user-select: none;
    -ms-touch-action: none;
    -webkit-user-zoom: fixed;
    -moz-user-zoom: fixed;
    -ms-user-zoom: fixed;
    pointer-events: auto; /* Ensure touch events work on canvas */
    user-zoom: fixed;
}

/* Mass Display - Top Left */
.mass-display {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    color: white;
    pointer-events: none;
}

.mass-display #score {
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Room Display - Top Left below mass */
.room-display {
    position: fixed;
    top: 60px;
    left: 20px;
    z-index: 1000;
    color: white;
    pointer-events: none;
}

.room-display #roomNumber {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Death Screen */
.death-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    pointer-events: auto;
}

.death-content {
    background: rgba(30, 30, 30, 0.95);
    border: none;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    color: white;
    max-width: 700px;
    width: 100%;
    box-shadow: none;
    box-sizing: border-box;
    margin: auto;
    z-index: 20001;
    position: relative;
}

.death-content h2 {
    color: #ffffff;
    font-size: 32px;
    margin-bottom: 20px;
    font-family: 'Nunito', sans-serif;
    word-wrap: break-word;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.death-stats {
    margin: 20px 0;
    font-size: 18px;
    color: #e0e0e0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.death-stats p {
    margin: 10px 0;
}

/* Death Screen XP Section */
.level-up-message {
    margin: 15px 0;
    padding: 12px 20px;
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.4);
    border-radius: 8px;
    text-align: center;
    color: #4caf50;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.level-up-message p {
    margin: 0;
    color: #4caf50;
}

.death-xp-section {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: none;
}

.death-xp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 16px;
    color: #e0e0e0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.death-level-label {
    font-weight: bold;
    color: #ffffff;
}

.death-xp-text {
    color: #e0e0e0;
    font-size: 14px;
}

.death-xp-bar-wrapper {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: none;
}

.death-xp-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50 0%, #66bb6a 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: none;
}

#growthChart {
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 5px;
    max-width: 100%;
    height: auto;
}

.death-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.play-again-btn,
.back-to-lobby-btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.play-again-btn {
    color: #4caf50;
    border-color: #4caf50;
}

.play-again-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-2px);
}

.back-to-lobby-btn {
    color: #ff4444;
    border-color: #ff4444;
}

.back-to-lobby-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    transform: translateY(-2px);
}

/* Prizes Section */
.prizes-section {
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    border: none;
}

.prizes-section h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.prizes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prize-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: none;
}

.prize-icon {
    font-size: 24px;
}

.prize-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
}

.prize-content {
    flex: 1;
}

.prize-food-name {
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 4px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.prize-text {
    color: #e0e0e0;
    font-size: 14px;
    word-break: break-word;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.prize-text a {
    color: #4caf50;
    text-decoration: underline;
}

/* Pause Button */
.pause-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 15000;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(1px 1px 3px rgba(0, 0, 0, 0.8));
    pointer-events: auto;
}

.pause-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.pause-btn:hover {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

/* Pause Menu */
.pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 15000;
    pointer-events: auto;
}

.pause-content {
    background: rgba(30, 30, 30, 0.9);
    border: none;
    border-radius: 10px;
    padding: 30px 40px;
    text-align: center;
    color: white;
    max-width: 400px;
    box-shadow: none;
    z-index: 15001;
    position: relative;
}

.pause-content h2 {
    color: #ffffff;
    font-size: 28px;
    margin-bottom: 20px;
    font-family: 'Nunito', sans-serif;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.pause-stats {
    margin: 20px 0;
    font-size: 18px;
    color: #e0e0e0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.pause-stats p {
    margin: 10px 0;
}

.pause-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.resume-btn,
.end-game-btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.resume-btn {
    color: #4caf50;
    border-color: #4caf50;
}

.resume-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-2px);
}

.end-game-btn {
    color: #ff4444;
    border-color: #ff4444;
}

.end-game-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    transform: translateY(-2px);
}

/* Leaderboard - Top Right */
.leaderboard-display {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    color: white;
    pointer-events: none;
    text-align: right;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.leaderboard-item-display {
    font-size: 12px;
    margin: 3px 0;
    line-height: 1.4;
}

.leaderboard-item-display .rank {
    color: #FFD700;
    font-weight: bold;
    margin-right: 5px;
}

.leaderboard-item-display .name {
    color: white;
    font-weight: bold;
}

.leaderboard-item-display .mass {
    color: #cccccc;
    font-size: 11px;
    margin-left: 5px;
}

/* Food Counters - Bottom Right */
.food-counters {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    color: white;
    pointer-events: none;
    text-align: right;
    font-size: 14px;
    max-width: 200px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .food-counters {
        bottom: 10px;
        right: 10px;
        font-size: 13px;
        max-width: 180px;
        z-index: 1000;
    }
    
    .food-counter-item {
        font-size: 12px;
        margin: 4px 0;
    }
    
    .food-counter-logo {
        width: 14px;
        height: 14px;
        margin-left: 5px;
    }
    
    .mass-display {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1000;
    }
    
    .mass-display #score {
        font-size: 20px;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    }
    
    .leaderboard-display {
        position: fixed;
        top: 10px;
        right: 10px;
        font-size: 11px;
        z-index: 1000;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    }
    
    /* Death Screen Mobile */
    .death-screen {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .death-content {
        padding: 20px;
        border-radius: 10px;
        max-width: 100%;
        margin: 0;
    }
    
    .death-content h2 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .death-stats {
        margin: 15px 0;
        font-size: 16px;
    }
    
    .death-stats p {
        margin: 8px 0;
    }
    
    #growthChart {
        width: 100% !important;
        height: auto !important;
        max-width: 100%;
        margin: 15px 0;
    }
    
    .prizes-section {
        margin-top: 15px;
        padding: 15px;
    }
    
    .prizes-section h3 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .prize-item {
        padding: 10px;
        gap: 10px;
    }
    
    .prize-icon {
        font-size: 20px;
    }
    
    .prize-logo {
        width: 24px;
        height: 24px;
    }
    
    .prize-food-name {
        font-size: 14px;
    }
    
    .prize-text {
        font-size: 12px;
    }
    
    .death-buttons {
        flex-direction: column;
        gap: 10px;
        margin-top: 15px;
    }
    
    .play-again-btn,
    .back-to-lobby-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    /* Pause Menu Mobile */
    .pause-content {
        padding: 20px;
        max-width: 90%;
    }
    
    .pause-content h2 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .pause-stats {
        font-size: 16px;
        margin: 15px 0;
    }
    
    .pause-buttons {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }
    
    .resume-btn,
    .end-game-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 16px;
    }
}

.food-counter-item {
    display: block;
    margin-bottom: 8px;
}

.milestone-progress-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    visibility: visible !important;
    width: 100%;
    margin-top: 5px;
    gap: 5px;
}

.milestone-progress-bar {
    display: block !important;
    visibility: visible !important;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

.milestone-progress-fill {
    display: block !important;
    visibility: visible !important;
    height: 100%;
    background: #00ffff;
    transition: width 0.3s ease;
    min-width: 2px;
}

.milestone-progress-text {
    display: block !important;
    visibility: visible !important;
    font-size: 10px;
    color: rgba(255,255,255,0.7);
    margin-top: 2px;
}

.food-counter-item-old {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin: 3px 0;
    font-size: 12px;
}

.food-counter-logo {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-left: 6px;
    object-fit: cover;
}

.food-counter-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}


.milestone-complete {
    font-size: 10px;
    color: #00ff00;
    margin-top: 4px;
    text-align: right;
}

/* Prizes section in death screen */
.prizes-section {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: none;
}

.prizes-section h3 {
    color: #ffffff;
    font-size: 20px;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.prizes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prize-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border: none;
    transition: all 0.3s ease;
}

.prize-item.prize-wrapped {
    cursor: pointer;
    position: relative;
}

.prize-item.prize-wrapped:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.02);
}

.prize-item.prize-wrapped::after {
    content: '👆';
    position: absolute;
    right: 10px;
    font-size: 16px;
    opacity: 0.7;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.prize-icon {
    font-size: 24px;
}

.prize-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.prize-content {
    flex: 1;
}

.prize-food-name {
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 4px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.prize-text {
    font-size: 12px;
    color: #e0e0e0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.prize-wrapped-text {
    color: #888;
    font-style: italic;
}

/* Connection info (hidden by default) */
.connection-info {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    color: white;
    pointer-events: none;
    font-size: 12px;
}

.connection-status {
    color: #ffa07a;
    font-weight: bold;
}

.connection-status.connected {
    color: #4ade80;
}

.player-count {
    color: #85c1e2;
    font-weight: bold;
}

/* Lobby Screen - Dark Mode with Neon */
.mode-selection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a2e;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100px 100px;
    background-position: 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Authentication Screen */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a2e;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100px 100px;
    background-position: 0 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    pointer-events: auto;
    gap: 30px;
    padding: 20px;
    box-sizing: border-box;
}

.auth-logo {
    max-width: 300px;
    width: 100%;
    height: auto;
    margin: 0;
}

.auth-container {
    background: rgba(20, 20, 20, 0.95);
    padding: 40px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    color: #e0e0e0;
    pointer-events: auto;
    position: relative;
    z-index: 10001;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #e0e0e0;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: rgba(51, 51, 51, 0.8);
    color: #e0e0e0;
    border: 1px solid rgba(85, 85, 85, 0.3);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: rgba(102, 126, 234, 0.8);
    border-color: rgba(102, 126, 234, 0.5);
}

.auth-tab:hover {
    background: rgba(68, 68, 68, 0.9);
}

.auth-tab.active:hover {
    background: rgba(102, 126, 234, 0.9);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 15px;
}

.auth-form.active {
    display: flex;
}

.auth-form input {
    padding: 12px;
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid rgba(85, 85, 85, 0.3);
    border-radius: 5px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: 'Nunito', Arial, sans-serif;
}

.auth-form input:focus {
    outline: none;
    border-color: rgba(119, 119, 119, 0.6);
    background: rgba(30, 30, 30, 0.8);
}

.auth-btn {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 2px solid #4caf50;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Nunito', Arial, sans-serif;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.auth-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-1px);
}

.auth-error {
    color: #ff4444;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
}

.mode-selection-content {
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
}

/* Desktop: Add align-content center for gameLobby */
@media (min-width: 769px) {
    .mode-selection-content {
        align-content: center;
    }
    
    /* Daily Challenge Progress - Left Bottom Corner on PC */
    .challenge-progress {
        right: auto !important;
        left: 20px !important;
        bottom: 20px !important;
    }
    
    /* Daily Challenges Lobby - Left Bottom Corner on PC */
    .daily-challenges-lobby {
        top: auto !important;
        right: auto !important;
        bottom: 20px !important;
        left: 20px !important;
    }
}

.game-title {
    display: block;
    max-width: 400px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    margin-bottom: 30px;
    margin-top: 20px;
    filter: drop-shadow(0 0 20px rgba(78, 205, 196, 0.6)) drop-shadow(0 0 40px rgba(78, 205, 196, 0.4)) drop-shadow(0 0 60px rgba(78, 205, 196, 0.2));
    position: relative;
    z-index: 1;
}

@keyframes neonGlow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* User Stats - Clean, no background */
.user-stats {
    position: relative;
    top: auto;
    left: auto;
    z-index: 1001;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    margin: 0 auto 20px auto;
    align-items: center;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-label {
    font-size: 14px;
    color: #888;
    font-weight: 600;
}

.level-value {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.xp-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.xp-bar-wrapper {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #66bb6a);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 6px;
    box-shadow: none;
}

.xp-text {
    font-size: 13px;
    color: #e0e0e0;
    font-weight: 600;
    text-align: right;
}

.coins-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.coin-icon {
    width: 20px;
    height: 20px;
    margin-right: 5px;
    object-fit: contain;
}

.coins-label {
    font-size: 14px;
    color: #888;
    font-weight: 600;
}

.coins-value {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* User Account Info - Bottom Left (desktop), Bottom (mobile) */
.user-account {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 250px;
    max-width: 250px;
    width: 250px;
}

.user-greeting {
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 5px;
}

.referral-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.referral-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.referral-input {
    flex: 1;
    padding: 6px 10px;
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid rgba(85, 85, 85, 0.3);
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
    font-family: 'Nunito', Arial, sans-serif;
}

.referral-copy-btn {
    flex: 1;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 1px solid rgba(85, 85, 85, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Nunito', Arial, sans-serif;
    font-weight: 600;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.referral-copy-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-1px);
}

.coupon-apply-btn {
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(85, 85, 85, 0.3);
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Nunito', Arial, sans-serif;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Fix coupon section container to prevent button overflow */
#couponSection {
    width: 100%;
    box-sizing: border-box;
}

#couponSection > div {
    display: flex;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
}

#couponCodeInput {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.coupon-apply-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-1px);
}

.account-btn {
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Nunito', Arial, sans-serif;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
}

.logout-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 1px solid rgba(85, 85, 85, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.logout-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-1px);
}

.login-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 2px solid #4caf50;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.login-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-1px);
}

/* Login Perks Section - Top Left (same position as user stats) */
.login-perks {
    background: rgba(30, 30, 30, 0.9);
    border-radius: 10px;
    padding: 20px;
    min-width: 250px;
    max-width: 300px;
    border: none;
    box-shadow: none;
}

.perks-title {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: left;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.perks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.perk-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    transition: all 0.2s ease;
}

.perk-item:hover {
    opacity: 0.9;
    transform: translateX(2px);
}

.perk-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: #4caf50;
    fill: none;
}

.perk-text {
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding-top: 0;
    margin-bottom: 0;
}

.global-leaderboard-lobby {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 250px;
    max-height: 500px;
    overflow-y: auto;
    width: 250px;
    box-sizing: border-box;
    z-index: 1000;
    background: rgba(20, 20, 20, 0.9);
    border-radius: 8px;
    padding: 15px;
}

.leaderboard-title {
    color: #e0e0e0;
    margin-bottom: 12px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 4px 0;
}

.leaderboard-item-separator {
    padding: 8px 0;
    justify-content: center;
}

.leaderboard-item-current {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    margin-top: 4px;
}

.leaderboard-name.current-user {
    font-weight: bold;
    color: #4caf50;
}

.leaderboard-rank {
    font-weight: bold;
    color: #FFC107;
    flex-shrink: 0;
    min-width: 25px;
    font-size: 14px;
}

.leaderboard-name {
    flex: 1;
    color: #e0e0e0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* Allow text to be truncated */
    font-size: 14px;
}

.leaderboard-score {
    color: #b0b0b0;
    font-size: 13px;
    flex-shrink: 0;
    min-width: 50px;
    text-align: right;
}

/* Daily Challenges - Minimalistic, same width as leaderboard */
.daily-challenges-lobby {
    position: fixed;
    top: 540px;
    right: 20px;
    max-width: 350px;
    max-height: 400px;
    overflow-y: auto;
    width: 350px;
    box-sizing: border-box;
    z-index: 1000;
    background: rgba(20, 20, 20, 0.9);
    padding: 20px;
    border-radius: 8px;
}

.challenges-title {
    color: #e0e0e0;
    margin-bottom: 12px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.challenges-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.challenge-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}

.challenge-title {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 14px;
}

.challenge-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.challenge-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #45B7D1);
    transition: width 0.3s ease;
    border-radius: 3px;
}

.challenge-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
}

@media (max-width: 768px) {
    .mode-selection {
        align-items: flex-start !important;
    }
    
    .game-title {
        max-width: 250px;
        margin-bottom: 20px;
        margin-top: 20px;
    }
    
    .auth-logo {
        max-width: 200px;
        margin-top: 20px;
        margin-bottom: 10px;
    }
    
    .auth-screen {
        padding: 20px 15px;
        gap: 20px;
        justify-content: flex-start;
        align-items: center;
    }
    
    .auth-container {
        padding: 30px 20px;
    }
    
    .global-leaderboard-lobby {
        position: relative;
        top: auto;
        right: auto;
        max-width: calc(100% - 30px);
        width: calc(100% - 30px);
        max-height: 500px;
        margin: 20px 15px;
        padding: 15px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
        order: 998;
    }
    
    .global-leaderboard-lobby h3,
    .challenges-title {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }
    
    .leaderboard-item {
        padding: 6px 0 !important;
    }
    
    .daily-challenges-lobby {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        max-width: calc(100% - 30px) !important;
        width: calc(100% - 30px) !important;
        margin: 20px 15px !important;
        max-height: 40vh;
    }
    
    #tournamentsSection {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        max-width: calc(100% - 30px) !important;
        width: calc(100% - 30px) !important;
        margin: 20px 15px !important;
    }
    
    .global-leaderboard-lobby h3 {
        position: sticky;
        top: 0;
        background: rgba(20, 20, 20, 0.95);
        padding: 10px 15px;
        margin: 0 -15px 10px -15px;
        z-index: 10;
        box-sizing: border-box;
    }
    
    .leaderboard-item {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .leaderboard-name {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .lobby-container {
        padding: 20px 15px;
        gap: 20px;
        margin-bottom: 0;
        width: 100%;
        box-sizing: border-box;
        padding-bottom: 40px;
    }
    
    .mode-selection-content {
        padding: 20px 0 40px 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
        flex-direction: column !important;
        width: 100%;
        box-sizing: border-box;
        align-items: center;
        justify-content: flex-start !important;
        min-height: auto !important;
    }
    
    /* Set explicit order for all flex children on mobile - MUST be in order */
    .mode-selection-content > .game-title {
        order: 0 !important;
        margin-top: 0 !important;
    }
    
    .mode-selection-content > .user-stats {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: calc(100% - 30px);
        margin: 0 15px 20px 15px;
        padding: 0;
        min-width: auto;
        max-width: calc(100% - 30px);
        order: 1 !important; /* After logo */
        box-sizing: border-box;
    }
    
    .mode-selection-content > .lobby-container {
        order: 2 !important;
    }
    
    .mode-selection-content > .login-perks {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        order: 3 !important;
    }
    
    .mode-selection-content > #tournamentsSection {
        order: 996 !important;
    }
    
    .mode-selection-content > .daily-challenges-lobby {
        order: 997 !important;
    }
    
    .mode-selection-content > .global-leaderboard-lobby {
        order: 998 !important;
    }
    
    .mode-selection-content > .user-account {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        max-width: calc(100% - 30px) !important;
        width: calc(100% - 30px) !important;
        padding: 15px;
        margin: 20px 15px !important;
        min-width: auto;
        background: transparent;
        order: 1000 !important; /* Put at very bottom of flex container, after everything */
        box-sizing: border-box;
    }
    
    .user-greeting {
        font-size: 14px !important;
        text-align: center;
    }
    
    .account-btn {
        width: 100%;
        font-size: 13px !important;
    }
    
    #referralSection {
        margin-top: 15px !important;
        padding-top: 15px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .login-perks {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        max-width: calc(100% - 30px) !important;
        width: calc(100% - 30px) !important;
        margin: 20px 15px !important;
        padding: 15px !important;
    }
    
    .perk-icon {
        width: 16px !important;
        height: 16px !important;
    }
    
    .perk-text {
        font-size: 12px !important;
    }
    
    .perks-title {
        font-size: 15px !important;
        margin-bottom: 10px !important;
    }
    
    .referral-label {
        font-size: 11px !important;
        text-align: center;
    }
    
    .referral-buttons-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .referral-copy-btn {
        width: 100%;
        font-size: 12px !important;
    }
    
    .coupon-apply-btn {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
    
    .global-leaderboard-lobby h3,
    .challenges-title {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }
    
    .leaderboard-item {
        padding: 6px 0 !important;
    }
    
    .skin-selection-container {
        width: 100%;
        padding: 0 5px;
        box-sizing: border-box;
    }
    
    .selection-selectors {
        gap: 15px;
        margin: 15px 0;
    }
    
    .selector-preview {
        width: 60px;
        height: 60px;
    }
    
    .selector-label {
        font-size: 12px;
    }
    
    .modal-content {
        max-width: calc(100% - 40px);
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-body .skin-options {
        gap: 15px !important;
    }
    
    .modal-body .skin-option {
        width: 60px !important;
        height: 60px !important;
    }
    
    .name-input-container {
        width: calc(100% - 30px);
        margin: 0 15px;
        padding: 0;
        box-sizing: border-box;
    }
    
    .name-input-container input {
        width: 100%;
        max-width: 100%;
        padding: 12px;
        box-sizing: border-box;
    }
    
    .skin-options {
        gap: 15px;
        justify-content: center;
        max-width: calc(60px * 5 + 15px * 4) !important; /* 5 items * 60px + 4 gaps * 15px */
    }
    
    .skin-options > .skin-option {
        flex: 0 0 auto !important;
        width: 60px !important;
        height: 60px;
        box-sizing: border-box;
    }
    
    .play-btn {
        width: calc(100% - 30px);
        max-width: 300px;
        margin: 0 auto;
    }
}

.skin-selection-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Compact Selection Selectors */
.selection-selectors {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.selection-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 8px;
}

.selection-selector:hover {
    transform: translateY(-2px);
}

.selector-preview {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.selection-selector:hover .selector-preview {
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.selector-label {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.preview-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    font-weight: bold;
}

.preview-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Selection Modal */
.selection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
}

/* Confirmation modal should be above auth screen */
#confirmModal {
    z-index: 10001;
}

.modal-content {
    background: rgba(30, 30, 30, 0.95);
    border-radius: 10px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    color: #ffffff;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.modal-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.modal-body {
    padding: 20px;
}

/* Confirmation Modal Buttons */
.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Nunito', Arial, sans-serif;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.modal-btn-ok {
    background: rgba(76, 175, 80, 0.8);
    color: #ffffff;
    border: 1px solid rgba(76, 175, 80, 0.5);
}

.modal-btn-ok:hover {
    background: rgba(76, 175, 80, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.modal-btn-cancel {
    background: rgba(100, 100, 100, 0.6);
    color: #ffffff;
    border: 1px solid rgba(85, 85, 85, 0.3);
}

.modal-btn-cancel:hover {
    background: rgba(100, 100, 100, 0.8);
    transform: translateY(-2px);
}

.modal-body .skin-options {
    display: flex !important;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.modal-body .skin-option {
    width: 70px;
    height: 70px;
}

#premiumSkinsSection {
    border-top: 2px solid rgba(255, 193, 7, 0.3);
    padding-top: 15px;
    margin-top: 15px;
    width: 100%;
}

#premiumSkinsSection .skin-selection-label {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.skin-selection-label {
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.skin-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(70px * 5 + 20px * 4); /* 5 items * 70px + 4 gaps * 20px = 430px */
}

.skin-option {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    flex: 0 0 auto;
    box-sizing: border-box;
}

.trail-preview {
    background: #1a1a1a !important;
}

.trail-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    image-rendering: crisp-edges;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.skin-option:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

.skin-option.selected {
    border-color: white;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.8),
                0 0 15px rgba(255, 255, 255, 0.4) inset;
    transform: scale(1.15);
}

.skin-preview {
    font-size: 40px;
    line-height: 1;
}

.skin-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.skin-option.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.7);
    position: relative;
}

.skin-option.locked:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.4);
}

.skin-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    z-index: 100;
    pointer-events: none;
}

.skin-lock-overlay > div {
    z-index: 101;
    position: relative;
    text-align: center;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.trail-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    z-index: 100;
    pointer-events: none;
}

.trail-lock-overlay > div {
    z-index: 101;
    position: relative;
    text-align: center;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.trail-preview.locked {
    opacity: 0.6;
    cursor: pointer;
}

.trail-preview.locked:hover {
    opacity: 0.8;
}


.name-input-container {
    width: 100%;
    max-width: 300px;
}

.name-input-container input {
    padding: 12px 20px;
    font-size: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(30, 30, 30, 0.6);
    color: #e0e0e0;
    text-align: center;
    width: 100%;
    transition: all 0.2s ease;
    font-family: 'Nunito', Arial, sans-serif;
}

.name-input-container input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.name-input-container input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(30, 30, 30, 0.8);
}

.play-btn {
    padding: 18px 60px;
    font-size: 24px;
    font-weight: bold;
    border: 2px solid #4caf50;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #4caf50;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
    position: relative;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.play-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-2px);
}

.play-btn:active {
    transform: translateY(0);
}

