:root {
    --primary: #000000;
    --primary-dark: #1a1a1a;
    --primary-light: #f0ece3;
    --ink: #000000;
    --bg: #f2ede3;
    --card-bg: #ffffff;
    --text: #17140f;
    --muted: #7a7368;
    --border: #e7e1d4;
    --green: #1b8a4a;
    --green-bg: #e9f7ef;
    --red: #d32f2f;
    --red-bg: #fdecea;
    --amber: #333333;
    --accent: #a8834a;
    --accent-bg: #f3e9d6;
    --info: #2f6fed;
    --info-bg: #e8f0fe;
    --success: #1b8a4a;
    --success-bg: #e9f7ef;
    --radius: 22px;
    --radius-sm: 14px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 3px rgba(30,25,15,.06), 0 1px 2px rgba(30,25,15,.04);
    --shadow-md: 0 8px 24px rgba(30,25,15,.08);
    --shadow-lg: 0 16px 40px rgba(30,25,15,.14);
}

* { box-sizing: border-box; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27260%27%20height%3D%27260%27%3E%20%3Cg%20fill%3D%27none%27%20stroke%3D%27%238a7250%27%20stroke-width%3D%271.2%27%20opacity%3D%270.05%27%3E%20%3C%21--%20kitoblar%20to%27plami%20--%3E%20%3Crect%20x%3D%2730%27%20y%3D%27190%27%20width%3D%2770%27%20height%3D%2710%27%20rx%3D%272%27/%3E%20%3Crect%20x%3D%2734%27%20y%3D%27180%27%20width%3D%2762%27%20height%3D%2710%27%20rx%3D%272%27/%3E%20%3Crect%20x%3D%2738%27%20y%3D%27170%27%20width%3D%2754%27%20height%3D%2710%27%20rx%3D%272%27/%3E%20%3Cline%20x1%3D%2765%27%20y1%3D%27170%27%20x2%3D%2765%27%20y2%3D%27150%27%20/%3E%20%3Cpath%20d%3D%27M50%20150%20Q65%20140%2080%20150%20L80%20130%20Q65%20122%2050%20130%20Z%27%20/%3E%20%3C%21--%20bitiruv%20qalpog%27i%20--%3E%20%3Cpath%20d%3D%27M175%2055%20L215%2070%20L175%2085%20L135%2070%20Z%27%20/%3E%20%3Cline%20x1%3D%27175%27%20y1%3D%2785%27%20x2%3D%27175%27%20y2%3D%27100%27%20/%3E%20%3Ccircle%20cx%3D%27175%27%20cy%3D%27100%27%20r%3D%273%27%20/%3E%20%3Cline%20x1%3D%27205%27%20y1%3D%2774%27%20x2%3D%27205%27%20y2%3D%2795%27%20/%3E%20%3C/g%3E%20%3Cg%20fill%3D%27%238a7250%27%20font-family%3D%27Georgia%2C%20serif%27%20opacity%3D%270.045%27%3E%20%3Ctext%20x%3D%27210%27%20y%3D%27190%27%20font-size%3D%2720%27%3EA%2B%3C/text%3E%20%3Ctext%20x%3D%2715%27%20y%3D%2760%27%20font-size%3D%2716%27%3E%E2%9C%93%3C/text%3E%20%3C/g%3E%20%3C/svg%3E");
    background-repeat: repeat;
    color: var(--text);
    padding-bottom: 76px;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -.01em;
    animation: pageIn .35s ease both;
}

@keyframes pageIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.topbar {
    animation: fadeIn .3s ease both;
    background: var(--bg);
    padding: 16px 18px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h1 {
    font-size: 19px;
    font-weight: 800;
    margin: 0;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -.02em;
}
.topbar h1 i { color: var(--primary); font-size: 17px; }

.brand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    padding: 13px 18px;
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    color: #fff;
    font-weight: 700;
    font-size: 14.5px;
    letter-spacing: -.01em;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.brand-bar .brand-left {
    display: flex;
    align-items: center;
    gap: 9px;
}
.brand-bar img {
    height: 26px;
    width: 26px;
    object-fit: contain;
    border-radius: 7px;
    background: #fff;
}
.brand-bar i { font-size: 18px; color: #fff; opacity: .9; }
.brand-bar .tier-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 4px 11px;
    border-radius: var(--radius-pill);
    letter-spacing: .2px;
    white-space: nowrap;
}
.brand-bar .tier-badge.vip {
    background: linear-gradient(135deg, #f5d576, #c9971f);
    color: #3a2a00;
}
.brand-bar .tier-badge.premium {
    background: linear-gradient(135deg, #7fb8ff, #2f6fed);
    color: #fff;
}
.brand-bar .tier-badge.free {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
}

.banner {
    margin: 14px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.banner img { width: 100%; display: block; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 14px;
    box-shadow: var(--shadow-sm);
    animation: fadeIn .25s ease both;
    position: relative;
    overflow: hidden;
}

.card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.avatar-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-photo-3x4 {
    width: 72px;
    height: 96px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    overflow: hidden;
    border: 1.5px dashed var(--border);
}
.avatar-photo-3x4.has-photo {
    border-style: solid;
    border-color: var(--ink);
}
.avatar-photo-3x4 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 13px 22px;
    border-radius: var(--radius-pill);
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn:active { transform: scale(.98); }

.btn.secondary {
    background: var(--card-bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    box-shadow: none;
}
.btn.secondary:hover { border-color: var(--ink); background: var(--primary-light); }

.btn.danger {
    background: #fff;
    color: var(--red);
    border: 2px solid var(--red);
    box-shadow: none;
}
.btn.danger:hover { background: var(--red); color: #fff; }

.btn.block { width: 100%; }

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 14px 10px;
    background: var(--primary-light);
    border-radius: var(--radius-pill);
    padding: 4px;
}
.tabs button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    transition: background .15s ease, color .15s ease;
}
.tabs button.active {
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.fa-spin { animation: spin 1s linear infinite; }

.bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
}
.bottom-menu a {
    flex: 1;
    text-align: center;
    padding: 9px 0 8px;
    text-decoration: none;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}
.bottom-menu a.active { color: var(--primary); }
.bottom-menu a i { display: block; font-size: 17px; margin-bottom: 3px; }

/* Burger / yon menyu */
.side-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 199;
}
.side-menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 78%;
    max-width: 300px;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.side-menu.open { transform: translateX(0); }
.side-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.side-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.side-menu-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 14.5px;
    transition: background .15s ease;
}
.side-menu-nav a i { width: 20px; text-align: center; color: var(--primary); }
.side-menu-nav a.active { background: var(--primary-light); }
.side-menu-nav a:hover { background: var(--primary-light); }

.input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 10px;
    background: #fff;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}

.role-select {
    display: flex;
    gap: 10px;
}
.role-select label {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.role-select input { display: none; }
.role-select input:checked + span { color: var(--primary); font-weight: 700; }
.role-select label:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.role-select i { font-size: 22px; display: block; margin-bottom: 6px; color: var(--primary); }

.muted { color: var(--muted); font-size: 13px; }

.grade-badge {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--ink);
    border: none;
}

/* Premium / bonus / referal — yagona iliq urg'u rang */
.premium-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    background: var(--accent-bg);
    color: var(--accent);
    border: none;
}
.bonus-card {
    background: var(--accent-bg);
    border-color: var(--accent-bg);
}
.accent-text { color: var(--accent); }

.info-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    background: var(--info-bg);
    color: var(--info);
    border: none;
}
.success-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    background: var(--success-bg);
    color: var(--success);
    border: none;
}
.btn.info { background: var(--info); }
.btn.info:hover { background: #2456c4; }
.btn.telegram-share { background: #229ED9; }
.btn.telegram-share:hover { background: #1c85b8; }

.feature-icon-1 { background: var(--info-bg); color: var(--info); }
.feature-icon-2 { background: var(--accent-bg); color: var(--accent); }
.feature-icon-3 { background: var(--success-bg); color: var(--success); }
.feature-icon-4 { background: #fde8ec; color: #d6336c; }

.test-code-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 6px 13px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .2px;
    color: var(--primary);
    background: var(--primary-light);
    cursor: pointer;
    transition: background .15s ease;
}
.test-code-badge:active { background: #e5decd; }

.hint {
    font-size: 12.5px;
    color: var(--muted);
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    margin: 6px 0 12px;
    line-height: 1.5;
    border-left: none;
}

/* Jonli soat (test topshirish taymeri) */
.countdown-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius);
    margin: 14px;
    font-weight: 700;
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    background: var(--ink);
    color: #fff;
}
.countdown-bar.warning { background: #e08a00; }
.countdown-bar.danger { background: var(--red); outline: 2px solid var(--red); }
.countdown-bar i { font-size: 16px; opacity: .85; }

/* Test topshirish ekrani — savol matnini talabgor NUSXALAB
   TARQATIB YUBORMASLIGI uchun (bu — test bazasining maxfiyligini
   saqlash uchun muhim, manba hujjatlarda ham "tarqatish qat'iyan
   taqiqlanadi" deb alohida ta'kidlangan). Matn TANLASH (belgilash)
   VA nusxalash ikkalasi ham bloklanadi — lekin talabgorning O'ZI
   yozadigan input/textarea maydonlari BUNDAN ISTISNO (u yerda
   odatdagidek yozish, tahrirlash, belgilash ishlashi kerak).
*/
#testScreen {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}
#testScreen input,
#testScreen textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}

.dev-footer {
    text-align: center;
    padding: 16px 12px 90px;
    font-size: 11.5px;
    color: var(--muted);
}
.dev-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.support-fab {
    position: fixed;
    right: 16px;
    bottom: 86px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #229ED9;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    box-shadow: 0 4px 14px rgba(34,158,217,.45);
    z-index: 150;
    text-decoration: none;
    transition: transform .15s ease;
}
.support-fab:hover { transform: scale(1.07); }
.support-fab:active { transform: scale(.95); }

/* Natija ekrani — doiraviy foiz ko'rsatkichi (result ring) */
@keyframes rrCardIn {
    0% { opacity: 0; transform: translateY(18px) scale(.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rrTrophyPop {
    0% { transform: scale(0) rotate(-15deg); opacity: 0; }
    60% { transform: scale(1.25) rotate(8deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); }
}
@keyframes rrTrophyBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes rrConfettiFall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(220px) rotate(540deg); opacity: 0; }
}
.result-ring-card {
    background: linear-gradient(160deg, #4338ca, #312e81);
    border: none;
    border-radius: var(--radius);
    padding: 30px 20px 26px;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
    animation: rrCardIn .5s cubic-bezier(.2,.8,.3,1) both;
}
.result-ring-card .rr-title { font-size: 15px; opacity: .85; margin-bottom: 14px; }
.result-ring-card .rr-trophy {
    font-size: 40px;
    margin-bottom: 6px;
    display: inline-block;
    animation: rrTrophyPop .6s cubic-bezier(.2,.9,.3,1.3) .15s both,
               rrTrophyBounce 1.8s ease-in-out 0.9s infinite;
}
.result-ring-confetti {
    position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.result-ring-confetti span {
    position: absolute; top: -10px; width: 7px; height: 11px; border-radius: 2px;
    animation: rrConfettiFall 2.4s ease-in forwards;
}
.result-ring-wrap { position: relative; width: 168px; height: 168px; margin: 0 auto; }
.result-ring-wrap svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.result-ring-wrap .rr-bg { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 10; }
.result-ring-wrap .rr-fg { fill: none; stroke: #fff; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1.3s cubic-bezier(.2,.8,.2,1); }
.result-ring-wrap .rr-center {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 34px; font-weight: 800;
}
.result-ring-card .rr-level {
    font-weight: 700; font-size: 16px; margin-top: 14px;
    opacity: 0; animation: rrCardIn .5s ease .5s both;
}
.result-ring-card .rr-advice-box {
    background: rgba(255,255,255,.12);
    border-radius: 12px;
    padding: 14px 16px;
    margin-top: 16px;
    text-align: left;
    opacity: 0; animation: rrCardIn .5s ease .65s both;
}
.result-ring-card .rr-advice-box .rr-advice-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.result-ring-card .rr-advice-box .rr-advice-text { font-size: 13px; opacity: .9; line-height: 1.5; }
.rr-summary-row {
    display: flex; gap: 10px; margin-top: 14px;
    opacity: 0; animation: rrCardIn .5s ease .8s both;
}
.rr-summary-row .box {
    flex: 1; border-radius: 12px; padding: 12px; display: flex; align-items: center; justify-content: space-between; font-weight: 700;
}
.rr-summary-row .box.correct { background: #e6f7ed; color: #1e7e34; }
.rr-summary-row .box.wrong { background: #fdeaea; color: #a51c2c; }

/* Fan kartalari — test ro'yxatini fan bo'yicha tashkil qilish */
.subject-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.subject-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    transition: border-color .15s ease;
}
.subject-card:hover { border-color: var(--ink); }
.subject-card .icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
}
.subject-card .info { flex: 1; min-width: 0; }
.subject-card .info .name { font-weight: 700; font-size: 15px; }
.subject-card .info .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.subject-card .arrow { color: var(--muted); font-size: 15px; }

.subject-detail-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.subject-detail-header .icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.subject-detail-header .name { font-weight: 800; font-size: 18px; }

.test-row-numbered {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.test-row-numbered .num {
    color: var(--muted); font-weight: 700; font-size: 13px; width: 26px; flex-shrink: 0;
}
.test-row-numbered .info { flex: 1; min-width: 0; }
.test-row-numbered .info .title { font-weight: 700; font-size: 14.5px; }
.test-row-numbered .info .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.test-row-numbered .action-btn {
    flex-shrink: 0; padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 13px;
    border: none; cursor: pointer; white-space: nowrap;
}
.test-row-numbered .action-btn.open { background: var(--ink); color: #fff; }
.test-row-numbered .action-btn.locked { background: var(--primary-light); color: var(--muted); }
