* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-color: #1a1a2e;
    --game-bg: #16213e;
    --text-color: #eee;
    --accent-color: #4CAF50;
    --accent-dark: #2d7a2d;
    --border-color: #0f3460;
    --card-bg: rgba(255, 255, 255, 0.05);
}

body {
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    background: var(--bg-color);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 0;
    margin: 0;
    position: relative;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
}

.game-container {
    text-align: center;
    background: transparent;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ============================================
   MAIN MENU STYLES
   ============================================ */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.menu-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    width: 90%;
}

.game-title {
    font-size: 64px;
    color: var(--text-color);
    margin-bottom: 10px;
    text-shadow: 0 4px 20px rgba(76, 175, 80, 0.5), 0 0 60px rgba(76, 175, 80, 0.3);
    animation: titlePulse 3s ease-in-out infinite;
}

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

.game-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 40px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
}

.menu-btn {
    padding: 18px 40px;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.menu-btn:active {
    transform: scale(0.98);
}

.menu-btn.primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-dark));
    border-color: var(--accent-color);
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
}

.menu-btn.primary:hover {
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.6);
}

.menu-footer {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.menu-footer span {
    color: var(--accent-color);
    font-weight: bold;
}

/* How to Play Modal Styles */
.how-to-play-content {
    max-width: 500px;
    text-align: left;
}

.how-to-play-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

.controls-section, .tips-section {
    margin-bottom: 20px;
}

.controls-section h3, .tips-section h3 {
    color: var(--accent-color);
    font-size: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.control-item {
    padding: 8px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.control-item strong {
    background: rgba(76, 175, 80, 0.2);
    color: var(--accent-color);
    padding: 3px 8px;
    border-radius: 4px;
    margin: 0 2px;
}

.tips-section ul {
    list-style: none;
    padding: 0;
}

.tips-section li {
    padding: 8px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    padding-left: 20px;
    position: relative;
}

.tips-section li::before {
    content: '•';
    color: var(--accent-color);
    position: absolute;
    left: 0;
}

/* Leaderboard Modal Styles */
.leaderboard-modal-content {
    max-width: 600px;
    width: 95%;
    max-height: 80vh;
}

.leaderboard-modal-content .leaderboard-content {
    max-height: 60vh;
    overflow-y: auto;
}

/* Health Display - Top Right */
.health-container {
    position: fixed;
    top: 10px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    background: var(--card-bg);
    padding: 6px 12px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.health-icon {
    font-size: 16px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.health-bar-container {
    width: 80px;
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.health-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.5);
    position: relative;
}

.health-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent);
}

.health-text {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-color);
    min-width: 28px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Shield Display - Compact */
.shield-display {
    font-size: 12px;
    margin-left: 4px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* Weapon Display - Hidden by default */
.weapon-display {
    display: none;
}

/* XP and Level Display - Top Left */
.xp-container {
    position: fixed;
    top: 10px;
    left: 15px;
    right: 120px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
    max-width: 350px;
}

.level-badge {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-dark));
    color: white;
    padding: 6px 10px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#levelDisplay {
    font-size: 18px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.xp-bar-container {
    flex: 1;
    height: 24px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A, #81C784);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    position: relative;
}

.xp-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent);
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    z-index: 2;
    letter-spacing: 0.5px;
}

/* XP Bar Pulse Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    50% { opacity: 0.9; box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

/* Level Up Notification */
.level-up-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    padding: 25px 45px;
    border-radius: 15px;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.6);
    z-index: 1001;
    animation: levelUpAppear 0.5s ease-out;
    pointer-events: none;
    border: 4px solid #FF8C00;
}

@keyframes levelUpAppear {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Score Display - Top Center */
.score-container {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    z-index: 100;
    background: var(--card-bg);
    padding: 8px 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score {
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Canvas Wrapper - Full Screen Focus */
.canvas-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    min-height: 0;
    width: 100%;
    height: 100%;
}

#gameCanvas {
    border: 3px solid var(--border-color);
    border-radius: 8px;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 60%, #f7f7f7 60%, #f7f7f7 100%);
    display: block;
    cursor: pointer;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 100px rgba(15, 52, 96, 0.3);
}

/* Instructions - Bottom */
.instructions {
    padding: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-align: center;
}

.instructions p {
    margin: 3px 0;
}

.instructions strong {
    color: var(--accent-color);
    background: rgba(76, 175, 80, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Mobile controls - hidden (desktop mode default) */
.mobile-controls {
    display: none;
}

/* Joystick Container - hidden (desktop mode default) */
.joystick-container {
    display: none;
}
    position: relative;
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 600px) {
    .game-container {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }
    
    .canvas-wrapper {
        padding: 0;
        flex: 1;
        min-height: 0;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    #gameCanvas {
        /* Don't override JS-calculated dimensions - they already account for available space */
    }
    
    .xp-container {
        top: 5px;
        left: 10px;
        max-width: 200px;
    }
    
    .level-badge {
        padding: 4px 8px;
        min-width: 40px;
        font-size: 10px;
    }
    
    #levelDisplay {
        font-size: 14px;
    }
    
    .xp-bar-container {
        height: 18px;
    }
    
    .xp-text {
        font-size: 9px;
    }
    
    .health-container {
        top: 5px;
        right: 10px;
        padding: 4px 8px;
    }
    
    .health-hearts {
        font-size: 16px;
    }
    
    .score-container {
        top: 28px;
        right: 10px;
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .instructions {
        display: none;
    }
    
    .leaderboard-section {
        display: none;
    }
}

/* Leaderboard Section */
.leaderboard-section {
    padding: 15px;
}

.leaderboard-btn {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-dark));
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.leaderboard-btn:active {
    transform: scale(0.98);
}

.leaderboard-container {
    margin-top: 15px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    backdrop-filter: blur(10px);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.leaderboard-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 18px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.leaderboard-content {
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard-item {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    margin: 6px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.leaderboard-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-stats-preview {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.leaderboard-stats-preview span {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Expanded stats display */
.leaderboard-stats-expanded {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
}

.leaderboard-stats-expanded .stats-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.7);
}

.leaderboard-stats-expanded .stats-row:last-child {
    margin-bottom: 0;
}

.leaderboard-stats-expanded .stats-row span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-stats-expanded.no-stats-inline {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    text-align: center;
    padding: 4px 0;
}

.leaderboard-item.top-10 {
    background: rgba(100, 200, 255, 0.1);
    border-color: rgba(100, 200, 255, 0.3);
}

.leaderboard-item.top-3 {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.4);
}

.leaderboard-rank {
    font-weight: bold;
    color: rgba(255, 255, 255, 0.7);
    min-width: 50px;
}

.leaderboard-name {
    flex: 1;
    text-align: left;
    padding: 0 10px;
    color: var(--text-color);
}

.leaderboard-score {
    font-weight: bold;
    color: var(--accent-color);
}

/* Detailed stats view */
.stats-detail-view {
    padding: 10px;
}

.stats-detail-view h3 {
    margin: 10px 0;
    color: var(--text-color);
    font-size: 18px;
}

.stats-score {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.back-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 10px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stats-section {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-section h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: var(--accent-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 3px 0;
    color: rgba(255, 255, 255, 0.8);
}

.stat-row span:first-child {
    color: rgba(255, 255, 255, 0.6);
}

.stat-row span:last-child {
    font-weight: bold;
    color: var(--text-color);
}

.weapons-list {
    margin-top: 5px;
    font-size: 16px;
    letter-spacing: 3px;
}

.no-stats {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.loading, .error, .empty {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.6);
}

.error {
    color: #ff6b6b;
}

/* Modal for name input */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border-color);
}

.modal-content h2 {
    margin-top: 0;
    color: var(--text-color);
}

.modal-content p {
    margin: 15px 0;
    color: rgba(255, 255, 255, 0.7);
}

.modal-content .score-display {
    font-size: 28px;
    font-weight: bold;
    color: var(--accent-color);
    margin: 10px 0 20px 0;
    text-shadow: 0 0 10px var(--accent-color);
}

.modal-content input {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    margin: 10px 0;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-color);
}

.modal-content input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    transition: all 0.2s ease;
}

.modal-btn.primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.modal-btn:not(.primary) {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-btn:not(.primary):hover {
    background: rgba(255, 255, 255, 0.2);
}

.submit-result {
    margin-top: 15px;
    font-weight: bold;
    min-height: 20px;
}

.submit-result.success {
    color: var(--accent-color);
}

.submit-result.error {
    color: #ff6b6b;
}

/* Upgrade Modal */
.upgrade-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

.upgrade-modal .modal-content {
    max-width: 900px;
    width: 95%;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.upgrade-content h2 {
    margin-bottom: 15px;
    color: var(--accent-color);
    font-size: 20px;
    text-align: center;
}

.upgrade-choices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

/* Category Slot Container */
.upgrade-slot {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upgrade-slot-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--slot-color, #667eea);
    border-radius: 8px 8px 0 0;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slot-icon {
    font-size: 14px;
}

.slot-name {
    font-size: 11px;
}

/* Category-specific colors */
.upgrade-slot-defense { --slot-color: #4CAF50; }
.upgrade-slot-guns { --slot-color: #FF9800; }
.upgrade-slot-energy { --slot-color: #9C27B0; }
.upgrade-slot-elemental { --slot-color: #2196F3; }

.upgrade-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    color: white;
    padding: 15px 12px;
    border-radius: 0 0 12px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    border: 2px solid transparent;
    text-align: center;
    touch-action: manipulation;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.upgrade-slot-defense .upgrade-card {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.85) 0%, rgba(46, 125, 50, 0.9) 100%);
}

.upgrade-slot-guns .upgrade-card {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.85) 0%, rgba(230, 81, 0, 0.9) 100%);
}

.upgrade-slot-energy .upgrade-card {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.85) 0%, rgba(106, 27, 154, 0.9) 100%);
}

.upgrade-slot-elemental .upgrade-card {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.85) 0%, rgba(21, 101, 192, 0.9) 100%);
}

.upgrade-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    border-color: #FFD700;
}

.upgrade-card:active {
    transform: scale(0.97);
}

.upgrade-card-maxed {
    opacity: 0.5;
    cursor: default;
    background: linear-gradient(135deg, #444 0%, #333 100%) !important;
}

.upgrade-card-maxed:hover {
    transform: none;
    border-color: transparent;
    box-shadow: none;
}

.upgrade-icon {
    font-size: 32px;
    margin-bottom: 6px;
}

.upgrade-name {
    font-size: 14px;
    font-weight: bold;
    margin: 4px 0;
    line-height: 1.2;
}

.upgrade-level {
    font-size: 10px;
    opacity: 0.9;
    margin-bottom: 6px;
    padding: 2px 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    display: inline-block;
}

.upgrade-level.new-badge {
    background: #FFD700;
    color: #000;
    font-weight: bold;
}

.upgrade-description {
    font-size: 11px;
    opacity: 0.95;
    line-height: 1.3;
    flex: 1;
}

/* New weapon highlight */
.new-weapon-card {
    animation: newWeaponPulse 1.5s ease-in-out infinite;
}

@keyframes newWeaponPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.6); }
}

/* Weapon Selection Modal */
.weapon-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

.weapon-modal .modal-content {
    max-width: 800px;
    width: 95%;
    padding: 30px;
}

.weapon-subtitle {
    color: #666;
    margin: -10px 0 20px 0;
    font-size: 16px;
}

.weapon-choices {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.weapon-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 200px;
    max-width: 250px;
    border: 4px solid transparent;
    text-align: center;
    position: relative;
}

.weapon-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    border-color: #FFD700;
}

.weapon-card.selected {
    border-color: #00FF00;
    background: linear-gradient(135deg, #00C851 0%, #007E33 100%);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.6);
    transform: scale(1.05);
}

.weapon-card.selected::before {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 30px;
    color: #00FF00;
    background: rgba(255, 255, 255, 0.9);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.weapon-card:active {
    transform: scale(0.95);
}

.weapon-icon {
    font-size: 50px;
    margin-bottom: 15px;
    display: block;
}

.weapon-info {
    text-align: center;
}

.weapon-title {
    font-size: 22px;
    font-weight: bold;
    margin: 10px 0;
}

.weapon-desc {
    font-size: 14px;
    opacity: 0.95;
    line-height: 1.5;
    margin-top: 10px;
}

.current-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 215, 0, 0.9);
    color: #333;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.weapon-name {
    font-size: 22px;
    font-weight: bold;
    margin: 10px 0;
}

.weapon-description {
    font-size: 14px;
    opacity: 0.95;
    line-height: 1.5;
    margin-top: 10px;
}

.weapon-start-btn {
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.weapon-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.weapon-start-btn:active {
    transform: scale(0.98);
}

/* ============================================
   BULLET HELL VISUAL STYLES
   ============================================ */

/* Graze indicator glow effect */
.graze-indicator {
    position: fixed;
    pointer-events: none;
    z-index: 50;
}

/* Graze streak notification */
.graze-notification {
    position: fixed;
    top: 100px;
    left: 15px;
    padding: 8px 12px;
    background: rgba(255, 255, 100, 0.2);
    border: 2px solid rgba(255, 255, 100, 0.5);
    border-radius: 8px;
    color: #FFFF66;
    font-weight: bold;
    font-size: 14px;
    z-index: 100;
    animation: graze-pulse 0.3s ease-out;
}

@keyframes graze-pulse {
    0% { transform: scale(1.2); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Bullet count warning indicator */
.bullet-count {
    position: fixed;
    bottom: 20px;
    left: 15px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    z-index: 100;
    transition: color 0.2s ease;
}

.bullet-count.safe { color: #88FF88; }
.bullet-count.caution { color: #FFFF44; }
.bullet-count.warning { color: #FFAA44; }
.bullet-count.danger { color: #FF4444; animation: danger-pulse 0.5s infinite; }

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

/* Hitbox indicator help text */
.hitbox-help {
    position: fixed;
    bottom: 10px;
    right: 15px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    z-index: 100;
}

/* CRT/Pixel screen effect overlay */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Scanline effect */
.scanlines {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
}

/* Screen glow on graze */
.screen-graze-flash {
    animation: graze-screen-flash 0.2s ease-out;
}

@keyframes graze-screen-flash {
    0% { box-shadow: inset 0 0 100px rgba(255, 255, 100, 0.3); }
    100% { box-shadow: inset 0 0 100px rgba(255, 255, 100, 0); }
}

/* Bullet hell damage flash */
.damage-flash {
    animation: damage-screen-flash 0.15s ease-out;
}

@keyframes damage-screen-flash {
    0% { box-shadow: inset 0 0 150px rgba(255, 0, 0, 0.4); }
    100% { box-shadow: inset 0 0 150px rgba(255, 0, 0, 0); }
}

/* Enemy bullet glow effect (for canvas-drawn bullets) */
.enemy-bullet-glow {
    filter: drop-shadow(0 0 8px rgba(255, 20, 147, 0.8));
}

/* Player hitbox indicator pulse */
@keyframes hitbox-pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ============================================
   FULLSCREEN MODE STYLES
   ============================================ */

/* Ensure modals work correctly in fullscreen mode across browsers */
:-webkit-full-screen .modal,
:-moz-full-screen .modal,
:-ms-fullscreen .modal,
:fullscreen .modal {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Ensure upgrade modal is properly sized in fullscreen */
:-webkit-full-screen .upgrade-modal .modal-content,
:-moz-full-screen .upgrade-modal .modal-content,
:-ms-fullscreen .upgrade-modal .modal-content,
:fullscreen .upgrade-modal .modal-content {
    max-width: 900px;
    width: 95%;
}

/* Ensure game container uses full space in fullscreen */
:-webkit-full-screen .game-container,
:-moz-full-screen .game-container,
:-ms-fullscreen .game-container,
:fullscreen .game-container {
    width: 100%;
    height: 100%;
}

