/* ==========================================================================
   프리미엄 로또 6/45 스마트 조합기 & 통계 대시보드 스타일시트
   PC & 모바일 반응형 완벽 최적화
   ========================================================================== */

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

:root {
    /* 테마 색상 시스템 */
    --bg-main: #0B0E14;
    --bg-card: rgba(22, 27, 34, 0.85);
    --bg-card-hover: rgba(33, 38, 45, 0.95);
    --bg-surface: #161B22;
    --bg-surface-elevated: #21262D;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-glow: rgba(99, 102, 241, 0.4);

    --primary: #6366F1;
    --primary-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --primary-hover: #4F46E5;
    --accent-gold: #F59E0B;
    --accent-gold-gradient: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    
    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;
    --text-subtle: #6B7280;

    /* 로또 공식 5대 색상 순수 플랫/솔리드 컬러 (빛반사 100% 제거) */
    --ball-yellow: #FBC400;
    --ball-blue: #2D9CDB;
    --ball-red: #EB5757;
    --ball-gray: #8C68CD;
    --ball-green: #27AE60;

    --shadow-ball: 0 4px 10px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 12px 32px -4px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.35);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 기본 리셋 및 글로벌 타이포그래피 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(245, 158, 11, 0.08) 0%, transparent 45%);
    background-attachment: fixed;
    overflow-x: hidden;
}

/* 폰트 강조 */
.font-numeric {
    font-family: 'Outfit', sans-serif;
    font-variant-numeric: tabular-nums;
}

/* 컨테이너 */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 100px 20px;
}

/* ==========================================================================
   헤더 네비게이션
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-badge {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    font-size: 22px;
    animation: floatSlow 3s ease-in-out infinite;
}

.logo-text h1 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #FFFFFF 30%, #CBD5E1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-surface-elevated);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ==========================================================================
   실시간 최신 로또 당첨 번호 카드 위젯 (Live Lotto Draw Card)
   ========================================================================== */
.live-draw-card {
    margin-bottom: 20px;
    padding: 18px 22px;
    background: linear-gradient(135deg, rgba(22, 27, 34, 0.92) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 25px rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

.live-draw-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #6366F1, #F59E0B, #10B981, #6366F1);
    background-size: 200% 100%;
    animation: gradientMove 4s linear infinite;
}

@keyframes gradientMove {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

.live-draw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.live-draw-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.live-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6EE7B7;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.status-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: statusPulse 1.8s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
}

/* 회차 빠른 탐색 네비게이션 */
.round-nav-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 6px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-round-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #E2E8F0;
    font-size: 0.72rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-round-nav:hover:not(:disabled) {
    background: var(--primary);
    color: #FFF;
    border-color: var(--primary);
    transform: scale(1.08);
}

.btn-round-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.round-select-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.live-round-title {
    font-size: 1.12rem;
    font-weight: 800;
    color: #FFF;
    letter-spacing: -0.02em;
    margin: 0;
    pointer-events: none;
}

.header-round-dropdown {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.live-draw-date {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* 대조 모달 볼 하이라이트 */
.lotto-ball.xs {
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
    font-weight: 700;
}

.matched-win-ball {
    position: relative;
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.95), inset 0 0 6px rgba(255, 255, 255, 0.8) !important;
    border: 2px solid #FEF08A !important;
    transform: scale(1.12);
    animation: matchGlow 1.5s infinite alternate;
}

.matched-bonus-ball {
    position: relative;
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.95), inset 0 0 6px rgba(255, 255, 255, 0.8) !important;
    border: 2px solid #FBCFE8 !important;
    transform: scale(1.12);
    animation: matchGlowPink 1.5s infinite alternate;
}

@keyframes matchGlow {
    0% { box-shadow: 0 0 8px rgba(250, 204, 21, 0.7); }
    100% { box-shadow: 0 0 16px rgba(250, 204, 21, 1); }
}

@keyframes matchGlowPink {
    0% { box-shadow: 0 0 8px rgba(236, 72, 153, 0.7); }
    100% { box-shadow: 0 0 16px rgba(236, 72, 153, 1); }
}

.live-draw-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-update-time {
    font-size: 0.76rem;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.btn-live-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #E2E8F0;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-live-refresh:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: #FFF;
    transform: translateY(-1px);
}

.btn-live-refresh.loading .refresh-icon {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.live-draw-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
}

.live-balls-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.live-winning-balls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bonus-separator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.plus-sign {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-muted);
    user-select: none;
}

.bonus-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.bonus-tag {
    font-size: 0.68rem;
    font-weight: 700;
    color: #F59E0B;
    letter-spacing: -0.02em;
}

.live-prize-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.prize-box {
    display: flex;
    gap: 16px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.prize-item {
    display: flex;
    flex-direction: column;
}

.prize-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.prize-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: #E2E8F0;
}

.prize-value.highlight {
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.btn-check-my-numbers {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--primary-gradient);
    color: #FFF;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-check-my-numbers:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.shimmer-ball {
    background: #334155;
    color: #94A3B8;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* 상단 탭 내비게이션 */
.main-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* ==========================================================================
   PC 메인 그리드 레이아웃 (2열 구성)
   ========================================================================== */
.main-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
}

/* 공통 카드 스타일 (글래스모피즘) */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition-normal);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.2);
    color: #A5B4FC;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* ==========================================================================
   좌측 컨트롤 패널
   ========================================================================== */
.control-section {
    margin-bottom: 20px;
}

.section-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

/* 추출 모드 셀렉터 */
.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mode-item {
    position: relative;
}

.mode-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mode-label {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.mode-label:hover {
    background: var(--bg-surface-elevated);
}

.mode-item input:checked + .mode-label {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

.mode-label .title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-label .desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.3;
}

/* 게임 수 선택 버튼 그룹 */
.count-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.count-btn {
    padding: 10px 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.count-btn:hover {
    background: var(--bg-surface-elevated);
}

.count-btn.active {
    background: var(--accent-gold-gradient);
    color: #111827;
    border-color: var(--accent-gold);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* 고정수 / 제외수 인터랙티브 미리보기 카드 */
.custom-filter-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 14px;
}

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

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    align-items: center;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
}

.chip-fixed {
    background: rgba(39, 174, 96, 0.2);
    border: 1px solid #27AE60;
    color: #6EE7B7;
}

.chip-excluded {
    background: rgba(235, 87, 87, 0.2);
    border: 1px solid #EB5757;
    color: #FCA5A5;
}

.btn-open-pad {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-color-glow);
    background: rgba(99, 102, 241, 0.08);
    color: #A5B4FC;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-open-pad:hover {
    background: rgba(99, 102, 241, 0.18);
}

/* 주요 실행 버튼 */
.btn-generate {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    color: #FFFFFF;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-bounce);
    margin-top: 20px;
}

.btn-generate:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 35px rgba(99, 102, 241, 0.6);
}

.btn-generate:active {
    transform: translateY(1px) scale(0.98);
}

/* ==========================================================================
   우측 메인 비주얼 & 결과 영역
   ========================================================================== */
.display-area {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 3D 로또 볼 라이브 추첨 머신 디스플레이 */
.live-machine-box {
    text-align: center;
    padding: 28px 20px;
    background: linear-gradient(180deg, rgba(30, 37, 48, 0.9) 0%, rgba(17, 24, 39, 0.95) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

.live-machine-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.machine-status {
    font-size: 0.9rem;
    font-weight: 600;
    color: #A5B4FC;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* 6개 로또 볼 트레이 */
.balls-tray {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    flex-wrap: wrap;
}

/* 로또 볼 기본 플랫/매트 스타일 (빛반사 없는 깨끗한 단색) */
.lotto-ball {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    font-weight: 800;
    color: #FFFFFF;
    box-shadow: var(--shadow-ball);
    position: relative;
    user-select: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lotto-ball.sm {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.lotto-ball.xs {
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* 볼 색상 클래스 (노란색 볼은 검정 글씨, 나머지 흰색 글씨) */
.ball-yellow { 
    background-color: var(--ball-yellow); 
    color: #111827 !important; 
    font-weight: 900 !important;
}
.ball-blue   { background-color: var(--ball-blue); }
.ball-red    { background-color: var(--ball-red); }
.ball-gray   { background-color: var(--ball-gray); }
.ball-green  { background-color: var(--ball-green); }

/* 볼 생성 애니메이션 */
.ball-pop {
    animation: ballPopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ball-rolling {
    animation: ballRollSpin 0.2s linear infinite;
    opacity: 0.75;
}

.ball-placeholder {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 1.1rem;
}

/* ==========================================================================
   복권 영수증(Slip) 스타일 결과 카드 리스트
   ========================================================================== */
.slip-container {
    background: #11141A;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
}

.slip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.12);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.slip-title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.slip-actions {
    display: flex;
    gap: 8px;
}

.btn-slip-action {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition-fast);
}

.btn-slip-action:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
}

.slip-game-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 당첨 일치 볼 하이라이트 */
.lotto-ball.matched-ball {
    box-shadow: 0 0 0 3px #F59E0B, 0 0 14px rgba(245, 158, 11, 0.9) !important;
    transform: scale(1.08);
    z-index: 2;
}

.lotto-ball.bonus-matched-ball {
    box-shadow: 0 0 0 3px #38BDF8, 0 0 14px rgba(56, 189, 248, 0.9) !important;
    transform: scale(1.08);
    z-index: 2;
}

/* 등수 판정 배지 */
.rank-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rank-1st {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #000;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.rank-2nd {
    background: linear-gradient(135deg, #38BDF8, #0284C7);
    color: #FFF;
}

.rank-3rd {
    background: linear-gradient(135deg, #A78BFA, #7C3AED);
    color: #FFF;
}

.rank-4th {
    background: rgba(16, 185, 129, 0.25);
    color: #6EE7B7;
    border: 1px solid #10B981;
}

.rank-5th {
    background: rgba(59, 130, 246, 0.2);
    color: #93C5FD;
    border: 1px solid #3B82F6;
}

.rank-lose {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.game-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(22, 27, 34, 0.7);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: var(--transition-fast);
}

.game-row:hover {
    background: rgba(33, 38, 45, 0.9);
    border-color: rgba(255, 255, 255, 0.15);
}

.game-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.game-row .game-label {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--accent-gold);
}

.game-row .balls-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

.game-row .game-meta {
    font-size: 0.8rem;
    color: var(--text-subtle);
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-row .game-actions {
    display: flex;
    gap: 6px;
}

.btn-mini-save {
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: var(--transition-fast);
}

.btn-mini-save:hover, .btn-mini-save.saved {
    color: var(--accent-gold);
    transform: scale(1.15);
}

/* ==========================================================================
   45구 번호판 인터랙티브 모달 / 바텀시트
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    padding: 24px;
    box-shadow: var(--shadow-card);
    transform: translateY(20px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.pad-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.pad-tab-btn {
    flex: 1;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.pad-tab-btn.active.fixed-mode {
    background: rgba(39, 174, 96, 0.25);
    border-color: #27AE60;
    color: #6EE7B7;
}

.pad-tab-btn.active.exclude-mode {
    background: rgba(235, 87, 87, 0.25);
    border-color: #EB5757;
    color: #FCA5A5;
}

/* 45구 번호 그리드 */
.number-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.num-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-fast);
    position: relative;
}

/* 번호대별 subtle 하단 인디케이터 라인 */
.num-cell[data-color="yellow"] { border-color: rgba(251, 196, 0, 0.4); color: #FEE75C; }
.num-cell[data-color="blue"]   { border-color: rgba(45, 156, 219, 0.4); color: #79C0FF; }
.num-cell[data-color="red"]    { border-color: rgba(235, 87, 87, 0.4); color: #FFA198; }
.num-cell[data-color="gray"]   { border-color: rgba(140, 104, 205, 0.4); color: #D2A8FF; }
.num-cell[data-color="green"]  { border-color: rgba(39, 174, 96, 0.4); color: #7EE787; }

.num-cell:hover {
    transform: scale(1.15);
    z-index: 2;
}

.num-cell.is-fixed {
    background: #27AE60 !important;
    border-color: #27AE60 !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 12px rgba(39, 174, 96, 0.8) !important;
    transform: scale(1.05);
}

.num-cell.is-excluded {
    background: #EB5757 !important;
    border-color: #EB5757 !important;
    color: #FFFFFF !important;
    opacity: 0.75;
    box-shadow: 0 0 12px rgba(235, 87, 87, 0.8) !important;
    text-decoration: line-through;
    transform: scale(0.95);
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

/* ==========================================================================
   보관함 및 시뮬레이터 탭 뷰
   ========================================================================== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* 통계 및 시뮬레이터 카드 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
}

.stat-card-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #FFFFFF;
}

/* 최근 당첨 회차 셀렉터 & 시뮬레이터 */
.sim-checker-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

/* 모바일 전용 하단 고정 내비게이션 바 */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(11, 14, 20, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: 10px 16px;
    z-index: 900;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.mobile-bottom-bar .inner {
    display: flex;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

/* 토스트 알림 메시지 */
.toast-msg {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: #FFFFFF;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast-msg.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ==========================================================================
   애니메이션 키프레임
   ========================================================================== */
@keyframes ballPopIn {
    0% {
        transform: scale(0) translateY(40px) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.2) translateY(-8px) rotate(15deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(0) rotate(0deg);
        opacity: 1;
    }
}

@keyframes ballRollSpin {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(180deg); }
    100% { transform: translateY(0) rotate(360deg); }
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

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

@keyframes qrLaserScan {
    0%, 100% { top: 5%; opacity: 0.7; }
    50% { top: 92%; opacity: 1; }
}

/* ==========================================================================
   상단 탭 내비게이션 (모바일 가로 스크롤 지원)
   ========================================================================== */
.main-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.main-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.tab-btn {
    flex: 1;
    min-width: max-content;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* ==========================================================================
   미디어 쿼리: 모바일 및 태블릿 전면 최적화 (Mobile First / Responsive)
   ========================================================================== */
@media (max-width: 960px) {
    /* 글로벌 레이아웃 */
    .app-container {
        padding: 12px 10px calc(80px + env(safe-area-inset-bottom, 16px)) 10px;
    }

    /* 헤더 */
    .app-header {
        padding-bottom: 12px;
        margin-bottom: 14px;
    }

    .logo-badge {
        width: 36px;
        height: 36px;
        font-size: 17px;
    }

    .logo-text h1 {
        font-size: 1.15rem;
    }

    .logo-text p {
        font-size: 0.72rem;
    }

    .header-controls {
        gap: 6px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    /* 📱 실시간 당첨결과 카드 모바일 최적화 */
    .live-draw-card {
        padding: 12px 10px;
        margin-bottom: 14px;
        border-radius: var(--radius-md);
    }

    .live-draw-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .live-draw-title-group {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 4px;
    }

    .live-status-pill {
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    .round-nav-control {
        padding: 2px 4px;
        gap: 4px;
    }

    .btn-round-nav {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    .live-round-title {
        font-size: 0.98rem;
    }

    .live-draw-date {
        display: none; /* 모바일에서는 간결함을 위해 숨김 */
    }

    .live-draw-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .live-update-time {
        font-size: 0.7rem;
    }

    .btn-live-refresh {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .live-draw-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    /* 당첨 볼 6개 + 보너스 볼 한 줄 가로 꽉 차게 정렬 */
    .live-balls-container {
        justify-content: space-between;
        align-items: center;
        gap: 3px;
        width: 100%;
        padding: 6px 0;
        overflow-x: hidden;
    }

    .live-winning-balls {
        display: flex;
        gap: 3px;
        flex: 1;
        justify-content: space-between;
    }

    .live-winning-balls .lotto-ball.sm,
    #liveBonusBall .lotto-ball.sm {
        width: 35px;
        height: 35px;
        font-size: 0.88rem;
        font-weight: 800;
        flex-shrink: 0;
    }

    .bonus-separator {
        display: flex;
        align-items: center;
        gap: 3px;
        margin-left: 2px;
    }

    .plus-sign {
        font-size: 0.88rem;
        color: var(--text-muted);
    }

    .bonus-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .bonus-tag {
        font-size: 0.58rem;
        padding: 1px 4px;
    }

    /* 1등 당첨금 & 대조 버튼 */
    .live-prize-summary {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }

    .prize-box {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 10px;
        background: rgba(0, 0, 0, 0.35);
        border-radius: var(--radius-sm);
        gap: 8px;
    }

    .prize-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .prize-label {
        font-size: 0.68rem;
        color: var(--text-muted);
    }

    .prize-value {
        font-size: 0.88rem;
        font-weight: 700;
    }

    .prize-value.highlight {
        font-size: 0.95rem;
        color: #FCD34D;
    }

    .extra-prize {
        display: none !important; /* 모바일에서는 1인당 당첨금과 인원 수에 집중 */
    }

    .btn-check-my-numbers {
        width: 100%;
        text-align: center;
        padding: 10px;
        font-size: 0.88rem;
        font-weight: 700;
        border-radius: var(--radius-sm);
    }

    /* 📱 상단 탭바 모바일 스와이프 내비게이션 */
    .main-tabs {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        padding: 4px 2px;
        margin-bottom: 16px;
        background: rgba(22, 27, 34, 0.7);
        border-radius: 12px;
    }

    .main-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 8px 13px;
        font-size: 0.82rem;
        border-radius: 8px;
        white-space: nowrap;
    }

    /* 📱 모바일 핵심: 실시간 추첨 머신 & 영수증을 최상단(order: 1)으로 배치 */
    .main-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .display-area {
        order: 1; /* 추첨 머신과 영수증이 모바일 화면 맨 위 */
        gap: 14px;
    }

    aside.glass-card {
        order: 2; /* 설정 패널은 영수증 아래 */
        padding: 14px;
        border-radius: var(--radius-md);
    }

    /* 3D 추첨 머신 */
    .live-machine-box {
        padding: 16px 10px;
        border-radius: var(--radius-md);
    }

    .machine-status-bar {
        font-size: 0.8rem;
        margin-bottom: 12px;
    }

    .balls-tray {
        gap: 4px;
        min-height: 46px;
        justify-content: center;
    }

    .lotto-ball {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
        font-weight: 800;
    }

    .ball-placeholder {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
    }

    /* 영수증 카드 */
    .slip-container {
        padding: 14px 10px;
        border-radius: var(--radius-md);
    }

    .slip-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-bottom: 10px;
        margin-bottom: 12px;
    }

    .slip-title h3 {
        font-size: 1.05rem;
    }

    /* 영수증 액션 버튼 2x2 그리드 */
    .slip-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        width: 100%;
    }

    .btn-slip-action {
        justify-content: center;
        padding: 8px 6px;
        font-size: 0.78rem;
    }

    /* 영수증 게임 행 (모바일 카드 스타일) */
    .game-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 10px;
        margin-bottom: 8px;
        border-radius: var(--radius-sm);
    }

    .game-row-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
        padding-bottom: 6px;
    }

    .game-meta {
        gap: 6px;
    }

    .game-label {
        font-size: 0.88rem;
        font-weight: 800;
    }

    .game-row .balls-row {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 2px;
    }

    .game-row .lotto-ball.sm {
        width: 36px;
        height: 36px;
        font-size: 0.92rem;
        font-weight: 800;
        flex-shrink: 0;
    }

    /* 조합 설정 패널 */
    .card-title {
        font-size: 1rem;
        margin-bottom: 14px;
    }

    .control-section {
        margin-bottom: 16px;
    }

    .section-label {
        font-size: 0.82rem;
        margin-bottom: 8px;
    }

    .mode-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .mode-label {
        padding: 8px 6px;
        border-radius: var(--radius-sm);
    }

    .mode-label .title {
        font-size: 0.82rem;
    }

    .mode-label .desc {
        font-size: 0.65rem;
        line-height: 1.25;
    }

    .count-selector {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .count-btn {
        padding: 8px 2px;
        font-size: 0.78rem;
        text-align: center;
        justify-content: center;
    }

    /* 통계 분석 탭 모바일 최적화 */
    .stats-summary-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 12px 10px;
    }

    .stat-card-title {
        font-size: 0.76rem;
    }

    .stat-card-value {
        font-size: 1.15rem;
    }

    #frequencyHeatmap {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 5px !important;
    }

    .freq-cell {
        padding: 6px 4px !important;
    }

    /* 시뮬레이터 탭 모바일 최적화 */
    .simulator-control-card {
        padding: 14px 10px;
    }

    .sim-results-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    /* 모바일 바텀시트 모달 */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 88vh;
        padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 16px)) 14px;
        transform: translateY(100%);
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }

    .number-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 5px;
    }

    .num-cell {
        font-size: 0.84rem;
        padding: 8px 0;
    }

    /* 모바일 하단 바 (Safe Area) */
    .mobile-bottom-bar {
        display: block;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 14px)) 12px;
    }

    .btn-generate.pc-only {
        display: none;
    }
}

/* 초소형 스마트폰 (iPhone SE, Galaxy mini 360px 이하) 추가 초밀착 최적화 */
@media (max-width: 380px) {
    .app-container {
        padding: 8px 6px calc(75px + env(safe-area-inset-bottom, 14px)) 6px;
    }

    .live-winning-balls .lotto-ball.sm,
    #liveBonusBall .lotto-ball.sm {
        width: 31px;
        height: 31px;
        font-size: 0.8rem;
    }

    .game-row .lotto-ball.sm {
        width: 32px;
        height: 32px;
        font-size: 0.84rem;
    }

    .lotto-ball {
        width: 34px;
        height: 34px;
        font-size: 0.92rem;
    }

    .ball-placeholder {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }

    .mode-label .title {
        font-size: 0.75rem;
    }

    .count-btn {
        font-size: 0.72rem;
        padding: 6px 1px;
    }

    .tab-btn {
        padding: 6px 10px;
        font-size: 0.76rem;
    }
}

