/* Mavzu tanlash va savol ekrani (hamma savol turlari, javob bildirish, kasr, rasmlar, shakllar).
   Egasi: quiz agenti. Uslub: REDESIGN.md (chiziqsiz, yumshoq soya, shaftoli tugma, periwinkle tanlov).
   Ranglar faqat style.css :root o'zgaruvchilaridan. */

#screen-start, #screen-quiz {
  /* ✓ va ✕ belgilari (holatni rangdan tashqari shakl bilan ham ko'rsatish uchun); rangi — fon rangi */
  --m-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E");
  --m-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
  --gut: 20px; /* .screen yon bo'sh joyi (pastki panel chetga cho'zilishi uchun) */
}
@media (min-width: 760px) { #screen-start, #screen-quiz { --gut: 28px; } }
@media (max-width: 380px) { #screen-start, #screen-quiz { --gut: 16px; } }

/* ---------- mavzu tanlash ---------- */
.start-head { display: flex; justify-content: center; }
.start-head .pill { padding: 8px 18px; font-size: 16px; font-weight: 800; color: var(--brand-deep); }
#screen-start .mascot-row { align-items: center; gap: 14px; }
/* izohlar (sana bo'yicha taxmin, savollar soni, oldingi testlar): sariq blok emas, tugma ostidagi xira matn — bob tanlash birinchi o'rinda qoladi */
#screen-start #sample-banner { margin: 0; padding: 0 10px; background: none; border-radius: 0; font-size: 16px; line-height: 1.4; font-weight: 700; color: var(--muted); text-align: center; }
#screen-start #start-note, #screen-start #student-note { font-size: 16px; line-height: 1.4; }
#screen-start .bubble { font-size: 20px; line-height: 1.3; font-weight: 800; padding: 16px 20px; overflow-wrap: break-word; }
#screen-start .bubble::before { top: 50%; bottom: auto; margin-top: -9px; }
#screen-start .sample { padding: 12px 16px; border-radius: var(--r-md); font-size: 16px; line-height: 1.4; font-weight: 700; }
#screen-start .field { gap: 14px; }
#screen-start .label { font-size: 20px; font-weight: 800; line-height: 1.25; }

/* bob tanlagich: bitta yumshoq panel. Sarlavha butun kenglikda (so'z o'rtasidan uzilmaydi),
   pastki qatorda: ← "N-bob · M tadan" → (strelkalar ikki chetda). .topic-box qutisi yo'qoladi, bolalari panel katagiga o'tadi */
.stepper { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 8px 6px; padding: 14px 10px 10px; background: var(--soft); border-radius: var(--r-md); }
.topic-box { display: contents; }
.stepper .btn-sq { grid-row: 2; width: 48px; height: 48px; background: var(--navy); color: #fff; box-shadow: var(--sh-1); }
#prev { grid-column: 1; }
#next { grid-column: 3; }
.stepper .btn-sq .ico { width: 26px; height: 26px; }
.stepper .btn-sq:disabled { opacity: .3; box-shadow: none; }
/* ikki qator joyi doim saqlanadi: strelkani bosganda tugmalar sakramasin */
.topic-title { grid-area: 1 / 1 / 2 / 4; display: flex; align-items: center; justify-content: center; min-height: 2.3em; padding: 2px 6px 0; text-align: center; font-weight: 800; font-size: 24px; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: break-word; text-wrap: balance; }
.topic-no { grid-area: 2 / 2; text-align: center; font-size: 16px; font-weight: 700; line-height: 1.25; color: var(--brand-deep); text-wrap: balance; }
@media (min-width: 400px) { .topic-title { font-size: 26px; } }

/* nuqta-indikatorlar: o'tilgani shaftoli, hozirgisi periwinkle "tabletka", qolgani yengil */
.dots { display: flex; justify-content: center; align-items: center; gap: 6px; padding-top: 2px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 999px; background: var(--brand-soft); transition: width .2s, background .2s; }
.dot.done { background: var(--peach); }
.dot.cur { width: 26px; background: var(--brand); }

/* tavsiya: yumshoq blok (ma'lumot — sovuq ko'k, bosiladigan — qaymoq) */
.suggest { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; text-align: left; border: 0; border-radius: var(--r-md); padding: 12px 16px; background: var(--sky); color: var(--ink); font: 700 16px/1.3 var(--font); }
.suggest .ico { width: 22px; height: 22px; color: var(--brand-deep); }
.suggest.ok { background: var(--ok-bg); color: var(--ok-ink); }
.suggest.ok .ico { color: var(--ok-ink); }
.suggest.go { background: var(--warn-bg); cursor: pointer; transition: transform .12s, background .15s; }
.suggest.go:not(:disabled):active { transform: scale(.98); }
.suggest.go .ico { color: var(--peach-deep); }

/* ---------- savol: tepa qism ---------- */
#screen-quiz { gap: 14px; padding-bottom: 0; min-height: calc(100vh - env(safe-area-inset-top)); min-height: calc(100dvh - env(safe-area-inset-top)); }
body[data-screen="quiz"] { padding-bottom: 0; } /* pastki panel xavfsiz hududni o'zi yopadi */

/* yuqori qator: chiqish va yulduz; pastida butun kenglikda yumshoq segmentli yo'l */
.q-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px 12px; }
.q-top .btn-sq { grid-area: 1 / 1; width: 46px; height: 46px; }
.stars-chip { grid-area: 1 / 3; display: flex; align-items: center; gap: 6px; height: 46px; padding: 0 18px 0 14px; background: var(--navy); color: #fff; border-radius: 999px; font-weight: 800; font-size: 21px; line-height: 1; box-shadow: var(--sh-1); }
.star { width: 24px; height: 24px; fill: var(--sun); stroke: var(--peach-deep); stroke-width: 1.5; stroke-linejoin: round; }
.segs { grid-area: 2 / 1 / 3 / 4; display: flex; align-items: center; gap: 4px; }
.seg { position: relative; flex: 1; min-width: 0; height: 14px; border-radius: 999px; background: #fff; box-shadow: 0 1px 4px rgba(58, 52, 140, .14); transition: background .2s, transform .2s; }
.seg.ok { background: var(--ok-seg); }
.seg.bad { background: var(--bad-seg); }
.seg.cur { background: var(--brand); transform: scaleY(1.3); }
/* to'g'ri / xato rangdan tashqari shakl bilan ham ajraladi: ✓ yoki ✕ belgisi, xato segment pastroq (rang ko'rmaydiganlar uchun) */
.seg.bad { height: 10px; }
.seg.ok::after, .seg.bad::after { content: ""; position: absolute; left: 50%; top: 50%; width: min(9px, 100%); height: 9px; transform: translate(-50%, -50%); -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.seg.ok::after { background: var(--ok-ink); -webkit-mask-image: var(--m-check); mask-image: var(--m-check); }
.seg.bad::after { background: var(--bad-ink); -webkit-mask-image: var(--m-x); mask-image: var(--m-x); }
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: -2px; }
#q-topic { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 800; color: var(--brand-deep); padding: 7px 16px; min-width: 0; }
/* "Savol 3 / 18": to'q lavanda gradient ustida ham 4.5:1 dan yuqori bo'lishi uchun --muted emas, --ink-2 */
#q-no { font-size: 16px; font-weight: 800; white-space: nowrap; color: var(--ink-2); }

/* ---------- boyqush va savol pufagi ---------- */
#screen-quiz .mascot-row.small { align-items: center; gap: 12px; }
#screen-quiz .owl-wrap { width: 88px; height: 88px; }
#screen-quiz .bubble { padding: 15px 18px; border-radius: 24px; overflow-wrap: break-word; }
#screen-quiz .bubble::before { top: 50%; bottom: auto; margin-top: -9px; }
#screen-quiz .bubble h1 { font-size: 24px; line-height: 1.22; font-weight: 800; letter-spacing: -.01em; }
.bubble h1.long { font-size: 21px; line-height: 1.28; }
.bubble h1.xlong { font-size: 18px; line-height: 1.35; font-weight: 700; letter-spacing: 0; }

/* uzun matn (telefonda): boyqush tepada kichkina, pufak butun kenglikda; so'zlar o'rtasidan uzilmaydi */
@media (max-width: 559px) {
  #screen-quiz .mascot-row.small:has(h1.long),
  #screen-quiz .mascot-row.small:has(h1.xlong) { flex-direction: column; align-items: stretch; gap: 0; }
  #screen-quiz .mascot-row.small:has(h1.long) .owl-wrap,
  #screen-quiz .mascot-row.small:has(h1.xlong) .owl-wrap { width: 64px; height: 64px; margin: 0 0 -6px 8px; position: relative; z-index: 1; }
  #screen-quiz .mascot-row.small:has(h1.long) .bubble::before,
  #screen-quiz .mascot-row.small:has(h1.xlong) .bubble::before { left: 34px; top: -7px; margin-top: 0; }
}

/* ---------- savolning rasmi ---------- */
.q-visual { display: flex; justify-content: center; background: #fff; border-radius: var(--r-lg); padding: 14px 14px; box-shadow: var(--sh-1); }
.vis { width: 100%; display: flex; justify-content: center; }
.vis svg { display: block; width: 100%; max-width: 320px; height: auto; }
.vis.pv { gap: 8px; flex-wrap: wrap; }
.pv-col { display: flex; flex-direction: column; min-width: 0; flex: 1 1 0; max-width: 96px; background: var(--soft); border-radius: 16px; overflow: hidden; text-align: center; }
.pv-h { background: var(--brand-soft); color: var(--ink-2); font-weight: 800; font-size: 15px; padding: 6px 2px; line-height: 1.1; min-height: 42px; display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere; }
.pv-d { font-weight: 800; font-size: 28px; padding: 8px 0; color: var(--ink); }
/* telefonda 5 va undan ko'p ustun bir qatorga sig'maydi (sarlavha o'qilmay qoladi): 3 tadan qatorlarga (7 ta bo'lsa 4 tadan) */
@media (max-width: 559px) {
  .vis.pv:has(.pv-col:nth-child(5)) .pv-col { flex: 0 0 calc((100% - 16px) / 3); max-width: none; }
  .vis.pv:has(.pv-col:nth-child(7)) .pv-col { flex-basis: calc((100% - 24px) / 4); }
}
/* eng tor ekran: "Mingdan birlar" kabi so'z ustun ichida uzilmasin (kartochka yon bo'sh joyi va oraliq kamayadi) */
@media (max-width: 340px) {
  .pv-h { font-size: 14px; padding-inline: 1px; }
  .q-visual:has(.vis.pv) { padding-inline: 10px; }
  .vis.pv { gap: 6px; }
  .vis.pv:has(.pv-col:nth-child(5)) .pv-col { flex-basis: calc((100% - 12px) / 3); }
  .vis.pv:has(.pv-col:nth-child(7)) .pv-col { flex-basis: calc((100% - 18px) / 4); }
}

/* ---------- javob variantlari (choice) ---------- */
.q-body { display: flex; flex-direction: column; gap: 12px; }
.options { display: flex; flex-direction: column; gap: 12px; }
.opt { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 10px 16px 10px 12px; text-align: left; border: 0; border-radius: var(--r-md); background: var(--card); box-shadow: var(--sh-1); font: 800 22px/1.2 var(--font); color: var(--ink); cursor: pointer; transition: transform .12s, box-shadow .15s, background .15s; }
.opt:not(:disabled):active { transform: scale(.985); background: var(--brand-soft); box-shadow: inset 0 0 0 3px var(--brand), var(--sh-1); }
.opt:disabled { cursor: default; color: var(--ink); }
.opt .t { flex: 1; min-width: 0; overflow-wrap: break-word; }
.badge { width: 44px; height: 44px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.badge svg { width: 22px; height: 22px; fill: var(--navy); stroke: var(--navy); stroke-width: 1.5; }
/* ✓ / ✕ belgisi oqimga qo'shilmaydi: belgi chap tomondagi shakl (.badge) ustiga o'tirib uni almashtiradi,
   shuning uchun javob bildirilganda matn kengligi o'zgarmaydi va qatorlar sakramaydi */
.opt .mark { position: absolute; left: 12px; top: 50%; width: 44px; height: 44px; margin-top: -22px; padding: 10px; border-radius: 50%; color: #fff; stroke-width: 3.2; }
.opt.is-ok { background: var(--ok-bg); box-shadow: inset 0 0 0 3px var(--ok), var(--sh-1); }
.opt.is-ok .mark { background: var(--ok-ink); }
.opt.is-bad { background: var(--bad-bg); box-shadow: inset 0 0 0 3px var(--bad), var(--sh-1); }
.opt.is-bad .mark { background: var(--bad-ink); }
/* tanlanmagan variantlar: shaffoflik emas, qattiq yumshoq rang (orqa fon naqshi ko'rinib qolmaydi) */
.opt.is-dim { background: var(--soft); color: var(--muted); box-shadow: none; }
.opt.long { font-size: 19px; }
@media (hover: hover) { .opt:not(:disabled):hover { background: var(--soft); } }

/* ---------- javob bildirish ---------- */
#fb { scroll-margin-bottom: 140px; }
.fb-box { min-height: 76px; display: flex; align-items: center; gap: 14px; border-radius: var(--r-md); padding: 12px 16px; }
.fb-wait { justify-content: center; background: var(--soft); color: var(--muted); font-weight: 700; font-size: 16px; line-height: 1.35; text-align: center; min-height: 64px; }
.fb-ok { background: var(--ok-bg); color: var(--ink); }
.fb-bad { background: var(--bad-bg); color: var(--ink); }
.fb-ic { width: 48px; height: 48px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.fb-ok .fb-ic { background: var(--ok-ink); }
.fb-bad .fb-ic { background: var(--bad-ink); }
.fb-ic .ico { stroke-width: 3; }
.fb-t { font-weight: 800; font-size: 22px; line-height: 1.15; }
.fb-ok .fb-t { color: var(--ok-ink); }
.fb-bad .fb-t { color: var(--bad-ink); }
.fb-s { font-weight: 700; font-size: 16px; line-height: 1.35; margin-top: 3px; color: var(--ink-2); overflow-wrap: break-word; }

/* ---------- pastki tugmalar: telefonda doim yetib boradi ---------- */
/* bitta qatorda: "Bilmayman" ikkilamchi, shaftoli tugma asosiy (qolgan joyni egallaydi) */
.bottom { position: sticky; bottom: 0; z-index: 20; display: flex; flex-flow: row nowrap; align-items: center; gap: 10px; margin: auto calc(-1 * var(--gut)) 0; padding: 8px var(--gut) calc(14px + env(safe-area-inset-bottom)); background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.bottom::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px; background: linear-gradient(to bottom, transparent, var(--bg)); background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 88%, transparent)); pointer-events: none; }
.bottom .btn { width: auto; height: 58px; font-size: 19px; }
#skip { order: 0; flex: 0 0 auto; padding: 0 20px; }
#check, #next-q { order: 1; flex: 1 1 auto; min-width: max-content; }
/* faqat "Bilmayman" ko'rinib tursa (test savollari) — butun kenglikda */
.bottom:has(#check[hidden]):has(#next-q[hidden]) #skip { flex: 1 1 auto; }

/* ---------- javob yozish (input) ---------- */
.in-display { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 84px; padding: 12px 18px; background: var(--card); border-radius: var(--r-lg); box-shadow: inset 0 0 0 3px var(--brand-soft), var(--sh-1); font-weight: 800; font-size: 40px; line-height: 1.1; overflow-wrap: anywhere; transition: background .15s, box-shadow .15s; }
.in-val.empty { color: var(--muted); } /* "?" — javob shu yerga yoziladi: oq ustida 6:1 */
.in-unit { font-size: 24px; color: var(--muted); font-weight: 700; }
.in-display.is-ok { background: var(--ok-bg); box-shadow: inset 0 0 0 3px var(--ok); }
.in-display.is-bad { background: var(--bad-bg); box-shadow: inset 0 0 0 3px var(--bad); }
.in-display.is-ok::after, .in-display.is-bad::after { content: ""; width: 34px; height: 34px; flex: none; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.in-display.is-ok::after { background: var(--ok-ink); -webkit-mask-image: var(--m-check); mask-image: var(--m-check); }
.in-display.is-bad::after { background: var(--bad-ink); -webkit-mask-image: var(--m-x); mask-image: var(--m-x); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kp-key { height: 60px; font: 800 28px var(--font); background: var(--card); border: 0; border-radius: 20px; box-shadow: var(--sh-1); cursor: pointer; color: var(--ink); padding: 0; transition: transform .1s, background .15s; }
.kp-key:not(:disabled):active { transform: scale(.95); background: var(--brand-soft); }
.kp-key:disabled { background: var(--soft); color: var(--muted); cursor: default; box-shadow: none; }
.kp-del { background: var(--brand-soft); color: var(--brand-deep); }
.kp-wide { grid-column: span 3; height: 50px; font: 800 18px var(--font); background: var(--soft); box-shadow: none; border-radius: 999px; }
/* past ekran: raqam kiritishda javob oynasi va 4 qator klaviatura pastki tugmalar tepasiga sig'adi.
   Boyqush yig'iladi, oraliqlar va tugmalar ixchamlashadi; sig'masa ham yozilayotgan javob tepada yopishib turadi */
@media (max-height: 900px) and (max-width: 759px) {
  #screen-quiz:has(.keypad) { gap: 10px; }
  #screen-quiz:has(.keypad) .q-meta { margin-top: -4px; }
  #screen-quiz:has(.keypad) .mascot-row.small .owl-wrap { display: none; }
  #screen-quiz:has(.keypad) .mascot-row.small .bubble { padding: 12px 16px; }
  #screen-quiz:has(.keypad) .mascot-row.small .bubble::before { display: none; }
  #screen-quiz:has(.keypad) .q-body { gap: 10px; }
  .in-display { min-height: 60px; padding: 6px 16px; font-size: 34px; position: sticky; top: 8px; z-index: 6; }
  .in-unit { font-size: 22px; }
  .keypad { gap: 8px; }
  .kp-key { height: 50px; font-size: 26px; border-radius: 18px; }
  .kp-wide { height: 44px; font-size: 18px; }
}
/* eng past ekran (320x568): mavzu nomi yashirinadi ("Savol N / M" qoladi), tugmalar yana ixcham */
@media (max-height: 600px) {
  #screen-quiz:has(.keypad) { gap: 8px; }
  #screen-quiz:has(.keypad) #q-topic { display: none; }
  #screen-quiz:has(.keypad) .q-meta { justify-content: flex-end; margin-top: -8px; }
  #screen-quiz:has(.keypad) .q-body { gap: 8px; }
  .in-display { min-height: 52px; }
  .keypad { gap: 6px; }
  .kp-key { height: 46px; font-size: 24px; }
}

/* ---------- tartiblash (order) ---------- */
.ord-wrap { display: flex; flex-direction: column; gap: 10px; }
.ord-end { font-weight: 800; font-size: 16px; color: var(--brand-deep); text-align: center; }
.ord-list { display: flex; flex-direction: column; gap: 10px; }
/* matn ustuni kamida eng uzun so'zi (min-content) kengligida bo'ladi; sig'masa ▲▼ tugmalari pastki qatorga tushadi (so'z o'rtasidan uzilmaydi) */
.ord-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 68px; padding: 8px 10px 8px 14px; background: var(--card); border-radius: var(--r-md); box-shadow: var(--sh-1); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; transition: background .15s, box-shadow .15s, scale .15s; }
.ord-chip.dragging { position: relative; z-index: 5; cursor: grabbing; background: var(--brand-soft); box-shadow: var(--sh-2), 0 0 0 3px var(--brand); scale: 1.03; }
.ord-no { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); display: flex; align-items: center; justify-content: center; font: 800 19px var(--font); }
.ord-t { flex: 1 1 100px; min-width: min-content; max-width: 100%; font-weight: 800; font-size: 22px; line-height: 1.2; overflow-wrap: break-word; }
.ord-btns { display: flex; gap: 6px; margin-left: auto; }
.ord-b { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--soft); color: var(--brand-deep); display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; transition: transform .1s, background .15s; }
.ord-b:not(:disabled):active { transform: scale(.92); background: var(--brand-soft); }
.ord-b:disabled { opacity: .3; cursor: default; }
.ord-b .ico { width: 22px; height: 22px; stroke-width: 3; }
.grip { order: -1; width: 12px; height: 28px; flex: none; background: radial-gradient(circle, var(--brand-tint) 2px, transparent 2.6px) 0 0 / 8px 9px; }
.ord-chip.is-ok { background: var(--ok-bg); box-shadow: inset 0 0 0 3px var(--ok); }
.ord-chip.is-bad { background: var(--bad-bg); box-shadow: inset 0 0 0 3px var(--bad); }
.ord-chip.is-ok .ord-no, .ord-chip.is-bad .ord-no { background: #fff; }
.ord-chip.is-ok .ord-btns, .ord-chip.is-bad .ord-btns, .ord-chip.is-ok .grip, .ord-chip.is-bad .grip { display: none; }
.ord-chip.is-ok::after, .ord-chip.is-bad::after { content: ""; width: 34px; height: 34px; flex: none; margin-right: 4px; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.ord-chip.is-ok::after { background: var(--ok-ink); -webkit-mask-image: var(--m-check); mask-image: var(--m-check); }
.ord-chip.is-bad::after { background: var(--bad-ink); -webkit-mask-image: var(--m-x); mask-image: var(--m-x); }

/* ---------- birlashtirish (match) ---------- */
/* 1fr = minmax(auto, 1fr): uzun so'z (parallelogramm) ustunni kengaytiradi, so'z o'rtasidan uzilmaydi. Eng tor ekranda (<= 340px)
   oraliq va yon bo'sh joy kamaytiriladi (pastda), shunda ikkala ustun va eng uzun so'z sahifaga sig'adi */
.m-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 40px; }
.m-col { display: flex; flex-direction: column; gap: 14px; }
.m-card { position: relative; min-height: 64px; padding: 10px 12px; font: 800 19px/1.2 var(--font); text-align: center; background: var(--card); border: 0; border-radius: var(--r-md); box-shadow: var(--sh-1); cursor: pointer; color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; display: flex; align-items: center; justify-content: center; transition: background .15s, box-shadow .15s, transform .12s; }
.m-card.right { touch-action: auto; }
.m-card.linked { background: var(--soft); background: color-mix(in srgb, var(--pc) 16%, #fff); box-shadow: inset 0 0 0 3px var(--pc), var(--sh-1); }
/* tanlangan: to'q periwinkle (oq matn 7:1), atrofida yengil halqa; shu rang kichik matnda ham kontrastli */
.m-card.sel { background: var(--brand-deep); color: #fff; box-shadow: 0 0 0 4px var(--brand-tint), var(--sh-2); transform: translateY(-2px); }
.m-card:disabled { cursor: default; color: var(--ink); }
.m-card .ct { display: block; min-width: 0; max-width: 100%; text-align: center; overflow-wrap: break-word; }
/* kasr raqamlari ham kartochka matni (>= 18px) o'lchamida: .frac odatda .95em */
.m-card .frac { font-size: 1em; }
/* juftlik raqami (rangdan tashqari belgi): ikki uchida bir xil raqam, tekshirgandan keyin ✓ yoki ✕ */
.m-card[data-pair]::before { content: attr(data-pair); position: absolute; top: -10px; left: -10px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--pc), 0 2px 6px rgba(58, 52, 140, .25); color: var(--ink); font: 800 16px/28px var(--font); text-align: center; }
.m-card.is-ok[data-pair]::before, .m-card.is-bad[data-pair]::before { content: ""; background-color: #fff; box-shadow: 0 0 0 3px var(--pc), 0 2px 6px rgba(58, 52, 140, .25); }
.m-card.is-ok[data-pair]::after, .m-card.is-bad[data-pair]::after { content: ""; position: absolute; top: -5px; left: -5px; width: 18px; height: 18px; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.m-card.is-ok[data-pair]::after { background: var(--ok-ink); -webkit-mask-image: var(--m-check); mask-image: var(--m-check); }
.m-card.is-bad[data-pair]::after { background: var(--bad-ink); -webkit-mask-image: var(--m-x); mask-image: var(--m-x); }
.m-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 2; }

/* ---------- guruhlash (group) ---------- */
.grp-wrap { display: flex; flex-direction: column; gap: 14px; }
.grp-pool { display: flex; flex-wrap: wrap; gap: 10px; min-height: 76px; padding: 14px; background: var(--soft); border-radius: var(--r-lg); box-shadow: inset 0 0 0 2px var(--brand-soft); justify-content: center; align-items: center; }
.grp-pool.empty::after { content: "Hammasi joylaştirildi"; /* CSS matni DOM tuguni emas: public/alifbo.js uni o'tkazmaydi, shuning uchun yangi imloda yozilgan */ font-weight: 800; font-size: 16px; color: var(--muted); }
/* quti kamida 190px: telefonda bitta ustun (chiplardagi uzun iboralar so'z o'rtasidan uzilmaydi), planshet va kompyuterda 2-3 ustun */
.grp-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.grp-box { min-width: 0; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--sh-1); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.grp-title { padding: 11px 12px; background: var(--brand-soft); color: var(--ink); font-weight: 800; font-size: 16px; line-height: 1.2; text-align: center; }
.grp-box:nth-child(2) .grp-title { background: var(--warn-bg); }
.grp-box:nth-child(3) .grp-title { background: var(--sky); }
.grp-box:nth-child(4) .grp-title { background: var(--soft); }
.grp-zone { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; min-height: 96px; align-content: flex-start; }
/* uzun so'z chip ichida qoladi (chegaradan chiqib, qutiga tegmaydi): chip kengligi qutiga qadar, matn o'raladi */
.grp-chip { display: inline-block; max-width: 100%; min-width: 48px; min-height: 44px; padding: 9px 16px; overflow-wrap: anywhere; text-align: left; font: 800 19px/1.2 var(--font); background: var(--card); border: 0; border-radius: 22px; box-shadow: var(--sh-1), inset 0 0 0 2px var(--brand-soft); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; color: var(--ink); transition: background .15s, transform .12s; }
.grp-chip.sel { background: var(--brand-deep); color: #fff; box-shadow: 0 0 0 3px var(--brand-tint), var(--sh-2); transform: translateY(-2px); }
.grp-chip.lifted { opacity: .35; }
.grp-chip.ghost { position: fixed; z-index: 1000; pointer-events: none; margin: 0; background: var(--brand-soft); color: var(--ink); box-shadow: var(--sh-2), 0 0 0 3px var(--brand); transform: rotate(-3deg) scale(1.06); }
.grp-chip.is-ok { background: var(--ok-bg); box-shadow: inset 0 0 0 3px var(--ok); }
.grp-chip.is-bad { background: var(--bad-bg); box-shadow: inset 0 0 0 3px var(--bad); }
.grp-chip.is-ok::after, .grp-chip.is-bad::after { content: ""; display: inline-block; width: 20px; height: 20px; margin-left: 8px; vertical-align: -3px; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.grp-chip.is-ok::after { background: var(--ok-ink); -webkit-mask-image: var(--m-check); mask-image: var(--m-check); }
.grp-chip.is-bad::after { background: var(--bad-ink); -webkit-mask-image: var(--m-x); mask-image: var(--m-x); }
.grp-chip:disabled { cursor: default; color: var(--ink); }

/* ---------- ekran o'lchamlariga moslash ---------- */
@media (min-width: 760px) {
  /* katta ekranda pastki tugmalar — suzuvchi oq panel (chetlari ko'rinib qolmasin) */
  .bottom { bottom: 16px; margin: auto 0 0; padding: 10px; border-radius: var(--r-lg); background: rgba(255, 255, 255, .86); box-shadow: var(--sh-2); }
  .bottom::before { display: none; }
  #screen-quiz { padding-bottom: 16px; }
  .opt { font-size: 24px; min-height: 76px; }
  .opt.long { font-size: 20px; }
  #screen-quiz .bubble h1 { font-size: 27px; }
  .bubble h1.long { font-size: 23px; }
  .bubble h1.xlong { font-size: 20px; }
  #screen-quiz .owl-wrap { width: 104px; height: 104px; }
}
@media (max-width: 380px) {
  #screen-quiz .owl-wrap { width: 76px; height: 76px; }
  #screen-quiz .bubble { padding: 13px 16px; }
  #screen-quiz .bubble h1 { font-size: 22px; }
  .bubble h1.long { font-size: 20px; }
  .bubble h1.xlong { font-size: 18px; }
  .opt { font-size: 21px; }
  .opt.long { font-size: 18px; }
  .topic-title { font-size: 22px; }
  .in-display { font-size: 36px; }
  .ord-t { font-size: 21px; }
  .ord-chip { gap: 8px 10px; padding-left: 10px; }
  .m-grid { column-gap: 32px; }
  .m-card { font-size: 18px; }
}
@media (max-width: 340px) { .m-grid { column-gap: 18px; } .m-card { padding-inline: 8px; } }
/* telefon: sudrash belgisi (.grip) yashiriladi — matn ustuni kengroq bo'ladi (▲▼ tugmalari doim bor) */
@media (max-width: 440px) { .grip { display: none; } }
/* kichik telefon (320x568): sarlavha va pastki tugmalar ixcham, kontentga joy ko'proq */
@media (max-width: 340px), (max-height: 640px) {
  .q-top { gap: 10px; }
  .q-top .btn-sq { width: 44px; height: 44px; }
  .stars-chip { height: 44px; padding: 0 14px 0 11px; font-size: 19px; }
  /* jarayon yo'li X va yulduz orasiga sig'sa shu yerda (12 tagacha savol); undan ko'p bo'lsa — butun kenglikda ikkinchi qatorda
     (segment kamida ~9px: ✓/✕ belgisi ko'rinadi, to'g'ri/xato faqat rangda qolmaydi) */
  .segs { grid-area: 1 / 2; gap: 3px; }
  .bottom { gap: 8px; padding-top: 6px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .bottom .btn { height: 52px; font-size: 18px; }
  #skip { padding: 0 16px; }
  .bottom .btn.cta:has(> .ico:last-child) { padding: 0 6px 0 18px; }
  .bottom .btn.cta > .ico:last-child { width: 40px; height: 40px; padding: 10px; }
}
/* telefon: 12 tadan ko'p segment (X va yulduz orasiga sig'maydi) butun kenglikda ikkinchi qatorda qoladi */
@media (max-width: 559px) { .segs:has(.seg:nth-child(13)) { grid-area: 2 / 1 / 3 / 4; } }
/* eng tor ekran (320): pufak butun kenglikda, boyqush tepada */
@media (max-width: 340px) {
  #screen-quiz .mascot-row.small { flex-direction: column; align-items: stretch; gap: 0; }
  #screen-quiz .mascot-row.small .owl-wrap { width: 64px; height: 64px; margin: 0 0 -6px 8px; position: relative; z-index: 1; }
  #screen-quiz .mascot-row.small .bubble::before { left: 34px; top: -7px; margin-top: 0; }
  .in-display { font-size: 34px; }
}
/* mavzu tanlash: tor ekranda kartochka va boyqush ixchamlashadi (bob nomiga joy ko'proq), pufak so'zni o'rtasidan uzmaydi */
@media (max-width: 380px) {
  #screen-start .owl-wrap { width: 92px; height: 92px; }
  #screen-start .mascot-row { gap: 10px; }
  #screen-start .bubble { font-size: 18px; padding: 14px 16px; }
  #screen-start .card { padding: 18px 14px; gap: 14px; }
  .stepper { grid-template-columns: 46px minmax(0, 1fr) 46px; padding: 12px 8px 8px; gap: 8px 4px; }
  .stepper .btn-sq { width: 46px; height: 46px; }
}
/* tartib: salomlashuv, bob tanlash kartochkasi, darhol ostida asosiy tugma; izohlar tugmadan keyin (tugma ularni yopmasin) */
#screen-start > .start-head { order: 0; }
#screen-start > .mascot-row { order: 1; }
#screen-start > .card { order: 2; }
#screen-start > #start { order: 3; }
#screen-start > #start-note { order: 4; }
#screen-start > #sample-banner { order: 5; }
#screen-start > #student-note { order: 6; }
#screen-start > #show-map { order: 7; }
/* asosiy tugma pastki panel tepasida doim ko'rinib turadi; joy yetarli bo'lsa kartochka ostida o'z o'rnida qoladi */
#screen-start > #start { position: sticky; bottom: calc(var(--dock) + 4px + env(safe-area-inset-bottom)); z-index: 15; }
/* tugma va pastki panel ostida: xiralashgan "muz" qatlam. Ostidan o'tayotgan matn tugma va panel orasida ko'rinib qolmaydi,
   tepa chetida asta-sekin so'nadi (tugma qatlam ustida, panel undan ham ustida) */
#screen-start { padding-bottom: calc(var(--dock) + 112px + env(safe-area-inset-bottom)); } /* oxirgi izoh qatlam tepasida to'liq o'qiladi */
#screen-start::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 14; height: calc(var(--dock) + 4px + 60px + 34px + env(safe-area-inset-bottom)); pointer-events: none; background: color-mix(in srgb, var(--bg) 78%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); -webkit-mask-image: linear-gradient(to bottom, transparent, #000 34px); mask-image: linear-gradient(to bottom, transparent, #000 34px); }
/* o'rtacha balandlik (iPhone/Android brauzer paneli bilan): boyqush ixchamroq, kartochka tugma tepasiga sig'sin */
@media (max-height: 840px) {
  #screen-start .owl-wrap { width: 96px; height: 96px; }
  #screen-start .bubble { font-size: 18px; padding: 14px 16px; }
}
/* past ekran: asosiy vazifa (bobni tanlash) birinchi ko'rinishda tugma tepasida; salomlashuv undan keyin */
@media (max-height: 760px) {
  #screen-start { gap: 14px; }
  #screen-start > .card { order: 1; }
  #screen-start > .mascot-row { order: 2; }
  #screen-start .owl-wrap { width: 84px; height: 84px; }
  #screen-start .label { font-size: 19px; }
}
/* eng past ekran (320x568): jarayon nuqtalari yashirinadi ("N-bob · M tadan" o'sha ma'lumotni beradi), taklif tugma tepasida qoladi */
@media (max-height: 600px) {
  #screen-start .card { gap: 10px; padding-top: 16px; padding-bottom: 14px; }
  #screen-start .field { gap: 10px; }
  .dots { display: none; }
}
/* gorizontal telefon (balandlik <= 480px): yopishqoq tugma va qatlam birinchi ko'rinishning yarmini egallab, bob tanlagichni yopib qo'yardi.
   Tugma oqimda qoladi (kartochka ostida), pastki panel o'zi suzib turadi */
@media (max-height: 480px) {
  #screen-start { gap: 12px; padding-top: 12px; padding-bottom: calc(var(--dock) + 24px); }
  .start-head { display: none; } /* kurs nomi yuqori panelda ham bor: bob tanlagich pastki panel ostida qolmasin */
  #screen-start > #start { position: static; }
  #screen-start::after { display: none; }
}

/* ---------- kasr: surat tepada, maxraj pastda, o'rtasida chiziq (matematik yozuvdagidek) ---------- */
.frac { position: relative; display: inline-flex; flex-direction: column; align-items: stretch; text-align: center; vertical-align: middle; margin: -.05em .12em; font-size: .95em; line-height: 1; white-space: nowrap; }
.frac .fn { padding: 0 .2em .08em; border-bottom: max(1.5px, .09em) solid currentColor; } /* ingichka, lekin har doim ko'rinadigan chiziq */
.frac .fd { padding: .06em .2em 0; }
/* hali yozilmagan joy: yumshoq katakcha (chiziqsiz) */
.frac .ph { display: inline-block; width: .62em; height: .8em; border-radius: .18em; background: var(--brand-soft); box-shadow: inset 0 0 0 .07em var(--brand-tint); vertical-align: -.08em; }
.mixed { display: inline-flex; align-items: center; vertical-align: middle; white-space: nowrap; }
.mixed .mw { margin-right: .06em; }
.mixed .frac { margin: 0 0 0 .06em; }

/* bir-biridan ajralmaydigan "1 butun 3/4" */
.nobr { white-space: nowrap; }

/* ---------- savoldagi narsa rasmlari (pictures.js): so'z yonida kichik rasm va sonli iboralar uchun rasmlar qatori ---------- */
.po { stroke: var(--pic-ink, var(--ink)); stroke-width: var(--pic-sw, 2); stroke-linejoin: round; stroke-linecap: round; }
.wi { width: 1.35em; height: 1.35em; vertical-align: -.34em; margin: 0 .1em 0 .2em; }
.vis.pics { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 24px; }
.pics .pg { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
.pics .pic { width: 46px; height: 46px; flex: none; }
.vis .pie { width: 132px; height: 132px; }
/* bo'lakli doira kattalashadi (48 -> 132px): chiziq ham qalinlashib ketmasin */
.vis .pie .po { stroke: var(--vis-ink); stroke-width: 2px; vector-effect: non-scaling-stroke; }

/* ---------- geometriya shakllari (figures.js): savol ostida va kartochka ichida ---------- */
/* chiziq — ingichka (2px) to'q periwinkle (--vis-ink); to'ldirish — pastel lavanda / shaftoli / sovuq ko'k.
   vector-effect: non-scaling-stroke — rasm telefondan planshetga kattalashganda chiziq qalinlashmaydi (eski qalin qora chiziq qaytmasin).
   Yozuvlar (.fg-t, <text>) esa to'q ko'k (--ink) bo'lib qoladi: o'qilishi uchun */
.q-visual, .ifig { --vis-ink: var(--brand-deep); }
/* savolning o'z rasmlari (kasr tasmasi, son o'qi, to'g'ri to'rtburchak, uchburchak, burchak): app.js ularni stroke="..." atributlari bilan chizadi */
.vis:not(.fig):not(.pv):not(.pics) svg [stroke] { stroke: var(--vis-ink); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.vis:not(.fig):not(.pv):not(.pics) svg [stroke-width="3"] { stroke-width: 2.6px; }
.vis.fig svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.ifig { display: block; margin: 0 auto 6px; }
.ifig svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.fg-poly { fill: var(--fig-fill, var(--brand-soft)); stroke: var(--vis-ink); stroke-width: 2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.fg-poly.fg-y { fill: var(--peach); }
.fg-poly.fg-b { fill: var(--sky); }
.fg-poly.fg-p { fill: var(--brand-tint); }
.fg-poly.fg-g2 { fill: var(--brand-tint); }
.fg-seg { stroke: var(--vis-ink); stroke-width: 2px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.fg-seg.fg-dash { stroke-dasharray: 6 5; }
.fg-seg.fg-bold { stroke-width: 3px; }
.fg-hl { stroke: var(--fig-hl, var(--peach-deep)); stroke-width: 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.fg-mark { fill: none; stroke: var(--vis-ink); stroke-width: 1.8px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.fg-dot { fill: var(--vis-ink); }
.fg-t { fill: var(--ink); font-family: var(--font); font-weight: 800; }

/* ---------- mavzu tanlash: bob rasmi sarlavha ustida (public/art/bob-NN.webp) ---------- */
.topic-title { flex-direction: column; gap: 6px; }
.topic-art { width: 64px; height: 64px; object-fit: contain; }
@media (max-height: 760px) { .topic-art { width: 48px; height: 48px; } }

/* ---------- kasr katakchalari (javob yozish): butun | surat ustida, maxraj ostida ---------- */
.kp-gap { visibility: hidden; }
.kp-next { background: var(--brand-soft); color: var(--brand-deep); }
.kp-next:disabled { background: var(--soft); color: var(--muted); }
.in-display.fin { flex-wrap: wrap; gap: 6px 14px; min-height: 0; padding: 10px 16px; }
.fin-row { display: inline-flex; align-items: center; gap: 14px; }
.fin-frac { display: inline-flex; flex-direction: column; align-items: stretch; gap: 5px; }
.fin-bar { height: 4px; border-radius: 3px; background: var(--ink); }
.fin-slot { min-width: 64px; height: 48px; padding: 0 12px; border: 3px dashed var(--brand-tint); border-radius: 16px; background: var(--soft); color: var(--ink); font: 800 32px/1 var(--font); cursor: pointer; transition: box-shadow .15s, border-color .15s, background .15s; }
.fin-slot[data-slot="w"] { min-width: 68px; height: 72px; font-size: 40px; }
.fin-slot[hidden] { display: none; }
.fin-slot:not(.empty) { border-style: solid; border-color: var(--brand-soft); background: var(--card); }
.fin-slot.on { border-style: solid; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px var(--brand-soft); }
.fin-slot.on.empty::after { content: ""; display: inline-block; width: 3px; height: 30px; border-radius: 2px; background: var(--brand); vertical-align: middle; animation: fin-caret 1s steps(1) infinite; }
@keyframes fin-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fin-slot.on.empty::after { animation: none; } }
.fin-slot:disabled { cursor: default; }
.fin-toggle { align-self: center; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--soft); color: var(--brand-deep); font: 800 17px var(--font); cursor: pointer; }
.fin-toggle[aria-pressed="true"] { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand-tint); }
.fin-toggle:disabled { opacity: .5; cursor: default; }
@media (max-height: 700px) {
  .fin-slot { min-width: 56px; height: 46px; font-size: 30px; border-radius: 13px; }
  .fin-slot[data-slot="w"] { min-width: 60px; height: 68px; font-size: 38px; }
  .fin-toggle { min-height: 38px; font-size: 16px; }
  #screen-quiz:has(.fin-toggle) .q-body { gap: 8px; }
}
@media (max-height: 600px) {
  .fin-slot { min-width: 50px; height: 40px; font-size: 26px; }
  .fin-slot[data-slot="w"] { min-width: 54px; height: 58px; font-size: 32px; }
  .fin-toggle { min-height: 34px; padding: 0 14px; font-size: 15px; }
}
/* kasr katakchalari bor savolda: maslahat qutisi va klaviatura ixchamroq (telefon ekraniga sig'sin) */
#screen-quiz:has(.fin) .fb-wait { display: none; }
#screen-quiz:has(.fin) .kp-key { height: 54px; font-size: 26px; border-radius: 18px; }
#screen-quiz:has(.fin) .keypad { gap: 8px; }
@media (max-height: 700px) { #screen-quiz:has(.fin) .kp-key { height: 46px; font-size: 24px; } }
@media (max-height: 600px) { #screen-quiz:has(.fin) .kp-key { height: 42px; font-size: 22px; } }

/* katta matn o'lchamida ("Tekshirish" matni siqilmaydi) tugmalar keyingi qatorga tushadi; juftlash ustunlari kenglikdan chiqmaydi */
.bottom { flex-wrap: wrap; }
#check, #next-q { white-space: nowrap; }
.m-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.m-card { overflow-wrap: anywhere; }
