/* ============================================
   Anatomy Blaster - Medical Edition
   HUD Styles 
   ============================================ */

.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: var(--z-hud);
    padding: var(--space-sm) var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(2, 12, 24, 0.85) 0%, transparent 100%);
}

.hud-left, .hud-right, .hud-center {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    background: linear-gradient(135deg, rgba(4, 20, 40, 0.9), rgba(2, 12, 26, 0.9));
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-stone);
    border: 1px solid var(--border-vine);
    box-shadow: 
        inset 1px 1px 3px rgba(0,0,0,0.5),
        inset -1px -1px 3px rgba(255,255,255,0.1),
        0 3px 8px rgba(0,0,0,0.5);
    pointer-events: all;
}

.hud-center {
    align-items: center;
}

.hud-right {
    align-items: flex-end;
}

.hud-label {
    font-family: var(--font-display);
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.hud-value {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 900;
    color: var(--med-bright);
    text-shadow: 
        0 0 8px rgba(0, 180, 255, 0.6),
        1px 1px 3px rgba(0,0,0,0.8);
    line-height: 1.2;
}

.hud-value.score {
    color: var(--med-glow);
    text-shadow: 
        0 0 10px rgba(0, 220, 255, 0.7),
        1px 1px 3px rgba(0,0,0,0.8);
}

.hud-value.combo {
    color: var(--gold-light);
    text-shadow: 
        0 0 12px rgba(232, 192, 119, 0.8),
        1px 1px 3px rgba(0,0,0,0.8);
    font-size: 22px;
    transition: transform var(--transition-fast);
}

.combo-active {
    animation: comboPulse 0.3s ease;
}

@keyframes comboPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Health Bar - Golden energy */
.health-bar-container {
    width: 120px;
    height: 10px;
    background: var(--stone-dark);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-carved);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.health-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold));
    border-radius: var(--radius-sm);
    transition: width var(--transition-normal);
    will-change: width;
    box-shadow: 0 0 8px rgba(212, 168, 85, 0.6);
    position: relative;
}

.health-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.3), transparent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.health-bar.medium {
    background: linear-gradient(90deg, #c87a3a, #e8a855);
}

.health-bar.low {
    background: linear-gradient(90deg, #a84432, #d4855a);
    animation: healthPulse 0.5s ease infinite;
}

@keyframes healthPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* XP Bar */
.xp-bar-container {
    width: 100%;
    max-width: 200px;
    height: 6px;
    background: var(--stone-dark);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-vine);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--med-blue), var(--med-teal));
    border-radius: 3px;
    transition: width var(--transition-normal);
    will-change: width;
    box-shadow: 0 0 6px rgba(0, 160, 200, 0.5);
}

/* Powerup Indicators - Stone medallions */
.powerup-indicators {
    position: absolute;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-sm);
    z-index: var(--z-hud);
    pointer-events: none;
}

.powerup-indicator {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid var(--border-vine);
    background: linear-gradient(135deg, var(--stone-light), var(--stone-medium));
    box-shadow: 
        inset 1px 1px 3px rgba(0,0,0,0.5),
        inset -1px -1px 3px rgba(255,255,255,0.1),
        0 3px 8px rgba(0,0,0,0.5);
}

.powerup-indicator .icon-sm {
    width: 16px;
    height: 16px;
}

.powerup-timer {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 4px;
    background: var(--stone-dark);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--border-vine);
}

.powerup-timer-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.1s linear;
    will-change: width;
    box-shadow: 0 0 6px rgba(212, 168, 85, 0.6);
}

/* ============================================
   PAUSE BUTTON - Carved Stone
   ============================================ */
.pause-btn {
    position: absolute;
    top: var(--space-sm);
    right: 50px;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-stone);
    background: linear-gradient(135deg, var(--stone-light), var(--stone-medium));
    border: 2px solid var(--border-vine);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-buttons);
    cursor: pointer;
    pointer-events: all;
    transition: all var(--transition-fast);
    padding: 0;
    outline: none;
    box-shadow: 
        inset 2px 2px 4px rgba(0,0,0,0.4),
        inset -2px -2px 4px rgba(255,255,255,0.1),
        0 3px 10px rgba(0,0,0,0.5);
}

.pause-btn:hover {
    background: linear-gradient(135deg, var(--stone-light), var(--stone-dark));
    box-shadow: 
        inset 2px 2px 4px rgba(0,0,0,0.5),
        inset -2px -2px 4px rgba(255,255,255,0.15),
        0 4px 12px rgba(0,0,0,0.6);
}

.pause-btn:active {
    transform: scale(0.95);
    box-shadow: 
        inset 3px 3px 6px rgba(0,0,0,0.6),
        inset -1px -1px 2px rgba(255,255,255,0.1),
        0 2px 6px rgba(0,0,0,0.4);
}

/* Pause icon - gold color */
.pause-btn .icon-pause::before,
.pause-btn .icon-pause::after {
    background: var(--gold) !important;
}

/* Resume icon - gold color */
.pause-btn .icon-resume::after {
    border-color: transparent transparent transparent var(--gold) !important;
}

/* ============================================
   KEYBOARD BUTTON - Stone Toggle
   Positioned above input area when keyboard active
   ============================================ */
.keyboard-btn {
    position: fixed;
    bottom: 70px;
    right: var(--space-md);
    width: 50px;
    height: 50px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--stone-light), var(--stone-medium));
    border: 2px solid var(--border-vine);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: calc(var(--z-buttons) + 1);
    cursor: pointer;
    pointer-events: all;
    box-shadow: 
        inset 2px 2px 4px rgba(0, 0, 0, 0.4),
        inset -2px -2px 4px rgba(255, 255, 255, 0.1),
        0 3px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    padding: 0;
    outline: none;
}

.keyboard-btn:active {
    transform: scale(0.95);
    box-shadow: 
        inset 3px 3px 6px rgba(0, 0, 0, 0.6),
        inset -1px -1px 2px rgba(255, 255, 255, 0.1),
        0 2px 6px rgba(0, 0, 0, 0.4);
}

.keyboard-btn .icon-keyboard::after {
    border-color: var(--gold) !important;
}

.keyboard-btn .icon-keyboard::before {
    background: var(--gold) !important;
}

.keyboard-btn.keyboard-open {
    bottom: calc(var(--keyboard-height, 300px) + 80px);
}

/* Button sits above input area */
.keyboard-btn.gk-active {
    bottom: 293px; /* keyboard 213px + input ~80px */
}

/* ============================================
   INPUT AREA - Stone Panel
   FIXED: Now appears WELL ABOVE game keyboard
   ============================================ */
.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: calc(var(--z-hud) + 1);
    padding: var(--space-md) var(--space-md) var(--space-sm);
    background: linear-gradient(to top, rgba(2, 10, 20, 0.98) 0%, rgba(4, 16, 32, 0.85) 60%, transparent 100%);
    transition: bottom 0.3s ease;
    pointer-events: none;
}

.input-area.keyboard-open {
    bottom: var(--keyboard-height, 0px);
    pointer-events: auto;
}

/* Input area sits directly on top of game keyboard */
.input-area.gk-active {
    bottom: 213px; /* Actual game keyboard height: 4 rows� 44px + 3 gaps� 5px + padding */
}

.typing-display {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(4,18,40,0.95), rgba(2,10,24,0.95));
    border: 2px solid var(--border-vine);
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--med-bright);
    text-align: center;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 3px;
    text-shadow: 
        0 0 8px rgba(212, 168, 85, 0.6),
        1px 1px 3px rgba(0,0,0,0.8);
    box-shadow: 
        inset 2px 2px 5px rgba(0, 0, 0, 0.5),
        inset -2px -2px 5px rgba(255, 255, 255, 0.08),
        0 4px 16px rgba(0, 0, 0, 0.6);
    position: relative;
    overflow: hidden;
    cursor: text;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: all;
}

.typing-display::after {
    content: '|';
    animation: cursorBlink 0.7s ease infinite;
    margin-left: 2px;
    color: var(--gold);
}

.typing-display.has-text::after {
    animation: cursorBlink 0.5s ease infinite;
}

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

.typing-correct {
    color: var(--med-teal);
    text-shadow: 0 0 8px rgba(0, 200, 180, 0.7);
}

.typing-wrong {
    color: #d4855a;
    text-shadow: 0 0 8px rgba(212, 133, 90, 0.7);
}

.typing-remaining {
    color: var(--text-muted);
}

/* Wave Banner - Stone inscription */
.wave-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: clamp(28px, 7vw, 52px);
    font-weight: 900;
    color: var(--gold);
    text-shadow: 
        2px 2px 6px rgba(0,0,0,0.9),
        0 0 20px rgba(212, 168, 85, 0.5);
    z-index: var(--z-floating);
    pointer-events: none;
    animation: waveBanner 2s ease forwards;
    text-align: center;
    white-space: nowrap;
    letter-spacing: 3px;
}

.wave-banner.boss-wave {
    color: var(--gold-light);
    text-shadow: 
        2px 2px 8px rgba(0,0,0,0.9),
        0 0 30px rgba(232, 192, 119, 0.7);
}

@keyframes waveBanner {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    40% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Floating Text - Gold points */
.float-text {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 900;
    pointer-events: none;
    z-index: var(--z-floating);
    animation: floatUp 1s ease forwards;
    white-space: nowrap;
    color: var(--gold);
    text-shadow: 
        0 0 10px rgba(212, 168, 85, 0.8),
        1px 1px 3px rgba(0,0,0,0.9);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.5);
    }
}

/* Achievement Popup - Stone tablet */
.achievement-popup {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--stone-light), var(--stone-medium));
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    z-index: var(--z-popups);
    animation: achieveSlide 3s ease forwards;
    text-align: center;
    white-space: nowrap;
    border: 2px solid var(--border-vine);
    box-shadow: 
        inset 2px 2px 4px rgba(0,0,0,0.4),
        inset -2px -2px 4px rgba(255,255,255,0.1),
        0 4px 16px rgba(0,0,0,0.5);
}

.achievement-popup .achieve-title {
    font-family: var(--font-display);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.achievement-popup .achieve-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 
        0 0 8px rgba(212, 168, 85, 0.6),
        1px 1px 3px rgba(0,0,0,0.8);
}

@keyframes achieveSlide {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    10% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
}

/* ============================================
   BUILT-IN GAME KEYBOARD - Stone Keys
   ============================================ */
.game-keyboard {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: var(--z-hud);
    padding: 8px 6px 12px;
    background: linear-gradient(to top, rgba(2, 10, 22, 0.98) 0%, rgba(2, 10, 22, 0.95) 100%);
    border-top: 2px solid var(--kb-border-top);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.gk-row {
    display: flex;
    gap: 4px;
    justify-content: center;
    width: 100%;
    max-width: 500px;
}

.gk-key {
    flex: 1;
    max-width: 42px;
    height: 44px;
    border: 1px solid var(--kb-key-border);
    border-radius: var(--radius-stone);
    background: linear-gradient(135deg, var(--stone-light), var(--stone-medium));
    color: var(--warm-highlight);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
    padding: 0;
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-shadow: 
        inset 1px 1px 3px rgba(0,0,0,0.4),
        inset -1px -1px 3px rgba(255,255,255,0.1),
        0 2px 6px rgba(0,0,0,0.4);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}

.gk-key:active,
.gk-key.pressed {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border-color: var(--gold-light);
    transform: scale(0.92);
    box-shadow: 
        inset 2px 2px 4px rgba(0,0,0,0.6),
        inset -1px -1px 2px rgba(255,255,255,0.2),
        0 1px 3px rgba(0,0,0,0.3);
    color: var(--kb-key-active-text);
}

.gk-key.correct {
    background: linear-gradient(135deg, var(--med-blue), var(--med-teal));
    border-color: var(--med-teal);
    color: var(--warm-highlight);
}

.gk-key.wrong {
    background: linear-gradient(135deg, #a84432, #d4855a);
    border-color: #d4855a;
    color: var(--warm-highlight);
}

/* Backspace key */
.gk-backspace {
    flex: 1.5;
    max-width: 64px;
    background: linear-gradient(135deg, rgba(4,18,40,0.95), rgba(2,10,24,0.95));
    border-color: #d4855a;
    font-size: 18px;
    color: var(--warm-highlight);
}

.gk-backspace:active {
    background: linear-gradient(135deg, #8a3828, #6a2818);
    border-color: #a84432;
}

.gk-spacer {
    width: 20px;
    flex-shrink: 0;
}

.gk-spacer-half {
    width: 10px;
    flex-shrink: 0;
}

/* Space key */
.gk-space {
    flex: 2;
    max-width: 120px;
}

/* Hint key on keyboard */
.gk-hint {
    flex: 0 0 auto;
    width: 52px;
    max-width: 52px;
    position: relative;
    background: linear-gradient(135deg, #1a3a5c, #0d2240);
    border-color: #00c8ff;
    color: #00c8ff;
    font-size: 18px;
    font-weight: 900;
    gap: 0;
    flex-direction: column;
    line-height: 1;
}
.gk-hint:active {
    background: linear-gradient(135deg, #00c8ff, #0090c0);
    color: #fff;
    border-color: #00eaff;
}
.gk-hint:disabled,
.gk-hint.hint-exhausted {
    background: linear-gradient(135deg, rgba(4,18,40,0.9), rgba(2,10,24,0.9));
    border-color: rgba(0,200,255,0.2);
    color: rgba(0,200,255,0.25);
    cursor: not-allowed;
}
.gk-hint-icon {
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    font-family: var(--font-display);
}
.gk-hint-badge {
    position: absolute;
    top: 3px;
    right: 4px;
    background: #00c8ff;
    color: #000;
    font-size: 9px;
    font-weight: 900;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: var(--font-display);
}
.gk-hint:disabled .gk-hint-badge,
.gk-hint.hint-exhausted .gk-hint-badge {
    background: rgba(0,200,255,0.2);
    color: rgba(0,0,0,0.3);
}

/* Keyboard type toggle in settings */
.keyboard-type-btn {
    font-family: var(--font-display);
    font-size: 11px;
    padding: 8px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--kb-key-border);
    background: linear-gradient(135deg, var(--kb-key-bg), var(--kb-panel-bg));
    color: var(--kb-key-text);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-transform: uppercase;
    letter-spacing: 1px;
    outline: none;
    min-width: 90px;
    text-align: center;
    box-shadow: 
        inset 1px 1px 3px rgba(0,0,0,0.4),
        inset -1px -1px 3px rgba(255,255,255,0.1),
        0 2px 6px rgba(0,0,0,0.4);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}

.keyboard-type-btn:hover {
    background: linear-gradient(135deg, var(--stone-light), var(--stone-dark));
}

.keyboard-type-btn:active {
    transform: scale(0.95);
    box-shadow: 
        inset 2px 2px 4px rgba(0,0,0,0.6),
        inset -1px -1px 2px rgba(255,255,255,0.1),
        0 1px 3px rgba(0,0,0,0.3);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 360px) {
    .gk-key {
        height: 38px;
        font-size: 13px;
        max-width: 36px;
    }
    .gk-backspace {
        max-width: 54px;
        font-size: 16px;
    }
    .game-keyboard {
        padding: 6px 4px 10px;
        gap: 3px;
    }
    .gk-row {
        gap: 3px;
    }
    /* Small screen: keyboard ~177px */
    .input-area.gk-active {
        bottom: 177px;
    }
    .keyboard-btn.gk-active {
        bottom: 257px;
    }
    .typing-display {
        font-size: 16px;
        padding: 10px 16px;
        min-height: 48px;
    }
}

@media (min-width: 481px) {
    .gk-key {
        height: 48px;
        font-size: 16px;
        max-width: 48px;
    }
    .gk-backspace {
        max-width: 72px;
        font-size: 20px;
    }
    .game-keyboard {
        gap: 6px;
    }
    /* Large screen: keyboard ~230px */
    .input-area.gk-active {
        bottom: 230px;
    }
    .keyboard-btn.gk-active {
        bottom: 310px;
    }
    .typing-display {
        font-size: 22px;
        padding: 16px 22px;
        min-height: 60px;
    }
}

@media (max-height: 420px) and (orientation: landscape) {
    .gk-key {
        height: 34px;
        font-size: 12px;
        max-width: 36px;
    }
    .game-keyboard {
        padding: 4px 4px 6px;
        gap: 2px;
    }
    .gk-row {
        gap: 2px;
    }
    /* Landscape: keyboard ~152px */
    .input-area.gk-active {
        bottom: 152px;
    }
    .keyboard-btn.gk-active {
        bottom: 232px;
    }
    .typing-display {
        font-size: 16px;
        padding: 10px 16px;
        min-height: 44px;
    }
    .input-area {
        padding: var(--space-sm) var(--space-md) 4px;
    }
}