@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800;900&display=swap');

/* ================= Ranglar (kunduzgi) ================= */
:root {
  --page: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --surface-3: #e2e7f0;
  --ink: #16213a;
  --muted: #667089;
  --line: #e3e7ef;
  --field: #ffffff;
  --btn: #16213a;
  --navy: #16213a;
  --stage-1: #0b3c6b;
  --stage-2: #0a7c86;
  --brand: #0099b5;
  --brand-dark: #00708a;
  --gold: #ffd84d;
  --green: #1eb53a;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --emerald: #26890c;
  --radius: 16px;
  --shadow: 0 4px 0 rgba(0, 0, 0, .18);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 10px rgba(16, 24, 40, .08), 0 12px 28px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 50px rgba(5, 20, 45, .3);
  --ease-out: cubic-bezier(.2, .9, .3, 1);
  --ease-back: cubic-bezier(.3, 1.6, .6, 1);
  color-scheme: light;
}

/* ================= Ranglar (tungi) ================= */
[data-theme="dark"] {
  --page: #0b1220;
  --surface: #141d30;
  --surface-2: #1c273d;
  --surface-3: #27344f;
  --ink: #e8edf6;
  --muted: #95a1b9;
  --line: #253049;
  --field: #0f1727;
  --btn: #0a8aa3;
  --stage-1: #061428;
  --stage-2: #063f49;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
html.theme-anim * { transition: background-color .3s, color .3s, border-color .3s, fill .3s !important; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(160deg, var(--stage-1), var(--stage-2)) fixed;
  -webkit-tap-highlight-color: transparent;
}
body.light { background: var(--page); color: var(--ink); }

/* Oʻzbek naqshi (girih) — sahna fonida sekin suzadi */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='white' stroke-width='1.4'%3E%3Crect x='27' y='27' width='42' height='42'/%3E%3Crect x='27' y='27' width='42' height='42' transform='rotate(45 48 48)'/%3E%3Ccircle cx='48' cy='48' r='9'/%3E%3Cpath d='M0 0l27 27M96 0L69 27M0 96l27-27M96 96L69 69M48 0v18M48 78v18M0 48h18M78 48h18'/%3E%3C/g%3E%3C/svg%3E");
  animation: drift 120s linear infinite;
}
body.light::before { display: none; }
@keyframes drift { to { background-position: 960px 480px; } }

.flagbar { position: relative; z-index: 2; height: 5px; background: linear-gradient(var(--brand) 0 40%, #fff 40% 45%, var(--red) 45% 55%, #fff 55% 60%, var(--green) 60%); }

.hidden { display: none !important; }
.screen { position: relative; z-index: 1; min-height: calc(100vh - 5px); display: flex; flex-direction: column; }
.screen.enter { animation: screenIn .38s var(--ease-out) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; }

/* ---- Ikonkalar ---- */
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.18em; }
.medal { width: 64px; height: 80px; flex: none; }

/* ---- Logotip ---- */
.logo { display: inline-flex; align-items: center; gap: 14px; font-weight: 900; font-size: clamp(40px, 9vw, 68px); letter-spacing: -1.5px; margin: 0 0 6px; text-shadow: 0 4px 0 rgba(0,0,0,.18); }
.logo .hl, .brandname .hl { color: var(--gold); }
body.light .brandname .hl { color: var(--brand); }
.mark { display: inline-grid; place-items: center; width: 1.15em; height: 1.15em; border-radius: 28%; background: linear-gradient(135deg, #ffe680, #ffb800); color: var(--navy); box-shadow: 0 6px 0 rgba(0,0,0,.18); text-shadow: none; animation: bob 4s ease-in-out infinite; }
.mark .ic { width: 62%; height: 62%; stroke-width: 2.4; }
.mark.sm { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 3px 0 rgba(0,0,0,.15); animation: none; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-6deg); } }
.tagline { opacity: .88; margin: 0 0 28px; font-size: 18px; }

/* ---- Panel va maydonlar ---- */
.panel { background: var(--surface); color: var(--ink); border-radius: 20px; padding: 22px; width: 100%; max-width: 390px; box-shadow: var(--shadow-lg); animation: rise .5s var(--ease-out) both; }
.panel input, .panel select { width: 100%; font: inherit; font-weight: 800; font-size: 22px; text-align: center; padding: 14px; border: 2px solid var(--line); border-radius: 12px; margin-bottom: 12px; outline: none; color: var(--ink); background: var(--field); transition: border-color .2s, box-shadow .2s; }
.panel input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,153,181,.18); }
.panel input::placeholder { color: var(--muted); opacity: .8; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* ---- Tugmalar ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 800; font-size: 18px; border: 0; border-radius: 12px; padding: 14px 22px; cursor: pointer; color: #fff; background: var(--btn); box-shadow: var(--shadow); transition: transform .12s var(--ease-out), filter .15s, box-shadow .12s, background-color .2s; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.brand { background: var(--brand); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red) !important; color: #fff !important; }
.btn.ghost { background: rgba(255,255,255,.14); box-shadow: none; }
.btn.ghost:hover { background: rgba(255,255,255,.22); }
.btn.light { background: #fff; color: var(--navy); }
.btn.small { font-size: 14px; padding: 9px 14px; border-radius: 10px; }
.btn.icon-only { padding: 9px; width: 38px; height: 38px; }
.btn.telegram { background: #229ed9; }
body.light .btn.ghost { background: var(--surface-2); color: var(--ink); }
body.light .btn.ghost:hover { background: var(--surface-3); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(0,153,181,.55); outline-offset: 2px; }

.error { color: var(--red); min-height: 22px; margin: 4px 0 0; font-size: 15px; }
[data-theme="dark"] .error { color: #ff6b81; }
.link { color: #fff; opacity: .88; margin-top: 22px; font-size: 15px; }
.link a { color: var(--gold); }
.corner-tools { position: fixed; top: 14px; right: 14px; z-index: 5; display: flex; gap: 8px; }

/* ---- Javob rangi va shakllari ---- */
.a0 { background: var(--red); }
.a1 { background: var(--blue); }
.a2 { background: var(--yellow); }
.a3 { background: var(--emerald); }
.shape { width: 32px; height: 32px; flex: none; fill: #fff; }

/* ---- Spinner va kutish nuqtalari ---- */
.spinner { width: 46px; height: 46px; border: 5px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.dots::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.pop { animation: pop .45s var(--ease-back) both; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
.shake { animation: shake .5s ease both; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.topbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: rgba(0,0,0,.18); font-weight: 800; backdrop-filter: blur(10px); }
body.light .topbar { background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--line); }
.topbar .brandname { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; font-size: 22px; letter-spacing: -.5px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 800; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: calc(100% - 32px); animation: toastIn .4s var(--ease-back) both; }
[data-theme="dark"] .toast { background: var(--surface-3); }
.toast.out { animation: toastOut .3s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 10px); } }

/* Zakovat jamoalari ranglari (8 tagacha) */
.t0 { --team: #e21b3c; } .t1 { --team: #1368ce; } .t2 { --team: #d89e00; } .t3 { --team: #26890c; }
.t4 { --team: #5b3f9e; } .t5 { --team: #0a7c86; } .t6 { --team: #c2410c; } .t7 { --team: #9d174d; }
:is(.t0, .t1, .t2, .t3, .t4, .t5, .t6, .t7) { background: var(--team); }

.team-chip { display: inline-block; color: #fff; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 900; margin-left: 6px; }

/* ================= Oʻquvchi ekranlari (telefon) ================= */
.answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
.answers.tf { grid-template-columns: 1fr; }
.ans { border: 0; border-radius: var(--radius); color: #fff; font: inherit; font-weight: 800; font-size: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; min-height: 110px; word-break: break-word; transition: opacity .25s, transform .12s; animation: tileIn .45s var(--ease-back) both; }
.ans:nth-child(2) { animation-delay: .06s; }
.ans:nth-child(3) { animation-delay: .12s; }
.ans:nth-child(4) { animation-delay: .18s; }
.ans .shape { width: 44px; height: 44px; transition: transform .2s; }
.ans:hover .shape { transform: scale(1.12) rotate(-6deg); }
.ans:active { transform: scale(.97); }
.ans.dim { opacity: .3; }
.ans.picked { outline: 5px solid #fff; outline-offset: -5px; }
@keyframes tileIn { from { opacity: 0; transform: translateY(16px) scale(.92); } }

.qtext { padding: 14px 16px 4px; font-size: 19px; font-weight: 800; text-align: center; animation: screenIn .4s var(--ease-out) both; }
.timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.25); border-radius: 99px; min-width: 48px; padding: 4px 12px; text-align: center; transition: background-color .3s; }
.timer.low { background: var(--red); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.bottombar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,.25); font-weight: 800; }
.score-chip { background: var(--navy); padding: 4px 12px; border-radius: 8px; font-variant-numeric: tabular-nums; }

#result { transition: background-color .3s; }
#result.good { background: linear-gradient(160deg, #1eb53a, #128a2b); }
#result.bad { background: linear-gradient(160deg, #e21b3c, #a5122b); }

/* Katta ikonka nishoni */
.badge-icon { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 6px rgba(255,255,255,.12); animation: badgeIn .6s var(--ease-back) both; }
.badge-icon .ic { width: 64px; height: 64px; stroke-width: 2.2; }
.badge-icon .medal { width: 80px; height: 100px; }
.badge-icon.gold { background: rgba(255,216,77,.22); }
@keyframes badgeIn { from { transform: scale(0) rotate(-30deg); opacity: 0; } }
.big { font-size: 34px; font-weight: 900; margin: 6px 0; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(0,0,0,.25); border-radius: 99px; padding: 8px 18px; margin: 6px; font-weight: 800; animation: pop .45s var(--ease-back) .15s both; }
.rankno { font-size: 96px; font-weight: 900; line-height: 1; }
.countdown { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; font-size: 84px; font-weight: 900; margin: 20px auto; border: 8px solid rgba(255,255,255,.25); border-top-color: var(--gold); animation: spin 1s linear infinite; }
.countdown span { display: block; animation: spinBack 1s linear infinite; }
@keyframes spinBack { to { transform: rotate(-360deg); } }

/* ================= Zakovat (telefon) ================= */
.zp-choices { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; margin-top: 10px; }
.zp-choice { display: flex; justify-content: space-between; align-items: center; border: 0; border-radius: var(--radius); color: #fff; font: inherit; font-weight: 900; font-size: 22px; padding: 16px 20px; box-shadow: var(--shadow); cursor: pointer; animation: tileIn .45s var(--ease-back) both; transition: transform .12s; }
.zp-choice:active { transform: scale(.97); }
.zp-choice small { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; opacity: .9; }
.zp-choice.on { outline: 4px solid #fff; outline-offset: -4px; }
.zp-team { width: 100%; max-width: 360px; margin: 10px 0; }
.zp-team-name { border-radius: 14px 14px 0 0; padding: 12px; font-size: 26px; font-weight: 900; }
.zp-members { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; background: rgba(0,0,0,.22); border-radius: 0 0 14px 14px; padding: 12px; }
.zp-members span { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.14); border-radius: 99px; padding: 4px 12px; font-size: 15px; }
.zp-members span.cap { background: #fff; color: var(--navy); }
.zp-members .ic, .zp-role .ic, .zk-me-role .ic, .zq-label .ic { color: var(--gold); fill: var(--gold); }
.zp-members span.cap .ic { color: #e0a800; fill: #ffd84d; }
.zp-role { font-size: 17px; max-width: 340px; }
.zk-me-role { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }

.zq-text { padding: 14px 16px 6px; font-size: 18px; font-weight: 800; line-height: 1.4; white-space: pre-line; max-height: 38vh; overflow-y: auto; animation: screenIn .4s var(--ease-out) both; }
.zq-img { display: block; max-width: calc(100% - 32px); max-height: 26vh; margin: 6px auto; border-radius: 12px; }
.zq-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 10px 14px 16px; }
.zq-body > .pill { align-self: center; }
.zq-form { background: var(--surface); color: var(--ink); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-lg); animation: rise .4s var(--ease-out) both; }
.zq-label { display: flex; align-items: center; gap: 6px; font-weight: 900; margin-bottom: 8px; }
.zq-row { display: flex; gap: 8px; }
.zq-row input { flex: 1; min-width: 0; font: inherit; font-weight: 800; font-size: 20px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: var(--field); }
.zq-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,153,181,.18); }
.zq-row .btn { padding: 12px 16px; font-size: 16px; }
.zq-status { margin-top: 10px; font-size: 15px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.zq-status small { flex-basis: 100%; font-size: 13px; }
.zq-status b { color: var(--ink); }
.zq-status.ok, .zq-status.ok .ic { color: var(--green); }
.zq-status.warn { color: var(--red); font-weight: 900; animation: pulse .5s infinite alternate; }
.zq-ideas-title { font-weight: 900; opacity: .85; margin-bottom: 8px; }
.zq-idea { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; border: 2px solid transparent; border-radius: 12px; background: rgba(0,0,0,.25); color: #fff; font: inherit; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; animation: tileIn .35s var(--ease-back) both; transition: border-color .2s, background-color .2s; }
.zq-idea b { font-size: 18px; word-break: break-word; }
.zq-idea small { opacity: .75; font-size: 13px; }
.zq-idea.chosen { border-color: var(--gold); background: rgba(255,216,77,.16); }

#z-result.good { background: linear-gradient(160deg, #1eb53a, #128a2b); }
#z-result.bad { background: linear-gradient(160deg, #e21b3c, #a5122b); }
.zr-comment { max-width: 420px; background: rgba(0,0,0,.2); border-radius: 14px; padding: 12px 16px; line-height: 1.45; }

/* ================= Oʻz oʻyini (telefon) ================= */
.bp-turn { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 360px; padding: 26px 18px; border-radius: 22px; background: rgba(0,0,0,.22); animation: rise .45s var(--ease-out) both; }
.bp-turn .ic { width: 52px; height: 52px; }
.bp-turn b { font-size: 26px; }
.bp-turn span { opacity: .85; }
.bp-turn.mine { background: var(--team); box-shadow: 0 0 0 4px #fff, var(--shadow-lg); animation: rise .45s var(--ease-out) both, pulse .8s .5s infinite alternate; }
.bp-turn.mine .ic { color: #ffd84d; fill: #ffd84d; }
.bp-standing { font-size: 17px; font-weight: 800; }
.bp-standing .ic { color: var(--gold); }
.bp-banner { display: flex; align-items: center; gap: 12px; margin: 12px 14px 0; padding: 14px 16px; border-radius: 16px; background: rgba(0,0,0,.25); text-align: left; animation: rise .4s var(--ease-out) both; }
.bp-banner .ic { width: 36px; height: 36px; flex: none; }
.bp-banner b { display: block; font-size: 19px; }
.bp-banner span { display: block; font-size: 14px; opacity: .9; }
.bp-banner.mine { background: var(--team); box-shadow: 0 0 0 3px #fff; }
.bp-banner.cat { background: linear-gradient(135deg, #6d28d9, #4c1d95); }
.bp-banner.luck { background: linear-gradient(135deg, #d89e00, #b45309); }
.bp-results { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 10px 14px; }
.bp-results .bd-res { display: inline-flex; align-items: center; gap: 6px; background: rgba(0,0,0,.25); border-radius: 99px; padding: 3px 12px 3px 3px; font-size: 15px; }
.bp-results .team-chip { margin: 0; }
.bp-results .bd-res.plus b { color: #8ff0a4; }
.bp-results .bd-res.minus b { color: #ffd0d7; }
#b-result.good { background: linear-gradient(160deg, #1eb53a, #128a2b); }
#b-result.bad { background: linear-gradient(160deg, #e21b3c, #a5122b); }

/* ================= Oʻqituvchi pulti (telefon) ================= */
.rm-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; }
.rm-head b { font-size: 17px; }
.rm-head .muted { font-size: 13px; }
.rm-scores { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px 0; }
.rm-scores span { display: inline-flex; align-items: center; gap: 6px; color: #fff; border-radius: 99px; padding: 4px 12px; font-weight: 900; font-size: 14px; }
.rm-scores span.turn { box-shadow: 0 0 0 3px var(--ink); }
.rm-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.rm-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow-sm); }
.rm-tag { font-size: 13px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.rm-q { font-size: 17px; font-weight: 800; margin: 6px 0 0; }
.rm-answer { background: color-mix(in srgb, var(--green) 14%, transparent); border: 2px solid var(--green); border-radius: 14px; padding: 12px 14px; }
.rm-answer b { display: block; font-size: 24px; color: var(--green); }
.rm-answer small { color: var(--muted); }
.rm-grid { display: grid; gap: 6px; }
.rm-grid .tp { font-size: 12px; font-weight: 900; display: flex; align-items: center; color: var(--muted); line-height: 1.1; }
.rm-grid button { border: 0; border-radius: 10px; padding: 12px 0; font: inherit; font-weight: 900; font-size: 15px; color: #ffd84d; background: linear-gradient(160deg, #1d4ed8, #1e3a8a); cursor: pointer; }
.rm-grid button:disabled { background: var(--surface-2); color: transparent; }
.rm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rm-btns .btn { padding: 18px; font-size: 20px; }
.rm-btns .wide { grid-column: 1 / -1; }

/* Konfetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
