/* ============================================
   GACHA APP — Mobile-first Pink Theme
   ============================================ */

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

:root {
    --pink:        #e8174a;
    --pink-mid:    #f03060;
    --pink-bg:     #f5306a;
    --pink-light:  #ff80b4;
    --pink-pale:   #fce4ec;
    --pink-card:   #ffd6e7;
    --gray-card:   #e8eaf0;
    --white:       #ffffff;
    --text-dark:   #222222;
    --text-mid:    #555555;
    --text-lo:     #999999;
    --gold:        #ffd700;
    --radius-sm:   8px;
    --radius-md:   14px;
    --radius-lg:   24px;
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-out:    cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    height: 100dvh;
}

body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    background: #f0f0f0;
    color: var(--text-dark);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    /* #appを確実に中央寄せ */
    display: flex;
    justify-content: center;
}

/* ============ PARTICLES BG ============ */
#particles-bg { display: none; }

/* ============ SCREEN FLASH ============ */
#screen-flash {
    position: fixed; inset: 0;
    background: white; opacity: 0;
    pointer-events: none; z-index: 9999;
    transition: opacity 0.05s;
}
#screen-flash.flash { animation: flashAnim 0.5s ease-out forwards; }
@keyframes flashAnim { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* ============ APP LAYOUT ============ */
#app {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100%;
    max-width: 480px;
    background: var(--white);
    overflow: hidden;
    z-index: 1;
    flex-shrink: 0;
}

/* ============ HEADER ============ */
header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    background: var(--pink);
    z-index: 10;
}

.header-title { text-align: center; }

.header-title h1 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--white);
    -webkit-text-fill-color: var(--white);
    background: none;
    animation: none;
}

.header-sub { display: none; }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.35); }

/* ============ PRIZE TICKER ============ */
.prize-ticker-wrap {
    flex-shrink: 0;
    overflow: hidden;
    padding: 6px 0;
    background: var(--gray-card);
    border-bottom: 1px solid #ddd;
}

.prize-ticker {
    display: flex;
    gap: 20px;
    animation: ticker 30s linear infinite;
    white-space: nowrap;
    will-change: transform;
}

.prize-ticker .tick-item {
    font-size: 0.75rem;
    color: var(--text-mid);
    padding: 0 8px;
    flex-shrink: 0;
}
.prize-ticker .tick-item.ssr { color: #c8860b; font-weight: 700; }
.prize-ticker .tick-item.sr  { color: #9b30ff; font-weight: 700; }
.prize-ticker .tick-item.r   { color: #1565c0; }

@keyframes ticker {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============ MAIN SCROLL AREA ============ */
main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 0 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(232,23,74,0.3) transparent;
    -webkit-overflow-scrolling: touch;
}
main::-webkit-scrollbar { width: 3px; }
main::-webkit-scrollbar-thumb { background: rgba(232,23,74,0.3); border-radius: 2px; }

/* ============ GACHA MACHINE CONTAINER ============ */
#gacha-machine-container {
    width: 100%;
    background: var(--pink-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 0 20px;
    position: relative;
    flex-shrink: 0;
}

.machine-shadow { display: none; }

#gacha-machine {
    position: relative;
    width: min(240px, 65vw);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Arm --- */
.machine-arm-wrap {
    position: absolute;
    right: -14px;
    top: 55px;
    z-index: 5;
}

.machine-arm {
    width: 16px;
    height: 72px;
    background: linear-gradient(to right, #ccc, #fff, #ccc);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    cursor: pointer;
    transform-origin: center 72px;
    transition: transform 0.12s ease;
}
.machine-arm:active { transform: rotate(30deg); }

.arm-knob {
    width: 26px; height: 26px;
    background: radial-gradient(circle at 35% 35%, #ff80b4, var(--pink));
    border-radius: 50%;
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(232,23,74,0.5);
}

/* --- Globe (lottery drum style) --- */
.globe-outer {
    width: min(210px, 60vw);
    height: min(210px, 60vw);
    border-radius: 50%;
    position: relative;
    background: rgba(255,255,255,0.15);
    border: 6px solid rgba(255,255,255,0.9);
    box-shadow:
        inset 0 0 30px rgba(255,255,255,0.2),
        0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
    z-index: 2;
}

.globe-ring-h {
    position: absolute;
    background: rgba(255,255,255,0.7);
    top: 50%; left: 0; right: 0;
    height: 4px;
    transform: translateY(-50%);
}
.globe-ring-v {
    position: absolute;
    background: rgba(255,255,255,0.7);
    height: auto; width: 4px;
    top: 0; bottom: 0; left: 50%;
    transform: translateX(-50%);
}

.globe-inner {
    width: 100%; height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    background: var(--pink-bg);
}

.globe-shine {
    position: absolute;
    top: 8%; left: 10%;
    width: 32%; height: 32%;
    background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.globe-center-dot {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 24px; height: 24px;
    background: radial-gradient(circle at 40% 40%, #fff, #ddd);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 4;
}

/* --- Capsules (balls) --- */
#capsules-container {
    width: 100%; height: 100%;
    position: relative;
}

.capsule {
    width: 34px; height: 34px;
    border-radius: 50%;
    position: absolute;
    box-shadow: inset -3px -3px 6px rgba(0,0,0,0.25), 2px 2px 5px rgba(0,0,0,0.2);
}

.capsule-red    { background: radial-gradient(circle at 35% 35%, #ff8080, #cc0010); }
.capsule-blue   { background: radial-gradient(circle at 35% 35%, #80cfff, #1565c0); }
.capsule-green  { background: radial-gradient(circle at 35% 35%, #aff08a, #2e7d32); }
.capsule-yellow { background: radial-gradient(circle at 35% 35%, #fff176, #f57f17); }
.capsule-purple { background: radial-gradient(circle at 35% 35%, #e040fb, #6a1b9a); }
.capsule-gold   { background: radial-gradient(circle at 35% 35%, #fff8e1, #f9a825); box-shadow: 0 0 8px rgba(255,200,0,0.6), inset -3px -3px 6px rgba(0,0,0,0.2); }

/* --- Stand --- */
.machine-neck {
    width: 50px; height: 24px;
    background: rgba(255,255,255,0.5);
    border-left: 3px solid rgba(255,255,255,0.8);
    border-right: 3px solid rgba(255,255,255,0.8);
}

.machine-body {
    width: 160px; height: 70px;
    background: rgba(255,255,255,0.25);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 8px;
}

.body-panel {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.4);
}

.body-coin-slot {
    width: 26px; height: 5px;
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.body-exit {
    width: 36px; height: 36px;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 3px;
}

.exit-door {
    width: 26px; height: 14px;
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.machine-feet {
    display: flex;
    gap: 70px;
    margin-top: -3px;
}

.foot {
    width: 32px; height: 8px;
    background: rgba(255,255,255,0.4);
    border-radius: 0 0 6px 6px;
    border: 1px solid rgba(255,255,255,0.6);
    border-top: none;
}

/* ============ MACHINE ANIMATIONS ============ */
@keyframes machineShake {
    0%, 100% { transform: translate(0,0) rotate(0deg); }
    10%  { transform: translate(-3px,-2px) rotate(-0.5deg); }
    20%  { transform: translate(3px,0) rotate(0.5deg); }
    30%  { transform: translate(-3px,2px) rotate(-0.3deg); }
    40%  { transform: translate(3px,2px) rotate(0.5deg); }
    50%  { transform: translate(-2px,-2px) rotate(-0.5deg); }
    60%  { transform: translate(3px,0) rotate(0.3deg); }
    70%  { transform: translate(-3px,3px) rotate(-0.5deg); }
    80%  { transform: translate(3px,-3px) rotate(0.5deg); }
    90%  { transform: translate(-3px,2px) rotate(0deg); }
}
.shaking { animation: machineShake 0.12s infinite; }

@keyframes capsuleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33%  { transform: translateY(calc(-1 * var(--float-dist, 6px))) rotate(5deg); }
    66%  { transform: translateY(calc(0.5 * var(--float-dist, 6px))) rotate(-3deg); }
}

@keyframes globePulse {
    0%, 100% { box-shadow: inset 0 0 30px rgba(255,255,255,0.2), 0 4px 20px rgba(0,0,0,0.2); }
    50%  { box-shadow: inset 0 0 50px rgba(255,255,255,0.4), 0 4px 30px rgba(0,0,0,0.3); }
}
.globe-outer.globe-pulse { animation: globePulse 0.25s ease-in-out infinite; }

/* ============ PRIZE GRID ============ */
#prize-grid-section {
    width: 100%;
    padding: 12px 12px 0;
    background: var(--white);
    flex-shrink: 0;
}

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

.section-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-mid);
    letter-spacing: 1px;
}

.section-count {
    font-size: 0.72rem;
    background: #f0f0f0;
    padding: 2px 10px;
    border-radius: 20px;
    color: var(--text-lo);
}

.prize-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.prize-card {
    border-radius: 10px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.68rem;
    padding: 5px 3px;
    background: var(--gray-card);
    border: 1px solid #ddd;
    transition: all 0.3s var(--ease-spring);
    position: relative;
    overflow: hidden;
}

.prize-card.empty {
    color: var(--text-lo);
    font-size: 1.1rem;
    background: #f0f2f8;
}

.prize-card.won {
    background: var(--pink-card);
    border-color: #f8a0c0;
    animation: cardReveal 0.4s var(--ease-spring);
}

@keyframes cardReveal {
    0%  { transform: scale(0.7) rotate(-5deg); opacity: 0; }
    100%{ transform: scale(1) rotate(0deg); opacity: 1; }
}

.prize-card .grid-rarity {
    font-weight: 900;
    font-size: 0.62rem;
    letter-spacing: 0.5px;
    color: var(--text-dark);
}

.prize-card .grid-name {
    font-size: 0.58rem;
    color: var(--text-mid);
    text-align: center;
    line-height: 1.2;
}

/* Rarity Colors for Grid */
.prize-card.rarity-ssr {
    background: linear-gradient(135deg, #fff8e1, #ffe082);
    border-color: #f9a825;
}
.prize-card.rarity-ssr .grid-rarity { color: #b8860b; }

.prize-card.rarity-sr {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
    border-color: #ab47bc;
}
.prize-card.rarity-sr .grid-rarity { color: #7b1fa2; }

.prize-card.rarity-r {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-color: #42a5f5;
}
.prize-card.rarity-r .grid-rarity { color: #1565c0; }

.prize-card.rarity-n .grid-rarity { color: var(--text-mid); }

.prize-card.glow::after {
    content: '';
    position: absolute; inset: 0;
    background: inherit;
    filter: blur(6px);
    opacity: 0.3;
    z-index: -1;
}

/* ============ FOOTER ============ */
footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px max(20px, env(safe-area-inset-bottom));
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    width: 100%;
}

.ctrl-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.2s var(--ease-out);
}

.ctrl-secondary {
    flex: 0 0 68px;
    height: 68px;
    background: #e8e8e8;
    border: 1px solid #ccc;
    color: var(--text-mid);
    border-radius: 50%;
}
.ctrl-secondary:hover { background: #ddd; color: var(--text-dark); }
.ctrl-secondary:active { transform: scale(0.93); }

.ctrl-primary {
    flex: 1;
    height: 68px;
    background: var(--pink);
    color: white;
    font-size: 1rem;
    letter-spacing: 4px;
    font-weight: 900;
    border-radius: 34px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(232,23,74,0.4);
    animation: none;
}
.ctrl-primary:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(232,23,74,0.3); }

.ctrl-primary .draw-icon {
    font-size: 1.2rem;
    display: block;
    line-height: 1;
}

.btn-glow { display: none; }

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

/* ============ MODAL OVERLAY ============ */
#modal-overlay {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: grid;
    place-items: center;
    z-index: 200;
    transition: opacity 0.25s ease;
    padding: 20px;
    box-sizing: border-box;
}
#modal-overlay.m-hidden { opacity: 0; pointer-events: none; }

/* ============ MODAL BASE ============ */
.modal {
    background: var(--white);
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-lg);
    width: min(96%, 440px);
    max-height: 90dvh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    transform: translateY(30px) scale(0.95);
    transition: all 0.35s var(--ease-spring);
    position: relative;
    display: flex;
    flex-direction: column;
    grid-area: 1 / 1;
}
#modal-overlay:not(.m-hidden) .modal:not(.m-hidden) { transform: translateY(0) scale(1); }
.modal.m-hidden { opacity: 0; pointer-events: none; transform: translateY(40px) scale(0.9); }

.modal-header {
    padding: 14px 18px;
    background: var(--pink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.modal-header h2 {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: white;
    white-space: nowrap;
}

.close-modal {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.25);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.close-modal:hover { background: rgba(255,255,255,0.4); }

.modal-hint {
    font-size: 0.76rem;
    color: var(--text-lo);
    margin-bottom: 14px;
    line-height: 1.6;
}

.modal-body {
    padding: 16px 18px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(232,23,74,0.3) transparent;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: stretch;
    flex-shrink: 0;
}

/* ============ PRIZE EDIT ROWS ============ */
.prize-edit-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
    background: #f8f8f8;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #eee;
}

.prize-edit-row input {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: var(--text-dark);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 8px 10px;
    transition: border-color 0.2s;
    min-width: 0;
}
.prize-edit-row input:focus { outline: none; border-color: var(--pink); }
.prize-edit-row .edit-name   { grid-column: 1 / -1; }
.prize-edit-row .edit-rarity { width: 60px; }
.prize-edit-row .edit-weight { width: 60px; }

.remove-btn {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #ffe0e0;
    border: 1px solid #ffb0b0;
    color: #cc0000;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.remove-btn:hover { background: #ffb0b0; }

.add-btn {
    width: 100%;
    padding: 10px;
    background: #f8f8f8;
    border: 2px dashed #ddd;
    color: var(--text-lo);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 8px;
    transition: all 0.2s;
}
.add-btn:hover { border-color: var(--pink); color: var(--pink); }

.save-btn {
    background: var(--pink);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 12px rgba(232,23,74,0.3);
    width: 100%;
}
.save-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(232,23,74,0.4); }

/* ============ RESULT MODAL ============ */
.result-modal {
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 36px 28px 32px;
    gap: 0;
    overflow: visible;
    position: relative;
}

.result-stars {
    position: absolute; inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.star-particle {
    position: absolute;
    width: 6px; height: 6px;
    border-radius: 50%;
    animation: starFloat 1.5s ease-out forwards;
}
@keyframes starFloat {
    0%   { transform: translate(0,0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.capsule-anim-wrap {
    position: relative;
    height: 80px; width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.capsule-pop {
    width: 70px; height: 70px;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 24px rgba(232,23,74,0.4);
    animation: popBounce 0.5s var(--ease-spring) forwards;
    overflow: hidden;
}
.capsule-pop .capsule-top { position: absolute; top: 0; left: 0; right: 0; height: 50%; border-radius: 100px 100px 0 0; }
.capsule-pop .capsule-bottom { position: absolute; bottom: 0; left: 0; right: 0; height: 50%; border-radius: 0 0 100px 100px; }
.capsule-pop .capsule-shine { position: absolute; top: 12%; left: 18%; width: 30%; height: 25%; background: rgba(255,255,255,0.5); border-radius: 50%; filter: blur(4px); }

@keyframes popBounce {
    0%  { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100%{ transform: scale(1) rotate(0deg); }
}

.prize-reveal {
    text-align: center;
    margin-top: 20px;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.6s var(--ease-spring) 0.3s;
}
#result-modal.show-reveal .prize-reveal { opacity: 1; transform: translateY(0) scale(1); }

.rarity-badge {
    display: inline-block;
    padding: 5px 18px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.badge-ssr { background: linear-gradient(90deg, #ffd700, #f57f17, #ffd700); background-size: 300%; animation: rainbowBadge 2s linear infinite; color: #000; box-shadow: 0 0 16px rgba(255,200,0,0.5); }
.badge-sr  { background: linear-gradient(135deg, #e879f9, #9b30ff); color: white; box-shadow: 0 0 12px rgba(232,121,249,0.5); }
.badge-r   { background: linear-gradient(135deg, #60a5fa, #2563eb); color: white; }
.badge-n   { background: #f0f0f0; border: 1px solid #ddd; color: var(--text-mid); }

@keyframes rainbowBadge { 0% { background-position: 0%; } 100% { background-position: 300%; } }

.result-name {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text-dark);
    margin-bottom: 8px;
    text-align: center;
    line-height: 1.5;
    word-break: break-all;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.result-sparkles { position: relative; height: 14px; }

.confirm-btn {
    margin-top: 22px;
    background: var(--pink);
    border: none;
    color: white;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 12px 48px;
    border-radius: 30px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(232,23,74,0.35);
}
.confirm-btn:hover { transform: scale(1.04); }
.confirm-btn:active { transform: scale(0.97); }

/* ============ CONFETTI ============ */
.confetti-particle {
    position: absolute;
    pointer-events: none;
    animation: confettiFly 1.2s ease-out forwards;
    top: 50%; left: 50%;
}
@keyframes confettiFly {
    0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot)) scale(0.2); opacity: 0; }
}

/* ============ SSR RAIN ============ */
.star-rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.star-fall { position: absolute; width: 2px; border-radius: 1px; animation: fall linear forwards; }
@keyframes fall { 0% { transform: translateY(-20px); opacity: 1; } 100% { transform: translateY(110%); opacity: 0.3; } }

/* ============ PROBABILITY TABLE ============ */
.prob-table {
    margin-top: 16px;
    padding: 12px;
    background: #f8f8f8;
    border-radius: 10px;
    border: 1px solid #eee;
}
.prob-title { font-size: 0.78rem; font-weight: 700; color: var(--text-lo); letter-spacing: 1px; margin-bottom: 10px; }
.prob-row { display: grid; grid-template-columns: 40px 1fr 40px; grid-template-rows: auto auto; gap: 2px 6px; align-items: center; margin-bottom: 8px; }
.prob-rarity { font-size: 0.68rem; font-weight: 900; letter-spacing: 1px; }
.prob-ssr { color: #b8860b; }
.prob-sr  { color: #7b1fa2; }
.prob-r   { color: #1565c0; }
.prob-n   { color: var(--text-mid); }
.prob-name { font-size: 0.68rem; color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prob-pct  { font-size: 0.68rem; font-weight: 700; color: var(--text-dark); text-align: right; }
.prob-bar-wrap { grid-column: 1 / -1; background: #e0e0e0; border-radius: 4px; height: 4px; overflow: hidden; }
.prob-bar { height: 100%; border-radius: 4px; transition: width 0.5s var(--ease-spring); min-width: 2px; }
.prob-bar-ssr { background: linear-gradient(90deg, #ffd700, #f57f17); }
.prob-bar-sr  { background: linear-gradient(90deg, #e879f9, #9b30ff); }
.prob-bar-r   { background: linear-gradient(90deg, #60a5fa, #2563eb); }
.prob-bar-n   { background: #bbb; }

/* ============ GRID NUMBER ============ */
.prize-card { position: relative; }

.grid-num {
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 0.52rem;
    color: var(--text-lo);
    font-weight: 600;
    line-height: 1;
}

.prize-card.empty .grid-num { color: #bbb; }
