/* ============================================
   BROWSER GAMES - Common Styles
   ============================================ */

/* ============================================
   Z-INDEX HIERARCHY (Standardized Scale)
   ============================================
   Use these values consistently across all games:

   0    - Video element (camera feed)
   1    - Game canvas
   50   - Game elements (in-game UI, hand indicators)
   100  - UI overlay (score panel, control panel, instructions, warnings)
   150  - Power-up displays, message popups
   200  - Pause overlay, game-over overlay, wave transitions
   300  - Modal dialogs (reserved for critical overlays)
   1000 - Loading screen
   1001 - Error screen
   ============================================ */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #fff;
    touch-action: none; /* Prevent default touch behaviors */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Game Container */
.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Canvas Styling */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#videoElement {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror the video */
    z-index: 0;
}

#gameCanvas {
    z-index: 1;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #4ecdc4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #4ecdc4;
}

/* Error Screen */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2d1f1f 0%, #3d2020 50%, #4a2525 100%);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    padding: 20px;
    text-align: center;
}

.error-screen.visible {
    display: flex;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error-title {
    font-size: 1.8rem;
    color: #ff6b6b;
    margin-bottom: 15px;
}

.error-message {
    font-size: 1rem;
    color: #ccc;
    max-width: 400px;
    line-height: 1.6;
}

/* UI Overlay */
.ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 100;
    pointer-events: none;
}

.ui-overlay > * {
    pointer-events: auto;
}

/* Score Display */
.score-panel {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-value {
    font-size: 2rem;
    font-weight: bold;
    color: #4ecdc4;
}

.score-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.missed-value {
    font-size: 1.2rem;
    color: #ff6b6b;
    margin-top: 5px;
}

/* Control Buttons */
.control-panel {
    display: flex;
    gap: 10px;
}

.btn {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #4ecdc4;
}

.btn:active {
    transform: scale(0.95);
}

.btn-icon {
    font-size: 1.5rem;
}

/* Fullscreen Button */
.fullscreen-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

/* Game Title */
.game-title {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 100;
    white-space: nowrap;
}

/* Instructions Overlay */
.instructions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 25px;
    border-radius: 25px;
    font-size: 0.9rem;
    color: #4ecdc4;
    z-index: 100;
    backdrop-filter: blur(10px);
}

/* No Body Detected Warning */
.no-body-warning {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 107, 107, 0.9);
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.3rem;
    color: #fff;
    z-index: 100;
    display: none;
    text-align: center;
    animation: pulse 1s ease-in-out infinite;
}

.no-body-warning.visible {
    display: block;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.1rem;
        top: 10px;
    }

    .score-panel {
        padding: 10px 15px;
    }

    .score-value {
        font-size: 1.5rem;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .instructions {
        font-size: 0.8rem;
        padding: 8px 20px;
        bottom: 10px;
    }

    .ui-overlay {
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 0.9rem;
    }

    .score-value {
        font-size: 1.2rem;
    }

    .missed-value {
        font-size: 1rem;
    }

    .control-panel {
        gap: 5px;
    }

    .btn {
        padding: 8px 12px;
    }
}

/* Landscape mode adjustments for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .ui-overlay {
        padding: 5px 15px;
    }

    .score-panel {
        padding: 8px 15px;
    }

    .score-value {
        font-size: 1.3rem;
    }

    .game-title {
        font-size: 1rem;
        top: 5px;
    }

    .instructions {
        display: none;
    }
}
