/*
   LOTTERY NUMBER GENERATOR - EXPERT WEB TOOLS
*/

@font-face { 
    font-family: 'Inter';       
    src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); 
    font-weight: 400; 
    font-display: swap; 
}
@font-face { 
    font-family: 'Orbitron';    
    src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2'); 
    font-weight: 700; 
    font-display: swap; 
}
@font-face { 
    font-family: 'Roboto Mono'; 
    src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2'); 
    font-weight: 400; 
    font-display: swap; 
}

:root {
    /* DARK THEME (Default) */
    --bg-main:          #0a0a0f;
    --primary-accent:   #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main:        #ffffff;
    --text-muted:       #94a3b8;
    --card-bg:          rgba(25, 25, 35, 0.6);
    --card-border:      rgba(255, 255, 255, 0.08);
    --input-bg:         rgba(255, 255, 255, 0.05);
    
    /* 3D Ball Base Gradients */
    --ball-bg-main:     linear-gradient(135deg, #3b82f6, #1d4ed8);
    --ball-bg-special:  linear-gradient(135deg, #f59e0b, #b45309);
    --ball-bg-lucky:    linear-gradient(135deg, #10b981, #047857);
    --ball-shadow:      inset -3px -3px 6px rgba(0,0,0,0.5), 
                        inset 2px 2px 5px rgba(255,255,255,0.4), 
                        0 5px 10px rgba(0,0,0,0.4);
    
    --font-heading:     'Orbitron', sans-serif;
    --font-body:        'Inter', sans-serif;
    --font-code:        'Roboto Mono', monospace;
}

/* LIGHT THEME VARIABLES (Mapped to HTML Root) */
html.light-theme {
    --bg-main:          #f8fafc;
    --primary-accent:   #2563eb;
    --secondary-accent: #7c3aed;
    --text-main:        #0f172a;
    --text-muted:       #475569;
    --card-bg:          #ffffff;
    --card-border:      #cbd5e1;
    --input-bg:         #f1f5f9;
    --ball-shadow:      inset -3px -3px 6px rgba(0,0,0,0.3), 
                        inset 2px 2px 5px rgba(255,255,255,0.6), 
                        0 4px 8px rgba(0,0,0,0.2);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

/* FIX: Removed overflow-x hidden for proper mobile panning & accessibility */
html, body { 
    width: 100%; 
    /* FIX: Transition bug fix for Chromium */
    transition: background-color 0.2s ease;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

.sr-only { 
    position: absolute; width: 1px; height: 1px; 
    padding: 0; margin: -1px; overflow: hidden; 
    clip: rect(0,0,0,0); border-width: 0; 
}

.background-glow {
    position: fixed; 
    top: -50%; left: -50%; 
    width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59,130,246,0.06) 0%, rgba(10,10,15,0) 50%);
    z-index: -1; pointer-events: none;
}
html.light-theme .background-glow { opacity: 0; }

/* Header & Controls */
.tool-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 5%; max-width: 1400px; margin: 0 auto; width: 100%; gap: 15px;
}
.back-btn { 
    color: var(--text-muted); text-decoration: none; 
    display: flex; align-items: center; gap: 8px; font-weight: 500; 
}
.back-btn:hover { color: var(--primary-accent); }
.back-btn:focus-visible { outline: 2px solid var(--primary-accent); border-radius: 4px; }
.logo { font-family: var(--font-heading); font-size: 1.2rem; margin: 0 auto; }
.logo span { color: var(--primary-accent); }

/* Language & Theme Switchers */
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    background: var(--input-bg); border: 1px solid var(--card-border); 
    color: var(--text-main); width: 44px; height: 44px; border-radius: 50%; 
    cursor: pointer; display: flex; align-items: center; justify-content: center; 
    transition: all 0.2s;
}
.icon-btn:hover { border-color: var(--primary-accent); color: var(--primary-accent); }
.icon-btn:focus-visible { outline: 2px solid var(--primary-accent); }

/* Standardized Theme Toggle Button */
.theme-toggle-btn {
    background: transparent; border: none; cursor: pointer; color: var(--text-muted); 
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    padding: 8px; border-radius: 50%; transition: background 0.2s, color 0.2s;
    width: 44px; height: 44px;
}
.theme-toggle-btn:hover { color: var(--primary-accent); background: var(--input-bg); }
.theme-toggle-btn:focus-visible { outline: 2px solid var(--primary-accent); }
.theme-toggle-btn i { pointer-events: none; }

.lang-switcher { position: relative; }
.lang-dropdown {
    position: absolute; right: 0; top: 120%; 
    background: var(--card-bg); border: 1px solid var(--card-border); 
    border-radius: 8px; display: none; flex-direction: column; 
    min-width: 140px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    backdrop-filter: blur(10px); overflow: hidden;
}
.lang-dropdown a {
    padding: 12px 15px; color: var(--text-main); text-decoration: none; 
    border-bottom: 1px solid var(--card-border); font-size: 0.9rem; 
    font-weight: 500; transition: background 0.2s;
}
.lang-dropdown a:last-child { border-bottom: none; }
.lang-dropdown a:hover { background: var(--primary-accent); color: #fff; }
.lang-switcher:hover .lang-dropdown, 
.lang-switcher:focus-within .lang-dropdown { 
    display: flex; animation: fadeIn 0.2s ease; 
}

.main-content { flex-grow: 1; padding: 2rem 5%; max-width: 1000px; margin: 0 auto; width: 100%; min-width: 0; }
.tool-intro { text-align: center; margin-bottom: 2rem; }
.tool-intro h1 { font-family: var(--font-heading); font-size: clamp(1.5rem, 4vw, 2.2rem); margin-bottom: 0.5rem; }
.tool-intro p { color: var(--text-muted); font-size: 1.05rem; }

/* Control Cards */
.card {
    background: var(--card-bg); border: 1px solid var(--card-border); 
    border-radius: 16px; padding: 1.5rem; margin-bottom: 2rem; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); min-width: 0;
}
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 1.5rem; }
.control-group label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 0.9rem; font-weight: 600; }
.control-group label i { color: var(--primary-accent); margin-right: 5px; }

.control-group input, .premium-select {
    background: var(--input-bg); border: 1px solid var(--card-border); 
    color: var(--text-main); padding: 10px 15px; border-radius: 8px; 
    width: 100%; font-size: 1rem; font-family: var(--font-body); 
    min-height: 44px; outline: none; transition: border-color 0.2s; box-sizing: border-box;
}
.control-group input:focus, .premium-select:focus { border-color: var(--primary-accent); }

.premium-select {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394a3b8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat; background-position: right 1rem top 50%; background-size: 0.65rem auto;
}
html.light-theme .premium-select {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23475569%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
}

.sub-label { display: block; font-size: 0.75rem; color: #64748b; margin-top: 6px; }
.toggle-label { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; font-size: 0.85rem; font-weight: 500; }
.toggle-label input { accent-color: var(--primary-accent); width: 16px; height: 16px; cursor: pointer; }
.wheeling-group { grid-column: 1 / -1; border-top: 1px dashed var(--card-border); padding-top: 15px; margin-top: 5px; }

/* Tabs & Action Bar */
.region-tabs {
    display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; 
    padding: 1.5rem 0; border-top: 1px solid var(--card-border); 
    border-bottom: 1px solid var(--card-border); margin-bottom: 1.5rem;
}
.tab-btn {
    background: transparent; border: 1px solid var(--card-border); color: var(--text-muted); 
    padding: 8px 16px; border-radius: 20px; cursor: pointer; font-weight: 600; 
    min-height: 44px; transition: all 0.2s; font-family: var(--font-body);
}
.tab-btn:hover { background: var(--input-bg); color: var(--text-main); }
.tab-btn.active { background: var(--primary-accent); color: #fff; border-color: var(--primary-accent); }
.tab-btn:focus-visible { outline: 2px solid var(--primary-accent); outline-offset: 2px; }

.action-bar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.action-bar button {
    padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; 
    font-weight: bold; min-height: 44px; display: flex; align-items: center; 
    justify-content: center; gap: 8px; font-family: var(--font-body); transition: transform 0.1s, opacity 0.2s;
}
.primary-btn { background: var(--primary-accent); color: #fff; flex: 1; min-width: 200px; }
.secondary-btn { background: var(--input-bg); color: var(--text-main); border: 1px solid var(--card-border); flex: 1; min-width: 150px; }
.action-bar button:active { transform: scale(0.98); }
.action-bar button:focus-visible { outline: 2px solid var(--primary-accent); outline-offset: 2px; }

/* Lottery Boards */
.region-section { display: none; }
.region-section.active { display: block; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.lottery-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.lottery-item { background: var(--input-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 1.5rem; min-width: 0; }
.lottery-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 15px; }
.lottery-title h3 { font-family: var(--font-heading); font-size: 1.2rem; margin-bottom: 4px; }
.lottery-title span { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }

.lottery-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lottery-controls label { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.lottery-controls input[type="number"] {
    width: 60px; background: var(--bg-main); border: 1px solid var(--card-border); 
    color: var(--text-main); text-align: center; border-radius: 6px; 
    font-family: var(--font-body); font-weight: bold; min-height: 44px; outline: none;
}
.lottery-controls input:focus { border-color: var(--primary-accent); }
.generate-btn {
    background: var(--secondary-accent); color: #fff; border: none; 
    padding: 0 20px; border-radius: 8px; cursor: pointer; font-weight: bold; 
    min-height: 44px; transition: background 0.2s, transform 0.1s;
}
.generate-btn:hover { background: #7c3aed; }
.generate-btn:active { transform: scale(0.95); }
.generate-btn:focus-visible { outline: 2px solid var(--primary-accent); }

/* Premium Results */
.lottery-result { display: flex; flex-direction: column; gap: 15px; }
.result-line {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px; 
    padding-bottom: 12px; border-bottom: 1px dashed var(--card-border); min-height: 56px;
}
.result-line:last-child { border-bottom: none; padding-bottom: 0; }

.ball {
    position: relative;
    width: clamp(36px, 10vw, 48px);
    height: clamp(36px, 10vw, 48px);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: #fff; font-family: var(--font-heading);
    font-size: clamp(0.85rem, 3vw, 1.1rem); background: var(--ball-bg-main);
    box-shadow: var(--ball-shadow); flex-shrink: 0; opacity: 0; transform: scale(0.5);
}
.ball::after {
    content: ''; position: absolute; top: 10%; left: 15%; width: 40%; height: 40%;
    border-radius: 50%; background: radial-gradient(circle at center, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}
.ball.special { background: var(--ball-bg-special); }
.ball.lucky { background: var(--ball-bg-lucky); border: 2px solid #fff; }

/* FIX: GPU Acceleration for smoother ball animations */
.ball.ball-enter { 
    animation: drawBall 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; 
    will-change: transform, opacity;
}
@keyframes drawBall { 
    0% { opacity: 0; transform: scale(0.2) translateY(-20px) rotate(-45deg); } 
    100% { opacity: 1; transform: scale(1) translateY(0) rotate(0); } 
}

.copy-line-btn {
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; margin-left: auto; font-size: 1.2rem;
    padding: 8px; border-radius: 6px; min-height: 44px; min-width: 44px;
    display: flex; align-items: center; justify-content: center; transition: color 0.2s, background 0.2s;
}
.copy-line-btn:hover { color: var(--text-main); background: var(--input-bg); }
.copy-line-btn:focus-visible { outline: 2px solid var(--primary-accent); }

/* Toast */
.toast {
    position: fixed; left: 50%; transform: translateX(-50%);
    background: #1e293b; border: 1px solid var(--primary-accent);
    color: #fff; padding: 12px 24px; border-radius: 8px; z-index: 2000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); font-weight: 500;
    white-space: nowrap; opacity: 0; pointer-events: none; bottom: -60px;
    transition: opacity 0.3s, bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.toast-visible { opacity: 1; pointer-events: auto; bottom: 30px; }
html.light-theme .toast { background: #ffffff; color: #0f172a; border-color: var(--primary-accent); }

/* Info & FAQ Section */
.info-section { margin-top: 4rem; padding: 0 1rem; border-top: 1px solid var(--card-border); padding-top: 3rem; }
.info-section h2 { font-family: var(--font-heading); margin-bottom: 2rem; font-size: 1.8rem; text-align: center; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2.5rem; }
.info-grid h3 { color: var(--primary-accent); font-family: var(--font-heading); font-size: 1.2rem; margin-bottom: 0.8rem; display: flex; align-items: center; gap: 8px; }
.info-grid p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.7; }

.faq-container { margin-top: 3.5rem; border-top: 1px solid var(--card-border); padding-top: 2.5rem; }
.faq-container h3 { font-family: var(--font-heading); color: var(--text-main); margin-bottom: 1.5rem; font-size: 1.5rem; text-align: center; }
.faq-container h4 { color: var(--secondary-accent); font-size: 1.1rem; margin-bottom: 0.5rem; margin-top: 1.5rem; font-family: var(--font-body); font-weight: 600; }
.faq-container p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1rem; line-height: 1.7; }
.faq-container code { background: var(--input-bg); padding: 2px 6px; border-radius: 4px; font-family: var(--font-code); color: var(--primary-accent); }

footer { text-align: center; padding: 3rem 0; color: var(--text-muted); font-size: 0.9rem; margin-top: 3rem; }
footer a { color: var(--text-main); font-weight: bold; text-decoration: none; }
.print-area { position: absolute; left: -9999px; top: 0; width: 1px; overflow: hidden; }

/* =========================================================================
   MEDIA QUERIES (Strict Layout Enforcement for Mobile)
   ========================================================================= */

@media (max-width: 768px) {
    .controls-grid { grid-template-columns: 1fr; gap: 15px; }
    .lottery-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .lottery-controls { width: 100%; justify-content: space-between; }
    .generate-btn { flex-grow: 1; margin-left: 10px; }
    .action-bar button { width: 100%; min-width: 100%; }
    .result-line { justify-content: flex-start; }
}

@media (max-width: 400px) {
    .tool-header { padding: 1rem; flex-direction: column; align-items: flex-start; gap: 10px; }
    .header-actions { width: 100%; justify-content: space-between; flex-direction: row-reverse; }
    .logo { margin-left: 0; }
    .main-content { padding: 1.5rem 1rem; }
    .lottery-item { padding: 1rem; }
    .tab-btn { padding: 8px 12px; font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) { 
    *, *::before, *::after { 
        animation-duration: 0.01ms !important; 
        transition-duration: 0.01ms !important; 
    } 
}

@media print {
    .no-print { display: none !important; }
    body { background: white; color: black; font-family: sans-serif; display: block; }
    .print-area { position: static; width: 100%; height: auto; overflow: visible; left: 0; top: 0; }
    .print-header { text-align: center; margin-bottom: 20px; border-bottom: 2px solid #000; padding-bottom: 10px; }
    .print-lottery { margin-bottom: 20px; page-break-inside: avoid; }
    .print-lottery h3 { font-size: 1.2rem; margin-bottom: 8px; border-bottom: 1px solid #ccc; padding-bottom: 4px; }
    .print-line { font-family: monospace; font-size: 1.1rem; margin-bottom: 5px; }
    .print-line span { display: inline-block; width: 35px; text-align: center; }
    .print-line span.special { font-weight: bold; border: 1px solid #000; border-radius: 50%; }
    .print-line span.lucky { text-decoration: underline; font-weight: bold; }
}