/* =========================================
   System Colors
   ========================================= */
:root {
    --primary: #007AFF; 
    --accent: #5E5CE6; 
    --success: #34C759; 
    --warning: #FF9500; 
    --error: #FF3B30; 
    
    --bg: #F4F5F0; 
    --card: #FCFBF8;
    --text: #2C3E50;
    --text-sec: #718096;
    --glass-border: rgba(0,0,0,0.06);
    --bg-overlay: linear-gradient(to bottom, rgba(244, 245, 240, 0.85), rgba(244, 245, 240, 0.95));
    --magic-glow: 0 0 20px rgba(0, 122, 255, 0.3);
}

body.dark-mode {
    --bg: #121418;
    --card: #1A1D24;
    --text: #E2E8F0;
    --text-sec: #A0AEC0;
    --glass-border: rgba(255,255,255,0.05);
    --bg-overlay: linear-gradient(to bottom, rgba(18, 20, 24, 0.88), rgba(18, 20, 24, 0.95));
    --magic-glow: 0 0 25px rgba(10, 132, 255, 0.6);
}

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

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    background-color: var(--bg);
    background-image: var(--bg-overlay), url('bino.png'); 
    background-size: cover; 
    background-position: center; 
    background-attachment: fixed;
    color: var(--text); 
    transition: background-color 0.4s, color 0.4s; 
    overflow-x: hidden; 
    user-select: none; 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; 
}

.hidden { display: none !important; }
.active { display: flex; flex-direction: column; flex-grow: 1; }
.screen { flex-grow: 1; display: flex; flex-direction: column; position: relative;}
.container { max-width: 1200px; margin: 0 auto; padding: 15px; width: 100%; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.max-total { font-size: 0.85rem; color: var(--text-sec); font-weight: normal; }

.app-footer { text-align: center; padding: 15px; font-size: 0.85rem; color: var(--text-sec); font-weight: 500; margin-top: auto; letter-spacing: 0.5px; }
.app-footer-welcome { position: absolute; bottom: 15px; width: 100%; text-align: center; font-size: 0.85rem; color: rgba(113, 128, 150, 0.8); font-weight: 500; z-index: 10; }
body.dark-mode .app-footer-welcome { color: rgba(255,255,255,0.7); }

.glass-effect { background: rgba(255, 255, 255, 0.65); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border: 1px solid var(--glass-border); box-shadow: 0 10px 40px rgba(0,0,0,0.06); }
body.dark-mode .glass-effect { background: rgba(26, 29, 36, 0.7); border: 1px solid var(--glass-border); }

.slide-up { animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; filter: blur(5px); } to { transform: translateY(0); opacity: 1; filter: blur(0); } }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4); } 70% { box-shadow: 0 0 0 15px rgba(0, 122, 255, 0); } 100% { box-shadow: 0 0 0 0; } }

@keyframes magicCorrect {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.8); }
    50% { transform: scale(1.03); box-shadow: 0 0 25px 5px rgba(52, 199, 89, 0.3); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
@keyframes magicWrong {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); box-shadow: 0 0 15px rgba(255, 59, 48, 0.4); }
    40%, 80% { transform: translateX(6px); box-shadow: 0 0 15px rgba(255, 59, 48, 0.4); }
}
.magic-correct { animation: magicCorrect 0.6s ease-out forwards; background: rgba(52, 199, 89, 0.15) !important; border-color: var(--success) !important; color: var(--success) !important; }
.magic-wrong { animation: magicWrong 0.5s ease-out forwards; background: rgba(255, 59, 48, 0.15) !important; border-color: var(--error) !important; color: var(--error) !important; text-decoration: line-through; opacity: 0.8; }
.magic-particle { position: fixed; width: 8px; height: 8px; background: var(--success); border-radius: 50%; pointer-events: none; z-index: 9999; box-shadow: 0 0 12px var(--success); }

.hero-overlay { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 15px; position: relative; }
.hero-card { width: 100%; max-width: 550px; text-align: center; padding: 40px 25px; border-radius: 35px; z-index: 2; margin-bottom: 30px; }

.main-logo { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; margin-bottom: 20px; border: 2px solid var(--primary); cursor: pointer; animation: pulseGlow 2s infinite alternate; }
@keyframes pulseGlow { from { box-shadow: 0 0 10px rgba(0, 122, 255, 0.3); } to { box-shadow: var(--magic-glow); border-color: var(--accent); } }

.hero-badge { background: var(--primary); color: white; padding: 6px 16px; border-radius: 20px; font-size: 0.85rem; display: inline-block; margin-bottom: 15px; font-weight: 600; }
.main-title { font-size: 2.3rem; font-weight: 800; margin-bottom: 15px; letter-spacing: -0.5px; }
.hero-subtitle { font-size: 1rem; opacity: 0.9; margin-bottom: 25px; line-height: 1.5; }
.rules-box { background: rgba(0,0,0,0.05); padding: 15px; border-radius: 15px; text-align: left; font-size: 0.9rem; margin-bottom: 25px; line-height: 1.6; border: 1px solid var(--glass-border); }
body.dark-mode .rules-box { background: rgba(255,255,255,0.05); }
.premium-input { width: 100%; padding: 18px; border-radius: 18px; border: none; margin-bottom: 15px; font-size: 1.05rem; text-align: center; background: var(--card); color: var(--text); font-weight: 600; outline: none; transition: 0.3s; box-shadow: inset 0 2px 5px rgba(0,0,0,0.02); }
.premium-input:focus { box-shadow: 0 0 0 3px rgba(0,122,255,0.3); }
.btn-start { width: 100%; padding: 18px; border-radius: 18px; background: var(--primary); color: white; border: none; font-weight: 700; font-size: 1.1rem; cursor: pointer; transition: 0.2s; margin-bottom: 15px; }
.btn-start:active { transform: scale(0.96); }

.social-links { display: flex; justify-content: center; gap: 15px; margin-top: 10px; }
.social-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--card); box-shadow: 0 4px 10px rgba(0,0,0,0.1); transition: 0.3s ease; text-decoration: none; border: 1px solid var(--glass-border); }
.social-btn img { width: 22px; height: 22px; object-fit: contain; }
.social-btn:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 6px 15px rgba(0,0,0,0.15); }

.global-nav { padding: 12px 20px; background: var(--glass-effect); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1000; border-bottom: 1px solid var(--glass-border); }
.nav-logo-mini { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; vertical-align: middle; border: 1px solid var(--primary); }
.logo-text { font-weight: 800; font-size: 1rem; color: var(--text); margin-left: 8px; cursor: pointer; vertical-align: middle; }
.badge { font-size: 0.6rem; background: var(--error); color: white; padding: 2px 6px; border-radius: 8px; vertical-align: top; }
.nav-right { display: flex; gap: 10px; align-items: center; }
.timer-badge { background: var(--error); color: white; padding: 6px 10px; border-radius: 10px; font-weight: 700; font-size: 0.95rem; font-family: ui-monospace, monospace; }
.exit-mini { background: rgba(255, 59, 48, 0.1); color: var(--error); border: none; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: 0.2s;}
.exit-mini:active { transform: scale(0.9); }

/* =========================================
   ZAMONAVIY KUN/TUN SURGICHI (SLIDER)
   ========================================= */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    margin-left: 5px;
}
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #E2E8F0; transition: 0.4s; border-radius: 34px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}
.theme-slider:before {
    position: absolute; content: "☀️"; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    height: 22px; width: 22px; left: 3px; bottom: 3px;
    background-color: white; transition: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
body.dark-mode .theme-slider { background-color: var(--glass-border); }
body.dark-mode .theme-slider:before {
    transform: translateX(24px); content: "🌙";
    background-color: #2C3E50; box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* Dashboard Grid & Install Button */
.dash-header { margin-bottom: 25px; margin-top: 10px; }
.header-top-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.install-btn { background-color: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: 12px; font-weight: 700; font-size: 0.9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 4px 10px rgba(0, 122, 255, 0.2); transition: all 0.2s ease; }
.install-btn:active { transform: scale(0.95); box-shadow: 0 2px 5px rgba(0, 122, 255, 0.2); }

.stats-row { display: flex; gap: 15px; margin-top: 15px; }
.stat-card { flex: 1; background: var(--card); padding: 20px; border-radius: 20px; font-weight: 600; font-size: 0.95rem; box-shadow: 0 5px 20px rgba(0,0,0,0.03); border: 1px solid var(--glass-border); }
.stat-card b { font-size: 1.6rem; display: block; margin-top: 5px; }

.category-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cat-btn { background: var(--card); padding: 20px; border-radius: 20px; border: 1px solid var(--glass-border); color: var(--text); font-weight: 700; font-size: 0.95rem; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.03); transition: transform 0.2s; text-align: left;}
.cat-btn:active { transform: scale(0.97); }
.btn-special { background: var(--card); color: var(--primary); border: 2px solid var(--primary); text-align: center;}
.btn-outline { background: transparent; border: 2px solid var(--text-sec); color: var(--text); text-align: center;}
.btn-error { background: rgba(255, 59, 48, 0.1); color: var(--error); border-color: rgba(255, 59, 48, 0.2); text-align: center;}
.btn-error:disabled { opacity: 0.5; background: var(--card); color: var(--text-sec); border-color: var(--glass-border); cursor: not-allowed; }
.btn-exam { background: linear-gradient(135deg, var(--accent), var(--primary)); color: white; border: none; text-align: center; font-size: 1.05rem; }

/* Setup / Modal Screens */
.setup-container { display: flex; align-items: center; justify-content: center; min-height: 75vh; }
.setup-card { width: 100%; max-width: 480px; padding: 30px; border-radius: 25px; color: var(--text); }
.setup-card h2 { text-align: center; margin-bottom: 25px; font-size: 1.5rem; }
.setup-group { margin-bottom: 25px; }
.setup-group label { font-weight: 600; margin-bottom: 12px; display: block; font-size: 1rem; }
.segmented-control { display: flex; background: rgba(0, 0, 0, 0.05); border-radius: 14px; padding: 4px; gap: 4px; }
body.dark-mode .segmented-control { background: rgba(255,255,255,0.05); }
.flex-col { flex-direction: column; }
.seg-btn { flex: 1; padding: 12px; border: 2px solid transparent; background: transparent; border-radius: 12px; font-weight: 600; font-size: 0.9rem; color: var(--text-sec); transition: 0.3s; cursor: pointer; text-align: center; }
.order-opt { text-align: left; padding-left: 20px; }

.diff-easy { color: var(--success); border-color: rgba(52, 199, 89, 0.3); }
.diff-easy.active { background: var(--success); color: white; border-color: var(--success); box-shadow: 0 3px 10px rgba(52,199,89,0.3); }
.diff-medium { color: var(--warning); border-color: rgba(255, 149, 0, 0.3); }
.diff-medium.active { background: var(--warning); color: white; border-color: var(--warning); box-shadow: 0 3px 10px rgba(255,149,0,0.3); }
.diff-hard { color: var(--error); border-color: rgba(255, 59, 48, 0.3); }
.diff-hard.active { background: var(--error); color: white; border-color: var(--error); box-shadow: 0 3px 10px rgba(255,59,48,0.3); }
.order-random.active, .order-seq.active { background: var(--card); color: var(--primary); box-shadow: 0 3px 10px rgba(0,0,0,0.05); border-color: transparent; }

.small-note { font-size: 0.8rem; color: var(--text-sec); margin-top: 10px; font-style: italic; }
.setup-actions { display: flex; gap: 15px; margin-top: 30px; }
.btn-cancel, .btn-start-test { flex: 1; padding: 16px; border-radius: 16px; border: none; font-weight: 700; font-size: 1.05rem; cursor: pointer; transition: 0.2s; }
.btn-cancel { background: rgba(0, 0, 0, 0.05); color: var(--text); }
body.dark-mode .btn-cancel { background: rgba(255,255,255,0.1); }
.btn-start-test { background: var(--primary); color: white; }

.progress-bar-container { height: 6px; background: rgba(0,0,0,0.05); width: 100%; position: sticky; top: 60px; z-index: 999; }
body.dark-mode .progress-bar-container { background: rgba(255,255,255,0.05); }
#progress-fill { height: 100%; background: var(--success); width: 0%; transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); }

.test-layout { display: flex; flex-direction: column; gap: 20px; padding-top: 20px; flex-grow: 1; }

.only-pc { display: none; }
.map-container { overflow-x: auto; white-space: nowrap; padding-bottom: 10px; width: 100%; -webkit-overflow-scrolling: touch; }
.mini-map { display: inline-flex; gap: 8px; padding: 2px; }
.dot { min-width: 38px; height: 38px; border-radius: 12px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; border: 1px solid var(--glass-border); cursor: pointer; transition: 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.dot.active-dot { border: 2px solid var(--primary); color: var(--primary); transform: scale(1.1); box-shadow: var(--magic-glow); }
.dot.correct { background: var(--success); color: white; border: none; }
.dot.wrong { background: var(--error); color: white; border: none; }

.question-container { flex: 1; display: flex; flex-direction: column; }
.q-list-wrapper { height: 65vh; overflow-y: auto; scroll-behavior: smooth; padding: 10px 5px; flex-grow: 1; }
.q-list-wrapper::-webkit-scrollbar { width: 6px; }
.q-list-wrapper::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
body.dark-mode .q-list-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

.q-block { 
    background: var(--card); padding: 25px 20px; border-radius: 25px; margin-bottom: 25px; 
    box-shadow: 0 8px 25px rgba(0,0,0,0.04); border: 2px solid transparent;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.q-block.blurred-q { opacity: 0.4; filter: blur(3.5px); transform: scale(0.96); pointer-events: none; }
.q-block.active-q { opacity: 1; filter: blur(0); transform: scale(1); pointer-events: auto; border-color: rgba(0, 122, 255, 0.2); box-shadow: 0 12px 35px rgba(0, 122, 255, 0.08); }

.spin-box { font-size: 1.1rem; color: var(--primary); font-weight: 900; margin-bottom: 10px; display: inline-block;}
.q-meta { color: var(--text-sec); font-weight: 700; font-size: 0.85rem; margin-bottom: 15px; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 8px;}

.q-text { font-size: 1.2rem; font-weight: 700; margin-bottom: 25px; line-height: 1.4; }
.option-btn { width: 100%; padding: 16px 20px; margin-bottom: 12px; border-radius: 16px; border: 1px solid var(--glass-border); background: var(--bg); text-align: left; font-size: 1.05rem; font-weight: 600; cursor: pointer; color: var(--text); transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.option-btn:active:not(:disabled) { transform: scale(0.98); background: rgba(0,122,255,0.08); }

.scroll-pad { height: 35vh; } 
.nav-controls { display: flex; gap: 15px; margin-top: 15px; padding-bottom: 10px; }
.nav-btn { flex: 1; padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--glass-border); color: var(--primary); font-weight: 700; font-size: 1rem; box-shadow: 0 5px 15px rgba(0,0,0,0.04); cursor: pointer; transition: 0.2s; }
.nav-btn:active { transform: scale(0.96); }
.finish-btn { flex: 2; background: var(--success); color: white; border: none; font-weight: bold; border-radius: 16px; font-size: 1rem; cursor: pointer;}

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-content { width: 100%; max-width: 450px; padding: 25px; border-radius: 35px; max-height: 85vh; overflow-y: auto; background: var(--card); border: 1px solid var(--glass-border); box-shadow: 0 20px 50px rgba(0,0,0,0.2);}
.modal-content::-webkit-scrollbar { display: none; }
.level-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 15px; }
.lvl-btn { padding: 15px; border-radius: 18px; background: var(--bg); border: 1px solid var(--glass-border); color: var(--text); font-weight: 700; cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; align-items: center; gap: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.02);}
.lvl-btn:active { transform: scale(0.95); border-color: var(--primary); }

.donut { width: 140px; height: 140px; border-radius: 50%; border: 12px solid var(--glass-border); margin: 20px auto; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 20px rgba(0,0,0,0.1); }
.donut span { font-size: 2.2rem; font-weight: 900; }
.res-msg { text-align: center; font-size: 1.1rem; font-weight: 700; margin-bottom: 25px; line-height: 1.4;}

@media (min-width: 768px) {
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .q-text { font-size: 1.35rem; }
    .test-layout { flex-direction: row; align-items: flex-start; gap: 30px; height: calc(100vh - 120px); overflow: hidden; }
    .map-container { width: 260px; overflow-y: auto; overflow-x: hidden; white-space: normal; height: 100%; padding-right: 10px; border-right: 1px solid var(--glass-border); }
    .only-pc { display: block; font-weight: 800; font-size: 1.1rem; margin-bottom: 15px; color: var(--text); }
    .mini-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
    .question-container { flex: 1; height: 100%; display: flex; flex-direction: column; }
    .q-list-wrapper { height: auto; flex: 1; padding-right: 20px; }
    .q-block { padding: 35px 30px; }
}

@media (min-width: 1024px) {
    .category-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
    .btn-special, .btn-outline, .btn-error, .btn-exam { grid-column: span 1; }
    .map-container { width: 300px; }
    .mini-map { grid-template-columns: repeat(5, 1fr); }
}