/* ==========================================================================
   Bala Hanuman 3D: Chronicles of Kishkindha
   Styling for 3D WebGL Canvas, Mythological HUD, Minimap & Mobile Controls
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Yatra+One&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    --gold-primary: #FFD700;
    --gold-glow: rgba(255, 215, 0, 0.6);
    --gold-deep: #D4AF37;
    --saffron-orange: #FF671F;
    --saffron-glow: rgba(255, 103, 31, 0.5);
    --divine-blue: #00E5FF;
    --divine-purple: #9D4EDD;
    --sacred-red: #D90429;
    --emerald-green: #10B981;
    --dark-bg: rgba(15, 12, 28, 0.85);
    --panel-bg: rgba(20, 16, 35, 0.88);
    --border-gold: rgba(255, 215, 0, 0.4);
    --font-mythic: 'Yatra One', 'Cinzel', serif;
    --font-ui: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0c0915;
    font-family: var(--font-ui);
    color: #FFFFFF;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#webgl-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#webgl-canvas:active {
    cursor: grabbing;
}

/* ==========================================================================
   HUD Overlay Layer
   ========================================================================== */
#hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    z-index: 10;
}

/* Top Bar */
.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    gap: 16px;
}

/* Top-Left: Player Vital Status */
.player-status-card {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 8px 16px 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 215, 0, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.avatar-ring {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 2px solid var(--gold-primary);
    box-shadow: 0 0 12px var(--gold-glow);
    overflow: hidden;
    background: radial-gradient(circle, #ff8c00 0%, #3e1b00 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--saffron-orange);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    border: 1px solid #ffd700;
}

.vital-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}

.player-name-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.player-name {
    font-family: var(--font-mythic);
    font-size: 16px;
    color: var(--gold-primary);
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.player-title {
    font-size: 11px;
    color: #e0d0b0;
    font-weight: 500;
}

/* Health Hearts */
.health-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.heart-icon {
    font-size: 15px;
    color: var(--sacred-red);
    filter: drop-shadow(0 0 4px rgba(217, 4, 41, 0.7));
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.heart-icon.lost {
    opacity: 0.25;
    transform: scale(0.85);
    filter: grayscale(1);
}

/* Prana / Divine Energy Bar */
.prana-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    overflow: hidden;
    position: relative;
}

.prana-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #FF671F, #FFD700);
    box-shadow: 0 0 8px var(--gold-glow);
    border-radius: 3px;
    transition: width 0.15s ease-out;
}

/* Top-Center: Quest Progress & Connection Bridge Awakening Meter */
.bridge-progress-card {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--panel-bg);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 10px 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 280px;
    max-width: 420px;
}

.bridge-title-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    margin-bottom: 6px;
}

.realm-label {
    font-family: var(--font-mythic);
    font-size: 13px;
    color: var(--gold-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

.realm-label .realm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 8px #10B981;
}

.harmony-percent {
    font-size: 13px;
    font-weight: 700;
    color: #FFFFFF;
}

.harmony-meter-track {
    width: 100%;
    height: 14px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 7px;
    border: 1px solid rgba(255, 215, 0, 0.35);
    position: relative;
    overflow: hidden;
}

.harmony-meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #10B981, #FFD700, #FF671F);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    border-radius: 6px;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 80% Threshold Indicator Marker */
.threshold-80-line {
    position: absolute;
    left: 80%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #FFFFFF;
    box-shadow: 0 0 6px #FFFFFF;
    z-index: 2;
}

.bridge-state-text {
    font-size: 11px;
    margin-top: 4px;
    color: #FFD700;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: center;
    transition: color 0.3s;
}

.bridge-state-text.unlocked {
    color: #00E5FF;
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 4px #00E5FF, 0 0 12px #00E5FF; }
    50% { text-shadow: 0 0 12px #00E5FF, 0 0 24px #FFD700; }
}

/* Top-Right: Minimap & Compass */
.minimap-wrapper {
    pointer-events: auto;
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px solid var(--gold-primary);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.3), inset 0 0 12px rgba(0, 0, 0, 0.8);
    background: radial-gradient(circle, rgba(20, 35, 20, 0.9) 0%, rgba(10, 15, 10, 0.95) 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
}

.compass-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-needle-n {
    position: absolute;
    top: 3px;
    font-size: 9px;
    font-weight: 900;
    color: #FF3B30;
    text-shadow: 0 0 3px #000;
}

/* Top-Right Controls & Action Bar */
.top-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: auto;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 1px solid var(--border-gold);
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.icon-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.08);
    box-shadow: 0 0 12px var(--gold-glow);
}

/* Bottom HUD: Quest Tracker & Controls Guide */
.hud-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    gap: 16px;
}

/* Quest Tracker List */
.quest-tracker-card {
    pointer-events: auto;
    background: var(--panel-bg);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 12px 18px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 220px;
}

.quest-card-header {
    font-family: var(--font-mythic);
    font-size: 13px;
    color: var(--gold-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 4px;
}

.quest-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #e5e5e5;
    margin-bottom: 5px;
    font-weight: 500;
}

.quest-item .quest-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quest-item .quest-count {
    font-weight: 700;
    color: var(--gold-primary);
}

.quest-item.completed .quest-count {
    color: #10B981;
}

.quest-item.completed {
    opacity: 0.85;
}

/* Desktop Controls Helper */
.controls-guide-card {
    pointer-events: auto;
    background: var(--panel-bg);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 10px 16px;
    backdrop-filter: blur(12px);
    font-size: 11px;
    color: #cbd5e1;
    display: flex;
    gap: 12px;
    align-items: center;
}

.key-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    color: var(--gold-primary);
}

/* ==========================================================================
   Mobile Touch Controls (Shown only on touch / small screens)
   ========================================================================== */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    pointer-events: none;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 20;
}

.touch-device #mobile-controls {
    display: flex;
}

/* Virtual Joystick */
.joystick-zone {
    pointer-events: auto;
    width: 130px;
    height: 130px;
    position: relative;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border: 2px dashed rgba(255, 215, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.joystick-knob {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle, #FFD700 0%, #FF671F 100%);
    box-shadow: 0 0 15px var(--gold-glow);
    border: 2px solid #FFFFFF;
    position: absolute;
    pointer-events: none;
    transform: translate(0px, 0px);
    transition: transform 0.05s ease-out;
}

/* Action Buttons Cluster */
.action-buttons-cluster {
    pointer-events: auto;
    display: grid;
    grid-template-columns: repeat(2, 64px);
    grid-gap: 12px;
    touch-action: manipulation;
}

.action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--gold-primary);
    background: var(--panel-bg);
    color: #FFFFFF;
    font-family: var(--font-mythic);
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    transition: transform 0.1s, background 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.action-btn:active {
    transform: scale(0.92);
}

.action-btn.btn-jump {
    background: radial-gradient(circle, #059669 0%, #064e3b 100%);
    border-color: #34D399;
}

.action-btn.btn-dash {
    background: radial-gradient(circle, #0284C7 0%, #0c4a6e 100%);
    border-color: #38BDF8;
}

.action-btn.btn-smash {
    background: radial-gradient(circle, #DC2626 0%, #7f1d1d 100%);
    border-color: #F87171;
    grid-column: span 2;
    width: 100%;
    height: 52px;
    border-radius: 26px;
}

.action-btn .btn-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

/* ==========================================================================
   Toast Announcements & Cinematic Banner
   ========================================================================== */
#toast-banner {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--panel-bg);
    border: 2px solid var(--gold-primary);
    border-radius: 30px;
    padding: 10px 28px;
    color: #FFF;
    font-family: var(--font-mythic);
    font-size: 15px;
    letter-spacing: 0.8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px var(--gold-glow);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 50;
}

#toast-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Modals & Menus (Pause, Instructions, Level Complete)
   ========================================================================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 4, 12, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: linear-gradient(135deg, rgba(26, 19, 44, 0.95), rgba(15, 10, 26, 0.95));
    border: 2px solid var(--gold-primary);
    border-radius: 24px;
    padding: 32px;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px var(--gold-glow);
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.modal-overlay.active .modal-dialog {
    transform: scale(1);
}

.modal-dialog::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.modal-title {
    font-family: var(--font-mythic);
    font-size: 26px;
    color: var(--gold-primary);
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.modal-subtitle {
    font-size: 14px;
    color: #E2E8F0;
    margin-bottom: 24px;
    line-height: 1.6;
}

.dialog-stats-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    text-align: left;
}

.dialog-stat-item {
    display: flex;
    flex-direction: column;
}

.stat-item-label {
    font-size: 11px;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-item-value {
    font-family: var(--font-mythic);
    font-size: 18px;
    color: var(--gold-primary);
}

.modal-btn-row {
    display: flex;
    justify-content: center;
    gap: 14px;
}

.btn-mythic {
    font-family: var(--font-mythic);
    font-size: 15px;
    padding: 12px 28px;
    border-radius: 30px;
    border: 2px solid var(--gold-primary);
    background: linear-gradient(135deg, #FF671F 0%, #FFD700 100%);
    color: #1a0b00;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255, 103, 31, 0.4);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.btn-mythic:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(255, 215, 0, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #FFF;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.2);
}

/* Floating Damage / Score Popups */
.floating-text-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 15;
}

.floating-popup {
    position: absolute;
    font-family: var(--font-mythic);
    font-weight: 700;
    font-size: 16px;
    pointer-events: none;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
    animation: float-up-fade 1.2s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes float-up-fade {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    15% {
        opacity: 1;
        transform: translateY(-8px) scale(1.15);
    }
    100% {
        opacity: 0;
        transform: translateY(-45px) scale(0.9);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #hud-overlay {
        padding: 10px;
    }
    
    .hud-header {
        gap: 8px;
    }

    .player-status-card {
        padding: 6px 12px 6px 6px;
    }

    .avatar-ring {
        width: 46px;
        height: 46px;
    }

    .vital-bars {
        min-width: 100px;
    }

    .player-name {
        font-size: 14px;
    }

    .bridge-progress-card {
        min-width: 180px;
        padding: 6px 12px;
    }

    .minimap-wrapper {
        width: 80px;
        height: 80px;
    }

    .controls-guide-card {
        display: none;
    }

    .quest-tracker-card {
        min-width: 160px;
        padding: 8px 12px;
        font-size: 11px;
    }
}
