/* ==========================================
   ガチャプラグイン v4
   伝説・超激レア・激レア・レア
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700;900&family=Noto+Sans+JP:wght@400;700;900&display=swap');

:root {
    --bg:       #080812;
    --panel:    #0e0e20;
    --border:   #1e1e3a;
    --accent:   #7c6fff;
    --text-dim: #555;
    --text-mid: #999;

    /* レインボー */
    --legend-a: #ff3cac;
    --legend-b: #2b86c5;
    --legend-c: #784ba0;

    /* 金 */
    --super-a:  #ffd200;
    --super-b:  #e67c00;
    --super-c:  #7a3d00;

    /* 銀 */
    --rare-a:   #f0f4f8;
    --rare-b:   #8fa8bc;
    --rare-c:   #3c5060;

    /* 銅 */
    --normal-a: #d48a3a;
    --normal-b: #8b4a14;
    --normal-c: #3d1800;
}

/* ==========================================
   全体ラッパー
   ========================================== */
.gacha-wrap {
    max-width: 540px;
    margin: 36px auto;
    background: var(--bg);
    border-radius: 28px;
    border: 1px solid var(--border);
    padding: 36px 28px 40px;
    font-family: 'Noto Sans JP', sans-serif;
    box-shadow:
        0 0 0 1px rgba(124,111,255,0.12),
        0 24px 80px rgba(0,0,0,0.9),
        inset 0 1px 0 rgba(255,255,255,0.04);
    position: relative;
    overflow: hidden;
    color: #fff;
}

.gacha-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(124,111,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(124,111,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

/* ==========================================
   タイトル
   ========================================== */
.gacha-header {
    text-align: center;
    margin-bottom: 20px;
}

.gacha-title-text {
    font-family: 'Orbitron', monospace;
    font-size: 3em;
    font-weight: 900;
    letter-spacing: 0.25em;
    background: linear-gradient(135deg, #a78bfa 0%, #60a5fa 50%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 6px;
}

.gacha-subtitle {
    color: var(--text-dim);
    font-size: 0.8em;
    letter-spacing: 0.15em;
}

/* ==========================================
   確率バッジ
   ========================================== */
.gacha-odds {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.odds-item {
    font-size: 0.76em;
    font-weight: 700;
    padding: 4px 11px;
    border-radius: 20px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    letter-spacing: 0.04em;
}

.legend-text { color: #ff79c6; }
.super-text  { color: #fbbf24; }
.rare-text   { color: #94a3b8; }
.normal-text { color: #b87333; }

/* ==========================================
   抽選エリア
   ========================================== */
.gacha-drawing-area {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 28px;
}

/* ==========================================
   待機状態の浮遊する球
   ========================================== */
.gacha-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.idle-balls {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
}

.idle-ball {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    animation: idle-float 2.8s ease-in-out infinite;
    position: relative;
}
/* 待機球の光沢 */
.idle-ball::before {
    content: '';
    position: absolute;
    top: 10%; left: 18%;
    width: 38%; height: 28%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.65) 0%, transparent 70%);
    border-radius: 50%;
}

.idle-ball:nth-child(1) { animation-delay: 0s; }
.idle-ball:nth-child(2) { animation-delay: 0.4s; }
.idle-ball:nth-child(3) { animation-delay: 0.8s; }
.idle-ball:nth-child(4) { animation-delay: 1.2s; }
.idle-ball:nth-child(5) { animation-delay: 1.6s; }

@keyframes idle-float {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

/* 待機球の色（クラス名） */
.b-legend { background: conic-gradient(from 0deg, #ff3cac, #ffd200, #2b86c5, #ff3cac);
            box-shadow: 0 0 14px rgba(255,60,172,0.7); animation: idle-float 2.8s ease-in-out infinite, rainbow-hue 2.5s linear infinite; }
.b-super  { background: radial-gradient(circle at 35% 30%, #fff0aa 0%, var(--super-a) 45%, var(--super-c) 100%);
            box-shadow: 0 0 14px rgba(255,210,0,0.7); }
.b-rare   { background: radial-gradient(circle at 35% 30%, #ffffff 0%, var(--rare-b) 45%, var(--rare-c) 100%);
            box-shadow: 0 0 12px rgba(200,220,240,0.5); }
.b-normal { background: radial-gradient(circle at 35% 30%, #ffcc99 0%, var(--normal-a) 45%, var(--normal-c) 100%);
            box-shadow: 0 0 10px rgba(180,100,30,0.5); }

.idle-text {
    color: var(--text-dim);
    font-size: 0.88em;
    letter-spacing: 0.1em;
}

/* ==========================================
   抽選中ドラム
   ========================================== */
.gacha-spinning {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.drum-wrap {
    width: 100%;
    position: relative;
    height: 110px;
}

.drum-window {
    width: 100%;
    height: 110px;
    overflow: hidden;
    border-radius: 16px;
    background: #03030a;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.9);
    position: relative;
}

.drum-track {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 20px;
    padding: 0 30px;
    will-change: transform;
}

.drum-fade-left,
.drum-fade-right {
    position: absolute;
    top: 0; bottom: 0;
    width: 80px;
    z-index: 3;
    pointer-events: none;
}
.drum-fade-left  { left: 0;  background: linear-gradient(to right, #03030a, transparent); border-radius: 16px 0 0 16px; }
.drum-fade-right { right: 0; background: linear-gradient(to left,  #03030a, transparent); border-radius: 0 16px 16px 0; }

.drum-selector {
    position: absolute;
    top: 10px; bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 94px;
    border: 2px solid rgba(124,111,255,0.6);
    border-radius: 10px;
    z-index: 4;
    box-shadow: 0 0 12px rgba(124,111,255,0.4), inset 0 0 12px rgba(124,111,255,0.08);
    pointer-events: none;
}

.drawing-label {
    color: var(--accent);
    font-size: 0.9em;
    font-weight: 700;
    letter-spacing: 0.15em;
    animation: label-blink 1s ease-in-out infinite;
}

@keyframes label-blink {
    0%,100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* ==========================================
   球体 共通
   ========================================== */
.gacha-ball {
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    display: block;
}

/* 光沢ハイライト */
.gacha-ball::before {
    content: '';
    position: absolute;
    top: 10%; left: 18%;
    width: 38%; height: 28%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.72) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

/* 底面の陰影 */
.gacha-ball::after {
    content: '';
    position: absolute;
    bottom: 8%; left: 12%;
    width: 76%; height: 22%;
    background: radial-gradient(ellipse, rgba(0,0,0,0.45) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

/* ドラム内の球 */
.drum-track .gacha-ball {
    width: 72px;
    height: 72px;
}

/* 結果グリッドの球 */
.result-balls .gacha-ball {
    width: 68px;
    height: 68px;
    animation: ball-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes ball-pop {
    0%   { opacity: 0; transform: scale(0) rotate(-90deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* 1回ガチャ用大球 */
.ball-single-wrap .gacha-ball {
    width: 120px;
    height: 120px;
    animation: ball-grand 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ball-grand {
    0%   { opacity: 0; transform: scale(0.2) rotate(-270deg); }
    70%  { transform: scale(1.12) rotate(5deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ==========================================
   レアリティ別 球の色
   ========================================== */

/* レインボー - 七色に回転 */
.gacha-ball.legend {
    background:
        radial-gradient(circle at 32% 28%, rgba(255,255,255,0.2) 0%, transparent 45%),
        conic-gradient(from 0deg at 50% 50%,
            #ff3cac 0deg, #ff6b3d 60deg, #ffd200 120deg,
            #39d353 180deg, #2b86c5 240deg, #784ba0 300deg, #ff3cac 360deg);
    box-shadow:
        0 0 20px rgba(255,60,172,0.8),
        0 0 40px rgba(43,134,197,0.5),
        0 0 60px rgba(255,210,0,0.3);
    animation: rainbow-hue 2.5s linear infinite;
}

@keyframes rainbow-hue {
    from { filter: hue-rotate(0deg) brightness(1.05); }
    to   { filter: hue-rotate(360deg) brightness(1.05); }
}

/* 金 */
.gacha-ball.super {
    background:
        radial-gradient(circle at 32% 28%, rgba(255,255,200,0.28) 0%, transparent 48%),
        radial-gradient(circle at 65% 65%, rgba(80,30,0,0.5) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, #fff0aa 0%, var(--super-a) 40%, var(--super-b) 70%, var(--super-c) 100%);
    box-shadow:
        0 0 18px rgba(255,210,0,0.9),
        0 0 36px rgba(230,124,0,0.5),
        inset 0 -6px 14px rgba(80,30,0,0.5);
}

/* 銀 */
.gacha-ball.rare {
    background:
        radial-gradient(circle at 32% 28%, rgba(255,255,255,0.5) 0%, transparent 48%),
        radial-gradient(circle at 65% 65%, rgba(40,60,80,0.4) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, var(--rare-a) 0%, var(--rare-b) 45%, var(--rare-c) 100%);
    box-shadow:
        0 0 12px rgba(200,220,240,0.5),
        0 0 24px rgba(140,170,200,0.3),
        inset 0 -6px 14px rgba(20,40,60,0.4);
}

/* 銅 */
.gacha-ball.normal {
    background:
        radial-gradient(circle at 32% 28%, rgba(255,200,150,0.28) 0%, transparent 48%),
        radial-gradient(circle at 65% 65%, rgba(30,10,0,0.5) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, #ffc080 0%, var(--normal-a) 40%, var(--normal-b) 70%, var(--normal-c) 100%);
    box-shadow:
        0 0 10px rgba(180,100,30,0.6),
        0 0 20px rgba(100,50,0,0.3),
        inset 0 -6px 14px rgba(20,5,0,0.5);
}

/* ==========================================
   ボタン
   ========================================== */
.gacha-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.gacha-btn {
    padding: 16px 36px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: 1em;
    letter-spacing: 0.08em;
    color: #fff;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    min-width: 148px;
}

.gacha-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
    border-radius: 50px 50px 0 0;
    pointer-events: none;
}

.gacha-btn:hover   { transform: translateY(-4px) scale(1.04); }
.gacha-btn:active  { transform: translateY(1px) scale(0.97); }
.gacha-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

.btn-single {
    background: linear-gradient(160deg, #5b4fff, #9333ea);
    box-shadow: 0 6px 24px rgba(91,79,255,0.55), 0 2px 4px rgba(0,0,0,0.4);
}

.btn-ten {
    background: linear-gradient(160deg, #e11d48, #f97316);
    box-shadow: 0 6px 24px rgba(225,29,72,0.55), 0 2px 4px rgba(0,0,0,0.4);
}

/* ==========================================
   結果エリア
   ========================================== */
.gacha-result-area {
    animation: fade-up 0.5s ease;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-label {
    text-align: center;
    font-size: 1.1em;
    font-weight: 900;
    color: #fbbf24;
    letter-spacing: 0.08em;
    margin-bottom: 18px;
}

.result-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

/* 1回ガチャ 大きい球 */
.ball-single-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.single-rarity-name {
    font-size: 1.3em;
    font-weight: 900;
    letter-spacing: 0.08em;
}
.single-rarity-name.legend { color: #ff79c6; }
.single-rarity-name.super  { color: #fbbf24; }
.single-rarity-name.rare   { color: #94a3b8; }
.single-rarity-name.normal { color: #b87333; }

/* ==========================================
   集計サマリー
   ========================================== */
.result-summary {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
}

.summary-title {
    font-size: 0.8em;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.12em;
    margin-bottom: 10px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.9em;
}
.summary-row:last-child { border-bottom: none; }

.summary-ball-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.summary-count {
    font-weight: 900;
    color: #fbbf24;
}

/* ==========================================
   スマホ対応
   ========================================== */
@media (max-width: 480px) {
    .gacha-wrap { padding: 24px 14px 30px; }
    .gacha-title-text { font-size: 2.2em; }
    .gacha-buttons { flex-direction: column; align-items: center; }
    .gacha-btn { width: 88%; }
    .result-balls .gacha-ball { width: 54px; height: 54px; }
    .ball-single-wrap .gacha-ball { width: 96px; height: 96px; }
    .drum-track .gacha-ball { width: 58px; height: 58px; }
}


/* ==========================================
   累計統計パネル
   ========================================== */
.gacha-stats {
    margin-top: 24px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    animation: fade-up 0.4s ease;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.stats-title {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--text-mid);
    letter-spacing: 0.12em;
}

/* リセットボタン */
.stats-reset-btn {
    padding: 5px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    color: #888;
    font-size: 0.78em;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.2s;
}
.stats-reset-btn:hover {
    background: rgba(255,80,80,0.15);
    border-color: rgba(255,80,80,0.4);
    color: #ff8080;
}

/* 合計行 */
.stats-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 10px;
}

.stats-total-label {
    font-size: 0.88em;
    color: var(--text-mid);
    letter-spacing: 0.08em;
}

.stats-total-count {
    font-size: 1.3em;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.04em;
}

/* 各レアリティ行 */
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.88em;
}
.stats-row:last-child { border-bottom: none; }

.stats-row-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
}

/* 色ドット */
.stats-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 略称バッジ */
.stats-abbr {
    font-family: 'Orbitron', monospace;
    font-size: 0.78em;
    font-weight: 700;
    color: #aaa;
    min-width: 32px;
}

.stats-row-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-row-count {
    font-weight: 900;
    color: #fff;
    min-width: 52px;
    text-align: right;
}

.stats-row-pct {
    font-size: 0.85em;
    color: #888;
    min-width: 64px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ==========================================
   確率セット タブメニュー
   ========================================== */
.gacha-preset-menu {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.preset-tab {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255,255,255,0.04);
    color: #666;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.82em;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.2s;
    white-space: nowrap;
}

.preset-tab:hover {
    background: rgba(124,111,255,0.12);
    border-color: rgba(124,111,255,0.4);
    color: #aaa;
}

.preset-tab.active {
    background: linear-gradient(135deg, rgba(124,111,255,0.25), rgba(96,165,250,0.2));
    border-color: rgba(124,111,255,0.7);
    color: #fff;
    box-shadow: 0 0 12px rgba(124,111,255,0.3);
}

/* ==========================================
   球内の頭文字テキスト
   ========================================== */
.ball-abbr {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1;
    z-index: 2;
    pointer-events: none;
}

/* 結果グリッドの球（68px） */
.result-balls .gacha-ball .ball-abbr {
    font-size: 0.82em;
    color: rgba(255,255,255,0.92);
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

/* 1回ガチャ大球（120px） */
.ball-single-wrap .gacha-ball .ball-abbr {
    font-size: 1.4em;
    color: rgba(255,255,255,0.95);
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

/* 金球は文字色を暗く */
.gacha-ball.super .ball-abbr  { color: rgba(60,30,0,0.85) !important; text-shadow: 0 1px 3px rgba(255,220,100,0.5) !important; }
/* 銀球はやや暗く */
.gacha-ball.rare .ball-abbr   { color: rgba(20,40,60,0.85) !important; text-shadow: 0 1px 3px rgba(200,220,240,0.4) !important; }
