/* ============================================
   DUNGEON HUNTER — In-Game HUD
   Vibrant RPG-themed, rich colors, dungeon feel
   ============================================ */

.hud {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 5;
    pointer-events: none;
}

.hud > * {
    pointer-events: auto;
}

/* ---- Styled Text Icons ---- */
.hp-icon-styled {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 800;
    color: #ff4444;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255,68,68,0.5);
    background: linear-gradient(135deg, rgba(255,68,68,0.15), transparent);
    padding: 2px 6px;
    border-radius: 4px;
}

.timer-icon-styled {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 600;
    color: rgba(200,180,230,0.7);
    letter-spacing: 2px;
}

.key-icon-styled {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    padding: 3px 8px;
    border-radius: 6px;
}

.key-icon-styled.inactive {
    color: rgba(200,180,230,0.25);
    opacity: 0.5;
}

.key-icon-styled.active {
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255,215,0,0.6);
    background: linear-gradient(135deg, rgba(255,215,0,0.15), transparent);
    animation: key-glow 1.5s ease-in-out infinite;
}

@keyframes key-glow {
    0%, 100% { text-shadow: 0 0 8px rgba(255,215,0,0.4); }
    50% { text-shadow: 0 0 20px rgba(255,215,0,0.7); }
}

.gold-icon-styled {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 900;
    color: #3d2200;
    width: 20px; height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700, #ff9f00);
    box-shadow: 0 2px 6px rgba(255,215,0,0.4), inset 0 -2px 0 rgba(0,0,0,0.1);
}

/* ---- HUD Element Base Style (Rich RPG Look) ---- */
.hud-element {
    background: linear-gradient(135deg, rgba(20,10,40,0.75), rgba(30,15,55,0.65));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(200,160,60,0.18);
    border-radius: 10px;
    box-shadow: 
        0 2px 10px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(200,160,60,0.08);
}

/* ---- HP Bar ---- */
.hud-hp {
    position: absolute;
    top: 14px; left: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(20,10,40,0.8), rgba(30,15,55,0.7));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255,68,68,0.2);
    border-radius: 10px;
    padding: 6px 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,68,68,0.05);
}

.hp-bar {
    width: 140px;
    height: 14px;
    background: rgba(255,68,68,0.08);
    border-radius: 7px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,68,68,0.15);
}

.hp-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #cc2222, #ff4444, #ff6666);
    border-radius: 7px;
    transition: width 0.3s ease;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 0 8px rgba(255,68,68,0.3);
}

.hp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.3), transparent);
    border-radius: 7px 7px 0 0;
}

.hp-bar-fill.critical {
    animation: hp-pulse 0.5s ease-in-out infinite;
    background: linear-gradient(90deg, #aa0000, #ff3333);
}

@keyframes hp-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(255,0,0,0.4); }
    50% { opacity: 0.6; box-shadow: 0 0 16px rgba(255,0,0,0.6); }
}

.hp-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    white-space: nowrap;
}

/* ---- Timer ---- */
.hud-timer {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(20,10,40,0.8), rgba(30,15,55,0.7));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(200,160,60,0.18);
    border-radius: 10px;
    padding: 5px 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.timer-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: #e0d0f0;
    letter-spacing: 2px;
    min-width: 55px;
    text-align: center;
}

.timer-text.warning { 
    color: #ffa030;
    text-shadow: 0 0 8px rgba(255,160,48,0.4);
    animation: timer-blink 1s ease-in-out infinite; 
}
.timer-text.danger { 
    color: #ff4040;
    text-shadow: 0 0 12px rgba(255,64,64,0.5);
    animation: timer-blink 0.5s ease-in-out infinite; 
}

@keyframes timer-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Right Side Stack (Level, Key, Gold) ---- */
.hud-right-stack {
    position: absolute;
    top: 14px; right: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
}

.hud-level, .hud-key, .hud-gold {
    background: linear-gradient(135deg, rgba(20,10,40,0.8), rgba(30,15,55,0.7));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(200,160,60,0.18);
    border-radius: 8px;
    padding: 4px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.hud-level {
    display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
    border-color: rgba(120,80,200,0.3);
}

.level-text {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: #c090ff;
    letter-spacing: 2px;
    text-shadow: 0 0 6px rgba(120,80,200,0.3);
}

.floor-text {
    font-size: 10px;
    color: rgba(200,180,230,0.5);
}

.hud-gold {
    display: flex; align-items: center; gap: 5px;
    border-color: rgba(200,160,60,0.25);
}

.gold-text {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 6px rgba(255,215,0,0.3);
}

/* ---- Camera Toggle ---- */
.btn-camera-toggle {
    position: absolute;
    bottom: 14px;
    left: 14px;
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(20,10,40,0.75), rgba(30,15,55,0.65));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(200,160,60,0.18);
    color: #c090ff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.btn-camera-toggle:hover {
    background: linear-gradient(135deg, rgba(200,160,60,0.2), rgba(120,80,200,0.15));
    color: #ffd700;
    border-color: rgba(200,160,60,0.4);
    box-shadow: 0 0 12px rgba(200,160,60,0.2);
}

/* ---- Minimap (Top Right, below right stack) ---- */
.hud-minimap {
    position: absolute;
    top: 90px; right: 14px;
    background: linear-gradient(135deg, rgba(20,10,40,0.85), rgba(30,15,55,0.75));
    border: 1.5px solid rgba(120,80,200,0.2);
    border-radius: 8px;
    padding: 3px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

#minimap-canvas {
    display: block;
    border-radius: 5px;
    image-rendering: pixelated;
}

/* ---- Prompt ---- */
.hud-prompt {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(20,10,40,0.85), rgba(30,15,55,0.75));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1.5px solid rgba(200,160,60,0.25);
    border-radius: 10px;
    padding: 10px 20px;
    animation: prompt-fade 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 12px rgba(200,160,60,0.1);
}

#prompt-text {
    font-family: var(--font-heading);
    font-size: 14px;
    color: #ffd700;
    letter-spacing: 1px;
}

@keyframes prompt-fade {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Crosshair (1st person only) ---- */
.hud-crosshair {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    color: rgba(255,255,255,0.5);
    pointer-events: none;
    font-weight: 300;
    text-shadow: 0 0 6px rgba(0,0,0,0.7);
}

/* ---- Damage Overlay ---- */
.hud-damage-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(200,20,20,0.5) 100%);
    transition: opacity 0.15s ease;
}

.hud-damage-overlay.flash {
    animation: damage-flash 0.4s ease-out forwards;
}

@keyframes damage-flash {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* ---- Hit Marker ---- */
.hud-hit-marker {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 30px; height: 30px;
    pointer-events: none;
    opacity: 0;
}

.hud-hit-marker.show {
    animation: hit-flash 0.25s ease-out forwards;
}

.hud-hit-marker.show::before,
.hud-hit-marker.show::after {
    content: '';
    position: absolute;
    background: #ffd700;
    box-shadow: 0 0 8px rgba(255,215,0,0.7);
}

.hud-hit-marker.show::before {
    width: 2px; height: 14px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

.hud-hit-marker.show::after {
    width: 2px; height: 14px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
}

@keyframes hit-flash {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* ==============================
   MOBILE CONTROLS
   Only show on actual touch devices
   Use JS detection, not CSS
   ============================== */
.mobile-controls {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 200px;
    pointer-events: none;
    display: none; /* Hidden by default, shown via JS for touch devices */
}

.mobile-controls.visible {
    display: block;
}

/* Virtual Joystick */
.joystick-area {
    position: absolute;
    bottom: 24px; left: 24px;
    width: 120px; height: 120px;
    pointer-events: auto;
    touch-action: none;
}

.joystick-base {
    width: 100%; height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(20,10,40,0.5), rgba(30,15,55,0.3));
    border: 2px solid rgba(120,80,200,0.25);
    position: relative;
    box-shadow: inset 0 0 20px rgba(120,80,200,0.1);
}

.joystick-thumb {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 44px; height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200,160,60,0.5), rgba(200,160,60,0.15));
    border: 2px solid rgba(200,160,60,0.5);
    box-shadow: 0 0 14px rgba(200,160,60,0.25);
    transition: none;
}

/* Action Buttons */
.mobile-action-buttons {
    position: absolute;
    bottom: 24px; right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}

.mobile-btn {
    width: 58px; height: 58px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(20,10,40,0.5), rgba(30,15,55,0.3));
    border: 2px solid rgba(120,80,200,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c090ff;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.mobile-btn:active {
    background: linear-gradient(135deg, rgba(200,160,60,0.3), rgba(120,80,200,0.2));
    transform: scale(0.88);
    border-color: #ffd700;
    color: #ffd700;
}

.mobile-btn-attack {
    width: 68px; height: 68px;
    background: linear-gradient(135deg, rgba(255,68,68,0.2), rgba(200,30,30,0.15));
    border-color: rgba(255,68,68,0.4);
    color: #ff6666;
    border-radius: 50%;
}

.mobile-btn-attack:active {
    background: linear-gradient(135deg, rgba(255,68,68,0.4), rgba(200,30,30,0.3));
    border-color: #ff4444;
    color: #ff4444;
    box-shadow: 0 0 16px rgba(255,68,68,0.3);
}

/* ---- Responsive Mobile Layout ---- */
@media (max-width: 768px) {
    .hud-hp { top: 10px; left: 10px; padding: 4px 8px; }
    .hp-bar { width: 100px; height: 12px; }
    .hp-text { font-size: 8px; }
    .hud-timer { top: 10px; padding: 4px 12px; }
    .timer-text { font-size: 18px; }
    .hud-right-stack { top: 10px; right: 10px; }
    .level-text { font-size: 11px; }
    .gold-text { font-size: 11px; }
    .hud-minimap { top: 75px; transform: scale(0.85); transform-origin: top right; }
    .hud-prompt { bottom: 220px; }
    #prompt-text { font-size: 12px; }
    .btn-camera-toggle { bottom: 230px; left: auto; right: 24px; }
}

@media (max-width: 400px) {
    .hp-bar { width: 80px; height: 10px; }
    .timer-text { font-size: 15px; }
    .joystick-area { width: 100px; height: 100px; bottom: 16px; left: 16px; }
    .joystick-thumb { width: 36px; height: 36px; }
    .mobile-btn { width: 48px; height: 48px; border-radius: 12px; }
    .mobile-btn-attack { width: 58px; height: 58px; }
    .mobile-action-buttons { bottom: 16px; right: 16px; gap: 8px; }
}
