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

/* Mobile optimizations */
html, body {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body {
    background: #000;
    font-family: 'Courier New', monospace;
    overflow: hidden;
}

#game-container {
    position: absolute;
    width: 100vw;
    height: 100vh;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

#objective-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #ffffff;
    padding: 10px;
    min-width: 250px;
    pointer-events: auto;
}

#objective-panel p {
    font-size: 13px;
    line-height: 1.4;
    color: #ffffff;
}

#status-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #ffffff;
    padding: 10px;
    min-width: 200px;
    pointer-events: auto;
}

#minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

#minimap canvas {
    width: 100%;
    height: 100%;
    border-radius: 3px;
}

/* Game stats at top center */
#game-stats {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 30px;
    color: #ffffff;
    font-size: 16px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
}

#game-stats .stat-item {
    display: flex;
    gap: 5px;
    align-items: center;
}

#game-stats .stat-item span:first-child {
    color: #cccccc;
}

#game-stats .stat-item span:last-child {
    color: #ffffff;
}

/* Controls at bottom left */
#controls-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: #ffffff;
    padding: 10px 15px;
    pointer-events: auto;
    font-size: 12px;
    border: none;
}

#stealth-meter {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
}

#stealth-meter span {
    margin-right: 10px;
    min-width: 50px;
}

.meter {
    flex: 1;
    height: 20px;
    background: #333;
    border: 1px solid #00ff00;
    border-radius: 3px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
    width: 100%;
    transition: width 0.3s ease;
}

#alert-level {
    font-size: 12px;
    text-transform: uppercase;
}

#alert-text {
    font-weight: bold;
}

#alert-text.clear {
    color: #00ff00;
}

#alert-text.suspicious {
    color: #ffff00;
}

#alert-text.alert {
    color: #ff0000;
}

/* Game canvas styling */
canvas {
    display: block;
    margin: 0 auto;
    /* border: 2px solid #333; */
}

/* Mobile Play Button Overlay */
#mobile-play-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(20, 20, 40, 0.95));
    z-index: 4000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.play-overlay-content {
    text-align: center;
    color: white;
    padding: 60px 40px;
    max-width: 400px;
    animation: fadeInUp 0.6s ease-out;
}

.game-logo {
    font-size: 72px;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
}

.play-overlay-content h2 {
    font-size: 32px;
    margin-bottom: 15px;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    letter-spacing: 2px;
}

.play-overlay-content p {
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 40px;
    color: #cccccc;
    opacity: 0.9;
}

.play-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 18px;
    font-weight: bold;
    padding: 20px 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 0 auto;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 160px;
}

.play-btn:hover {
    background: linear-gradient(135deg, #45a049, #4CAF50);
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(76, 175, 80, 0.4);
}

.play-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
}

.play-icon {
    font-size: 24px;
    line-height: 1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Rotation Prompt for Portrait Mode */
#rotation-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.rotation-content {
    text-align: center;
    color: white;
    padding: 40px 20px;
    max-width: 300px;
}

.phone-icon {
    font-size: 48px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.rotation-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #ffffff;
}

.rotation-content p {
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 20px;
    color: #cccccc;
}

.rotation-arrow {
    font-size: 32px;
    animation: rotate 3s linear infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

/* Touch Controls for Mobile */
#touch-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
    z-index: 2000;
}

/* Virtual Joystick */
#virtual-joystick {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
}

#joystick-base:active,
#joystick-base.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 255, 255, 0.2);
}

#joystick-knob {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: grab;
    will-change: transform;
}

#joystick-knob:active,
#joystick-base.active #joystick-knob {
    cursor: grabbing;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6));
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

/* Smooth return animation when released */
#joystick-knob:not(.dragging) {
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

/* Virtual D-Pad */
#virtual-dpad {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 2px;
    pointer-events: auto;
}

.dpad-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    color: white;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.1s ease;
}

.dpad-button:active,
.dpad-button.pressed {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(0.95);
}

.dpad-center {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#dpad-up { grid-column: 2; grid-row: 1; }
#dpad-left { grid-column: 1; grid-row: 2; }
#dpad-center { grid-column: 2; grid-row: 2; }
#dpad-right { grid-column: 3; grid-row: 2; }
#dpad-down { grid-column: 2; grid-row: 3; }

/* Action Buttons */
#action-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.action-btn {
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: none;
    border-radius: 8px;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 6px 12px;
    min-width: 80px;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.1s ease;
}

.action-btn:active,
.action-btn.pressed {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(0.95);
}

/* Mobile Portrait - Show play overlay and rotation prompt */
@media (max-width: 1024px) and (orientation: portrait) {
    #mobile-play-overlay {
        display: flex;
    }
    
    #rotation-prompt {
        display: none; /* Hidden initially, shown after play button */
    }
    
    #touch-controls {
        display: none;
    }
    
    #controls-info {
        display: none;
    }
    
    #minimap {
        display: block;
        width: 120px;
        height: 90px;
        top: 20px;
        right: 20px;
        bottom: auto;
        z-index: 1000;
    }
}

/* Mobile Landscape - Show play overlay initially, then game controls */
@media (max-width: 1024px) and (orientation: landscape) {
    #mobile-play-overlay {
        display: flex;
    }
    
    #rotation-prompt {
        display: none;
    }
    
    #touch-controls {
        display: none; /* Hidden initially, shown after play button */
    }
    
    #controls-info {
        display: none;
    }
    
    #minimap {
        display: block;
        width: 140px;
        height: 105px;
        top: 20px;
        right: 20px;
        bottom: auto;
        z-index: 1000;
    }
    
    #objective-panel {
        position: absolute;
        top: 10px;
        left: 10px;
        padding: 8px;
        min-width: 120px;
        max-width: 180px;
        font-size: 11px;
    }
    
    #objective-panel h3 {
        font-size: 12px;
        margin-bottom: 5px;
    }
    
    #objective-panel p {
        font-size: 10px;
        line-height: 1.2;
    }
    
    #status-panel {
        position: absolute;
        top: 10px;
        right: 10px;
        padding: 8px;
        min-width: 100px;
        max-width: 150px;
        font-size: 11px;
    }
    
    #stealth-meter {
        margin-bottom: 5px;
        font-size: 10px;
    }
    
    #stealth-meter span {
        margin-right: 5px;
        min-width: 35px;
    }
    
    .meter {
        height: 8px;
        width: 60px;
    }
    
    #alert-level {
        font-size: 10px;
    }
    
    #game-stats {
        font-size: 12px;
        gap: 20px;
    }
}

/* General mobile fallback - ensure touch controls work */
@media (max-width: 1024px) {
    #controls-info {
        display: none;
    }
    
    #minimap {
        display: block;
        width: 130px;
        height: 98px;
        top: 20px;
        right: 20px;
        bottom: auto;
        z-index: 1000;
    }
}

/* Desktop and larger screens */
@media (min-width: 1025px) {
    #rotation-prompt {
        display: none;
    }
    
    #touch-controls {
        display: none;
    }
    
    #controls-info {
        display: block;
    }
    
    #minimap {
        display: block;
    }
}

