@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

:root {
    --neon-pink: #ff006e;
    --neon-blue: #00f5ff;
    --neon-purple: #8b00ff;
    --neon-green: #00ff41;
    --neon-red: #ff0040;
    --neon-yellow: #ffff00;
    --dark-bg: #0a0a0a;
    --mid-bg: #1a1a1a;
    --light-bg: #2a2a2a;
}

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

body {
    font-family: 'Orbitron', monospace;
    background-color: var(--dark-bg);
    color: white;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    /* Prevent all touch gestures and pinch-to-zoom */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    /* Prevent pull-to-refresh and overscroll */
    overscroll-behavior: none;
    position: fixed;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Prevent touch gestures on container */
    touch-action: none;
    overflow: hidden;
}

#gameCanvas {
    background-color: #000;
    box-shadow: 0 0 50px var(--neon-blue);
    max-width: 100%;
    max-height: 100%;
    /* Ensure canvas can receive touch events */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: none;
}

.hud-top {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.health-bar {
    width: 300px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--neon-pink);
    position: relative;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-pink), #ff0040);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--neon-pink);
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

.score, .wave-info {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border: 2px solid var(--neon-blue);
    text-align: center;
}

.label {
    color: var(--neon-blue);
    font-size: 12px;
    margin-right: 10px;
}

#credits, #wave {
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 10px var(--neon-blue);
}

.hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ammo-display {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border: 2px solid var(--neon-green);
}

#ammo {
    font-size: 24px;
    font-weight: bold;
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green);
    margin-right: 10px;
}

.weapon-name {
    font-size: 14px;
    color: var(--neon-green);
}

.audience-meter {
    width: 400px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--neon-purple);
    position: relative;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
    transition: width 0.5s ease;
    box-shadow: 0 0 20px var(--neon-purple);
}

.meter-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none; /* Hide completely when inactive */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100; /* Base z-index for screens */
}

.screen.active {
    display: flex; /* Show when active */
    opacity: 1;
    pointer-events: all;
    z-index: 101; /* Active screens go above base */
}

.game-title {
    font-size: 80px;
    font-weight: 900;
    margin-bottom: 50px;
    text-align: center;
    background: linear-gradient(45deg, var(--neon-blue), var(--neon-pink), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 0, 110, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: brightness(1) drop-shadow(0 0 20px var(--neon-pink)); }
    to { filter: brightness(1.2) drop-shadow(0 0 40px var(--neon-blue)); }
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 50px;
}

.menu-btn {
    font-family: 'Orbitron', monospace;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 40px;
    background-color: transparent;
    color: white;
    border: 2px solid var(--neon-blue);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.menu-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--neon-blue), transparent);
    transition: left 0.5s ease;
}

.menu-btn:hover {
    color: var(--dark-bg);
    background-color: var(--neon-blue);
    box-shadow: 0 0 30px var(--neon-blue);
    transform: scale(1.05);
}

.menu-btn:hover:before {
    left: 100%;
}

.tagline {
    font-size: 16px;
    color: var(--neon-purple);
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: flicker 3s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.game-over-title {
    font-size: 60px;
    font-weight: 900;
    margin-bottom: 40px;
    color: var(--neon-pink);
    text-shadow: 0 0 30px var(--neon-pink);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.stats {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border: 2px solid var(--neon-purple);
    margin-bottom: 40px;
    text-align: center;
}

.stats p {
    font-size: 20px;
    margin: 10px 0;
    color: var(--neon-blue);
}

.stats span {
    color: white;
    font-weight: bold;
    text-shadow: 0 0 10px var(--neon-blue);
}

/* Glitch effect */
@keyframes glitch {
    0% {
        text-shadow: 0.05em 0 0 var(--neon-pink), -0.05em -0.025em 0 var(--neon-blue),
                     0.025em 0.05em 0 var(--neon-purple);
    }
    14% {
        text-shadow: 0.05em 0 0 var(--neon-pink), -0.05em -0.025em 0 var(--neon-blue),
                     0.025em 0.05em 0 var(--neon-purple);
    }
    15% {
        text-shadow: -0.05em -0.025em 0 var(--neon-pink), 0.025em 0.025em 0 var(--neon-blue),
                     -0.05em -0.05em 0 var(--neon-purple);
    }
    49% {
        text-shadow: -0.05em -0.025em 0 var(--neon-pink), 0.025em 0.025em 0 var(--neon-blue),
                     -0.05em -0.05em 0 var(--neon-purple);
    }
    50% {
        text-shadow: 0.025em 0.05em 0 var(--neon-pink), 0.05em 0 0 var(--neon-blue),
                     0 -0.05em 0 var(--neon-purple);
    }
    99% {
        text-shadow: 0.025em 0.05em 0 var(--neon-pink), 0.05em 0 0 var(--neon-blue),
                     0 -0.05em 0 var(--neon-purple);
    }
    100% {
        text-shadow: -0.025em 0 0 var(--neon-pink), -0.025em -0.025em 0 var(--neon-blue),
                     -0.025em -0.05em 0 var(--neon-purple);
    }
}

.game-title:hover {
    animation: glitch 0.5s infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .game-title {
        font-size: 50px;
    }
    
    .menu-btn {
        font-size: 18px;
        padding: 12px 30px;
    }
    
    .hud-top, .hud-bottom {
        transform: scale(0.8);
        transform-origin: left top;
    }
}

/* Multiplayer UI */
.multiplayer-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.player-hud {
    position: absolute;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    padding: 20px;
    width: 300px;
}

.player-1-hud {
    top: 0;
    left: 0;
    border-bottom-right-radius: 20px;
}

.player-2-hud {
    top: 0;
    right: 0;
    border-bottom-left-radius: 20px;
}

.player-label {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 0 0 10px currentColor;
}

.player-1-hud .player-label {
    color: var(--neon-blue);
}

.player-2-hud .player-label {
    color: var(--neon-pink);
}

.player-hud .health-bar {
    width: 100%;
    margin-bottom: 15px;
}

.player-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.credits-display, .weapon-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.weapon-display {
    color: var(--neon-yellow);
}

.shared-hud {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.shared-hud .wave-info {
    font-size: 28px;
    background: rgba(0,0,0,0.8);
    padding: 10px 30px;
    border-radius: 20px;
    border: 2px solid var(--neon-purple);
}

/* Weapon Shop */
.shop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Ensure shop is always on top */
}

.shop-container {
    background: rgba(10, 10, 10, 0.95);
    border: 3px solid var(--neon-purple);
    border-radius: 20px;
    padding: 40px;
    max-width: 800px;
    width: 90%;
    box-shadow: 0 0 50px var(--neon-purple);
}

.shop-title {
    font-size: 36px;
    text-align: center;
    color: var(--neon-pink);
    margin-bottom: 20px;
    text-shadow: 0 0 20px var(--neon-pink);
}

.shop-credits {
    text-align: center;
    font-size: 24px;
    color: var(--neon-yellow);
    margin-bottom: 30px;
}

.weapon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    max-height: 400px;
    overflow-y: auto;
}

.weapon-item {
    background: rgba(20, 20, 20, 0.8);
    border: 2px solid var(--neon-blue);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.weapon-item:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--neon-blue);
}

.weapon-item.owned {
    border-color: var(--neon-green);
    opacity: 0.7;
}

.weapon-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.weapon-name {
    font-size: 18px;
    color: var(--neon-pink);
    margin-bottom: 10px;
}

.weapon-stats {
    font-size: 12px;
    color: var(--neon-blue);
    margin-bottom: 10px;
}

.weapon-price {
    font-size: 16px;
    color: var(--neon-yellow);
    text-align: right;
}

.weapon-price.affordable {
    color: var(--neon-green);
}

#continue-btn {
    display: block;
    margin: 0 auto;
}

/* Character Selection Screen */
#character-select-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    flex-direction: column;
    align-items: center;
    padding-top: 50px;
    background-color: var(--dark-bg);
    z-index: 101; /* Above other screens */
}

#character-select-screen.active {
    display: flex;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin: 40px auto;
    max-width: 800px;
    padding: 0 20px;
}

.character-card {
    background: rgba(20, 20, 20, 0.9);
    border: 3px solid var(--neon-purple);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.character-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 40px rgba(139, 0, 255, 0.5);
    border-color: var(--neon-pink);
}

.character-card.selected {
    border-color: var(--neon-green);
    box-shadow: 0 0 50px var(--neon-green);
}

.character-preview {
    width: 100px;
    height: 100px;
    margin: 20px 0;
    position: relative;
}

.character-preview canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.character-card h3 {
    color: var(--neon-blue);
    font-size: 20px;
    margin: 10px 0;
    text-transform: uppercase;
    text-align: center;
}

.character-card .ability-preview {
    font-size: 12px;
    color: var(--neon-yellow);
    text-align: center;
    margin-top: 10px;
    line-height: 1.4;
}

.character-card .ability-preview div {
    margin: 2px 0;
}

.character-details {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 90%;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.95);
    border: 2px solid var(--neon-blue);
    border-radius: 10px;
    padding: 20px 30px;
}

.character-details h3 {
    color: var(--neon-pink);
    font-size: 28px;
    margin-bottom: 5px;
}

.character-details p {
    color: var(--neon-blue);
    font-size: 14px;
    margin-bottom: 15px;
}

.character-stats {
    margin: 15px 0;
}

.stat-item {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-label {
    color: var(--neon-yellow);
    font-size: 14px;
    min-width: 80px;
}

.stat-bar {
    flex: 1;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--neon-blue);
    position: relative;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-pink));
    transition: width 0.3s ease;
}

#passive-ability-name, #active-ability-name {
    color: var(--neon-green);
    font-size: 16px;
    text-transform: uppercase;
}

#active-ability-name {
    color: var(--neon-yellow);
}

.select-btn {
    background: var(--neon-green);
    color: var(--dark-bg);
    margin-top: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.select-btn:hover {
    background: var(--neon-pink);
    box-shadow: 0 0 30px var(--neon-pink);
}

.back-btn {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    min-width: 120px;
    padding: 12px 30px;
}

/* Character sprite animations */
@keyframes characterFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.character-preview {
    animation: characterFloat 2s ease-in-out infinite;
}

.character-card:hover .character-preview {
    animation-duration: 0.5s;
}

/* Controls Screen */
#controls-screen {
    background: radial-gradient(ellipse at center, rgba(138, 43, 226, 0.1) 0%, transparent 70%);
    z-index: 1000;
}

.controls-container {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    max-width: 1200px;
    margin: 100px auto 40px;
    padding: 0 20px;
    justify-content: center;
}

.controls-section {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--neon-purple);
    border-radius: 20px;
    padding: 30px;
    min-width: 320px;
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.3);
}

.controls-section h3 {
    color: var(--neon-pink);
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 0 0 15px var(--neon-pink);
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.control-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.control-key {
    color: var(--neon-green);
    font-weight: bold;
    font-size: 18px;
    text-shadow: 0 0 10px var(--neon-green);
    min-width: 100px;
}

.control-desc {
    color: var(--light-text);
    font-size: 16px;
    text-align: right;
    flex: 1;
    margin-left: 20px;
}

.controls-footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
}

.controls-footer p {
    color: var(--neon-blue);
    font-size: 18px;
    text-shadow: 0 0 10px var(--neon-blue);
    animation: pulse 2s ease-in-out infinite;
}

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


/* Primary/Secondary Weapon Display */
.primary-weapon, .secondary-weapon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.weapon-label {
    font-size: 10px;
    color: #888;
    min-width: 80px;
}

#secondary-ammo {
    font-size: 24px;
    font-weight: bold;
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink);
    min-width: 40px;
}

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

/* Weapon Inventory */
.inventory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 10, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.inventory-container {
    background-color: var(--dark-bg);
    border: 2px solid var(--neon-blue);
    border-radius: 10px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    box-shadow: 0 0 30px var(--neon-blue);
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: 2px solid var(--neon-pink);
    color: var(--neon-pink);
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--neon-pink);
    color: var(--dark-bg);
    transform: scale(1.1);
}

@media (pointer: coarse) {
    .close-btn {
        width: 45px;
        height: 45px;
        font-size: 32px;
    }
}

.desktop-instructions {
    display: inline;
}

.mobile-instructions {
    display: none;
}

@media (pointer: coarse) {
    .desktop-instructions {
        display: none;
    }
    
    .mobile-instructions {
        display: inline;
    }
}

.inventory-title {
    font-size: 2rem;
    text-align: center;
    color: var(--neon-blue);
    margin-bottom: 10px;
    text-shadow: 0 0 20px currentColor;
}

.inventory-instructions {
    text-align: center;
    color: var(--neon-yellow);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.inventory-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.inventory-section h3 {
    color: var(--neon-pink);
    margin-bottom: 15px;
    text-align: center;
}

.equipped-weapons,
.inventory-weapons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    min-height: 150px;
}

.weapon-slot {
    background-color: var(--mid-bg);
    border: 2px solid var(--light-bg);
    border-radius: 5px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.weapon-slot:hover {
    transform: scale(1.05);
    border-color: var(--neon-yellow);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.weapon-slot.equipped {
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
}

.weapon-slot.empty {
    opacity: 0.5;
    cursor: default;
}

.weapon-slot.empty:hover {
    transform: none;
    box-shadow: none;
}

.weapon-slot .weapon-name {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.weapon-slot .weapon-stats {
    font-size: 0.7rem;
    color: var(--light-bg);
}

.weapon-slot .weapon-ammo {
    font-size: 0.8rem;
    margin-top: 5px;
}

.weapon-slot .weapon-ammo.low {
    color: var(--neon-pink);
}

.weapon-slot .weapon-ammo.empty {
    color: #ff0000;
    font-weight: bold;
}

.inventory-hint {
    text-align: center;
    color: var(--light-bg);
    font-size: 0.8rem;
}

/* Deathmatch UI */
.deathmatch-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.dm-score {
    position: absolute;
    top: 20px;
    background-color: rgba(26, 26, 26, 0.9);
    border: 2px solid var(--neon-blue);
    border-radius: 10px;
    padding: 20px 30px;
    text-align: center;
}

.dm-score-left {
    left: 20px;
}

.dm-score-right {
    right: 20px;
}

.dm-player-name {
    font-size: 1.2rem;
    color: var(--neon-blue);
    margin-bottom: 10px;
}

.dm-kills {
    font-size: 3rem;
    font-weight: bold;
    color: var(--neon-pink);
    text-shadow: 0 0 20px currentColor;
}

.dm-timer {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(26, 26, 26, 0.9);
    border: 2px solid var(--neon-purple);
    border-radius: 10px;
    padding: 15px 40px;
    text-align: center;
}

.dm-timer-label {
    font-size: 0.8rem;
    color: var(--neon-purple);
    margin-bottom: 5px;
}

.dm-timer-value {
    font-size: 2rem;
    font-weight: bold;
    color: white;
}

.kill-feed {
    position: absolute;
    top: 150px;
    right: 20px;
    width: 300px;
}

.kill-message {
    background-color: rgba(26, 26, 26, 0.8);
    border-left: 3px solid var(--neon-pink);
    padding: 10px 15px;
    margin-bottom: 5px;
    font-size: 0.9rem;
    animation: slideInRight 0.3s ease-out, fadeOut 3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    0%, 80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Dual Character Selection */
#dual-character-select-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
}

.dual-selection-main-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    max-width: 1600px;
    margin: 40px 0;
}

.side-panel {
    flex: 0 0 250px;
    padding: 20px;
}

.side-panel .selected-character {
    background: rgba(20, 20, 20, 0.9);
    border: 3px solid var(--neon-green);
    border-radius: 15px;
    padding: 20px;
    min-height: 400px;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 30px rgba(0, 255, 0, 0.3); }
    50% { box-shadow: 0 0 50px rgba(0, 255, 0, 0.5); }
}

.side-panel .player-title {
    color: var(--neon-blue);
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
}

.side-panel .selected-info h3 {
    color: var(--neon-green);
    font-size: 1.8rem;
    margin-bottom: 15px;
    text-align: center;
}

.side-panel .selected-info p {
    color: var(--light-bg);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Ensure start button is visible in dual character select */
#dual-character-select-screen #start-game-btn {
    position: relative;
    margin: 20px auto;
    min-width: 250px;
    background: var(--neon-green);
    color: var(--dark-bg);
    border: 2px solid var(--neon-green);
    font-size: 20px;
    padding: 15px 30px;
}

.dual-selection-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    flex: 1;
}

.player-selection {
    flex: 1;
    text-align: center;
}

.player-title {
    font-size: 1.5rem;
    color: var(--neon-blue);
    margin-bottom: 20px;
    text-shadow: 0 0 15px currentColor;
}

.character-grid.small-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
    max-height: 400px;
    overflow-y: auto;
}

.character-grid.small-grid .character-card {
    padding: 15px;
}
.character-grid.small-grid .character-preview {
    width: 60px;
    height: 60px;
    margin: 10px auto;
    display: block;
}
.character-card-name {
    color: var(--neon-blue);
    font-size: 14px;
    margin: 5px 0;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.2;
}
.character-card-ability {
    font-size: 11px;
    color: var(--neon-yellow);
    text-align: center;
    margin-top: 5px;
    line-height: 1.2;
}

.character-card-ability div {
    margin: 1px 0;
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 100px;
    height: 200px;
}

#dual-character-select-screen .select-btn {
    position: relative;
    z-index: 100;
    margin: 30px auto 20px;
    display: block;
    min-width: 250px;
}

.vs-text {
    font-size: 3rem;
    font-weight: bold;
    color: var(--neon-pink);
    text-shadow: 0 0 30px currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.player-selection .selected-character {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(26, 26, 26, 0.8);
    border: 2px solid var(--neon-green);
    border-radius: 10px;
}

.selected-info h3 {
    color: var(--neon-green);
    margin-bottom: 10px;
}

.selected-info p {
    color: var(--light-bg);
    font-size: 0.9rem;
}

/* Touch Controls */
#touch-ui-buttons {
    display: none;
}

@media (max-width: 768px), (pointer: coarse) {
    #touch-ui-buttons {
        display: block;
    }
}

.touch-button {
    position: absolute;
    background: rgba(20, 20, 20, 0.8);
    border: 2px solid var(--neon-blue);
    border-radius: 10px;
    color: var(--neon-blue);
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: bold;
    padding: 15px 20px;
    pointer-events: auto;
    touch-action: manipulation; /* Eliminates 300ms delay */
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.2s ease;
    z-index: 2001;
    /* Minimum touch target size */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.touch-button:active {
    background: rgba(0, 234, 255, 0.3);
    border-color: var(--neon-green);
    color: var(--neon-green);
    transform: scale(0.95);
}

#touch-pause {
    width: 50px;
    height: 50px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#touch-dodge {
    background: rgba(255, 0, 128, 0.3);
    border-color: var(--neon-pink);
    color: var(--neon-pink);
}

.touch-icon-btn {
    width: clamp(45px, 10vw, 60px); /* Responsive with min/max */
    height: clamp(45px, 10vw, 60px);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1/1;
}

#touch-switch {
    background: rgba(0, 234, 255, 0.3);
    border-color: var(--neon-blue);
    color: var(--neon-blue);
}

#touch-inventory {
    background: rgba(138, 43, 226, 0.3);
    border-color: var(--neon-purple);
    color: var(--neon-purple);
}

/* Shop overlay styles for mobile */
.shop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Responsive Design for Mobile */
@media (max-width: 768px), (max-height: 600px), (pointer: coarse) {
    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    .shop-overlay {
        padding: 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #game-container {
        width: 100vw;
        height: 100vh;
    }
    
    .menu-btn {
        font-size: 16px;
        padding: 15px 30px;
        margin: 10px;
    }
    
    .game-title {
        font-size: 2.5rem;
    }
    
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        max-width: 90vw;
    }
    
    .character-card {
        padding: 10px;
    }
    
    .dual-selection-main-container {
        flex-direction: column;
        max-width: 100%;
        padding: 10px;
    }
    
    .side-panel {
        display: none;
    }
    
    .dual-selection-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .vs-divider {
        width: 100%;
        height: 50px;
    }
    
    .controls-container {
        flex-direction: column;
        gap: 20px;
        padding: 10px;
    }
    
    .control-section {
        width: 100%;
    }
    
    /* Compact ammo display on mobile */
    .ammo-display {
        right: 10px;
        bottom: 140px;
        transform: scale(0.7);
        transform-origin: bottom right;
    }
    
    .weapon-slot {
        width: 50px;
        height: 50px;
        margin: 0;
    }
    
    .weapon-icon {
        font-size: 20px;
    }
    
    .weapon-name {
        font-size: 10px;
    }
    
    .ammo-count {
        font-size: 11px;
    }
    
    /* Hide weapon stats on mobile to save space */
    .weapon-stats {
        display: none;
    }
    
    /* Adjust HUD positioning */
    .hud-top {
        padding: 5px;
    }
    
    .health-bar {
        max-width: 150px;
        height: 20px;
    }
    
    .score {
        font-size: 16px;
    }
    
    .wave-info {
        font-size: 14px;
    }
    
    /* Shop screen mobile adjustments */
    .shop-container {
        padding: 20px;
        max-width: 100%;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .shop-title {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .shop-credits {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .weapon-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        max-height: 60vh;
        margin-bottom: 20px;
    }
    
    .weapon-item {
        padding: 10px;
    }
    
    .weapon-name {
        font-size: 16px;
    }
    
    .weapon-price {
        font-size: 14px;
    }
    
    #continue-btn {
        padding: 12px 24px;
        font-size: 16px;
        position: sticky;
        bottom: 10px;
        z-index: 10;
        background: var(--neon-green);
        border: 2px solid var(--neon-green);
    }
}

/* Specific adjustments for very small screens (phones) */
@media (max-width: 480px) and (max-height: 900px) {
    .ammo-display {
        right: 5px;
        bottom: 260px;
        transform: scale(0.5);
    }
    
    .weapon-slot {
        width: 40px;
        height: 40px;
    }
    
    #touch-dodge {
        bottom: 60px;
        right: 10px;
        padding: 12px 16px;
        font-size: 12px;
    }
}

/* Extra small phones / low resolution - more aggressive optimization */
@media (max-width: 414px), (max-height: 736px) {
    .ammo-display {
        position: fixed !important;
        right: 10px !important; /* Align with buttons */
        bottom: 70px !important; /* Align with dodge button */
        transform: scale(0.35);
        transform-origin: bottom right;
        background: rgba(0, 0, 0, 0.7);
        padding: 2px;
        border-radius: 5px;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    
    /* Make audience meter more compact on small screens */
    .audience-meter {
        position: fixed !important;
        bottom: 20px !important;
        left: 10px !important;
        right: auto !important;
        width: 150px !important;
        height: 20px !important;
        transform: scale(0.9);
        transform-origin: bottom left;
        background: rgba(0, 0, 0, 0.7);
        padding: 2px;
        border-radius: 5px;
        z-index: 100;
    }
    
    .meter-label {
        display: none; /* Hide label to save space */
    }
    
    .meter-fill {
        height: 100%;
    }
    
    /* More compact weapon slots */
    .weapon-slot {
        width: 35px;
        height: 35px;
        margin: 0;
        padding: 2px;
    }
    
    .weapon-icon {
        font-size: 16px;
    }
    
    .weapon-name {
        display: none; /* Hide weapon names to save space */
    }
    
    .ammo-count {
        font-size: 10px;
        bottom: 2px;
    }
    
    .touch-icon-btn {
        width: 40px;
        height: 40px;
        padding: 6px;
    }
    
    #touch-switch {
        bottom: 230px;
        right: 10px;
    }
    
    #touch-inventory {
        bottom: 180px;
        right: 10px;
    }
    
    #touch-dodge {
        bottom: 130px;
        right: 10px;
    }
    
    /* Move touch buttons in landscape to avoid overlap */
    @media (orientation: landscape) {
        .ammo-display {
            bottom: 50px !important;
            right: 10px !important;
            transform: scale(0.3);
        }
        
        .audience-meter {
            bottom: 5px;
            transform: scale(0.7);
        }
        
        #touch-switch {
            bottom: 200px;
        }
        
        #touch-inventory {
            bottom: 150px;
        }
        
        #touch-dodge {
            bottom: 100px;
        }
    }
}

/* Tablet-specific styles */
@media (min-width: 769px) and (max-width: 1024px) and (pointer: coarse) {
    .ammo-display {
        transform: scale(0.85);
        bottom: 150px;
    }
    
    .shop-container {
        max-width: 600px;
        padding: 30px;
    }
    
    .weapon-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: 70vh;
    }
}

/* Landscape mode adjustments for mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .screen {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding: 20px 0;
    }
    
    #menu-screen {
        min-height: 100vh;
        padding-top: 20px;
    }
    
    .game-title {
        font-size: 2rem;
        margin-bottom: 20px;
    }
    
    .menu-options {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
        max-width: 90%;
        margin-bottom: 30px;
    }
    
    .menu-btn {
        font-size: 16px;
        padding: 10px 20px;
        margin: 5px;
        min-width: 150px;
    }
    
    .high-score {
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .controls-hint {
        font-size: 12px;
        position: relative;
        bottom: auto;
        margin-top: 20px;
    }
    
    /* Character selection in landscape */
    .character-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .character-card {
        padding: 8px;
    }
    
    .character-preview {
        width: 60px;
        height: 60px;
    }
    
    /* Make character details scrollable but keep select button visible */
    .character-details {
        max-height: 50vh;
        overflow-y: auto;
        padding-bottom: 60px; /* Space for fixed button */
    }
    
    /* Fixed select button in landscape */
    #select-character-btn {
        position: fixed;
        bottom: 70px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        min-width: 200px;
        background: var(--neon-green);
        box-shadow: 0 0 20px var(--neon-green);
    }
    
    /* Shop in landscape */
    .shop-container {
        max-height: 85vh;
        padding: 15px;
    }
    
    .weapon-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: 50vh;
    }
    
    /* Game UI in landscape */
    .ammo-display {
        bottom: 10px;
        transform: scale(0.6);
    }
    
    #touch-dodge {
        bottom: 10px;
        right: 10px;
    }
    
    /* Dual character select in landscape */
    .dual-selection-container {
        flex-direction: row;
        gap: 20px;
    }
    
    .player-selection {
        max-width: 45%;
    }
    
    .character-grid.small-grid {
        grid-template-columns: repeat(3, 1fr);
        max-height: 60vh;
    }
}

/* Ability UI Styles */
.ability-display {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border: 2px solid var(--neon-yellow);
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.ability-icon {
    width: 40px;
    height: 40px;
    border: 2px solid var(--neon-yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(255, 255, 0, 0.1);
}

.ability-key {
    font-size: 14px;
    color: var(--neon-yellow);
    font-weight: bold;
    text-shadow: 0 0 5px var(--neon-yellow);
}

/* Settings Screen Styles */
#settings-screen {
    padding: 20px;
}

.settings-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.settings-section {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--neon-blue);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.3);
}

.settings-section h3 {
    color: var(--neon-blue);
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-transform: uppercase;
    text-shadow: 0 0 10px var(--neon-blue);
}

.setting-item {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--neon-green);
}

.setting-label {
    color: #ffffff;
    font-size: 1rem;
    text-transform: uppercase;
}

.setting-description {
    color: #888;
    font-size: 0.85rem;
    margin-top: 5px;
    margin-left: 30px;
    flex-basis: 100%;
}

.setting-item input[type="range"] {
    flex: 1;
    min-width: 200px;
    accent-color: var(--neon-pink);
}

.volume-value {
    color: var(--neon-pink);
    font-weight: bold;
    min-width: 50px;
    text-align: right;
}

.ability-name {
    font-size: 14px;
    color: var(--neon-yellow);
    text-transform: uppercase;
    text-shadow: 0 0 5px var(--neon-yellow);
}

.ability-cooldown {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #666;
}

/* Multiplayer ability display */
.ability-display-small {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.ability-key-small {
    font-size: 12px;
    color: var(--neon-yellow);
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    border: 1px solid var(--neon-yellow);
}

.ability-cooldown-small {
    font-size: 12px;
    color: #666;
    font-weight: bold;
}

/* Mobile ability button */
#touch-ability {
    position: fixed;
    bottom: 160px;
    right: 20px;
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 0, 0.1);
    border: 3px solid var(--neon-yellow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow);
    touch-action: none;
    user-select: none;
    z-index: 1001;
}

#touch-ability:active {
    background: rgba(255, 255, 0, 0.3);
    transform: scale(0.95);
}

#touch-ability.cooldown {
    background: rgba(60, 60, 60, 0.3);
    border-color: #666;
    color: #666;
    text-shadow: none;
}

#touch-ability .cooldown-text {
    font-size: 18px;
}

/* Authentication Screens */
.auth-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
}

.auth-form {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--neon-blue);
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 20px;
}

.auth-form h2 {
    color: var(--neon-blue);
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--neon-blue);
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.8) !important;
    border: 1px solid var(--neon-purple);
    color: white !important;
    font-family: 'Orbitron', monospace;
    border-radius: 5px;
    font-size: 14px;
    -webkit-text-fill-color: white !important;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.3);
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    pointer-events: auto !important;
    cursor: text !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    z-index: 1000;
}

/* Specific fixes for register form inputs */
#register-form input {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    pointer-events: auto !important;
    cursor: text !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    -webkit-text-fill-color: white !important;
}

/* Hide auth form inputs from password managers when screen is not active */
#auth-screen:not(.active) input {
    visibility: hidden !important;
    display: none !important;
}

/* Ensure auth screen has proper z-index - inherit positioning from .screen */
#auth-screen {
    z-index: 10000 !important;
}

#auth-screen.active {
    z-index: 10001 !important;
}

/* Center the auth container properly */
#auth-screen .auth-container {
    max-width: 400px;
    width: 90%;
    margin: 0 auto;
    text-align: center;
}

/* Fix back button and similar buttons positioning across all screens */
.back-btn,
#auth-back-btn,
#mm-cancel-btn,
#lobby-browser-back-btn,
#create-lobby-back-btn,
#profile-back-btn,
#leaderboard-back-btn,
#character-back-btn,
#dual-character-back-btn,
#settings-back-btn {
    position: fixed !important;
    bottom: 40px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    min-width: 120px;
    padding: 12px 30px !important;
    margin: 0 !important;
    z-index: 1000 !important;
}

/* Hide game buttons when auth screen is active to prevent conflicts */
#auth-screen.active ~ * #restart-btn,
#auth-screen.active ~ * #start-btn,
#auth-screen.active ~ * #menu-btn {
    display: none !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* Ensure register link has proper positioning and z-index */
#show-register,
#show-login {
    z-index: 10002 !important;
    position: relative !important;
    display: inline-block !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Force ALL input fields to be interactive - global CSS approach */
input,
input[type="text"],
input[type="email"], 
input[type="password"],
input[type="search"],
textarea,
select {
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    cursor: text !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    z-index: 1000 !important;
    position: relative !important;
}

/* Specific styling for all game input fields */
.auth-form input,
.create-lobby-form input,
.lobby-chat input,
#lobby-name,
#lobby-password,
#lobby-chat-input,
input[type="text"],
input[type="email"],
input[type="password"] {
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    cursor: text !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    -webkit-text-fill-color: white !important;
    border: 1px solid var(--neon-purple) !important;
    padding: 12px !important;
    font-family: 'Orbitron', monospace !important;
    font-size: 14px !important;
    z-index: 10000 !important;
    position: relative !important;
    width: 100%;
    margin-bottom: 15px;
    border-radius: 5px;
}

/* Focus states for all inputs */
input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: var(--neon-pink) !important;
    box-shadow: 0 0 10px var(--neon-pink) !important;
    outline: none !important;
}

/* Fix button clickability issues - ensure all buttons are fully clickable */
button,
.menu-btn,
.btn,
input[type="button"],
input[type="submit"] {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 1000 !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
}

/* Only apply full width to main menu buttons and form buttons */
.menu-options .menu-btn,
.auth-form button,
.create-lobby-form button,
#create-lobby-submit,
#login-submit button,
#register-submit button {
    width: 100% !important;
    display: block !important;
    padding: 15px 20px !important;
    margin: 5px 0 !important;
}

/* Button hover and active states */
button:hover,
.menu-btn:hover,
.btn:hover,
input[type="button"]:hover,
input[type="submit"]:hover {
    background: var(--neon-blue) !important;
    color: black !important;
    box-shadow: 0 0 20px var(--neon-blue) !important;
    text-shadow: none !important;
}

button:active,
.menu-btn:active,
.btn:active,
input[type="button"]:active,
input[type="submit"]:active {
    transform: scale(0.98) !important;
}

/* Specific fixes for common problematic buttons - only ensure clickability, not width */
#create-lobby-btn,
#browse-lobbies-btn,
#quick-match-btn,
#profile-btn,
#logout-btn,
#online-btn,
#start-btn,
#coop-btn,
#deathmatch-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 1001 !important;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--neon-pink);
    box-shadow: 0 0 10px var(--neon-pink);
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.auth-switch a {
    color: var(--neon-blue);
    text-decoration: none;
}

.auth-switch a:hover {
    text-shadow: 0 0 5px var(--neon-blue);
}

.auth-error {
    color: var(--neon-red);
    text-align: center;
    margin-top: 10px;
    text-shadow: 0 0 5px var(--neon-red);
}

.auth-status {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: var(--neon-green);
    font-size: 12px;
}

/* Online Menu */
.online-info {
    text-align: center;
    margin-bottom: 20px;
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
}

/* Lobby Browser */
.lobby-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.lobby-filters select {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--neon-blue);
    color: white;
    font-family: 'Orbitron', monospace;
    border-radius: 5px;
    cursor: pointer;
}

.small-btn {
    padding: 10px 20px !important;
    font-size: 14px !important;
}

.lobby-list {
    max-width: 800px;
    margin: 0 auto;
    max-height: 400px;
    overflow-y: auto;
}

.lobby-item {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}

.lobby-item:hover {
    border-color: var(--neon-pink);
    box-shadow: 0 0 10px var(--neon-pink);
}

.lobby-item-info {
    text-align: left;
}

.lobby-item-name {
    color: var(--neon-blue);
    font-size: 18px;
    margin-bottom: 5px;
}

.lobby-item-details {
    color: #999;
    font-size: 14px;
}

.lobby-item-join {
    color: var(--neon-green);
    font-size: 14px;
}

/* Create Lobby */
.create-lobby-form {
    max-width: 400px;
    margin: 0 auto;
}

.create-lobby-form input,
.create-lobby-form select {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    color: white;
    font-family: 'Orbitron', monospace;
    border-radius: 5px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.checkbox-container input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    margin-bottom: 0;
}

/* Lobby Room */
.lobby-info {
    text-align: center;
    margin-bottom: 20px;
    color: var(--neon-blue);
}

.lobby-players {
    max-width: 600px;
    margin: 0 auto 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.lobby-player {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    padding: 15px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lobby-player.ready {
    border-color: var(--neon-green);
    box-shadow: 0 0 5px var(--neon-green);
}

.lobby-player-name {
    color: white;
}

.lobby-player-status {
    color: var(--neon-green);
    font-size: 12px;
}

.lobby-chat {
    max-width: 600px;
    margin: 0 auto 20px;
}

.chat-messages {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    height: 200px;
    overflow-y: auto;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
}

.chat-message {
    margin-bottom: 5px;
    font-size: 14px;
}

.chat-message-user {
    color: var(--neon-blue);
}

.chat-message-text {
    color: white;
}

.lobby-chat input {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    color: white;
    font-family: 'Orbitron', monospace;
    border-radius: 5px;
}

.lobby-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Matchmaking */
.matchmaking-info {
    text-align: center;
    padding: 50px;
}

.matchmaking-mode {
    color: var(--neon-blue);
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow: 0 0 10px var(--neon-blue);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--neon-pink);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.mm-queue-info,
.mm-time {
    color: #999;
    margin-top: 10px;
}

/* Leaderboard */
.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    color: white;
    font-family: 'Orbitron', monospace;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover {
    border-color: var(--neon-pink);
}

.tab-btn.active {
    background: var(--neon-purple);
    border-color: var(--neon-purple);
    box-shadow: 0 0 10px var(--neon-purple);
}

.leaderboard-list {
    max-width: 800px;
    margin: 0 auto;
}

.leaderboard-item {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-item.gold {
    border-color: #FFD700;
    box-shadow: 0 0 10px #FFD700;
}

.leaderboard-item.silver {
    border-color: #C0C0C0;
    box-shadow: 0 0 10px #C0C0C0;
}

.leaderboard-item.bronze {
    border-color: #CD7F32;
    box-shadow: 0 0 10px #CD7F32;
}

.leaderboard-rank {
    font-size: 24px;
    color: var(--neon-blue);
    width: 50px;
}

.leaderboard-player {
    flex: 1;
    text-align: left;
    margin-left: 20px;
}

.leaderboard-player-name {
    color: white;
    font-size: 18px;
}

.leaderboard-stats {
    text-align: right;
}

.leaderboard-rating {
    color: var(--neon-green);
    font-size: 20px;
}

.leaderboard-games {
    color: #999;
    font-size: 14px;
}

/* Profile */
.profile-header {
    text-align: center;
    margin-bottom: 30px;
}

.profile-header h2 {
    color: var(--neon-blue);
    font-size: 32px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px var(--neon-blue);
}

.profile-joined {
    color: #999;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    max-width: 600px;
    margin: 0 auto 40px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    padding: 20px;
    border-radius: 5px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 32px;
    color: var(--neon-green);
    margin-bottom: 5px;
    text-shadow: 0 0 5px var(--neon-green);
}

.stat-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
}

.profile-rankings {
    max-width: 600px;
    margin: 0 auto;
}

.profile-rankings h3 {
    color: var(--neon-purple);
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 0 0 5px var(--neon-purple);
}

.ranking-item {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--neon-purple);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ranking-mode {
    color: var(--neon-blue);
}

.ranking-info {
    text-align: right;
}

.ranking-position {
    color: var(--neon-green);
    font-size: 20px;
}

.ranking-rating {
    color: #999;
    font-size: 14px;
}

/* Ensure menu elements are hidden when screens are not active */
.screen:not(.active) {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    z-index: -1 !important;
}

.screen:not(.active) * {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Specifically hide online menu elements when not active */
#online-menu-screen:not(.active) .menu-options,
#online-menu-screen:not(.active) .menu-btn {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Touch control layout improvements */
.touch-pause {
    top: 2%;
    right: 2%;
}

.touch-controls-right {
    position: absolute;
    bottom: 5%;
    right: 3%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

/* Ensure touch controls don't overlap with other UI elements */
@media (max-width: 768px) {
    .ammo-display {
        /* Move ammo display to avoid touch control overlap */
        bottom: 50% !important;
        right: 10px !important;
        transform: translateY(50%) scale(0.7);
        transform-origin: right center;
    }
    
    .audience-meter {
        /* Keep audience meter on left side */
        left: 10px !important;
        bottom: 10px !important;
        right: auto !important;
        max-width: 150px;
    }
}

/* Responsive adjustments for different screen sizes */
@media (max-height: 600px) {
    .touch-controls-right {
        bottom: 3%;
        gap: 8px;
    }
    
    .touch-icon-btn {
        width: clamp(40px, 8vw, 50px) !important;
        height: clamp(40px, 8vw, 50px) !important;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .touch-controls-right {
        flex-direction: row;
        bottom: 5%;
        right: 5%;
        gap: 15px;
    }
    
    .ammo-display {
        /* In landscape, move ammo display higher */
        bottom: 60% !important;
        transform: translateY(50%) scale(0.6);
    }
}
