/* ============================================================
   로또 마스터 - Design System & Styles
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2035;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 255, 255, 0.08);

    --text-primary: #f0f4ff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-1: #6366f1; /* Indigo */
    --accent-2: #8b5cf6; /* Violet */
    --accent-3: #a855f7; /* Purple */
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --accent-glow: 0 0 30px rgba(99, 102, 241, 0.3);

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Lotto Ball Colors */
    --ball-yellow: #fbbf24;
    --ball-yellow-bg: linear-gradient(145deg, #fbbf24, #f59e0b);
    --ball-blue: #3b82f6;
    --ball-blue-bg: linear-gradient(145deg, #60a5fa, #2563eb);
    --ball-red: #ef4444;
    --ball-red-bg: linear-gradient(145deg, #f87171, #dc2626);
    --ball-gray: #6b7280;
    --ball-gray-bg: linear-gradient(145deg, #9ca3af, #4b5563);
    --ball-green: #22c55e;
    --ball-green-bg: linear-gradient(145deg, #4ade80, #16a34a);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Layout */
    --max-width: 1200px;
    --header-height: 70px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ---- Loading Screen ---- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-balls {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 24px;
}

.loading-ball {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    color: #fff;
    animation: loadingBounce 1.2s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.loading-ball:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-ball.ball-yellow {
    background: var(--ball-yellow-bg);
    color: #1a1a1a;
}

.loading-ball.ball-blue {
    background: var(--ball-blue-bg);
}

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

.loading-title {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.loading-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.loading-bar {
    width: 240px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin: 0 auto 12px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loading-status {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ---- Header ---- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-balls {
    display: flex;
    gap: 4px;
}

.mini-ball {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.7rem;
}

.mini-ball.ball-yellow {
    background: var(--ball-yellow-bg);
    color: #1a1a1a;
}

.mini-ball.ball-blue {
    background: var(--ball-blue-bg);
    color: #fff;
}

.logo-text {
    font-size: var(--font-size-xl);
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.nav-btn.active {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.15);
}

.nav-btn.active .nav-icon {
    transform: scale(1.1);
}

.mobile-menu-btn {
    display: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

/* ---- Main ---- */
.main {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--header-height) var(--space-lg) var(--space-3xl);
    min-height: 100vh;
}

.tab-content {
    display: none;
    animation: fadeInTab 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* ---- Hero ---- */
.hero {
    position: relative;
    padding: var(--space-3xl) 0;
    text-align: center;
    overflow: hidden;
}

.hero-bg-balls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.hero-bg-ball {
    position: absolute;
    border-radius: 50%;
    opacity: 0.12;
    animation: floatBall 8s ease-in-out infinite;
}

@keyframes floatBall {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-15px) rotate(5deg); }
    66% { transform: translateY(10px) rotate(-3deg); }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: var(--font-size-4xl);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

.hero-highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 36px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-xl);
    font-family: var(--font-family);
    font-size: var(--font-size-lg);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--accent-glow);
}

.hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}

/* ---- Section ---- */
.section {
    margin-bottom: var(--space-2xl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.section-badge {
    padding: 4px 14px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-xl);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--accent-1);
}

.section-more-btn {
    border: none;
    background: transparent;
    color: var(--accent-1);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.section-more-btn:hover {
    color: var(--accent-3);
}

/* ---- Glass Card ---- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: var(--space-lg);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.glass-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

/* ---- Latest Result ---- */
.latest-result-card {
    text-align: center;
    padding: var(--space-xl);
}

.latest-date {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-sm);
}

.latest-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.lotto-ball {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
                inset 0 -3px 6px rgba(0, 0, 0, 0.2),
                inset 0 3px 6px rgba(255, 255, 255, 0.15);
    position: relative;
    animation: ballAppear 0.5s ease backwards;
}

.lotto-ball::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 12px;
    width: 14px;
    height: 8px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: rotate(-20deg);
}

.lotto-ball.ball-1-10 { background: var(--ball-yellow-bg); color: #1a1a1a; }
.lotto-ball.ball-11-20 { background: var(--ball-blue-bg); }
.lotto-ball.ball-21-30 { background: var(--ball-red-bg); }
.lotto-ball.ball-31-40 { background: var(--ball-gray-bg); }
.lotto-ball.ball-41-45 { background: var(--ball-green-bg); }

.lotto-ball.ball-1-10::after { background: rgba(255, 255, 255, 0.35); }

@keyframes ballAppear {
    from {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.ball-separator {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 300;
}

.lotto-ball.bonus {
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.5),
                0 4px 12px rgba(0, 0, 0, 0.3),
                inset 0 -3px 6px rgba(0, 0, 0, 0.2),
                inset 0 3px 6px rgba(255, 255, 255, 0.15);
}

.latest-bonus-label {
    margin-top: var(--space-sm);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: right;
    padding-right: 20px;
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.stat-card {
    text-align: center;
    padding: var(--space-lg);
    transition: transform var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-detail {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ---- Frequency Chart ---- */
.frequency-chart-container {
    padding: var(--space-lg);
    overflow-x: auto;
}

.frequency-chart-container canvas {
    width: 100%;
    min-height: 250px;
}

/* ---- Hot & Cold ---- */
.hot-cold-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.hot-cold-card.hot {
    border-color: rgba(239, 68, 68, 0.2);
}

.hot-cold-card.cold {
    border-color: rgba(59, 130, 246, 0.2);
}

.hot-cold-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.hot-cold-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hot-cold-ball {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
                inset 0 -2px 4px rgba(0, 0, 0, 0.2),
                inset 0 2px 4px rgba(255, 255, 255, 0.15);
}

.hot-cold-ball::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 9px;
    width: 10px;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: rotate(-20deg);
}

.hot-cold-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    display: block;
    text-align: center;
    margin-top: 4px;
}

.hot-cold-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---- Generator ---- */
.generator-controls {
    padding: var(--space-xl);
}

.control-group {
    margin-bottom: var(--space-xl);
}

.control-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.algorithm-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
}

.algo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-family);
    color: var(--text-secondary);
}

.algo-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.05);
}

.algo-card.active {
    border-color: var(--accent-1);
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.algo-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.algo-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: 4px;
}

.algo-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}

/* Number Selector */
.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.filter-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    display: block;
}

.number-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.num-select-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.num-select-btn:hover {
    border-color: var(--accent-1);
    color: var(--text-primary);
}

.num-select-btn.selected {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}

.num-select-btn.disabled-exclude {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}

/* Game Count */
.game-count-selector {
    display: flex;
    gap: var(--space-sm);
}

.count-btn {
    padding: 8px 24px;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.count-btn:hover {
    border-color: var(--accent-1);
}

.count-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-1);
    color: var(--text-primary);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 18px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

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

.generate-btn-text {
    font-family: var(--font-family);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: #fff;
    position: relative;
    z-index: 1;
}

.generate-btn-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.generate-btn:hover .generate-btn-glow {
    width: 600px;
    height: 600px;
}

/* Draw Animation */
.draw-animation-area {
    margin: var(--space-xl) 0;
}

.draw-machine {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.machine-body {
    background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.08), transparent);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.machine-balls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.machine-ball {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
    color: #fff;
    opacity: 0;
    transform: scale(0);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4),
                inset 0 -3px 6px rgba(0, 0, 0, 0.2),
                inset 0 3px 6px rgba(255, 255, 255, 0.15);
    position: relative;
}

.machine-ball::after {
    content: '';
    position: absolute;
    top: 9px;
    left: 13px;
    width: 14px;
    height: 9px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: rotate(-20deg);
}

.machine-ball.revealed {
    animation: ballReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ballReveal {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-360deg);
    }
    60% {
        opacity: 1;
        transform: scale(1.2) rotate(20deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Generated Results */
.generated-results {
    margin-top: var(--space-xl);
}

.result-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
}

.result-actions-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.result-actions-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
}

.result-actions-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    line-height: 1.4;
}

.result-actions-buttons {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.result-action-btn {
    min-width: 72px;
    padding: 9px 14px;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.result-action-btn:hover {
    border-color: var(--accent-1);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.result-action-btn.primary {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}

.result-action-message {
    min-height: 22px;
    margin-bottom: var(--space-sm);
    color: var(--accent-2);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.result-game {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    animation: slideInResult 0.4s ease backwards;
}

.result-game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.result-game-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.result-game-algo {
    font-size: var(--font-size-xs);
    color: var(--accent-1);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 10px;
    border-radius: var(--radius-xl);
}

.result-numbers {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-ball {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3),
                inset 0 -2px 5px rgba(0, 0, 0, 0.2),
                inset 0 2px 5px rgba(255, 255, 255, 0.15);
    position: relative;
}

.result-ball::after {
    content: '';
    position: absolute;
    top: 7px;
    left: 10px;
    width: 12px;
    height: 7px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: rotate(-20deg);
}

@keyframes slideInResult {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---- Statistics Tab ---- */
.range-selector {
    margin-bottom: var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.range-btns {
    display: flex;
    gap: var(--space-sm);
}

.range-btn {
    padding: 8px 20px;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.range-btn:hover {
    border-color: var(--accent-1);
}

.range-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-1);
    color: var(--text-primary);
}

.chart-section {
    margin-bottom: var(--space-xl);
    padding: var(--space-xl);
}

.chart-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.chart-section canvas {
    width: 100%;
    min-height: 200px;
}

.stats-duo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.chart-legend {
    margin-top: var(--space-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.sum-stats {
    margin-top: var(--space-md);
    display: flex;
    gap: var(--space-xl);
    justify-content: center;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.sum-stat-item {
    text-align: center;
}

.sum-stat-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
}

/* Pair Table */
.pair-table {
    width: 100%;
}

.pair-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-glass);
    gap: var(--space-md);
}

.pair-rank {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--accent-1);
    width: 30px;
    text-align: center;
}

.pair-balls {
    display: flex;
    gap: 6px;
}

.pair-ball {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.pair-count {
    margin-left: auto;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.pair-bar-container {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.pair-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ---- Analyzer Tab ---- */
.analyzer-input {
    padding: var(--space-xl);
    text-align: center;
}

.analyzer-instruction {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.analyzer-number-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    max-width: 400px;
    margin: 0 auto var(--space-lg);
}

.analyzer-num-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    justify-self: center;
}

.analyzer-num-btn:hover {
    border-color: var(--accent-1);
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.analyzer-num-btn.selected {
    color: #fff;
    border-color: transparent;
    transform: scale(1.1);
}

.analyzer-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    min-height: 60px;
}

.analyzer-selected-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.analyzer-selected-balls {
    display: flex;
    gap: 8px;
}

.analyze-btn {
    padding: 14px 40px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
}

.analyze-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.analyze-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

/* Analysis Results */
.analysis-results {
    margin-top: var(--space-xl);
}

.analysis-card {
    margin-bottom: var(--space-xl);
    padding: var(--space-xl);
}

.analysis-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: var(--space-lg);
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.analysis-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
}

.analysis-item-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.analysis-item-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.analysis-item-detail {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-top: 4px;
}

.match-results {
    max-height: 400px;
    overflow-y: auto;
}

.match-row {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-glass);
    gap: var(--space-md);
}

.match-round {
    font-weight: 600;
    color: var(--accent-1);
    min-width: 80px;
}

.match-date {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    min-width: 100px;
}

.match-balls {
    display: flex;
    gap: 4px;
}

.match-ball {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    color: #fff;
}

.match-ball.matched {
    box-shadow: 0 0 0 2px #fff, 0 0 10px rgba(99, 102, 241, 0.6);
}

.match-count {
    margin-left: auto;
    font-size: var(--font-size-sm);
    font-weight: 700;
    padding: 2px 10px;
    border-radius: var(--radius-xl);
}

.match-count.match-6 { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.match-count.match-5 { background: rgba(168, 85, 247, 0.2); color: var(--accent-3); }
.match-count.match-4 { background: rgba(99, 102, 241, 0.2); color: var(--accent-1); }
.match-count.match-3 { background: rgba(34, 197, 94, 0.2); color: var(--success); }

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    border-top: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    position: relative;
    z-index: 1;
}

.footer-data-info {
    margin-top: var(--space-sm);
}

/* ---- Mobile Nav Overlay ---- */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-nav-overlay.active {
    display: block;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .algorithm-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --font-size-4xl: 1.75rem;
        --font-size-3xl: 1.5rem;
    }

    .nav {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: rgba(10, 14, 26, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--space-md);
        border-bottom: 1px solid var(--border-glass);
    }

    .nav.mobile-open {
        display: flex;
    }

    .mobile-menu-btn {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .hot-cold-grid,
    .stats-duo-grid,
    .filter-row {
        grid-template-columns: 1fr;
    }

    .algorithm-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .algo-card:last-child {
        grid-column: 1 / -1;
    }

    .lotto-ball {
        width: 46px;
        height: 46px;
        font-size: 1rem;
    }

    .range-selector {
        flex-direction: column;
        align-items: flex-start;
    }

    .range-btns {
        flex-wrap: wrap;
    }

    .result-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .result-actions-buttons {
        width: 100%;
    }

    .result-action-btn {
        flex: 1;
    }

    .analysis-grid {
        grid-template-columns: 1fr 1fr;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .algorithm-cards {
        grid-template-columns: 1fr 1fr;
    }

    .analysis-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Utility ---- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
