/* ==============================
   ランクアップ ポップアップ
   ----------------------------------------
   スコープ化方針:
     - すべて .rankup-modal 配下のセレクタにする
     - base CSS との干渉を避けるため、リセットも .rankup-modal 配下のみに限定
   ============================== */

.rankup-modal,
.rankup-modal *,
.rankup-modal *::before,
.rankup-modal *::after {
    box-sizing: border-box;
}

.rankup-modal button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/* ==============================
   モーダル本体 (デフォルト=非表示)
   ============================== */
.rankup-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;

    /* 非表示状態 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.rankup-modal.is-open {
    opacity: 1;
    visibility: visible;
}

/* 背景マスク */
.rankup-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

/* ==============================
   メインパネル
   ============================== */
.rankup-modal__panel {
    position: relative;
    width: 100%;
    max-width: 380px;
    padding: 36px 24px 32px;
    border-radius: 14px;
    text-align: center;
    color: #2a7fc9;

    /* デザインの水色グラデ背景(中央が明るい) */
    background:
        radial-gradient(ellipse at 50% 40%, #ffffff 0%, #e3f0fa 35%, #c2dcf2 100%);

    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;

    /* 表示時アニメーション */
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.18, 1.25, 0.5, 1.05),
                opacity 0.3s;
}

.rankup-modal.is-open .rankup-modal__panel {
    transform: scale(1);
    opacity: 1;
}

/* ==============================
   閉じるボタン
   ============================== */
.rankup-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    color: #888;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: color 0.2s, transform 0.2s;
    z-index: 2;
}

.rankup-modal__close:hover {
    color: #333;
    transform: scale(1.05);
}

/* ==============================
   タイトル
   ============================== */
.rankup-modal__title {
    position: relative;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    color: #2a7fc9;
    margin: 0 0 18px;
    letter-spacing: 0.02em;
    z-index: 1;
}

/* ==============================
   ランク名ラベル(ピル型)
   ============================== */
.rankup-modal__rank-label {
    position: relative;
    display: inline-block;
    padding: 6px 18px;
    background: #fff;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #2a7fc9;
    box-shadow: 0 2px 6px rgba(42, 127, 201, 0.15);
    margin: 0 0 22px;
    z-index: 1;
}

/* ==============================
   ランクバッジ画像
   ============================== */
.rankup-modal__badge {
    position: relative;
    display: flex;
    justify-content: center;
    z-index: 1;
}

.rankup-modal__badge img {
    width: 130px;
    height: auto;
    filter: drop-shadow(0 6px 12px rgba(180, 130, 30, 0.35));
    /* ふわっと登場アニメ */
    animation: rankup-badge-pop 0.8s cubic-bezier(0.18, 1.25, 0.5, 1.05) 0.15s both;
}

@keyframes rankup-badge-pop {
    0% {
        transform: scale(0.5) translateY(20px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ==============================
   モード切替
   ----------------------------------------
   data-rankup-mode の値に応じて、対応する
   .rankup-modal__body--xxx だけを表示する
   ============================== */
.rankup-modal__body {
    display: none;
    position: relative;
    z-index: 1;
}

.rankup-modal[data-rankup-mode="up"] .rankup-modal__body--up {
    display: block;
}

.rankup-modal[data-rankup-mode="reset"] .rankup-modal__body--reset {
    display: block;
}

/* ==============================
   ランクリセット モード
   ============================== */
.rankup-modal__body--reset .rankup-modal__title {
    margin-bottom: 20px;
}

/* メダル横並び一覧 */
.rankup-modal__ranks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.rankup-modal__ranks li {
    /* メダルを少し重ねて配置 */
    margin-left: -14px;
    /* 登場時のフェードイン+ふわっと */
    animation: rankup-rank-pop 0.6s cubic-bezier(0.18, 1.25, 0.5, 1.05) both;
}

.rankup-modal__ranks li:first-child {
    margin-left: 0;
}

/* 各メダルの登場タイミングをずらす + サイズ差をつける(中央が一番大きい) */
.rankup-modal__ranks li:nth-child(1) { animation-delay: 0.10s; z-index: 1; }
.rankup-modal__ranks li:nth-child(2) { animation-delay: 0.20s; z-index: 2; }
.rankup-modal__ranks li:nth-child(3) { animation-delay: 0.30s; z-index: 3; }
.rankup-modal__ranks li:nth-child(4) { animation-delay: 0.40s; z-index: 2; }
.rankup-modal__ranks li:nth-child(5) { animation-delay: 0.50s; z-index: 1; }

.rankup-modal__ranks img {
    display: block;
    filter: drop-shadow(0 4px 8px rgba(40, 60, 100, 0.25));
}

/* メダルのサイズ階層: 端は小さく、中央が最大 */
.rankup-modal__ranks li:nth-child(1) img,
.rankup-modal__ranks li:nth-child(5) img {
    width: 60px;
    height: 60px;
}

.rankup-modal__ranks li:nth-child(2) img,
.rankup-modal__ranks li:nth-child(4) img {
    width: 76px;
    height: 76px;
}

.rankup-modal__ranks li:nth-child(3) img {
    width: 84px;
    height: 84px;
}

@keyframes rankup-rank-pop {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==============================
   キラキラ装飾
   ============================== */
.rankup-modal__sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.rankup-modal__sparkle {
    position: absolute;
    background-image: url("../img/icon_sparkle.svg");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: rankup-sparkle 2.4s ease-in-out infinite;
}

/* 各スパークルの位置・サイズ・遅延を個別設定
   バッジ周辺(モーダル下半分)に集中して配置 */
.rankup-modal__sparkle--1 { top: 38%; left: 4%;   width: 30px; height: 30px; animation-delay: 0s;   }
.rankup-modal__sparkle--2 { top: 70%; left: 10%;  width: 22px; height: 22px; animation-delay: 0.6s; }
.rankup-modal__sparkle--3 { top: 88%; left: 28%;  width: 18px; height: 18px; animation-delay: 1.2s; }
.rankup-modal__sparkle--4 { top: 42%; right: 6%;  width: 28px; height: 28px; animation-delay: 0.3s; }
.rankup-modal__sparkle--5 { top: 72%; right: 10%; width: 26px; height: 26px; animation-delay: 0.9s; }
.rankup-modal__sparkle--6 { top: 90%; right: 32%; width: 16px; height: 16px; animation-delay: 1.5s; }
.rankup-modal__sparkle--7 { top: 55%; left: 14%;  width: 14px; height: 14px; animation-delay: 1.8s; }

@keyframes rankup-sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0.4);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==============================
   モバイル調整
   ============================== */
@media (max-width: 480px) {
    .rankup-modal__panel {
        padding: 32px 20px 28px;
        max-width: 320px;
    }

    .rankup-modal__title {
        font-size: 18px;
    }

    .rankup-modal__badge img {
        width: 110px;
    }

    /* リセットモードのメダルも縮小 */
    .rankup-modal__ranks li:nth-child(1) img,
    .rankup-modal__ranks li:nth-child(5) img {
        width: 42px;
        height: 42px;
    }
    .rankup-modal__ranks li:nth-child(2) img,
    .rankup-modal__ranks li:nth-child(4) img {
        width: 52px;
        height: 52px;
    }
    .rankup-modal__ranks li:nth-child(3) img {
        width: 60px;
        height: 60px;
    }

    .rankup-modal__ranks li {
        margin-left: -8px;
    }
}

/* ==============================
   テスト用ボタン (本番では不要)
   ============================== */
.rankup-test-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #2e87d8;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}

.rankup-test-btn:hover {
    background: #1a6cd1;
}
