/**
 * 재미있는 번호 생성 애니메이션 스타일 v2
 */

/* ============================================
   모달 스타일
   ============================================ */
.fun-generator-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(8px);
}

.fun-generator-modal.active {
    opacity: 1;
    visibility: visible;
}

.fun-generator-content {
    background: #1c1c1e;
    backdrop-filter: none;
    border-radius: 20px;
    padding: 0;
    max-width: 500px;
    width: 92%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                inset 0 1px 0 rgba(255,255,255,0.06);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    border: 1px solid rgba(255,255,255,0.08);
}

.fun-generator-modal.active .fun-generator-content {
    transform: scale(1);
}

.fun-generator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0,0,0,0.2);
}

.fun-generator-title {
    margin: 0;
    font-size: 1.3rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.fun-generator-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.fun-generator-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.fun-generator-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fun-generator-canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.fun-generator-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    justify-content: center;
    background: rgba(0,0,0,0.2);
}

/* ============================================
   버튼 스타일
   ============================================ */
.fun-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
}

.fun-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 시작 버튼 - Apple 에디토리얼 스타일 (pill) */
.fun-btn-start {
    background: var(--primary);
    color: #1a1a00;
    border: none;
    border-radius: 999px;
    padding: 12px 32px;
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 160px;
}

.fun-btn-start:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.fun-btn-start:active:not(:disabled) {
    transform: translateY(0);
}

/* 다시 추첨 버튼 - ghost pill */
.fun-btn-retry {
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 999px;
}

.fun-btn-retry:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

/* 저장 버튼 - primary pill */
.fun-btn-save {
    background: var(--primary);
    color: #1a1a00;
    border-radius: 999px;
}

.fun-btn-save:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

/* ============================================
   로또머신 스타일
   ============================================ */
.lotto-machine-canvas {
    border-radius: 50%;
    background: radial-gradient(circle, #2a2a4a 0%, #1a1a2e 100%);
    box-shadow: 0 0 30px rgba(255,215,0,0.1),
                inset 0 0 30px rgba(0,0,0,0.5);
}

.lotto-machine-result {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-height: 55px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 0;
}

.result-ball {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 17px;
    box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.3),
                inset 3px 3px 6px rgba(255, 255, 255, 0.4),
                0 5px 15px rgba(0, 0, 0, 0.4);
    position: relative;
}

.result-ball.extracting {
    animation: ballExtract 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.result-ball.landed {
    animation: ballLand 0.3s ease-out forwards;
}

/* 극적인 등장: 0.3 → 1.3(오버슈트) → 1, glow 페이드 */
@keyframes ballExtract {
    0% {
        transform: translateY(-30px) scale(0.3);
        opacity: 0;
        box-shadow: 0 0 0 0 var(--ball-glow, rgba(255,255,255,0.6));
    }
    60% {
        transform: translateY(4px) scale(1.3);
        opacity: 1;
        box-shadow: 0 0 20px 4px var(--ball-glow, rgba(255,255,255,0.6));
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
        box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.3),
                    inset 3px 3px 6px rgba(255, 255, 255, 0.4),
                    0 5px 15px rgba(0, 0, 0, 0.4);
    }
}

@keyframes ballLand {
    0% {
        transform: scale(1);
        box-shadow: 0 0 16px 3px var(--ball-glow, rgba(255,255,255,0.4)),
                    inset -3px -3px 6px rgba(0, 0, 0, 0.3),
                    inset 3px 3px 6px rgba(255, 255, 255, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.3),
                    inset 3px 3px 6px rgba(255, 255, 255, 0.4),
                    0 5px 15px rgba(0, 0, 0, 0.4);
    }
}

/* ============================================
   우주 테마 스타일
   ============================================ */
.galaxy-canvas {
    border-radius: 18px;
    background: linear-gradient(180deg, #0a0a1a 0%, #1a1a3e 100%);
    box-shadow: 0 0 40px rgba(100,80,180,0.2),
                inset 0 0 40px rgba(0,0,0,0.5);
}

.galaxy-result {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-height: 50px;
    align-items: center;
    padding: 12px 0;
}

/* ============================================
   생성 방식 선택 버튼 (메인 페이지)
   ============================================ */
.fun-gen-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
}

.fun-gen-btn {
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.fun-gen-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.fun-gen-btn:active {
    transform: translateY(0);
}

.fun-gen-btn .icon {
    font-size: 1.4rem;
}

/* ============================================
   다크모드 지원
   ============================================ */
[data-theme="light"] .fun-generator-content {
    background: linear-gradient(145deg, #ffffff, #f0f0f5);
    border-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .fun-generator-header {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .fun-generator-title {
    color: #333;
}

[data-theme="light"] .fun-generator-close {
    color: rgba(0, 0, 0, 0.5);
    background: rgba(0,0,0,0.05);
}

[data-theme="light"] .fun-generator-close:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .fun-generator-footer {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .fun-btn-retry {
    background: rgba(0, 0, 0, 0.06);
    color: #333;
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .fun-btn-retry:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .fun-gen-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: #222;
}

[data-theme="light"] .fun-gen-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .lotto-machine-canvas {
    background: radial-gradient(circle, #e8e8f0 0%, #d0d0e0 100%);
}

[data-theme="light"] .galaxy-canvas {
    /* 우주 테마는 항상 어두운 배경 유지 */
}

/* ============================================
   반응형
   ============================================ */
@media (max-width: 420px) {
    .fun-generator-content {
        width: 96%;
        max-width: none;
        border-radius: 20px;
    }

    .fun-generator-header {
        padding: 16px 20px;
    }

    .fun-generator-body {
        padding: 20px 16px;
    }

    .fun-generator-footer {
        padding: 16px 20px;
        flex-wrap: wrap;
    }

    .lotto-machine-canvas {
        width: 320px !important;
        height: 320px !important;
    }

    .galaxy-canvas {
        width: 340px !important;
        height: 280px !important;
    }

    .result-ball {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }

    .fun-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
        min-width: 120px;
    }

    .fun-btn-start {
        width: 100%;
        padding: 14px 24px;
    }

    .fun-gen-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .fun-gen-btn {
        padding: 12px 10px;
        justify-content: center;
    }
}

/* ============================================
   애니메이션 보조
   ============================================ */
/* pulse 제거: Apple 에디토리얼 톤 유지 */

/* ============================================
   세트 조립함 (Set Builder)
   ============================================ */
.set-builder {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.set-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.set-builder-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--primary);
    text-transform: uppercase;
}

.set-builder-count {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.set-builder-slots {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.set-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    min-height: 50px;
    position: relative;
}

.set-slot.empty {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.08);
}

.set-slot-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 20px;
    letter-spacing: 0.05em;
}

.set-slot-content {
    flex: 1;
    min-width: 0;
}

.set-slot-method {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.set-slot-placeholder {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

.set-slot-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    border-radius: 4px;
}

.set-slot-remove:hover {
    color: #ff6b6b;
}

.set-builder-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.set-builder-actions .btn {
    flex: 1;
    padding: 12px;
    font-size: 0.85rem;
}

/* Light mode */
[data-theme="light"] .set-builder {
    background: #ffffff;
}

[data-theme="light"] .set-slot {
    background: #f5f5f7;
}

[data-theme="light"] .set-slot.empty {
    background: transparent;
    border-color: rgba(0, 0, 0, 0.08);
}
