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

:root {
    --bg-primary: #0a0b10;
    --bg-secondary: rgba(18, 20, 29, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.15);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --font-outfit: 'Outfit', 'Noto Sans KR', sans-serif;
    
    /* Lotto Ball Colors (Premium metallic gradients) */
    --ball-yellow-1: #ffb703;
    --ball-yellow-2: #fb8500;
    --ball-blue-1: #4ea8de;
    --ball-blue-2: #5390d9;
    --ball-red-1: #ff4d6d;
    --ball-red-2: #c9184a;
    --ball-gray-1: #adb5bd;
    --ball-gray-2: #495057;
    --ball-green-1: #70e000;
    --ball-green-2: #38b000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    font-family: var(--font-outfit);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Background Animation */
.bg-ambient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
                radial-gradient(circle at 50% 50%, rgba(236, 72, 153, 0.08) 0%, transparent 50%);
    filter: blur(80px);
    animation: flowBg 20s ease-in-out infinite alternate;
}

@keyframes flowBg {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(10, 11, 16, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* App Header */
header {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

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

.logo-icon {
    font-size: 28px;
    animation: rotate 6s linear infinite;
    display: inline-block;
}

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

h1.logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--accent-blue) 70%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: var(--glass-highlight);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Main Content Area */
main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 60px;
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
}

@media (max-width: 992px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* Glass Card styles */
.glass-card {
    background: var(--bg-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

/* Left Column Components */
.machine-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* Canvas Machine container */
.lotto-machine-container {
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1;
    margin: 0 auto 30px;
    position: relative;
    border-radius: 50%;
    padding: 6px;
    background: linear-gradient(135deg, var(--glass-border), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.3);
}

#machineCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, rgba(20, 24, 38, 0.8) 0%, rgba(8, 9, 14, 0.95) 100%);
}

.machine-nozzle {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 40px;
    background: linear-gradient(180deg, #2b3043 0%, #11141e 100%);
    border: 2px solid var(--glass-border);
    border-radius: 0 0 12px 12px;
    z-index: 5;
}

.machine-nozzle::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border-radius: 0 0 8px 8px;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08) 0%, transparent 80%);
}

/* Trigger Button Container */
.draw-controls {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: all 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(139, 92, 246, 0.5);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    background: #2b3043;
    color: var(--text-secondary);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Current Draw Display */
.drawn-balls-display {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    min-height: 80px;
    width: 100%;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 15px;
    border: 1px dashed var(--glass-border);
}

.bonus-divider {
    color: var(--text-secondary);
    font-weight: 800;
    font-size: 24px;
    margin: 0 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.7;
}

.bonus-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Lotto Ball Element styles */
.lotto-ball {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    box-shadow: inset -4px -4px 10px rgba(0, 0, 0, 0.4),
                inset 4px 4px 10px rgba(255, 255, 255, 0.25),
                0 6px 15px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    animation: ballAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.lotto-ball::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 20%;
    width: 60%;
    height: 25%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 50% 50% 50% 50% / 80% 80% 20% 20%;
}

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

.ball-yellow {
    background: radial-gradient(circle at 35% 35%, var(--ball-yellow-1) 0%, var(--ball-yellow-2) 100%);
    box-shadow: inset -4px -4px 10px rgba(0,0,0,0.4), inset 4px 4px 10px rgba(255,255,255,0.25), 0 6px 15px rgba(251, 133, 0, 0.3);
}
.ball-blue {
    background: radial-gradient(circle at 35% 35%, var(--ball-blue-1) 0%, var(--ball-blue-2) 100%);
    box-shadow: inset -4px -4px 10px rgba(0,0,0,0.4), inset 4px 4px 10px rgba(255,255,255,0.25), 0 6px 15px rgba(83, 144, 217, 0.3);
}
.ball-red {
    background: radial-gradient(circle at 35% 35%, var(--ball-red-1) 0%, var(--ball-red-2) 100%);
    box-shadow: inset -4px -4px 10px rgba(0,0,0,0.4), inset 4px 4px 10px rgba(255,255,255,0.25), 0 6px 15px rgba(201, 24, 74, 0.3);
}
.ball-gray {
    background: radial-gradient(circle at 35% 35%, var(--ball-gray-1) 0%, var(--ball-gray-2) 100%);
    box-shadow: inset -4px -4px 10px rgba(0,0,0,0.4), inset 4px 4px 10px rgba(255,255,255,0.25), 0 6px 15px rgba(73, 80, 87, 0.3);
}
.ball-green {
    background: radial-gradient(circle at 35% 35%, var(--ball-green-1) 0%, var(--ball-green-2) 100%);
    box-shadow: inset -4px -4px 10px rgba(0,0,0,0.4), inset 4px 4px 10px rgba(255,255,255,0.25), 0 6px 15px rgba(56, 176, 0, 0.3);
}

/* Right Column: Settings, History & Stats */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.panel-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.panel-title svg {
    width: 20px;
    height: 20px;
    fill: var(--accent-blue);
}

/* Custom Checkbox/Pill grid for Inclusions/Exclusions */
.number-filter-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    margin-top: 10px;
    background: rgba(0,0,0,0.15);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    max-height: 180px;
    overflow-y: auto;
}

@media (max-width: 480px) {
    .number-filter-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}

.filter-chip {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    color: var(--text-secondary);
}

.filter-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* Inclusion Mode: Blue style */
.filter-chip.include {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-blue);
    color: #93c5fd;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

/* Exclusion Mode: Red style */
.filter-chip.exclude {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fca5a5;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

/* Filter selector tabs */
.filter-tabs {
    display: flex;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--glass-border);
}

.filter-tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    color: var(--text-secondary);
}

.filter-tab.active {
    background: var(--glass-highlight);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.filter-tab-include.active {
    background: var(--accent-blue);
    color: white;
}

.filter-tab-exclude.active {
    background: #ef4444;
    color: white;
}

/* Generator Options */
.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.option-label {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Select element */
select.custom-select {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    font-weight: 500;
    transition: border-color 0.3s ease;
}

select.custom-select:focus {
    border-color: var(--accent-blue);
}

/* Draw History List */
.history-container {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
}

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

.history-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-time {
    font-size: 11px;
    color: var(--text-secondary);
}

.history-balls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.history-ball {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.4), inset 2px 2px 5px rgba(255,255,255,0.2), 0 3px 6px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.history-ball::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 20%;
    width: 60%;
    height: 25%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 50%;
}

.history-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 0;
    font-size: 14px;
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
}

.clear-btn {
    font-size: 12px;
    color: var(--accent-pink);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.clear-btn:hover {
    opacity: 0.8;
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.stat-box {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px;
    text-align: center;
}

.stat-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.stat-lbl {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Info Tips Footer */
footer {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    border-top: 1px solid var(--glass-border);
}

footer a {
    color: var(--accent-blue);
    text-decoration: none;
}

/* Multi-Set Result Modal/Drawer (if user selects to generate multiple sets) */
.multi-set-card {
    margin-top: 24px;
    width: 100%;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
}

.multi-set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-wrap: wrap;
    gap: 10px;
}

.multi-set-row:last-child {
    border-bottom: none;
}

.multi-set-label {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-purple);
    width: 50px;
}

.multi-set-balls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Tooltip & Utilities */
.badge {
    background: var(--glass-highlight);
    border: 1px solid var(--glass-border);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}
.badge-red {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
