/* ============================================
   UI OVERLAY (Oyun İçi — Canvas Üstü)
   ============================================ */

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    border-radius: 10px;
    animation: hudFadeIn 0.4s ease-out;
}

@keyframes hudFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Genel Blok Stili --- */

.ui-block {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.50);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* --- Sol Üst: Can (Kalpler) --- */

.ui-lives-block {
    position: absolute;
    top: 12px;
    left: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 12px;
}

.ui-hearts {
    display: flex;
    gap: 5px;
}

.ui-heart {
    width: 26px;
    height: 26px;
    display: block;
    color: #ff4466;
    fill: currentColor;
    filter: drop-shadow(0 0 4px rgba(255, 60, 80, 0.5));
    transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.ui-heart path {
    fill: currentColor;
}

.ui-heart.lost {
    color: #333b48;
    opacity: 0.35;
    filter: none;
    transform: scale(0.8);
}

.ui-heart.losing {
    animation: heartLose 0.6s ease-out forwards;
}

/* --- Sol Üst Altı: Dengesizlik Barı --- */

.ui-stability-block {
    position: absolute;
    top: 78px;
    left: 12px;
    width: 112px;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 7px 12px 8px;
    box-sizing: border-box;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.stability-bar-bg {
    width: 100%;
    height: 7px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.55);
}

.stability-bar-fill {
    width: 0;
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, #54d9c9, #a6f0e6);
    box-shadow: 0 0 8px rgba(84, 217, 201, 0.45);
    transition: width 0.12s linear, background 0.25s ease, box-shadow 0.25s ease;
}

.stability-bar-fill.is-warn {
    background: linear-gradient(90deg, #f3b53a, #ffd97a);
    box-shadow: 0 0 9px rgba(243, 181, 58, 0.5);
}

.stability-bar-fill.is-danger {
    background: linear-gradient(90deg, #ff6b8a, #ffa1b6);
    box-shadow: 0 0 12px rgba(255, 107, 138, 0.7);
}

.ui-stability-block.is-danger {
    border-color: rgba(255, 107, 138, 0.5);
    box-shadow: 0 0 18px rgba(255, 107, 138, 0.22);
}

.ui-stability-block.is-danger .ui-label {
    color: #ff9db2;
}

/* --- Sağ Üst: Nüfus --- */

.ui-pop-block {
    position: absolute;
    top: 12px;
    right: 12px;
    gap: 10px;
    padding: 8px 14px;
}

.ui-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 0 4px rgba(255, 204, 51, 0.4));
}

.ui-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

/* --- Sağ Üst Altı: Kat --- */

.ui-floor-block {
    position: absolute;
    top: 78px;
    right: 12px;
    gap: 10px;
    padding: 6px 14px;
}

/* --- Etiket ve Değer --- */

.ui-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
}

.ui-value {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    min-width: 28px;
    text-align: right;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
    transition: color 0.3s ease;
}

.ui-pop-block .ui-value {
    color: var(--accent-gold);
    text-shadow: 0 0 12px rgba(255, 204, 51, 0.25);
}

.ui-floor-block .ui-value {
    color: var(--accent-cyan);
    text-shadow: 0 0 12px rgba(68, 238, 221, 0.25);
}

/* --- Pop Animasyonu (değer güncellendiğinde) --- */

@keyframes uiPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.ui-value.pop {
    animation: uiPop 0.3s ease-out;
}

/* --- Kalp Kaybı Sarsıntı --- */

@keyframes heartShake {
    0%, 100% { transform: translateX(0); }
    15%      { transform: translateX(-3px); }
    30%      { transform: translateX(3px); }
    45%      { transform: translateX(-2px); }
    60%      { transform: translateX(2px); }
    75%      { transform: translateX(-1px); }
}

.ui-lives-block.shake {
    animation: heartShake 0.35s ease-out;
}

/* --- KOMBO GÖSTERGESİ --- */

.ui-combo-block {
    position: absolute;
    top: 126px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 22px;
    min-width: 140px;
    border: 1px solid rgba(255, 204, 51, 0.25);
    background: rgba(0, 0, 0, 0.65);
    border-radius: 12px;
    animation: comboAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes comboAppear {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

.combo-label {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 3px;
    text-align: center;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #fff 40%, var(--accent-cyan) 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: comboTextShimmer 2s ease-in-out infinite;
}

@keyframes comboTextShimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.combo-bar-bg {
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.combo-bar-fill {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent-gold), #ffe066, var(--accent-cyan));
    background-size: 200% 100%;
    animation: comboBarShimmer 1.5s linear infinite;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(255, 204, 51, 0.6),
                0 0 20px rgba(255, 204, 51, 0.2);
}

@keyframes comboBarShimmer {
    0%   { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* Çarpan arttığında kısa süreli vurgu (animasyon değil, geçiş) */
.ui-combo-block {
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.ui-combo-block.combo-hot {
    border-color: rgba(255, 204, 51, 0.7);
    box-shadow: 0 0 26px rgba(255, 204, 51, 0.28),
                0 0 54px rgba(255, 204, 51, 0.1),
                inset 0 0 12px rgba(255, 204, 51, 0.06),
                0 4px 16px rgba(0, 0, 0, 0.4);
}

/* --- Screen Shake --- */

.screen-shake {
    animation: shake 0.3s ease-out !important;
}

/* --- Perfect Flash --- */

.perfect-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 8;
    border-radius: 10px;
    opacity: 0;
}

.perfect-flash.active {
    animation: flashPulse 0.4s ease-out;
}

@keyframes flashPulse {
    0% {
        opacity: 0.35;
        background: radial-gradient(ellipse at center, rgba(68, 238, 221, 0.3) 0%, transparent 70%);
    }
    100% {
        opacity: 0;
        background: radial-gradient(ellipse at center, rgba(68, 238, 221, 0) 0%, transparent 70%);
    }
}