/* ============================================================
   RPGガチャ風コイン交換アニメーション
   ============================================================ */

/* --- Overlay --- */
.gacha-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: linear-gradient(135deg, rgba(30, 0, 50, 0.95) 0%, rgba(10, 0, 30, 0.98) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: gachaFadeIn 0.5s ease-out forwards;
    overflow: hidden;
}

@keyframes gachaFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Skip / Close button --- */
.gacha-skip {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20010;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gacha-skip:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* --- Stage container --- */
.gacha-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

/* --- Phase 2: Coin countdown --- */
.gacha-coin-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: opacity 0.3s;
}

.gacha-coin-area.gacha-coin-fadeout {
    opacity: 0;
}

.gacha-coin-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.gacha-coin-spin {
    animation: gachaCoinSpin 0.6s ease-in-out 2;
}

@keyframes gachaCoinSpin {
    0%   { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.gacha-coin-cost {
    font-size: 2.4em;
    font-weight: 900;
    color: #ff6b6b;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
    min-height: 1.2em;
    opacity: 0;
}

.gacha-coin-cost.gacha-cost-animate {
    animation: gachaCostPop 0.5s ease-out forwards;
}

@keyframes gachaCostPop {
    0%   { opacity: 0; transform: scale(0.3) translateY(20px); }
    60%  { opacity: 1; transform: scale(1.2) translateY(-5px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.gacha-coin-balance {
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.8);
    opacity: 0;
    transition: opacity 0.3s;
    font-variant-numeric: tabular-nums;
}

/* --- Phase 3: Material reveal --- */
.gacha-reveal {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gacha-reveal-animate {
    animation: gachaRevealGlow 1s ease-out forwards;
}

@keyframes gachaRevealGlow {
    0% {
        opacity: 0;
        transform: scale(0.2);
        filter: brightness(3) drop-shadow(0 0 40px #FFD700);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
        filter: brightness(1.5) drop-shadow(0 0 30px #FFD700);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 15px rgba(255, 215, 0, 0.5));
    }
}

.gacha-reveal-img {
    max-width: 300px;
    max-height: 240px;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    object-fit: contain;
}

.gacha-reveal-sound {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    box-shadow: 0 0 40px rgba(102, 126, 234, 0.5);
}

/* --- Phase 4: GET! text --- */
.gacha-get-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4em;
    font-weight: 900;
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 50%, #FF8C00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    pointer-events: none;
    z-index: 5;
}

.gacha-get-bounce {
    animation: gachaGetBounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes gachaGetBounce {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.1); }
    50%  { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    70%  { transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* --- Phase 5: Confetti canvas --- */
.gacha-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

/* --- Phase 6: Result panel --- */
.gacha-result {
    position: relative;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 32px 28px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.gacha-result-slidein {
    animation: gachaResultSlide 0.5s ease-out forwards;
}

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

.gacha-result-name {
    font-size: 1.3em;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
}

.gacha-result-dl {
    display: block;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 14px;
}

.gacha-result-dl:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}


/* ============================================================
   Responsive (480px以下)
   ============================================================ */
@media (max-width: 480px) {
    .gacha-skip {
        top: 12px;
        right: 12px;
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    .gacha-coin-img {
        width: 60px;
        height: 60px;
    }

    .gacha-coin-cost {
        font-size: 1.8em;
    }

    .gacha-coin-balance {
        font-size: 1em;
    }

    .gacha-reveal-img {
        max-width: 220px;
        max-height: 180px;
    }

    .gacha-reveal-sound {
        width: 120px;
        height: 120px;
        font-size: 48px;
    }

    .gacha-get-text {
        font-size: 2.8em;
    }

    .gacha-result {
        padding: 24px 20px;
        border-radius: 12px;
    }

    .gacha-result-name {
        font-size: 1.1em;
    }

    .gacha-result-dl {
        padding: 12px 20px;
        font-size: 1em;
    }
}
