/* PS2 Era Gaming UI Styles - Early 2000s Aesthetic */

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

/* Improve mobile performance and touch responsiveness */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Prevent zoom on double tap for mobile and enhance touch responsiveness */
.character-card, .select-character-btn, .mode-card, .select-mode-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 107, 53, 0.3);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Improve button hit area on mobile */
    min-height: 48px;
    /* Ensure proper touch cursor */
    cursor: pointer;
    /* Smooth all transitions for mobile */
    transition: all 0.2s ease;
}

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

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000000;
    font-family: 'Rajdhani', sans-serif;
    user-select: none;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
    /* Improve font rendering on mobile */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Force scrolling when selection screens are active - Mobile Fix */
body.character-selection-active,
body.game-mode-selection-active {
    overflow: visible !important;
    overflow-y: auto !important;
    height: auto !important;
    position: static !important;
}

/* Additional mobile-specific body override */
@media (max-width: 768px) {
    body.character-selection-active,
    body.game-mode-selection-active {
        overflow: visible !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: auto !important;
    }
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    position: relative;
    cursor: crosshair;
}

/* Loading Screen - PS2 Style */
#loadingScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden;
}

.loading-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0.6);
    z-index: -1;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 60px;
}

.loading-content h1 {
    font-size: 5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #FFD700;
    text-shadow: 
        3px 3px 0px #B8860B,
        6px 6px 12px rgba(0, 0, 0, 0.9),
        0 0 30px rgba(255, 215, 0, 0.5);
    letter-spacing: 4px;
    text-transform: uppercase;
}

.loading-content p {
    font-size: 1.3rem;
    margin-bottom: 2.5rem;
    color: #E0E0E0;
    font-weight: 500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.loading-bar {
    width: 320px;
    height: 12px;
    background: linear-gradient(145deg, #0d0d0d, #1a1a1a);
    border: 1px solid #333333;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 
        inset 2px 2px 4px rgba(0, 0, 0, 0.5),
        inset -1px -1px 2px rgba(255, 255, 255, 0.1);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #FF6B35, #FFD700);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.6);
}

/* Character Selection Screen - PS2 Main Menu Style */
#characterSelection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 999;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: 2vh;
    padding-bottom: 4vh;
    box-sizing: border-box;
}

.character-selection-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0.5);
    z-index: -1;
}

.character-selection-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 20px 40px 20px;
    max-width: 1400px;
    width: 100%;
    box-sizing: border-box;
}

.character-selection-content h1 {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #FFD700;
    text-shadow: 
        3px 3px 0px #B8860B,
        6px 6px 12px rgba(0, 0, 0, 0.9),
        0 0 30px rgba(255, 215, 0, 0.5);
    letter-spacing: 4px;
    text-transform: uppercase;
}

.character-selection-content p {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    color: #E0E0E0;
    font-weight: 500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.character-options {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: stretch;
    flex-wrap: nowrap;
    margin-bottom: 2rem;
    width: 100%;
}

.character-card {
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 350px;
    flex: 1;
    max-width: 350px;
}

.character-card:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.6));
}

.character-preview {
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, #606060 0%, #808080 50%, #606060 100%);
    border: 3px solid #FFD700;
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 215, 0, 0.3),
        inset 0 0 50px rgba(255, 215, 0, 0.1);
}

.character-preview canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 4px;
}

.character-card h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #FFD700;
    text-shadow: 
        2px 2px 0px #B8860B,
        4px 4px 8px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.character-card p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #E0E0E0;
    font-weight: 500;
    text-shadow: 
        1px 1px 2px rgba(0, 0, 0, 0.8);
}

.select-character-btn {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: #FFFFFF;
    background: linear-gradient(145deg, #FF6B35, #E55A2B);
    border: 2px solid #CC4A20;
    border-radius: 8px;
    padding: 14px 35px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.5);
    min-height: 48px;
    box-sizing: border-box;
}

.select-character-btn:hover {
    background: linear-gradient(145deg, #FF8D63, #FF6B35);
    border-color: #FF6B35;
    transform: translateY(-2px);
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.4),
        inset -2px -2px 4px rgba(0, 0, 0, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.8),
        0 0 16px rgba(255, 107, 53, 0.6);
}

.select-character-btn:active {
    transform: translateY(0px);
    box-shadow: 
        inset 2px 2px 4px rgba(0, 0, 0, 0.4),
        inset -2px -2px 4px rgba(255, 255, 255, 0.2),
        0 3px 8px rgba(0, 0, 0, 0.6);
}

/* Responsive Design for PS2 Style */
@media (max-width: 1200px) and (min-width: 901px) {
    .character-card {
        width: 300px;
        max-width: 300px;
    }
    
    .character-preview {
        height: 250px;
    }
    
    .character-options {
        gap: 30px;
    }
    
    .character-selection-content h1 {
        font-size: 3.5rem;
    }
}

@media (max-width: 900px) and (min-width: 769px) {
    .character-card {
        width: 260px;
        max-width: 260px;
    }
    
    .character-preview {
        height: 220px;
    }
    
    .character-options {
        gap: 20px;
    }
    
    .character-selection-content h1 {
        font-size: 3rem;
    }
    
    .character-card h3 {
        font-size: 1.5rem;
    }
    
    .character-card p {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    #characterSelection {
        /* Ensure proper mobile scrolling */
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        padding-top: 1vh;
        padding-bottom: 6vh;
    }
    
    .character-selection-content {
        padding: 5px 10px 30px 10px;
        min-height: calc(100vh - 2vh);
        min-height: calc(100dvh - 2vh);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    .character-selection-content h1 {
        font-size: 1.5rem;
        letter-spacing: 1px;
        margin-bottom: 0.5rem;
    }
    
    .loading-content h1 {
        font-size: 3.5rem;
        letter-spacing: 2px;
    }
    
    .character-selection-content p {
        font-size: 0.8rem;
        margin-bottom: 1rem;
        line-height: 1.2;
        max-width: 95%;
    }
    
    .character-options {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .character-card {
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
        padding: 8px;
    }
    
    .character-preview {
        height: 160px;
        border-radius: 6px;
        overflow: hidden;
    }
    
    .character-preview canvas {
        object-fit: contain;
        width: 100% !important;
        height: 100% !important;
    }
    
    .character-card h3 {
        font-size: 1.2rem;
        margin: 8px 0 4px 0;
    }
    
    .character-card p {
        font-size: 0.75rem;
        margin-bottom: 8px;
        color: #CCCCCC;
    }
    
    .select-character-btn {
        font-size: 0.9rem;
        padding: 8px 20px;
        min-height: 40px;
    }
}

/* Game UI - PS2 Style HUD */
#ui {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    border: 2px solid #333333;
    border-radius: 6px;
    padding: 15px 20px;
    min-width: 200px;
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.1),
        inset -1px -1px 2px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.8);
}

#ui h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ui-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.ui-label {
    font-weight: 500;
    color: #CCCCCC;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.ui-value {
    font-weight: 600;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    text-align: right;
}

#healthBar {
    width: 100%;
    height: 12px;
    background: linear-gradient(145deg, #0d0d0d, #1a1a1a);
    border: 1px solid #333333;
    border-radius: 6px;
    margin: 5px 0 10px 0;
    overflow: hidden;
    position: relative;
    box-shadow: 
        inset 2px 2px 4px rgba(0, 0, 0, 0.5),
        inset -1px -1px 2px rgba(255, 255, 255, 0.1);
}

#healthFill {
    height: 100%;
    background: linear-gradient(90deg, #00FF88, #00CC6A);
    width: 100%;
    transition: width 0.5s ease;
    position: relative;
    box-shadow: 0 0 6px rgba(0, 255, 136, 0.5);
}

#healthFill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: healthShine 2s infinite;
}

@keyframes healthShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

#status {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #AAAAAA;
    font-weight: 400;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Instructions Panel - PS2 Style */
#instructions {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    border: 2px solid #333333;
    border-radius: 6px;
    padding: 15px 20px;
    max-width: 300px;
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.1),
        inset -1px -1px 2px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.8);
}

/* Hide keyboard instructions on mobile devices */
.is-mobile #instructions,
.is-tablet #instructions {
    display: none !important;
}

#instructions h3 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.control-item {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    gap: 10px;
    color: #CCCCCC;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.key {
    background: linear-gradient(145deg, #FF6B35, #E55A2B);
    border: 1px solid #CC4A20;
    border-radius: 3px;
    color: #FFFFFF;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    text-align: center;
    min-width: 24px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: 
        inset 1px 1px 1px rgba(255, 255, 255, 0.3),
        inset -1px -1px 1px rgba(0, 0, 0, 0.3);
}

/* Game Over Screen - PS2 Style */
#gameOverScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    text-align: center;
}

#gameOverScreen h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #FF4444;
    text-shadow: 
        2px 2px 0px #AA2222,
        4px 4px 8px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.restart-btn {
    background: linear-gradient(145deg, #FF6B35, #E55A2B);
    border: 2px solid #CC4A20;
    border-radius: 6px;
    color: #FFFFFF;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.3),
        inset -1px -1px 2px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.6);
}

.restart-btn:hover {
    background: linear-gradient(145deg, #FF7A45, #F55A2B);
    border-color: #FF6B35;
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.4),
        inset -1px -1px 2px rgba(0, 0, 0, 0.4),
        0 6px 16px rgba(0, 0, 0, 0.8),
        0 0 12px rgba(255, 107, 53, 0.4);
}

/* Comprehensive Device Adaptation */

/* Large tablets and small desktops */
@media (max-width: 1024px) and (min-width: 769px) {
    .character-options {
        gap: 30px;
    }
    
    .character-card {
        width: 300px;
    }
    
    .mode-options {
        gap: 30px;
    }
    
    .mode-card {
        max-width: 350px;
    }
    
    #ui {
        font-size: 0.95rem;
    }
}

/* Tablets (Portrait and Landscape) */
@media (max-width: 768px) and (min-width: 481px) {
    #ui {
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        padding: 15px;
        font-size: 16px;
        max-width: 300px;
    }
    
    #instructions {
        bottom: 10px;
        left: 10px;
        width: calc(100% - 20px);
        padding: 15px;
        font-size: 14px;
        max-width: 350px;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .controls {
        gap: 8px;
    }
    
    .control-item {
        font-size: 13px;
    }
    
    .character-options {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .character-card {
        width: 100%;
        max-width: 400px;
    }
    
    .mode-options {
        flex-direction: column;
        gap: 20px;
    }
    
    .mode-card {
        width: 100%;
        max-width: 400px;
    }
    
    .camera-info {
        font-size: 14px;
    }
    
    #interactionPrompt {
        bottom: 120px;
        padding: 15px 25px;
        font-size: 16px;
    }
    
    .loading-content h1 {
        font-size: 3rem;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    /* Ensure mobile scrolling works on small screens */
    #characterSelection, #gameModeSelection {
        position: fixed !important;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain;
    }
    
    .character-selection-content, .game-mode-content {
        padding-bottom: 120px; /* Extra space at bottom for scrolling */
        min-height: calc(100vh + 100px); /* Force content to be taller than viewport */
    }
    
    #ui {
        top: 5px;
        left: 5px;
        width: calc(100% - 10px);
        padding: 10px;
        font-size: 14px;
        max-width: none;
    }
    
    #ui h2 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
    
    #instructions {
        bottom: 80px; /* Make room for mobile controls */
        left: 5px;
        width: calc(100% - 10px);
        padding: 10px;
        font-size: 12px;
        max-height: 25vh;
        overflow-y: auto;
        max-width: none;
    }
    
    #instructions h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    .controls {
        gap: 6px;
        display: flex;
        flex-wrap: wrap;
    }
    
    .control-item {
        flex-direction: column;
        align-items: center;
        gap: 4px;
        font-size: 11px;
        flex: 1;
        min-width: 80px;
    }
    
    .key {
        padding: 4px 8px;
        font-size: 10px;
        min-width: auto;
    }
    
    .loading-content {
        padding: 15px 20px;
    }
    
    .loading-content h1 {
        font-size: 2.5rem;
        line-height: 1.1;
    }
    
    .loading-content p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .character-selection-content {
        padding: 8px 8px 15px 8px;
        padding-top: 2vh;
    }
    
    .character-selection-content h1,
    .game-mode-content h1 {
        font-size: 1.4rem;
        line-height: 1.1;
        margin-bottom: 0.4rem;
    }
    
    .character-selection-content p,
    .game-mode-content p {
        font-size: 0.75rem;
        margin-bottom: 0.8rem;
        line-height: 1.2;
        max-width: 95%;
    }
    
    .character-options,
    .mode-options {
        flex-direction: column;
        gap: 12px;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .character-card,
    .mode-card {
        width: 100%;
        max-width: 220px;
        margin: 0 auto;
        padding: 6px;
    }
    
    .character-preview {
        height: 140px;
        border-radius: 4px;
    }
    
    .character-preview canvas {
        border-radius: 4px;
    }
    
    .character-card h3 {
        font-size: 1.1rem;
        margin: 6px 0 3px 0;
    }
    
    .character-card p {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }
    
    .select-character-btn,
    .select-mode-btn {
        padding: 8px 18px;
        font-size: 0.85rem;
        min-height: 38px;
        width: 100%;
        max-width: 180px;
    }
    
    .mode-icon {
        font-size: 2.5rem;
    }
    
    .camera-info {
        font-size: 12px;
    }
    
    .camera-info-top,
    .camera-info-bottom {
        right: 10px;
    }
    
    .photo-counter {
        font-size: 16px;
    }
    
    #interactionPrompt {
        bottom: 100px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    #gameOverScreen h1 {
        font-size: 2.5rem;
    }
    
    #gameOverScreen p {
        font-size: 1rem;
    }
    
    .restart-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .character-selection-content {
        padding: 5px 5px 10px 5px;
        padding-top: 1vh;
    }
    
    .loading-content h1,
    .character-selection-content h1,
    .game-mode-content h1 {
        font-size: 1.2rem;
        line-height: 1.1;
        margin-bottom: 0.3rem;
    }
    
    .character-selection-content p {
        font-size: 0.7rem;
        margin-bottom: 0.6rem;
    }
    
    .character-card,
    .mode-card {
        max-width: 200px;
        padding: 4px;
    }
    
    .character-preview {
        height: 120px;
    }
    
    .character-card h3 {
        font-size: 1rem;
        margin: 5px 0 2px 0;
    }
    
    .character-card p {
        font-size: 0.65rem;
        margin-bottom: 5px;
    }
    
    .select-character-btn {
        font-size: 0.8rem;
        padding: 6px 16px;
        min-height: 36px;
    }
    
    .character-options,
    .mode-options {
        gap: 10px;
    }
    
    #ui {
        font-size: 12px;
    }
    
    #instructions {
        font-size: 11px;
        bottom: 70px;
    }
    
    .control-item {
        font-size: 10px;
        min-width: 70px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    #ui {
        top: 5px;
        font-size: 12px;
        padding: 8px;
    }
    
    #instructions {
        bottom: 5px;
        padding: 8px;
        max-height: 30vh;
    }
    
    .character-selection-content {
        padding: 15px 20px;
        min-height: 100vh;
        justify-content: center;
    }
    
    .loading-content h1,
    .character-selection-content h1,
    .game-mode-content h1 {
        font-size: 1.8rem;
        margin-bottom: 0.8rem;
    }
    
    .character-selection-content p {
        font-size: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .character-options,
    .mode-options {
        flex-direction: row;
        gap: 15px;
        overflow-x: auto;
        padding: 10px 5px;
        width: 100%;
        justify-content: flex-start;
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .character-card,
    .mode-card {
        min-width: 200px;
        max-width: 200px;
        flex-shrink: 0;
    }
    
    .character-preview {
        height: 120px;
    }
    
    .character-card h3 {
        font-size: 1rem;
        margin: 8px 0 4px 0;
    }
    
    .character-card p {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }
    
    .select-character-btn {
        font-size: 0.8rem;
        padding: 8px 18px;
        min-height: 38px;
    }
}

/* Touch device improvements */
@media (hover: none) {
    /* Improve button feedback on touch devices */
    .select-character-btn:active,
    .select-mode-btn:active {
        transform: scale(0.95);
        background: linear-gradient(145deg, #E55A2B, #CC4A20);
        transition: all 0.1s ease;
    }
    
    .character-card:active {
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
    
    /* Remove hover effects on touch devices */
    .character-card:hover,
    .mode-card:hover,
    .select-character-btn:hover,
    .select-mode-btn:hover,
    .restart-btn:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Enhanced mobile touch responsiveness */
@media (max-width: 768px) {
    .character-card, .mode-card {
        /* Increase touch target size */
        padding: 12px;
        margin: 8px 0;
    }
    
    .select-character-btn, .select-mode-btn {
        /* Ensure buttons are large enough for touch */
        min-height: 50px;
        padding: 12px 30px;
        font-size: 1rem;
        /* Add more prominent touch feedback */
        transition: all 0.15s ease;
    }
    
    .select-character-btn:active, .select-mode-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    /* Improve button spacing on mobile */
    .character-options, .mode-options {
        gap: 20px;
        margin-bottom: 20px;
    }
    
    /* Ensure proper scrollable areas on mobile */
    .character-options {
        padding-bottom: 20px;
    }
    
    .mode-options {
        padding-bottom: 20px;
    }
}

/* Hide desktop-specific keys on mobile */
.is-mobile #interactionPrompt .key,
.is-tablet #interactionPrompt .key {
    display: none;
}

/* Particle Effects - Simplified for PS2 Style */
.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #FFD700;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 4s linear infinite;
    box-shadow: 0 0 4px #FFD700;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0px) translateX(0px);
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(20px);
        opacity: 0;
    }
}

/* Interaction Prompt - PS2 Style */
#interactionPrompt {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    display: none;
    align-items: center;
    gap: 10px;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    border: 2px solid #FFD700;
    border-radius: 6px;
    padding: 12px 20px;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.1),
        inset -1px -1px 2px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.8),
        0 0 12px rgba(255, 215, 0, 0.3);
    animation: promptGlow 2s ease-in-out infinite alternate;
}

@keyframes promptGlow {
    from {
        box-shadow: 
            inset 1px 1px 2px rgba(255, 255, 255, 0.1),
            inset -1px -1px 2px rgba(0, 0, 0, 0.3),
            0 4px 12px rgba(0, 0, 0, 0.8),
            0 0 12px rgba(255, 215, 0, 0.3);
    }
    to {
        box-shadow: 
            inset 1px 1px 2px rgba(255, 255, 255, 0.15),
            inset -1px -1px 2px rgba(0, 0, 0, 0.4),
            0 6px 16px rgba(0, 0, 0, 0.9),
            0 0 16px rgba(255, 215, 0, 0.5);
    }
}

/* Crosshair - PS2 Style */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150;
    display: none;
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.crosshair-line {
    position: absolute;
    background: #FFD700;
    box-shadow: 0 0 4px #FFD700;
}

.crosshair-horizontal {
    width: 20px;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.crosshair-vertical {
    width: 2px;
    height: 20px;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

.crosshair-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: #FFD700;
    border-radius: 50%;
    animation: crosshairPulse 1.5s ease-in-out infinite alternate;
    box-shadow: 0 0 6px #FFD700;
}

@keyframes crosshairPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1.0; }
}

/* Game Mode Selection Screen - PS2 Style */
#gameModeSelection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 998;
    color: #E0E0E0;
    font-family: 'Rajdhani', sans-serif;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: 2vh;
    padding-bottom: 4vh;
    box-sizing: border-box;
}

.game-mode-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0.5);
    z-index: -1;
}

.game-mode-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 20px 40px 20px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
}

.game-mode-content h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #FFD700;
    text-shadow: 
        3px 3px 0px #B8860B,
        6px 6px 12px rgba(0, 0, 0, 0.9),
        0 0 30px rgba(255, 215, 0, 0.5);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.game-mode-content p {
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    color: #E0E0E0;
    font-weight: 500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.mode-options {
    display: flex;
    gap: 50px;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
}

.mode-card {
    background: linear-gradient(145deg, #2D2D2D, #1A1A1A);
    border: 3px solid #FFD700;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 400px;
    max-width: 400px;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.6),
        0 0 20px rgba(255, 215, 0, 0.3),
        inset 0 0 50px rgba(255, 215, 0, 0.1);
}

.mode-card:hover {
    transform: scale(1.03) translateY(-5px);
    border-color: #FFA500;
    filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
    box-shadow: 
        0 12px 32px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(255, 215, 0, 0.5),
        inset 0 0 60px rgba(255, 215, 0, 0.2);
}

.mode-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
}

.mode-card h3 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #FFD700;
    text-shadow: 
        2px 2px 0px #B8860B,
        4px 4px 8px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mode-card p {
    font-size: 1.1rem;
    margin-bottom: 25px;
    color: #E0E0E0;
    font-weight: 400;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.select-mode-btn {
    background: linear-gradient(145deg, #4CAF50, #45A049);
    border: 3px solid #388E3C;
    border-radius: 8px;
    color: #FFFFFF;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 18px 35px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.3),
        inset -2px -2px 4px rgba(0, 0, 0, 0.3),
        0 6px 16px rgba(0, 0, 0, 0.6);
}

.select-mode-btn:hover {
    background: linear-gradient(145deg, #5CBF60, #4CAF50);
    border-color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.4),
        inset -2px -2px 4px rgba(0, 0, 0, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.8),
        0 0 16px rgba(76, 175, 80, 0.6);
}

.select-mode-btn:active {
    transform: translateY(0px);
    box-shadow: 
        inset 2px 2px 4px rgba(0, 0, 0, 0.4),
        inset -2px -2px 4px rgba(255, 255, 255, 0.2),
        0 3px 8px rgba(0, 0, 0, 0.6);
}

/* Photo Mode specific styling */
.mode-card[data-mode="photo"] .select-mode-btn {
    background: linear-gradient(145deg, #9C27B0, #8E24AA);
    border-color: #7B1FA2;
}

.mode-card[data-mode="photo"] .select-mode-btn:hover {
    background: linear-gradient(145deg, #AB47BC, #9C27B0);
    border-color: #9C27B0;
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.4),
        inset -2px -2px 4px rgba(0, 0, 0, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.8),
        0 0 16px rgba(156, 39, 176, 0.6);
}

/* Responsive Design for Game Mode Selection */
@media (max-width: 900px) {
    .mode-options {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .mode-card {
        width: 100%;
        max-width: 400px;
        margin: 0;
    }
    
    .game-mode-content h1 {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    #gameModeSelection {
        /* Ensure proper mobile scrolling */
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        padding-top: 1vh;
        padding-bottom: 6vh;
    }
    
    .game-mode-content {
        padding: 10px 15px 40px 15px;
        min-height: calc(100vh - 2vh);
        min-height: calc(100dvh - 2vh);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    .game-mode-content h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }
    .mode-card {
        max-width: 320px;
        padding: 20px;
    }
    .mode-icon {
        font-size: 2.5rem;
    }
    .mode-card h3 {
        font-size: 1.5rem;
    }
    .select-mode-btn {
        padding: 12px 20px;
        font-size: 1rem;
        min-height: 44px;
    }
}

/* Camera Viewfinder UI - Realistic Camera Interface */
#cameraUI {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    user-select: none;
}

/* Camera Frame Borders */
.camera-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.camera-border {
    position: absolute;
    background: linear-gradient(45deg, #000000, #333333);
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 0 5px rgba(0, 0, 0, 0.5);
}

.camera-border-top {
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
}

.camera-border-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
}

.camera-border-left {
    top: 40px;
    left: 0;
    width: 40px;
    height: calc(100% - 80px);
}

.camera-border-right {
    top: 40px;
    right: 0;
    width: 40px;
    height: calc(100% - 80px);
}

/* Camera Corner Brackets */
.camera-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid #00ff88;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}

.camera-corner-tl {
    top: 50px;
    left: 50px;
    border-right: none;
    border-bottom: none;
}

.camera-corner-tr {
    top: 50px;
    right: 50px;
    border-left: none;
    border-bottom: none;
}

.camera-corner-bl {
    bottom: 50px;
    left: 50px;
    border-right: none;
    border-top: none;
}

.camera-corner-br {
    bottom: 50px;
    right: 50px;
    border-left: none;
    border-top: none;
}

/* Focus Crosshair */
.camera-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
}

.focus-line {
    position: absolute;
    background: #00ff88;
    box-shadow: 0 0 5px rgba(0, 255, 136, 0.8);
    animation: focusPulse 2s ease-in-out infinite;
}

.focus-horizontal {
    top: 50%;
    left: 20px;
    right: 20px;
    height: 2px;
    transform: translateY(-50%);
}

.focus-vertical {
    left: 50%;
    top: 20px;
    bottom: 20px;
    width: 2px;
    transform: translateX(-50%);
}

.focus-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 255, 136, 1);
}

.focus-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border: 2px solid #00ff88;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
    animation: focusRing 3s ease-in-out infinite;
}

@keyframes focusPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1.0; }
}

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

/* Camera Info Display */
.camera-info {
    position: absolute;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 136, 0.8);
    user-select: none;
}

.camera-info-top {
    position: absolute;
    top: 50px;
    right: 60px;
    display: flex;
    gap: 30px;
}

.camera-info-bottom {
    position: absolute;
    bottom: 50px;
    left: 60px;
    display: flex;
    gap: 30px;
}

.camera-mode {
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 3px;
    border: 1px solid #00ff88;
}

.camera-battery, .camera-flash {
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 8px;
    border-radius: 3px;
}

.photo-counter {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border-radius: 5px;
    border: 2px solid #00ff88;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

/* Target Indicator */
.camera-target-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
}

.target-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid #ff4444;
    border-radius: 10px;
    box-shadow: 
        0 0 20px rgba(255, 68, 68, 0.8),
        inset 0 0 20px rgba(255, 68, 68, 0.2);
    animation: targetPulse 1s ease-in-out infinite;
}

.target-text {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: #ff4444;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.8);
    background: rgba(0, 0, 0, 0.8);
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

@keyframes targetPulse {
    0%, 100% { 
        opacity: 0.8;
        transform: scale(1);
    }
    50% { 
        opacity: 1.0;
        transform: scale(1.05);
    }
}

/* Camera Vignette Effect */
#cameraUI::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle at center,
        transparent 40%,
        rgba(0, 0, 0, 0.3) 70%,
        rgba(0, 0, 0, 0.8) 100%
    );
    pointer-events: none;
}

/* Responsive Design for Camera UI */
@media (max-width: 768px) {
    .camera-border-top, .camera-border-bottom {
        height: 30px;
    }
    
    .camera-border-left, .camera-border-right {
        width: 30px;
        top: 30px;
        height: calc(100% - 60px);
    }
    
    .camera-corner {
        width: 20px;
        height: 20px;
    }
    
    .camera-corner-tl, .camera-corner-tr {
        top: 40px;
    }
    
    .camera-corner-tl, .camera-corner-bl {
        left: 40px;
    }
    
    .camera-corner-tr, .camera-corner-br {
        right: 40px;
    }
    
    .camera-corner-bl, .camera-corner-br {
        bottom: 40px;
    }
    
    .camera-info {
        font-size: 12px;
    }
    
    .camera-info-top, .camera-info-bottom {
        right: 50px;
    }
    
    .camera-info-top {
        top: 40px;
    }
    
    .camera-info-bottom {
        bottom: 40px;
    }
}

/* Photo Mode Centered Crosshair */
.photo-crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    z-index: 1500;
    pointer-events: none;
    display: none;
}

.photo-crosshair-horizontal, .photo-crosshair-vertical {
    position: absolute;
    background: #ff4444;
    box-shadow: 
        0 0 10px rgba(255, 68, 68, 0.8),
        0 0 20px rgba(255, 68, 68, 0.4);
}

.photo-crosshair-horizontal {
    top: 50%;
    left: 5px;
    right: 5px;
    height: 2px;
    transform: translateY(-50%);
}

.photo-crosshair-vertical {
    left: 50%;
    top: 5px;
    bottom: 5px;
    width: 2px;
    transform: translateX(-50%);
}

.photo-crosshair-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: #ff4444;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 
        0 0 15px rgba(255, 68, 68, 1),
        0 0 30px rgba(255, 68, 68, 0.6);
    animation: photoCrosshairPulse 1.5s ease-in-out infinite;
}

.photo-range-indicator {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.range-text {
    background: rgba(0, 0, 0, 0.8);
    color: #ff4444;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #ff4444;
    text-align: center;
}

.range-text.in-range {
    color: #00ff88;
    border-color: #00ff88;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

@keyframes photoCrosshairPulse {
    0%, 100% { 
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 1.0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* Level 2 Hardcore Mode Animations */

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

@keyframes flicker {
    0%, 100% { 
        opacity: 0.1;
    }
    10% { 
        opacity: 0.8;
    }
    20% { 
        opacity: 0.2;
    }
    30% { 
        opacity: 0.9;
    }
    40% { 
        opacity: 0.1;
    }
    50% { 
        opacity: 0.7;
    }
    60% { 
        opacity: 0.3;
    }
    70% { 
        opacity: 0.8;
    }
    80% { 
        opacity: 0.2;
    }
    90% { 
        opacity: 0.6;
    }
}

@keyframes shake {
    0%, 100% { 
        transform: translateX(0);
    }
    10% { 
        transform: translateX(-5px);
    }
    20% { 
        transform: translateX(5px);
    }
    30% { 
        transform: translateX(-3px);
    }
    40% { 
        transform: translateX(3px);
    }
    50% { 
        transform: translateX(-2px);
    }
    60% { 
        transform: translateX(2px);
    }
    70% { 
        transform: translateX(-1px);
    }
    80% { 
        transform: translateX(1px);
    }
         90% { 
         transform: translateX(-1px);
     }
 }

/* Mobile Touch Controls */
#mobileControls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none;
    display: none;
    height: 80px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.3));
    padding: 5px 0;
    box-sizing: border-box;
    border-top: 1px solid rgba(255, 215, 0, 0.3);
}

.mobile-controls-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    height: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

.mobile-joystick {
    width: 70px;
    height: 70px;
    border: 2px solid #FFD700;
    border-radius: 50%;
    background: rgba(255, 215, 0, 0.15);
    position: relative;
    touch-action: none;
    pointer-events: auto;
    flex-shrink: 0;
    backdrop-filter: blur(5px);
}

.mobile-joystick-knob {
    width: 30px;
    height: 30px;
    background: #FFD700;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.mobile-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.mobile-btn {
    width: 50px;
    height: 50px;
    border: 2px solid #FFD700;
    border-radius: 8px;
    background: rgba(255, 215, 0, 0.15);
    color: #FFD700;
    font-family: 'Orbitron', monospace;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
    transition: all 0.1s ease;
    pointer-events: auto;
    backdrop-filter: blur(5px);
}

.mobile-btn:active {
    background: rgba(255, 215, 0, 0.3);
    transform: scale(0.95);
}

.mobile-btn.pressed {
    background: rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
}

.mobile-action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 14px;
}

/* Mobile controls for different screen sizes */
@media (max-width: 360px) {
    #mobileControls {
        height: 70px;
        padding: 3px 0;
    }
    
    .mobile-controls-container {
        padding: 0 10px;
    }
    
    .mobile-joystick {
        width: 60px;
        height: 60px;
    }
    
    .mobile-joystick-knob {
        width: 25px;
        height: 25px;
    }
    
    .mobile-buttons {
        gap: 8px;
    }
    
    .mobile-btn {
        width: 45px;
        height: 45px;
        font-size: 11px;
    }
    
    .mobile-action-btn {
        width: 50px;
        height: 50px;
        font-size: 12px;
    }
}

/* Only hide mobile controls on desktop/non-touch devices */
@media (min-width: 769px) {
    #mobileControls {
        display: none !important;
    }
}

/* Ensure mobile controls show on tablets and phones regardless of orientation */
@media (max-width: 768px) {
    .is-mobile #mobileControls,
    .is-tablet #mobileControls {
        display: block !important;
    }
}

/* Mobile photo mode adjustments */
@media (max-width: 480px) {
    .photo-crosshair {
        width: 50px;
        height: 50px;
    }
    
    .photo-crosshair-center {
        width: 8px;
        height: 8px;
    }
    
    .camera-frame {
        border-width: 3px;
    }
    
    .camera-corner {
        width: 25px;
        height: 25px;
        border-width: 3px;
    }
}

/* Orientation change handling for landscape mode */
@media (orientation: landscape) and (max-height: 500px) {
    #mobileControls {
        height: 55px;
        padding: 3px 0;
        bottom: 0;
    }
    
    .mobile-controls-container {
        padding: 0 10px;
        justify-content: space-between;
        max-width: 100vw;
    }
    
    .mobile-joystick {
        width: 50px;
        height: 50px;
    }
    
    .mobile-joystick-knob {
        width: 20px;
        height: 20px;
    }
    
    .mobile-buttons {
        gap: 8px;
    }
    
    .mobile-btn {
        width: 38px;
        height: 38px;
        font-size: 9px;
    }
    
    .mobile-action-btn {
        width: 42px;
        height: 42px;
        font-size: 10px;
    }
}

/* Orientation change handling for landscape on larger screens */
@media (orientation: landscape) and (min-height: 501px) and (max-width: 768px) {
    #mobileControls {
        height: 70px;
        padding: 5px 0;
    }
    
    .mobile-controls-container {
        padding: 0 20px;
    }
    
    .mobile-joystick {
        width: 65px;
        height: 65px;
    }
    
    .mobile-joystick-knob {
        width: 28px;
        height: 28px;
    }
    
    .mobile-buttons {
        gap: 10px;
    }
    
    .mobile-btn {
        width: 48px;
        height: 48px;
        font-size: 11px;
    }
    
    .mobile-action-btn {
        width: 55px;
        height: 55px;
        font-size: 13px;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 480px) {
    .particle {
        display: none;
    }
    
    #cameraUI::before {
        display: none;
    }
    
    .focus-ring {
        animation: none;
    }
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    #mobileControls {
        padding-bottom: max(5px, env(safe-area-inset-bottom));
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .mobile-controls-container {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Prevent unwanted scrolling and ensure controls stay fixed */
@media (max-width: 768px) {
    #mobileControls {
        position: fixed !important;
        bottom: 0 !important;
        transform: none !important;
        will-change: auto;
    }
    
    .mobile-joystick,
    .mobile-btn {
        position: relative;
        will-change: transform;
    }
}

/* Additional landscape orientation fixes */
@media (orientation: landscape) and (max-width: 768px) {
    #mobileControls {
        height: 60px !important;
    }
    
    .mobile-controls-container {
        padding: 0 10px;
    }
}

/* Very small screens in any orientation */
@media (max-width: 320px) {
    #mobileControls {
        height: 65px !important;
    }
    
    .mobile-joystick {
        width: 55px !important;
        height: 55px !important;
    }
    
    .mobile-joystick-knob {
        width: 22px !important;
        height: 22px !important;
    }
    
    .mobile-btn {
        width: 40px !important;
        height: 40px !important;
        font-size: 10px !important;
    }
    
    .mobile-action-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 11px !important;
    }
}

/* Ultra compact landscape mode for very small screens */
@media (orientation: landscape) and (max-height: 400px) {
    #mobileControls {
        height: 50px !important;
        padding: 2px 0 !important;
    }
    
    .mobile-controls-container {
        padding: 0 8px !important;
    }
    
    .mobile-joystick {
        width: 45px !important;
        height: 45px !important;
    }
    
    .mobile-joystick-knob {
        width: 18px !important;
        height: 18px !important;
    }
    
    .mobile-buttons {
        gap: 6px !important;
    }
    
    .mobile-btn {
        width: 35px !important;
        height: 35px !important;
        font-size: 9px !important;
    }
    
    .mobile-action-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 10px !important;
    }
}

/* --- COMPREHENSIVE RESPONSIVE DESIGN --- */

/* Hide mobile controls by default */
#mobileControls {
    display: none;
}

/* Show mobile controls only on mobile devices via body class */
.is-mobile #mobileControls,
.is-tablet #mobileControls {
    display: block !important;
}


/* --- Base Mobile and Tablet Styles --- */
@media (max-width: 1024px) {
    .character-selection-content h1,
    .game-mode-content h1 {
        font-size: 3rem;
    }

    .character-options, .mode-options {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .character-card, .mode-card {
        width: 90%;
        max-width: 450px;
    }
}


/* --- TABLET STYLES (e.g., iPad) --- */
@media (max-width: 768px) {
    #ui {
        padding: 10px;
        font-size: 14px;
        min-width: 180px;
    }

    #instructions {
        padding: 10px;
        font-size: 12px;
        max-width: 250px;
        max-height: 35vh;
        overflow-y: auto;
    }

    .loading-content h1,
    .character-selection-content h1,
    .game-mode-content h1 {
        font-size: 2.5rem;
    }
}


/* --- MOBILE PHONE STYLES (Portrait) --- */
@media (max-width: 480px) {
    #ui {
        top: 5px;
        left: 5px;
        padding: 8px;
        font-size: 12px;
        min-width: auto;
        width: calc(50% - 10px);
    }

    #instructions {
        bottom: 90px;
        left: 5px;
        padding: 8px;
        font-size: 11px;
        width: calc(100% - 10px);
        max-height: 20vh;
        background: rgba(0, 0, 0, 0.7);
    }
    
    .controls {
        flex-wrap: wrap;
    }

    .control-item {
        font-size: 10px;
    }
    
    .key {
        padding: 2px 6px;
    }

    .character-card, .mode-card {
        max-width: 300px;
    }
    
    #gameOverScreen h1 {
        font-size: 2rem;
    }

    #interactionPrompt {
        font-size: 14px;
        padding: 10px 15px;
        bottom: 100px;
    }
}

/* --- MOBILE PHONE STYLES (Landscape) --- */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
     #ui {
        top: 5px;
        left: 5px;
        padding: 5px 8px;
        font-size: 11px;
    }
    
    #instructions {
        bottom: 5px;
        right: 5px;
        left: auto;
        width: 200px;
        max-height: calc(100% - 70px);
        padding: 5px 8px;
        font-size: 10px;
    }

    .loading-content h1,
    .character-selection-content h1,
    .game-mode-content h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .character-selection-content p,
    .game-mode-content p {
        font-size: 0.8rem;
        margin-bottom: 15px;
    }

    .character-options, .mode-options {
        flex-direction: row;
        gap: 15px;
    }
    
    .character-card, .mode-card {
        min-width: 220px;
    }

    .character-preview {
        height: 150px;
    }
}

/* --- Remove hover effects on touch devices --- */
@media (hover: none) {
    .character-card:hover,
    .mode-card:hover,
    .select-character-btn:hover,
    .select-mode-btn:hover,
    .restart-btn:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Particle Effects - Simplified for PS2 Style */
.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #FFD700;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 4s linear infinite;
    box-shadow: 0 0 4px #FFD700;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0px) translateX(0px);
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(20px);
        opacity: 0;
    }
} 

/* Adjust UI position when in photo mode to avoid camera frame */
body.photo-mode-active #ui {
    top: 70px;
    left: 70px;
    z-index: 1101; /* Above camera UI */
}

/* Mobile adjustment */
@media (max-width: 480px) {
    body.photo-mode-active #ui {
        top: 60px;
        left: 60px;
    }
}

/* Hide interaction prompt globally (no more portal sign) */
#interactionPrompt {
    display: none !important;
}

/* Permanently hide the yellow crosshair on desktop */
#crosshair {
    display: none !important;
}