/* Premium Mirza FX — transform/opacity only where possible */

/* Letter select: elastic bounce + gold glow (preserves tray centering) */
.mirza-letter-select {
    animation: mirzaLetterSelectPremium 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes mirzaLetterSelectPremium {
    0%   { transform: translate(-50%, -50%) scale(1); }
    40%  {
        transform: translate(-50%, -50%) scale(1.22);
        box-shadow:
            0 0 0 4px rgba(255, 215, 0, 0.55),
            0 8px 28px rgba(255, 200, 60, 0.45),
            0 4px 0 rgba(80, 50, 30, 0.45);
    }
    70%  { transform: translate(-50%, -50%) scale(0.96); }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow:
            0 0 0 3px rgba(255, 215, 0, 0.35),
            0 6px 0 rgba(80, 50, 30, 0.5);
    }
}

.mirza-letter-glow {
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.55));
}

/* ===== mamosta selection path ===== */
.mirza-path-halo {
    stroke: rgba(255, 200, 60, 0.28);
    stroke-width: 16;
    stroke-linecap: round;
    fill: none;
    pointer-events: none;
}

.mirza-path-core {
    stroke: #ffd700;
    stroke-width: 7;
    stroke-linecap: round;
    fill: none;
    pointer-events: none;
}

.mirza-path-shine {
    stroke: rgba(255, 255, 255, 0.55);
    stroke-width: 2.2;
    stroke-linecap: round;
    fill: none;
    pointer-events: none;
    opacity: 0.85;
}

.mirza-path-node {
    fill: #ffe9a0;
    stroke: #ffd700;
    stroke-width: 1.5;
    pointer-events: none;
}

.mirza-live-halo {
    stroke: rgba(255, 215, 0, 0.22);
    stroke-width: 14;
    stroke-linecap: round;
    fill: none;
    pointer-events: none;
}

.mirza-live-core {
    stroke: #ffd700;
    stroke-width: 5.5;
    stroke-linecap: round;
    fill: none;
    pointer-events: none;
    opacity: 0.95;
}

.mirza-live-tip {
    fill: #fff6c8;
    stroke: #ffd700;
    stroke-width: 2;
    pointer-events: none;
}

@media (max-width: 430px) {
    .mirza-path-halo { stroke-width: 20; }
    .mirza-path-core { stroke-width: 8.5; }
    .mirza-path-shine { stroke-width: 2.6; }
    .mirza-live-halo { stroke-width: 18; }
    .mirza-live-core { stroke-width: 6.5; }
    .mirza-live-tip { stroke-width: 2.4; }
}

.tray-container.is-path-active {
    box-shadow:
        0 0 0 2px rgba(255, 215, 0, 0.2),
        0 0 40px rgba(255, 200, 60, 0.18),
        inset 0 0 30px rgba(255, 215, 0, 0.06);
}

body.mirza-selecting .letter-cell.dragging,
.tray-container.mirza-selecting .letter-cell.dragging {
    box-shadow:
        0 0 0 clamp(3px, 0.55vw, 5px) #ffd700,
        0 0 28px rgba(255, 215, 0, 0.55),
        0 clamp(3px, 0.6vw, 6px) 0 rgba(80, 50, 30, 0.5) !important;
    border-color: #ffe082 !important;
    filter: brightness(1.12);
    z-index: 20;
}

body.mirza-selecting .word-display-text,
.tray-container.mirza-selecting ~ .word-display .word-display-text,
.tray-container.mirza-selecting .word-display-text {
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
    color: #fff4d0;
}

/* Golden connection trail (legacy fallback) */
.mirza-connection-glow {
    stroke: rgba(255, 215, 0, 0.35);
    stroke-width: 14;
    stroke-linecap: round;
    pointer-events: none;
}

.mirza-connection-gold {
    stroke: url(#mirzaGoldGrad) #ffd700 !important;
    stroke: #ffd700;
    stroke-width: 7;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(255, 200, 40, 0.85));
}

.mirza-connection-animated {
    stroke-dasharray: 14 8;
    animation: mirzaGoldDash 0.55s linear infinite;
}

@keyframes mirzaGoldDash {
    to { stroke-dashoffset: -44; }
}

/* Success glow on word box */
.mirza-success-glow {
    animation: mirzaSuccessGlow 0.7s ease;
}

@keyframes mirzaSuccessGlow {
    0%   { box-shadow: 0 0 0 rgba(40, 167, 69, 0); }
    40%  {
        box-shadow: 0 0 28px rgba(40, 167, 69, 0.55), 0 0 8px rgba(255, 215, 0, 0.4);
        border-color: #28a745;
    }
    100% { box-shadow: 0 0 0 rgba(40, 167, 69, 0); }
}

/* Wrong red flash */
.mirza-red-flash {
    position: fixed;
    inset: 0;
    z-index: 10015;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(220, 50, 50, 0.22) 0%, transparent 65%);
    animation: mirzaRedFlash 0.3s ease-out forwards;
}

@keyframes mirzaRedFlash {
    0%   { opacity: 0; }
    30%  { opacity: 1; }
    100% { opacity: 0; }
}

/* Letter ghost fly */
.mirza-letter-ghost {
    border-radius: 50%;
    will-change: transform, opacity, left, top;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 30%, #5a3a2a, #2a1a12) !important;
    color: #ffe9a8 !important;
    font-weight: 800;
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.45);
    left: auto;
    top: auto;
}

.mirza-letter-ghost-fly {
    animation: mirzaGhostFly 0.45s ease-in forwards;
}

@keyframes mirzaGhostFly {
    to {
        opacity: 0;
        transform: translate(var(--gx, 0), var(--gy, -40px)) scale(0.35);
    }
}

/* Hint magic */
.mirza-hint-sparkle {
    animation: mirzaHintSparkle 0.55s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes mirzaHintSparkle {
    0%   { transform: scale(0.6); filter: brightness(1); }
    50%  { transform: scale(1.2); filter: brightness(1.4) drop-shadow(0 0 8px #ffd700); }
    100% { transform: scale(1); filter: brightness(1); }
}

.mirza-hint-highlight {
    animation: mirzaHintHighlight 0.85s ease;
}

@keyframes mirzaHintHighlight {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 215, 0, 0); }
    40% {
        box-shadow: 0 0 22px rgba(255, 215, 0, 0.55);
        border-color: rgba(255, 215, 0, 0.65);
    }
}

/* Stars */
.mirza-star-shine {
    text-shadow:
        0 0 12px rgba(255, 215, 0, 0.9),
        0 0 24px rgba(255, 180, 40, 0.55);
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.7));
}

/* Counter bump */
.mirza-counter-bump {
    animation: mirzaCounterBump 0.35s ease;
    display: inline-block;
}

@keyframes mirzaCounterBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.28); color: #ffd700; }
    100% { transform: scale(1); }
}

/* Level entrance */
.mirza-card-slide-in {
    animation: mirzaCardSlideIn 0.4s ease both;
}

@keyframes mirzaCardSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mirza-entrance-pop {
    animation: mirzaEntrancePop 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

@keyframes mirzaEntrancePop {
    0%   {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4) translateY(16px);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
}

/* Popup blur backdrop — level-end only (tutorial must stay sharp for the cutout) */
.level-end-overlay.mirza-popup-open {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(26, 14, 10, 0.55);
}

.tutorial-overlay.mirza-popup-open {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: transparent;
}

/* Buttons */
.mirza-btn-fx {
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    will-change: transform;
}

.mirza-btn-fx.is-pressed {
    transform: scale(0.94);
    filter: brightness(1.08);
}

.mirza-btn-fx:hover {
    box-shadow: 0 6px 20px rgba(255, 180, 40, 0.25);
}

.mirza-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    pointer-events: none;
    animation: mirzaRipple 0.5s ease-out forwards;
}

@keyframes mirzaRipple {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

/* Cards depth polish */
.card-mamosta {
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.word-box {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.word-box:not(.completed):hover {
    transform: translateY(-1px);
}

/* Canvas layer safety */
#mirzaFxCanvas {
    position: fixed !important;
    inset: 0 !important;
    pointer-events: none !important;
    z-index: 10030 !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mirza-letter-select,
    .mirza-success-glow,
    .mirza-hint-sparkle,
    .mirza-entrance-pop,
    .mirza-connection-animated,
    .mirza-ripple,
    .mirza-path-node,
    .mirza-live-tip,
    .mirza-live-core {
        animation: none !important;
    }

    .mirza-btn-fx {
        transition: none;
    }
}
