/* ============================================
   Shepherd's Forest Rescue - UI Styles
   ============================================ */

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    z-index: 50;
    pointer-events: none;
}

.hud-left, .hud-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    pointer-events: auto;
}

.hud-center {
    flex: 1;
    text-align: center;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

#hud-health {
    background: rgba(0, 0, 0, 0.6);
    padding: 0.4rem 0.6rem;
}

#health-hearts {
    font-size: 1.3rem;
    letter-spacing: 2px;
}

.hud-icon {
    font-size: 1.2rem;
}

.hud-item span:last-child {
    font-weight: 600;
    color: var(--color-dark);
}

#level-name {
    color: white;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-size: 1.1rem;
}

.hud-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-soft);
}

.hud-btn:hover {
    background: white;
    transform: scale(1.1);
}

.hud-btn:active {
    transform: scale(0.95);
}

/* Music Player Button */
#btn-music-player {
    position: relative;
}

#btn-music-player.playing {
    animation: musicPulse 1.5s ease-in-out infinite;
}

#btn-music-player.paused {
    opacity: 0.6;
}

@keyframes musicPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 2px 12px rgba(255, 215, 0, 0.4);
    }
}

/* Touch Controls */
#touch-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 100;
}

#touch-controls.active {
    display: flex;
}

.touch-dpad, .touch-actions {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.touch-btn {
    width: 70px;
    height: 70px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:active,
.touch-btn.pressed {
    background: rgba(255, 255, 255, 0.7);
    border-color: white;
    transform: scale(0.9);
}

/* Notification Toast */
.toast {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 25px;
    font-weight: 500;
    z-index: 200;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

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

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

/* Sheep Rescued Popup */
.sheep-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1.5rem 2.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    text-align: center;
    z-index: 150;
    animation: popIn 0.3s ease;
    box-shadow: var(--shadow-hard);
}

.sheep-popup .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: bounce 0.5s ease infinite;
}

.sheep-popup .message {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* Dialogue Box */
.dialogue-box {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    border: 3px solid var(--color-primary);
    z-index: 100;
    animation: slideUp 0.3s ease;
}

.dialogue-box .speaker {
    font-weight: bold;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.dialogue-box .text {
    color: var(--color-dark);
    line-height: 1.5;
}

.dialogue-box .continue {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.8rem;
    color: #999;
    animation: blink 1s infinite;
}

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

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Tool Indicator */
.tool-indicator {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 0.5rem;
    z-index: 50;
}

.tool-slot {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
}

.tool-slot.active {
    border-color: var(--color-accent);
    box-shadow: 0 0 10px var(--color-accent);
}

.tool-slot .key {
    position: absolute;
    bottom: 2px;
    right: 5px;
    font-size: 0.7rem;
    color: white;
    font-weight: bold;
}

/* Energy Bar */
.energy-bar {
    position: absolute;
    top: 70px;
    left: 20px;
    width: 150px;
    z-index: 50;
}

.energy-bar .label {
    color: white;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.energy-bar .bar {
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
}

.energy-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #27ae60);
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 100%;
}

/* Stealth Indicator */
.stealth-indicator {
    position: absolute;
    top: 70px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stealth-indicator.active {
    opacity: 1;
}

.stealth-indicator.hidden .status {
    color: #27ae60;
}

.stealth-indicator.detected .status {
    color: #e74c3c;
    animation: pulse 0.5s infinite;
}

.stealth-indicator .icon {
    font-size: 1.2rem;
}

.stealth-indicator .status {
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Rescue Prompt */
.rescue-prompt {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: rgba(74, 124, 89, 0.9);
    color: white;
    border-radius: 25px;
    font-weight: 500;
    z-index: 100;
    animation: float 2s ease-in-out infinite;
    box-shadow: var(--shadow-medium);
}

.rescue-prompt .key {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: white;
    color: var(--color-primary);
    border-radius: 5px;
    font-weight: bold;
    margin: 0 0.25rem;
}

@keyframes float {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.tutorial-box {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    max-width: 80%;
    animation: popIn 0.3s ease;
}

.tutorial-box h3 {
    color: var(--color-primary);
    margin-bottom: 1rem;
    font-family: var(--font-title);
}

.tutorial-box p {
    color: var(--color-dark);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.tutorial-box .controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tutorial-box .control-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.tutorial-box .key-icon {
    width: 50px;
    height: 50px;
    background: var(--color-light);
    border: 2px solid var(--color-primary);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.tutorial-box .key-label {
    font-size: 0.8rem;
    color: #666;
}

/* Responsive Touch Controls */
@media (pointer: coarse) {
    #touch-controls {
        display: flex;
    }
}

@media (max-width: 768px) {
    .touch-btn {
        width: 65px;
        height: 65px;
        font-size: 1.5rem;
    }
    
    #touch-controls {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }
    
    .touch-dpad, .touch-actions {
        gap: 0.5rem;
    }
    
    #touch-controls {
        padding: 0.75rem;
    }
    
    .hud-item {
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
    }
    
    #level-name {
        font-size: 0.9rem;
    }
    
    .dialogue-box {
        width: 90%;
        bottom: 80px;
        padding: 1rem;
    }
}
