/* Orbitron is loaded via a <link> in index.html so the font CSS downloads in
   parallel with this stylesheet instead of serializing behind it. */

:root {
    --neon-pink: #ff006e;
    --neon-blue: #00f5ff;
    --neon-cyan: #00f5ff; /* Alias for --neon-blue, used in settings/pause menus for semantic distinction */
    --neon-purple: #8b00ff;
    --neon-green: #22c55e; /* was #00ff41 - toned down, pure saturated green read as too loud/bright across the shop and HUD */
    --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%;
    /* 100% (and 100vh below) sizes against the LARGEST possible mobile
       viewport, as if the browser's address bar/toolbar were hidden. When
       it's actually visible, that leaves real content below the fold. dvh
       tracks the true visible viewport and updates live as toolbars
       show/hide; unsupported browsers simply ignore this line and keep
       the 100% fallback above. */
    height: 100dvh;
    margin: 0;
    padding: 0;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    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;
    /* viewport-fit=cover lets content draw under notches/home-indicator
       areas; without this, HUD elements below (which resolve
       "top/right/bottom/left: Npx" against this element's padding edge)
       can render under those unsafe areas. This game is landscape-only
       (fixed 1920x1080 virtual res), where a notch/rounded corner is more
       likely on the left/right edge than top/bottom, so all four sides
       are covered here. env() resolves to 0 on devices without them, so
       this is a no-op elsewhere. */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    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);
}

.difficulty-indicator {
    background-color: rgba(255, 0, 64, 0.3);
    padding: 8px 16px;
    border: 2px solid var(--neon-red);
    text-align: center;
}

#difficulty-label {
    color: var(--neon-red);
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 10px var(--neon-red);
    letter-spacing: 2px;
}

.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; }
}

/* Difficulty Selection */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 40px 0;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 40px;
    min-width: 300px;
}

.difficulty-name {
    font-size: 24px;
    font-weight: bold;
}

.difficulty-desc {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 8px;
    font-weight: normal;
}

.difficulty-btn:hover .difficulty-desc {
    opacity: 1;
}

.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%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Ensure shop is always on top */
}

/* Old shop styles removed - using new .shop-container-new design */

/* ===== NEW WEAPON SHOP DESIGN ===== */
.shop-container-new {
    /* A quieter, near-black canvas so foreground accents (title glow, rarity-
       colored icons, the gold credits pill) are what actually draw the eye,
       instead of a moderately bright purple wash competing with everything
       drawn on top of it. */
    background: linear-gradient(135deg, rgba(6, 4, 12, 0.98) 0%, rgba(12, 6, 22, 0.98) 100%);
    border: 2px solid var(--neon-purple);
    border-radius: 16px;
    padding: 0;
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow: hidden;
    box-shadow:
        0 0 60px rgba(139, 0, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    /* Purple is the shop's one identity color (matches the container border
       and every other overlay in this game having its own single accent -
       pause is cyan, settings is purple, inventory is blue). One hue here,
       not a pink-to-purple-to-blue wash, so the gold credits pill on the
       right has room to read as a distinct, deliberate accent rather than
       a fourth color joining the fight. */
    background: linear-gradient(90deg, rgba(139, 0, 255, 0.18) 0%, rgba(139, 0, 255, 0.04) 100%);
    border-bottom: 1px solid rgba(139, 0, 255, 0.3);
}

.shop-title-new {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 4px;
    /* Solid off-white with a single-color glow reads as a premium terminal
       readout - a pink-purple-blue gradient here was a third and fourth
       hue competing with the header's own accent before a single card had
       even loaded. */
    color: #f0eef5;
    text-shadow: 0 0 20px rgba(139, 0, 255, 0.6), 0 0 40px rgba(139, 0, 255, 0.3);
}

.shop-credits-new {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.5);
    padding: 12px 24px;
    border-radius: 30px;
    border: 2px solid var(--neon-yellow);
    /* Gold is reserved exclusively for currency in this screen - the only
       other place it shows up is the "affordable" price state, so it stays
       legible as "this is about money" rather than being one more color in
       a crowd. */
    box-shadow: 0 0 16px rgba(255, 255, 0, 0.22);
}

.credits-icon {
    font-size: 24px;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow);
    animation: icon-pulse 2s infinite;
}

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

.shop-credits-new #shop-credits {
    font-size: 28px;
    font-weight: bold;
    color: var(--neon-yellow);
    text-shadow: 0 0 15px var(--neon-yellow);
}

.credits-label {
    font-size: 12px;
    color: rgba(255, 255, 0, 0.7);
    letter-spacing: 2px;
}

.shop-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* Equipped Panel */
.equipped-panel {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(0, 60, 20, 0.08) 100%);
    border: 2px solid var(--neon-green);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}

.panel-title {
    font-size: 14px;
    color: var(--neon-green);
    letter-spacing: 3px;
    margin-bottom: 16px;
    text-shadow: 0 0 10px var(--neon-green);
}

.equipped-weapon-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.weapon-icon-large {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid currentColor;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    position: relative;
    overflow: hidden;
}

.weapon-icon-large::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.equipped-info {
    flex: 1;
}

.equipped-name {
    font-size: 24px;
    font-weight: bold;
    display: block;
    margin-bottom: 8px;
    text-shadow: 0 0 15px currentColor;
}

.equipped-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.equipped-stats .stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.equipped-stats .stat-label {
    font-size: 11px;
    color: #888;
    min-width: auto;
}

.equipped-stats .stat-bar-mini {
    width: 100px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
}

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

/* Category Tabs */
.shop-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.category-tab {
    padding: 10px 24px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(139, 0, 255, 0.3);
    border-radius: 20px;
    color: #888;
    font-family: 'Orbitron', monospace;
    font-size: 12px;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-tab:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    box-shadow: 0 0 15px rgba(139, 0, 255, 0.3);
}

.category-tab.active {
    /* Solid identity color instead of a purple-to-pink gradient - one hue,
       used consistently, reads as "selected" more clearly than a second
       gradient competing with the title and the weapon cards below it. */
    background: var(--neon-purple);
    border-color: transparent;
    color: white;
    box-shadow: 0 0 20px rgba(139, 0, 255, 0.45);
}

/* New Weapon Grid */
.weapon-grid-new {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* New Weapon Card */
.weapon-card-new {
    background: linear-gradient(135deg, rgba(20, 15, 30, 0.9) 0%, rgba(30, 20, 45, 0.9) 100%);
    border: 2px solid rgba(139, 0, 255, 0.3);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.weapon-card-new::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--neon-blue), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.weapon-card-new:hover {
    transform: translateY(-4px);
    border-color: var(--neon-blue);
    box-shadow: 0 10px 40px rgba(0, 245, 255, 0.3);
}

.weapon-card-new:hover::before {
    opacity: 1;
}

.weapon-card-new.owned {
    border-color: var(--neon-green);
    background: linear-gradient(135deg, rgba(0, 40, 20, 0.9) 0%, rgba(0, 60, 30, 0.9) 100%);
}

.weapon-card-new.owned::after {
    content: '✓ OWNED';
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    color: var(--neon-green);
    background: rgba(34, 197, 94, 0.2);
    padding: 4px 8px;
    border-radius: 10px;
    letter-spacing: 1px;
}

.weapon-card-new.locked {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(100, 100, 100, 0.3);
}

.weapon-card-new.locked:hover {
    transform: none;
    box-shadow: none;
}

/* Weapon Card Header */
.weapon-card-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.weapon-icon-new {
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid currentColor;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

/* Weapon icons are rendered via JavaScript - data-type attr used for styling only */

.weapon-icon-img {
    width: 88%;
    height: 88%;
    object-fit: contain;
    pointer-events: none;
}

.weapon-card-info {
    flex: 1;
    min-width: 0;
}

.weapon-name-new {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 4px;
    /* Was inline-colored per-weapon (style="color: ${safeColor}") - with six
       weapon cards visible at once that meant six independently-blazing
       headline colors fighting for attention. The per-weapon color still
       shows on the icon swatch next to it (a small, contained "quick ID"),
       so nothing is lost - the name itself just reads as text now instead
       of competing as another light source. */
    color: #e8e6ee;
    text-shadow: none;
}

.weapon-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* All seven mechanic tags (piercing/explosive/burn/chain/poison/bounce/
   charge) previously each got their own fully-saturated background+text
   color - green, hot pink, orange, cyan, mint, lime, magenta - stacked
   across every card in the grid at once. The label text already says what
   the tag is; color doesn't need to re-encode that too. One quiet, shared
   chip style scans just as fast without adding to the noise. */
.weapon-tag {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0, 245, 255, 0.08);
    border: 1px solid rgba(0, 245, 255, 0.25);
    color: #9fd8dd;
    letter-spacing: 1px;
}

/* Weapon Stats Bars */
.weapon-stats-new {
    margin-bottom: 16px;
}

.stat-row-new {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.stat-label-new {
    font-size: 10px;
    color: #666;
    width: 50px;
    letter-spacing: 1px;
}

.stat-bar-new {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.stat-fill-new {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

/* Previously red-pink/mint-green/blue-cyan - literal clashing primaries
   repeated on every card, three bars deep. Two of the three now tie into
   the shop's own identity colors (cyan, purple) instead of introducing
   unrelated hues; damage keeps a single warm tone as the one intentional
   contrast, since "damage reads as aggressive/red" is a strong enough
   convention to be worth keeping as the lone exception. */
.stat-fill-new.damage {
    background: #e0304f;
    box-shadow: 0 0 8px rgba(224, 48, 79, 0.45);
}

.stat-fill-new.rate {
    background: var(--neon-blue);
    box-shadow: 0 0 8px rgba(0, 245, 255, 0.4);
}

.stat-fill-new.ammo {
    background: var(--neon-purple);
    box-shadow: 0 0 8px rgba(139, 0, 255, 0.4);
}

.stat-value-new {
    font-size: 10px;
    color: #888;
    width: 40px;
    text-align: right;
}

/* Weapon Price */
.weapon-price-new {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.price-amount {
    font-size: 18px;
    font-weight: bold;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

.price-amount.affordable {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.price-amount.owned {
    color: var(--neon-green);
    font-size: 14px;
}

.price-amount.locked {
    color: #666;
}

/* Solid fills instead of two-color gradients per state - purple=buy,
   green=equip (matches the equipped panel), blue=refill. Three distinct
   actions still get three distinct colors (that's meaningful, not
   decorative - it tells you what tapping the card will do), just without
   each one also being its own mini gradient. */
.buy-btn {
    padding: 8px 16px;
    background: var(--neon-purple);
    border: none;
    border-radius: 20px;
    color: white;
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.buy-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(139, 0, 255, 0.5);
}

.buy-btn.equip {
    background: var(--neon-green);
}

.buy-btn.refill {
    background: var(--neon-blue);
}

/* Shop Footer */
.shop-footer {
    padding: 20px 32px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(139, 0, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-hint {
    font-size: 12px;
    color: #666;
    letter-spacing: 1px;
}

.continue-btn-new {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--neon-green), #00aa44);
    border: none;
    border-radius: 30px;
    color: white;
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.3);
}

.continue-btn-new:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.45);
}

.btn-arrow {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.continue-btn-new:hover .btn-arrow {
    transform: translateX(5px);
}

/* Mobile Responsive for New Shop */
@media (max-width: 768px) {
    .shop-container-new {
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .shop-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .shop-title-new {
        font-size: 24px;
    }

    .shop-body {
        padding: 16px;
    }

    .equipped-panel {
        padding: 16px;
    }

    .equipped-weapon-card {
        flex-direction: column;
        text-align: center;
    }

    .weapon-grid-new {
        grid-template-columns: 1fr;
    }

    .shop-footer {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .shop-hint {
        text-align: center;
    }

    .continue-btn-new {
        width: 100%;
        justify-content: center;
    }
}

/* 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);
    max-height: calc(100dvh - 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;
}

/* Pause Menu */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.pause-container {
    background: rgba(10, 10, 10, 0.95);
    border: 3px solid var(--neon-cyan);
    border-radius: 20px;
    padding: 50px 80px;
    text-align: center;
    box-shadow: 0 0 50px var(--neon-cyan);
}

.pause-title {
    font-size: 48px;
    color: var(--neon-cyan);
    margin-bottom: 40px;
    text-shadow: 0 0 20px var(--neon-cyan);
    letter-spacing: 8px;
}

.pause-btn {
    display: block;
    width: 100%;
    margin: 15px 0;
    padding: 15px 40px;
    font-size: 20px;
    transition: transform 0.15s ease;
}

.pause-btn:hover {
    transform: scale(1.05);
}

/* Settings Menu
 * Z-index hierarchy for overlays:
 * 10002 - Settings menu (top-most, overlays pause menu)
 * 10001 - Pause menu
 * 1000  - Weapon shop, character select, inventory overlays
 * Default - Game UI elements
 */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
}

.settings-container {
    background: rgba(10, 10, 10, 0.95);
    border: 3px solid var(--neon-purple);
    border-radius: 20px;
    padding: 50px 80px;
    text-align: center;
    box-shadow: 0 0 50px var(--neon-purple);
    min-width: 400px;
}

.settings-title {
    font-size: 48px;
    color: var(--neon-purple);
    margin-bottom: 40px;
    text-shadow: 0 0 20px var(--neon-purple);
    letter-spacing: 8px;
}

.settings-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.settings-label {
    font-size: 24px;
    color: var(--neon-cyan);
    letter-spacing: 2px;
}

.toggle-btn {
    font-family: 'Orbitron', monospace;
    font-size: 18px;
    font-weight: bold;
    padding: 10px 30px;
    border: 2px solid var(--neon-green);
    background: transparent;
    color: var(--neon-green);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.toggle-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    box-shadow: 0 0 15px var(--neon-green);
}

.toggle-btn.off {
    border-color: var(--neon-pink);
    color: var(--neon-pink);
}

.toggle-btn.off:hover {
    background: rgba(255, 0, 110, 0.2);
    box-shadow: 0 0 15px var(--neon-pink);
}

.toggle-btn:focus {
    outline: none;
    box-shadow: 0 0 20px var(--neon-green), 0 0 5px var(--neon-green) inset;
}

.toggle-btn:focus-visible {
    outline: 2px solid var(--neon-green);
    outline-offset: 2px;
}

.toggle-btn.off:focus {
    box-shadow: 0 0 20px var(--neon-pink), 0 0 5px var(--neon-pink) inset;
}

.toggle-btn.off:focus-visible {
    outline-color: var(--neon-pink);
}

.settings-back-btn {
    margin-top: 30px;
    display: block;
    width: 100%;
}

/* Weapon Inventory */
.inventory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    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(34, 197, 94, 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%;
    height: 100dvh;
    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%;
        height: 100dvh;
    }
    
    .shop-overlay {
        padding: 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #game-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
    }
    
    .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;
    }
    
    /* Buttons are flex children of .touch-controls-right — no offsets */
    #touch-dodge {
        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 buttons are laid out by the .touch-controls-right flex column;
       per-button offsets predate it and misplace relative-positioned
       children, so none belong here. */

    /* Keep the ammo display legible in landscape (0.3 was unreadable) */
    @media (orientation: landscape) {
        .ammo-display {
            bottom: 50px !important;
            right: 10px !important;
            transform: scale(0.6);
        }

        .audience-meter {
            bottom: 5px;
            transform: scale(0.7);
        }
    }
}

/* 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;
        min-height: 100dvh;
        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;
        max-height: 60dvh;
        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;
        max-height: 50dvh;
        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);
    }
    
    /* 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;
        max-height: 60dvh;
    }
}

/* 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 (flex child of .touch-controls-right) */
#touch-ability {
    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,
#online-back-btn,
#mm-cancel-btn,
#lobby-browser-back-btn,
#create-lobby-back-btn,
#lobby-leave-btn,
#profile-back-btn,
#store-back-btn,
#leaderboard-back-btn,
#character-back-btn,
#dual-character-back-btn,
#difficulty-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;
}

/* Supporter Pack store screen */
.store-title {
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
}

.store-pitch {
    max-width: 480px;
    margin: 0 auto 30px;
    text-align: center;
    color: #ccc;
    line-height: 1.5;
}

.store-status-message {
    text-align: center;
    color: #999;
    margin: 20px 0;
    min-height: 1.2em;
}

.store-buy-btn {
    border-color: #ffd700 !important;
    color: #ffd700 !important;
}

.store-buy-btn:before {
    background: #ffd700 !important;
}

.store-owned-badge {
    text-align: center;
    color: #ffd700;
    text-shadow: 0 0 8px #ffd700;
    font-size: 18px;
    margin-bottom: 30px;
}

.store-option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 400px;
    margin: 0 auto 20px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #ffd700;
    border-radius: 5px;
}

.store-option-row label {
    color: #eee;
}

.store-option-row input[type="color"] {
    width: 48px;
    height: 32px;
    border: 1px solid #ffd700;
    border-radius: 4px;
    background: none;
    cursor: pointer;
}

.store-option-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #ffd700;
}

/* 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);
    }
}

/* Release-facing main menu */
#menu-screen {
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 35%, rgba(0, 245, 255, 0.13), transparent 32%),
        radial-gradient(circle at 82% 65%, rgba(255, 0, 110, 0.14), transparent 34%),
        linear-gradient(135deg, #03070a 0%, #08050d 52%, #030508 100%);
}

#menu-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 245, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 245, 255, 0.035) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    pointer-events: none;
}

#menu-screen::after {
    content: '';
    position: absolute;
    width: 45vw;
    height: 45vw;
    right: -24vw;
    top: -22vw;
    border: 1px solid rgba(255, 0, 110, 0.25);
    transform: rotate(45deg);
    box-shadow: 0 0 80px rgba(255, 0, 110, 0.1);
    pointer-events: none;
}

.menu-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, 88vw);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    gap: clamp(50px, 8vw, 130px);
    align-items: center;
}

.broadcast-status,
.menu-footer-line {
    position: absolute;
    z-index: 2;
    color: rgba(255, 255, 255, 0.52);
    font-size: 10px;
    letter-spacing: 3px;
}

.broadcast-status {
    top: 34px;
    left: 6vw;
}

.broadcast-status span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--neon-pink);
    box-shadow: 0 0 12px var(--neon-pink);
    animation: broadcastPulse 1.2s steps(2, end) infinite;
}

@keyframes broadcastPulse {
    50% { opacity: 0.35; }
}

.menu-footer-line {
    right: 6vw;
    bottom: 30px;
}

.menu-intro {
    text-align: left;
}

.menu-kicker {
    margin-bottom: 22px;
    color: var(--neon-yellow);
    font-size: 11px;
    letter-spacing: 4px;
}

#menu-screen .game-title {
    margin: 0 0 32px;
    font-size: clamp(76px, 8.5vw, 132px);
    line-height: 0.82;
    letter-spacing: -5px;
    text-align: left;
}

.menu-premise {
    max-width: 570px;
    margin-bottom: 28px;
    color: #a9b7c0;
    font-family: monospace;
    font-size: 15px;
    line-height: 1.7;
}

#menu-screen .tagline {
    display: inline-block;
    padding-left: 14px;
    border-left: 3px solid var(--neon-pink);
    color: var(--neon-blue);
    animation: none;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 34px;
    border-left: 1px solid rgba(0, 245, 255, 0.45);
    background: linear-gradient(90deg, rgba(0, 245, 255, 0.045), transparent 70%);
}

.menu-actions .menu-btn {
    margin: 0;
}

.primary-menu-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 22px 26px;
    border-color: var(--neon-pink);
    background: rgba(255, 0, 110, 0.09);
    color: white;
    text-align: left;
}

.primary-menu-btn span {
    font-size: 25px;
}

.primary-menu-btn small {
    margin-top: 7px;
    color: #c98ba5;
    font-family: monospace;
    font-size: 12px;
    font-weight: normal;
    letter-spacing: 1px;
    text-transform: none;
}

.primary-menu-btn:hover {
    background: var(--neon-pink);
    box-shadow: 0 0 34px rgba(255, 0, 110, 0.65);
}

.primary-menu-btn:hover small {
    color: #26000f;
}

.menu-section-label {
    margin-top: 12px;
    color: #6e7d85;
    font-size: 9px;
    letter-spacing: 3px;
}

.local-mode-row,
.menu-utility-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.secondary-menu-btn,
.utility-menu-btn {
    padding: 13px 12px;
    font-size: 14px;
}

.utility-menu-btn {
    border-color: #43545d;
    color: #a9b7c0;
    font-size: 11px;
}

.feature-unreleased {
    display: none !important;
}

/* Audience hype is the central run mechanic, not a passive progress bar. */
.audience-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.combo-display {
    display: flex;
    align-items: baseline;
    gap: 9px;
    opacity: 0;
    transform: translateY(10px) scale(0.85);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.combo-display.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#combo-count {
    color: var(--neon-pink);
    font-size: 28px;
    font-weight: 900;
    text-shadow: 0 0 18px var(--neon-pink);
}

.combo-display.hot #combo-count {
    color: var(--neon-yellow);
    text-shadow: 0 0 22px var(--neon-yellow);
    animation: comboHit 0.35s ease-in-out infinite alternate;
}

.combo-label {
    color: #cbd5da;
    font-size: 9px;
    letter-spacing: 2px;
}

@keyframes comboHit {
    to { transform: scale(1.13) rotate(-2deg); }
}

.meter-readout {
    position: absolute;
    inset: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    font-size: 10px;
    letter-spacing: 2px;
    text-shadow: 0 1px 4px black, 0 0 5px black;
}

#audience-level {
    color: white;
    font-size: 16px;
}

#credit-multiplier {
    font-size: 8px;
}

.audience-meter[data-level="3"],
.audience-meter[data-level="4"] {
    border-color: var(--neon-pink);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.4);
}

.audience-meter[data-level="5"],
.audience-meter.airstrike-ready {
    border-color: var(--neon-yellow);
    box-shadow: 0 0 22px rgba(255, 255, 0, 0.65);
}

/* Run summary and record feedback */
#game-over-screen {
    background:
        radial-gradient(circle at 50% 25%, rgba(255, 0, 110, 0.16), transparent 35%),
        rgba(1, 3, 6, 0.96);
}

.run-result-label {
    margin-bottom: 10px;
    color: #788891;
    font-size: 10px;
    letter-spacing: 5px;
}

#game-over-screen .game-over-title {
    margin-bottom: 20px;
}

.run-score-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 22px;
}

.run-score-label {
    color: var(--neon-blue);
    font-size: 10px;
    letter-spacing: 4px;
}

#final-score {
    color: white;
    font-size: 52px;
    text-shadow: 0 0 20px var(--neon-blue);
}

.personal-best {
    min-height: 18px;
    color: #88969d;
    font-size: 10px;
    letter-spacing: 2px;
}

.personal-best.new-best {
    color: var(--neon-yellow);
    text-shadow: 0 0 12px var(--neon-yellow);
}

#game-over-screen .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(230px, 1fr));
    gap: 0 26px;
    min-width: 540px;
    margin-bottom: 24px;
    padding: 20px 28px;
}

#game-over-screen .stats p {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    font-size: 13px;
}

#game-over-screen > .menu-btn {
    min-width: 260px;
    margin: 5px;
    font-size: 16px;
}

.audio-credit {
    margin: 18px 0;
    color: #718089;
    font-family: monospace;
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
}

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

.audio-credit a:hover,
.audio-credit a:focus-visible {
    color: var(--neon-yellow);
    text-decoration: underline;
}

.menu-btn:focus-visible,
.character-card:focus-visible {
    outline: 3px solid var(--neon-yellow);
    outline-offset: 4px;
}

/* Keep navigation clear of the final character card at common laptop heights. */
#character-select-screen > #character-back-btn {
    top: 28px !important;
    bottom: auto !important;
    left: 28px !important;
    transform: none !important;
}

@media (max-width: 820px) {
    .menu-shell {
        width: min(620px, 90vw);
        grid-template-columns: 1fr;
        gap: 30px;
        padding: 70px 0;
        overflow-y: auto;
    }

    #menu-screen {
        justify-content: flex-start;
        overflow-y: auto;
    }

    #menu-screen .game-title {
        font-size: clamp(58px, 18vw, 94px);
    }

    .menu-actions {
        padding: 24px 0 40px;
        border-top: 1px solid rgba(0, 245, 255, 0.45);
        border-left: 0;
    }

    .menu-footer-line {
        display: none;
    }

    #game-over-screen .stats {
        grid-template-columns: 1fr;
        min-width: min(90vw, 420px);
    }
}

@media (max-height: 680px) and (orientation: landscape) {
    .menu-shell {
        grid-template-columns: 1fr 1fr;
        gap: 45px;
        padding: 50px 0;
    }

    #menu-screen .game-title {
        font-size: clamp(54px, 10vw, 82px);
        margin-bottom: 20px;
    }

    .menu-premise {
        margin-bottom: 15px;
        font-size: 12px;
    }

    .menu-actions {
        padding: 16px 22px;
    }

    #game-over-screen {
        justify-content: flex-start;
        padding: 24px 0;
        overflow-y: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* First-click audio preload: busy state on the pressed menu button */
button.btn-loading {
    opacity: 0.6;
    pointer-events: none;
    animation: btn-loading-pulse 0.8s ease-in-out infinite;
}

@keyframes btn-loading-pulse {
    50% { opacity: 0.35; }
}

/* Advisory toast for touch-only devices picking keyboard-driven modes */
#touch-mode-notice {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    max-width: min(92vw, 560px);
    padding: 10px 18px;
    background: rgba(5, 7, 11, 0.95);
    border: 1px solid var(--neon-yellow, #ffd700);
    border-radius: 6px;
    color: var(--neon-yellow, #ffd700);
    font-size: 13px;
    letter-spacing: 1px;
    text-align: center;
    z-index: 4000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#touch-mode-notice.visible {
    opacity: 1;
}

/* Touch airstrike trigger — armed-state styling to match its rarity */
#touch-airstrike {
    background: rgba(255, 215, 0, 0.25);
    border-color: var(--neon-yellow, #ffd700);
    color: var(--neon-yellow, #ffd700);
    animation: airstrike-armed-pulse 0.9s ease-in-out infinite;
}

@keyframes airstrike-armed-pulse {
    50% { box-shadow: 0 0 18px var(--neon-yellow, #ffd700); }
}

/* Rotate prompt: gameplay is unplayable in a ~220px letterboxed strip.
   Must stack ABOVE the pause menu (10001) and weapon shop (10000): the
   portrait auto-pause relies on this overlay being the authoritative
   surface, so Resume/Continue can't be tapped until the device rotates. */
#rotate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10500;
    background: rgba(5, 7, 11, 0.96);
    color: var(--neon-blue, #00f5ff);
    text-align: center;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    font-size: 18px;
    letter-spacing: 2px;
    padding: 24px;
}

#rotate-overlay .rotate-icon {
    font-size: 42px;
    animation: rotate-hint 1.6s ease-in-out infinite;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

@media (orientation: portrait) and (pointer: coarse) {
    body.gameplay-active #rotate-overlay {
        display: flex;
    }
}
