/* Design System & CSS Variables */
:root {
    --bg-color: #0c0d19;
    --card-bg: rgba(20, 21, 38, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-focus: rgba(138, 75, 243, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.5);
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.5);
    --accent-pink: #ec4899;
    
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    /* Lotto Ball Colors */
    --ball-yellow-start: #ffea79;
    --ball-yellow-end: #f59e0b;
    --ball-blue-start: #60a5fa;
    --ball-blue-end: #2563eb;
    --ball-red-start: #f87171;
    --ball-red-end: #dc2626;
    --ball-gray-start: #9ca3af;
    --ball-gray-end: #4b5563;
    --ball-green-start: #34d399;
    --ball-green-end: #059669;
    
    --font-outfit: 'Outfit', 'Noto Sans KR', sans-serif;
    --font-noto: 'Noto Sans KR', sans-serif;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-purple-glow);
}

/* Light Mode Variables Override */
[data-theme="light"] {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-border-focus: rgba(138, 75, 243, 0.5);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-purple: #7c3aed;
    --accent-purple-glow: rgba(124, 58, 237, 0.25);
    --accent-cyan: #0891b2;
    --accent-cyan-glow: rgba(8, 145, 178, 0.25);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
    
    /* Make custom select items look better in light mode */
    --hover-color: var(--accent-purple);
}

/* Light Mode Element Overrides */
[data-theme="light"] .mode-selector {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .mode-tab {
    color: var(--text-secondary);
}

[data-theme="light"] .mode-tab:hover {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
}

[data-theme="light"] .mode-tab.active {
    color: white;
    background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
}

[data-theme="light"] .input-field input {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .input-field input:focus {
    background: #ffffff;
    border-color: var(--accent-purple);
}

[data-theme="light"] .quantity-selector select {
    background-color: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .ball-selector-grid {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .select-ball-btn {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .select-ball-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .select-ball-btn.included {
    background: linear-gradient(135deg, var(--accent-purple), #6366f1);
    color: white;
    border-color: transparent;
}

[data-theme="light"] .select-ball-btn.excluded {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    color: rgba(0, 0, 0, 0.3);
    border-color: #ef4444;
}

[data-theme="light"] .selected-summary {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .machine-glass {
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.1) 70%);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.6), 0 10px 25px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .machine-stand {
    background: linear-gradient(to right, #cbd5e1, #94a3b8, #cbd5e1);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .machine-tube {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .game-row {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.01);
}

[data-theme="light"] .btn-game-copy {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .btn-game-copy:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .analysis-card {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .stat-box {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .stat-progress-bar {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .history-item {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .btn-history-copy:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

[data-theme="light"] .btn-history-delete:hover {
    background: rgba(239, 68, 68, 0.08);
}

[data-theme="light"] .history-list-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .history-list-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .toast {
    background: rgba(255, 255, 255, 0.96);
    border-color: var(--accent-purple);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 0 15px var(--accent-purple-glow);
}

[data-theme="light"] .toast-message {
    color: #0f172a;
}


/* Theme Toggle Button Styles */
.theme-toggle-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.theme-toggle-btn:hover {
    transform: scale(1.05);
    border-color: var(--accent-purple);
    box-shadow: var(--shadow-glow);
}

.theme-toggle-btn i {
    width: 20px;
    height: 20px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    position: absolute;
}

/* Toggle icon display based on theme */
[data-theme="light"] .sun-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="light"] .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

@media (max-width: 968px) {
    .theme-toggle-btn {
        top: 1.5rem;
        right: 1.5rem;
    }
}

/* Reset & Basic Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-noto);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

/* Background Ambient Glows */
.ambient-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

.glow-1 {
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
    top: -10%;
    left: -10%;
    animation: pulse-glow 15s infinite alternate ease-in-out;
}

.glow-2 {
    background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation: pulse-glow 12s infinite alternate-reverse ease-in-out;
}

@keyframes pulse-glow {
    0% { transform: scale(1) translate(0, 0); opacity: 0.12; }
    50% { transform: scale(1.1) translate(5%, 5%); opacity: 0.18; }
    100% { transform: scale(0.9) translate(-5%, -5%); opacity: 0.12; }
}

/* Layout Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header Styles */
.app-header {
    text-align: center;
    padding: 1.5rem 0;
    position: relative;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.logo-icon i {
    width: 24px;
    height: 24px;
    color: white;
}

.app-header h1 {
    font-family: var(--font-outfit);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(to right, #ffffff, #e0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header h1 span {
    background: linear-gradient(135deg, #a78bfa, #22d3ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Card Styling (Glassmorphism) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.panel-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
}

.panel-section-title i {
    color: var(--accent-purple);
    width: 22px;
    height: 22px;
}

.panel-section-title h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Grid Layout */
.main-content {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 2rem;
}

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

/* Mode Tabs */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 14px;
    padding: 0.35rem;
    margin-bottom: 1.5rem;
    gap: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.mode-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-noto);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.75rem 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-tab i {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.mode-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.mode-tab:hover i {
    transform: translateY(-1px);
}

.mode-tab.active {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Tab contents */
.options-container {
    min-height: 120px;
    margin-bottom: 1.5rem;
}

.mode-option-content {
    display: none;
}

.mode-option-content.active {
    display: block;
    animation: fade-in 0.35s ease forwards;
}

.mode-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Balanced Mode rules */
.stat-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.rule-badge {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.15);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rule-badge i {
    width: 12px;
    height: 12px;
}

/* Custom Mode Board */
.custom-selection-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.selection-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 0.25rem;
}

.select-type-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-noto);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-type-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.ball-selector-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0.35rem;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

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

.select-ball-btn {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.select-ball-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Interactive States for Selector Board Balls based on Lot Ball ranges */
.select-ball-btn[data-num^="1"]:not([data-num^="10"]):not([data-num^="11"]):not([data-num^="12"]):not([data-num^="13"]):not([data-num^="14"]):not([data-num^="15"]):not([data-num^="16"]):not([data-num^="17"]):not([data-num^="18"]):not([data-num^="19"]),
.select-ball-btn[data-num="1"], .select-ball-btn[data-num="2"], .select-ball-btn[data-num="3"], .select-ball-btn[data-num="4"], .select-ball-btn[data-num="5"], .select-ball-btn[data-num="6"], .select-ball-btn[data-num="7"], .select-ball-btn[data-num="8"], .select-ball-btn[data-num="9"], .select-ball-btn[data-num="10"] {
    --hover-color: var(--ball-yellow-end);
}
.select-ball-btn[data-num="11"], .select-ball-btn[data-num="12"], .select-ball-btn[data-num="13"], .select-ball-btn[data-num="14"], .select-ball-btn[data-num="15"], .select-ball-btn[data-num="16"], .select-ball-btn[data-num="17"], .select-ball-btn[data-num="18"], .select-ball-btn[data-num="19"], .select-ball-btn[data-num="20"] {
    --hover-color: var(--ball-blue-end);
}
.select-ball-btn[data-num="21"], .select-ball-btn[data-num="22"], .select-ball-btn[data-num="23"], .select-ball-btn[data-num="24"], .select-ball-btn[data-num="25"], .select-ball-btn[data-num="26"], .select-ball-btn[data-num="27"], .select-ball-btn[data-num="28"], .select-ball-btn[data-num="29"], .select-ball-btn[data-num="30"] {
    --hover-color: var(--ball-red-end);
}
.select-ball-btn[data-num="31"], .select-ball-btn[data-num="32"], .select-ball-btn[data-num="33"], .select-ball-btn[data-num="34"], .select-ball-btn[data-num="35"], .select-ball-btn[data-num="36"], .select-ball-btn[data-num="37"], .select-ball-btn[data-num="38"], .select-ball-btn[data-num="39"], .select-ball-btn[data-num="40"] {
    --hover-color: var(--ball-gray-end);
}
.select-ball-btn[data-num="41"], .select-ball-btn[data-num="42"], .select-ball-btn[data-num="43"], .select-ball-btn[data-num="44"], .select-ball-btn[data-num="45"] {
    --hover-color: var(--ball-green-end);
}

.select-ball-btn:hover {
    box-shadow: 0 0 10px var(--hover-color);
    border-color: var(--hover-color);
}

.select-ball-btn.included {
    background: linear-gradient(135deg, var(--accent-purple), #6366f1);
    color: white;
    border-color: transparent;
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.6);
}

.select-ball-btn.excluded {
    background: linear-gradient(135deg, #4b5563, #1f2937);
    color: rgba(255, 255, 255, 0.3);
    border-color: #ef4444;
    text-decoration: line-through;
    opacity: 0.6;
}

.selected-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: 12px;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-item .label {
    color: var(--text-secondary);
    min-width: 90px;
    font-weight: 500;
}

.selected-balls-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.mini-ball {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-outfit);
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-sm);
    animation: scale-in-bounce 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Fortune Inputs */
.fortune-inputs {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}

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

.input-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.input-field label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-field input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 0.65rem 0.85rem;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.input-field input:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.25);
}

/* Quantity Selection */
.draw-settings {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.25rem;
    margin-bottom: 1.5rem;
}

.quantity-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quantity-selector label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.quantity-selector select {
    background: rgba(20, 21, 38, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 0.5rem 1.5rem 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    /* Custom Arrow */
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    min-width: 120px;
}

.quantity-selector select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.quantity-selector select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.2);
}

/* Action Button */
.btn-generate {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-purple) 0%, #7c3aed 50%, #6d28d9 100%);
    border: none;
    border-radius: 16px;
    color: white;
    font-family: var(--font-noto);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 1.1rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.45);
}

.btn-generate:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-generate .btn-text {
    position: relative;
    z-index: 2;
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: 0.5s;
    z-index: 1;
}

.btn-generate:hover .btn-glow {
    left: 100%;
    transition: 0.8s ease-in-out;
}

/* Right Panel: Display Elements */
.algorithm-badge {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: #a78bfa;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 30px;
}

/* Lotto Machine Visualizer */
.lotto-machine-container {
    width: 100%;
    height: 160px;
    margin: 0.5rem auto 1.5rem auto;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.machine-glass {
    width: 150px;
    height: 120px;
    border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 70%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.05), 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 3;
}

.machine-inner-glow {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

.machine-balls-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Floating BG balls inside machine */
.bg-ball {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    opacity: 0.75;
    box-shadow: var(--shadow-sm);
}

.bg-ball.yellow { background: linear-gradient(135deg, var(--ball-yellow-start), var(--ball-yellow-end)); }
.bg-ball.blue { background: linear-gradient(135deg, var(--ball-blue-start), var(--ball-blue-end)); }
.bg-ball.red { background: linear-gradient(135deg, var(--ball-red-start), var(--ball-red-end)); }
.bg-ball.gray { background: linear-gradient(135deg, var(--ball-gray-start), var(--ball-gray-end)); }
.bg-ball.green { background: linear-gradient(135deg, var(--ball-green-start), var(--ball-green-end)); }

/* Animation classes for bg balls */
.machine-spinning .bg-ball {
    animation: bounce-ball-crazy 0.8s infinite alternate ease-in-out;
}

@keyframes bounce-ball-crazy {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
    33% {
        transform: translate(var(--x1, 30px), var(--y1, -40px)) scale(0.9) rotate(120deg);
    }
    66% {
        transform: translate(var(--x2, -40px), var(--y2, -20px)) scale(1.1) rotate(240deg);
    }
    100% {
        transform: translate(var(--x3, 10px), var(--y3, -60px)) scale(1) rotate(360deg);
    }
}

.machine-stand {
    width: 90px;
    height: 25px;
    background: linear-gradient(to right, #1f2937, #111827, #1f2937);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: none;
    border-radius: 0 0 12px 12px;
    z-index: 2;
    margin-top: -2px;
}

.machine-tube {
    width: 24px;
    height: 35px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    border-right: 2px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    position: absolute;
    bottom: -5px;
    left: calc(50% - 12px);
    z-index: 1;
}

.tube-light {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(6, 182, 212, 0.2));
    animation: tube-glow-pulse 1.5s infinite alternate ease-in-out;
}

@keyframes tube-glow-pulse {
    0% { opacity: 0.2; }
    100% { opacity: 0.8; }
}

/* Results Display Area */
.results-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 140px;
    margin-bottom: 1.5rem;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 0.75rem;
    text-align: center;
}

.placeholder-icon {
    width: 48px;
    height: 48px;
    stroke-width: 1;
    opacity: 0.5;
}

.results-placeholder p {
    font-size: 0.9rem;
    font-weight: 300;
}

/* Result Game Card */
.game-row {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slide-up 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
}

.game-title-badge {
    font-family: var(--font-outfit);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.15);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    min-width: 60px;
    text-align: center;
}

.balls-container {
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

/* Lotto Balls Styling */
.lotto-ball {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-outfit);
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 -3px 8px rgba(0, 0, 0, 0.3), inset 0 3px 8px rgba(255, 255, 255, 0.3);
    position: relative;
    animation: pop-in-bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: scale(0.3) rotate(-180deg);
}

.lotto-ball::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 60%;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), transparent);
    border-radius: 50% 50% 40% 40% / 60% 60% 30% 30%;
}

.lotto-ball.yellow {
    background: linear-gradient(135deg, var(--ball-yellow-start), var(--ball-yellow-end));
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3), inset 0 -3px 8px rgba(0, 0, 0, 0.3), inset 0 3px 8px rgba(255, 255, 255, 0.4);
}

.lotto-ball.blue {
    background: linear-gradient(135deg, var(--ball-blue-start), var(--ball-blue-end));
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3), inset 0 -3px 8px rgba(0, 0, 0, 0.3), inset 0 3px 8px rgba(255, 255, 255, 0.4);
}

.lotto-ball.red {
    background: linear-gradient(135deg, var(--ball-red-start), var(--ball-red-end));
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3), inset 0 -3px 8px rgba(0, 0, 0, 0.3), inset 0 3px 8px rgba(255, 255, 255, 0.4);
}

.lotto-ball.gray {
    background: linear-gradient(135deg, var(--ball-gray-start), var(--ball-gray-end));
    box-shadow: 0 4px 12px rgba(75, 85, 99, 0.3), inset 0 -3px 8px rgba(0, 0, 0, 0.3), inset 0 3px 8px rgba(255, 255, 255, 0.4);
}

.lotto-ball.green {
    background: linear-gradient(135deg, var(--ball-green-start), var(--ball-green-end));
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3), inset 0 -3px 8px rgba(0, 0, 0, 0.3), inset 0 3px 8px rgba(255, 255, 255, 0.4);
}

@keyframes pop-in-bounce {
    0% { opacity: 0; transform: scale(0.3) rotate(-180deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.game-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-game-copy {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-game-copy:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-game-copy i {
    width: 15px;
    height: 15px;
}

/* Analysis Card Details */
.analysis-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 18px;
    padding: 1.25rem;
    animation: slide-up 0.5s ease;
}

.analysis-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.analysis-card h3 i {
    color: var(--accent-cyan);
    width: 16px;
    height: 16px;
}

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

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

.stat-box {
    background: rgba(0, 0, 0, 0.15);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-outfit);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-progress-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--accent-purple), var(--accent-cyan));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.stat-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* History Styles */
.history-panel {
    max-height: 400px;
}

.btn-clear-history {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    font-family: var(--font-noto);
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-history:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-clear-history i {
    width: 14px;
    height: 14px;
}

.history-list-wrapper {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

/* Custom scrollbar */
.history-list-wrapper::-webkit-scrollbar {
    width: 6px;
}
.history-list-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}
.history-list-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.history-list-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem 0;
    font-weight: 300;
}

.history-item {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fade-in 0.3s ease;
}

.history-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.history-time {
    font-family: var(--font-outfit);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-algo {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-purple);
}

.history-balls {
    display: flex;
    gap: 0.45rem;
}

.history-ball {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-outfit);
    font-size: 0.8rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    box-shadow: var(--shadow-sm);
}

.history-ball.yellow { background: linear-gradient(135deg, var(--ball-yellow-start), var(--ball-yellow-end)); }
.history-ball.blue { background: linear-gradient(135deg, var(--ball-blue-start), var(--ball-blue-end)); }
.history-ball.red { background: linear-gradient(135deg, var(--ball-red-start), var(--ball-red-end)); }
.history-ball.gray { background: linear-gradient(135deg, var(--ball-gray-start), var(--ball-gray-end)); }
.history-ball.green { background: linear-gradient(135deg, var(--ball-green-start), var(--ball-green-end)); }

.history-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-history-copy {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-history-copy:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-history-copy i {
    width: 14px;
    height: 14px;
}

.btn-history-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-history-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.btn-history-delete i {
    width: 14px;
    height: 14px;
}

/* Footer Section */
.app-footer-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.7;
    margin-top: 1rem;
}

.app-footer-info p {
    font-weight: 300;
}

.app-footer-info .copyright {
    margin-top: 0.5rem;
    color: rgba(255, 255, 255, 0.2);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--accent-purple);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-purple-glow);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

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

.toast-icon {
    color: var(--success);
    width: 18px;
    height: 18px;
}

.toast-message {
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
}

/* CSS Animations utilities */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fade-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 {
    animation-delay: 0.15s;
}

.delay-2 {
    animation-delay: 0.3s;
}

/* Flex helper classes */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
