:root {
  --bg: #f6f4ff;
  --card: #ffffff;
  --text: #1f1b3a;
  --muted: #6b6889;
  --line: #e6e2f7;
  --brand: #6d4aff;
  --brand-dark: #5233e0;
  --brand-soft: #efeaff;
  --ok: #16a34a;
  --bad: #e11d48;
  --c0: #f2545b;
  --c1: #7c5cff;
  --c2: #f5a524;
  --c3: #12b5a6;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(31, 27, 58, .08), 0 10px 30px rgba(31, 27, 58, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* --- navigatsiya --- */
.nav {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 900; font-size: 26px; color: var(--brand); letter-spacing: -.5px; }
.logo span { color: var(--c2); }
.nav .links { display: flex; gap: 18px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav .links a { color: var(--text); font-weight: 700; }
.nav .links a:hover { color: var(--brand); }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 16px 60px; }

/* --- tugmalar va formalar --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 800; font-size: 16px;
  padding: 12px 22px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--brand); color: #fff;
  box-shadow: 0 4px 0 var(--brand-dark);
  transition: transform .08s, box-shadow .08s, filter .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.light { background: var(--card); color: var(--text); box-shadow: 0 4px 0 var(--line); border: 2px solid var(--line); }
.btn.green { background: var(--ok); box-shadow: 0 4px 0 #0f7a36; }
.btn.danger { background: var(--bad); box-shadow: 0 4px 0 #a3123a; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.big { font-size: 22px; padding: 16px 34px; border-radius: 18px; }
.btn.block { width: 100%; }

input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  font: inherit; width: 100%; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--text);
  outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); }
label { font-weight: 700; display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 700; }
.flash.error { background: #ffe4ea; color: #9f1239; }
.flash.success { background: #dcfce7; color: #166534; }

/* --- bosh sahifa --- */
.hero {
  min-height: calc(100vh - 66px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; text-align: center;
}
.hero h1 { font-size: clamp(34px, 6vw, 56px); font-weight: 900; }
.hero p { font-size: 18px; color: var(--muted); max-width: 520px; }
.pin-card { width: 100%; max-width: 380px; margin: 20px 0; }
.pin-card input { font-size: 26px; text-align: center; font-weight: 800; letter-spacing: 4px; margin-bottom: 12px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; max-width: 900px; width: 100%; margin-top: 30px; }
.feature { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); text-align: left; }
.feature .icon { font-size: 30px; }

.auth-wrap { max-width: 420px; margin: 40px auto; }

/* --- boshqaruv paneli --- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.quiz-card { display: flex; flex-direction: column; gap: 10px; }
.quiz-card h3 { margin: 0; font-size: 20px; }
.quiz-card .meta { color: var(--muted); font-size: 14px; }
.quiz-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.quiz-card form { margin: 0; }
.empty { text-align: center; padding: 50px 20px; }
.empty .icon { font-size: 60px; }

.host-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.host-form select { width: auto; padding: 8px 10px; font-size: 14px; }

table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.table-wrap { overflow-x: auto; }

/* --- test muharriri --- */
.editor-top { display: grid; gap: 12px; }
.editor-top input.title { font-size: 24px; font-weight: 800; }
.q-card { margin-top: 18px; }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.q-num { background: var(--brand); color: #fff; font-weight: 900; border-radius: 10px; padding: 4px 12px; }
.q-head .spacer { flex: 1; }
.q-settings { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.q-settings .field { margin: 0; min-width: 150px; }
.q-settings select { padding: 8px 10px; }
.q-image-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.q-image-row img { max-height: 110px; border-radius: 12px; border: 2px solid var(--line); }
.choices-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.choice-edit {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 14px; color: #fff;
}
.choice-edit input[type=text] { border: 0; background: rgba(255,255,255,.95); }
.choice-edit .shape { font-size: 22px; width: 26px; text-align: center; }
.choice-edit .correct-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff;
  background: transparent; color: #fff; font-size: 20px; cursor: pointer; flex-shrink: 0;
}
.choice-edit .correct-toggle.on { background: #fff; color: var(--ok); }
.save-bar {
  position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 16px; display: flex; gap: 12px; align-items: center; justify-content: flex-end;
  margin: 24px -16px 0; z-index: 5;
}
.save-bar .status { margin-right: auto; font-weight: 700; color: var(--muted); }

/* --- javob variantlari ranglari (umumiy) --- */
.c0 { background: var(--c0); }
.c1 { background: var(--c1); }
.c2 { background: var(--c2); }
.c3 { background: var(--c3); }

/* --- o'yin ekranlari --- */
body.game {
  background: linear-gradient(160deg, #6d4aff 0%, #8b5cf6 45%, #ec4899 100%);
  background-attachment: fixed;
  color: #fff;
  overflow-x: hidden;
}
body.game .bubbles span {
  position: fixed; border-radius: 50%; background: rgba(255,255,255,.08); z-index: 0; pointer-events: none;
  animation: float 14s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-40px) scale(1.08); } }
.stage { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.stage-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 16px; gap: 18px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; font-weight: 800; }
.topbar .logo { color: #fff; }
.pill { background: rgba(255,255,255,.2); padding: 6px 14px; border-radius: 999px; font-weight: 800; }
.white-card { background: #fff; color: var(--text); border-radius: 22px; padding: 24px; box-shadow: 0 10px 0 rgba(0,0,0,.12); }

/* xost: lobbi */
.lobby-head { display: flex; gap: 24px; align-items: stretch; justify-content: center; flex-wrap: wrap; width: 100%; max-width: 1100px; }
.join-box { display: flex; flex-direction: column; justify-content: center; text-align: center; min-width: 280px; }
.join-box .url { font-size: 20px; font-weight: 800; word-break: break-all; }
.join-box .pin { font-size: clamp(48px, 9vw, 96px); font-weight: 900; letter-spacing: 6px; color: var(--brand); line-height: 1; margin: 6px 0; }
.qr-box { display: flex; align-items: center; justify-content: center; padding: 16px; }
.qr-box img, .qr-box canvas { display: block; }
.players-wrap { width: 100%; max-width: 1100px; }
.players-count { font-size: 22px; font-weight: 900; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.chip {
  background: #fff; color: var(--text); font-weight: 800; padding: 10px 16px; border-radius: 14px;
  box-shadow: 0 4px 0 rgba(0,0,0,.12); animation: pop .35s cubic-bezier(.3,1.6,.6,1);
  cursor: pointer; border: 0; font: inherit; font-weight: 800; font-size: 18px;
}
.chip:hover { text-decoration: line-through; background: #ffe4ea; }
.chip.off { opacity: .5; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.team-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.team-col { background: rgba(255,255,255,.14); border-radius: 18px; padding: 14px; }
.team-col h3 { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.team-col .chips { justify-content: flex-start; }
.waiting-dots::after { content: ""; animation: dots 1.5s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* xost: savol */
.q-title {
  background: #fff; color: var(--text); font-size: clamp(22px, 3.4vw, 40px); font-weight: 900;
  padding: 20px 28px; border-radius: 20px; text-align: center; max-width: 1100px; width: 100%;
  box-shadow: 0 8px 0 rgba(0,0,0,.12);
}
.q-middle { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; max-width: 1100px; }
.q-middle .q-img { flex: 1; display: flex; justify-content: center; }
.q-middle .q-img img { max-height: 34vh; max-width: 100%; border-radius: 18px; background: #fff; }
.timer {
  width: 110px; height: 110px; border-radius: 50%; background: #fff; color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 46px; font-weight: 900;
  box-shadow: 0 6px 0 rgba(0,0,0,.15); flex-shrink: 0;
}
.timer.hurry { color: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.answer-counter { text-align: center; font-weight: 900; font-size: 22px; min-width: 110px; }
.answer-counter b { display: block; font-size: 48px; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 1100px; }
.answer-tile {
  display: flex; align-items: center; gap: 14px; color: #fff; font-weight: 800;
  font-size: clamp(18px, 2.4vw, 28px); padding: 20px 22px; border-radius: 18px; min-height: 90px;
  box-shadow: 0 6px 0 rgba(0,0,0,.18); position: relative; transition: opacity .3s;
}
.answer-tile .shape { font-size: 1.3em; }
.answer-tile.dim { opacity: .35; }
.answer-tile .mark { margin-left: auto; font-size: 1.3em; }
.preview-bar { width: min(600px, 90%); height: 14px; border-radius: 99px; background: rgba(255,255,255,.25); overflow: hidden; }
.preview-bar div { height: 100%; background: #fff; border-radius: 99px; width: 0; }

/* natija ustunlari */
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 18px; height: 26vh; min-height: 150px; width: 100%; max-width: 700px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-col .bar { width: 100%; border-radius: 12px 12px 4px 4px; min-height: 8px; transition: height .8s cubic-bezier(.2,.9,.3,1); box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.bar-col .num { font-size: 26px; font-weight: 900; }
.bar-col.dim .bar { opacity: .35; }

/* reyting */
.leader-list { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 10px; }
.leader-row {
  display: flex; align-items: center; gap: 14px; background: #fff; color: var(--text);
  padding: 14px 20px; border-radius: 16px; font-size: 22px; font-weight: 800;
  box-shadow: 0 5px 0 rgba(0,0,0,.12); animation: slide .5s both;
}
.leader-row .place { width: 40px; font-weight: 900; color: var(--brand); }
.leader-row .score { margin-left: auto; }
@keyframes slide { from { transform: translateX(-40px); opacity: 0; } }
.team-bars { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 10px; }
.team-bar { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; }
.team-bar .label { width: 190px; display: flex; gap: 8px; align-items: center; }
.team-bar .track { flex: 1; background: rgba(255,255,255,.2); border-radius: 12px; height: 34px; overflow: hidden; }
.team-bar .fill { height: 100%; border-radius: 12px; transition: width 1s cubic-bezier(.2,.9,.3,1); display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; font-size: 16px; }

/* podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin-top: 10px; }
.podium .step { width: min(200px, 28vw); text-align: center; }
.podium .name { font-size: clamp(18px, 2.5vw, 28px); font-weight: 900; margin-bottom: 8px; word-break: break-word; animation: pop .6s both; }
.podium .block {
  background: #fff; color: var(--brand); border-radius: 16px 16px 0 0; font-weight: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 14px;
  font-size: 44px; box-shadow: 0 -4px 0 rgba(0,0,0,.08) inset;
}
.podium .block small { font-size: 16px; color: var(--muted); }
.podium .p1 .block { height: 240px; }
.podium .p2 .block { height: 180px; }
.podium .p3 .block { height: 130px; }
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 50; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* o'yinchi */
.player-card { width: 100%; max-width: 420px; text-align: center; }
.player-card h2 { font-size: 26px; }
.player-card input { font-size: 22px; text-align: center; font-weight: 800; margin-bottom: 12px; }
.team-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.team-pick button {
  font: inherit; font-weight: 800; border: 3px solid transparent; border-radius: 14px; padding: 12px 8px;
  color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.team-pick button .emoji { font-size: 30px; }
.team-pick button small { opacity: .85; font-weight: 700; }
.team-pick button.sel { border-color: var(--text); transform: scale(1.04); box-shadow: 0 0 0 3px #fff inset; }
.avatar-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.avatar-pick button {
  font-size: 26px; aspect-ratio: 1; border-radius: 12px; border: 3px solid transparent;
  background: var(--brand-soft); cursor: pointer; padding: 0; transition: transform .1s;
}
.avatar-pick button.sel { border-color: var(--brand); background: #fff; transform: scale(1.12); }
@media (max-width: 420px) { .avatar-pick { grid-template-columns: repeat(6, 1fr); } }
.status-big { font-size: clamp(28px, 7vw, 44px); font-weight: 900; text-align: center; }
.emoji-big { font-size: 80px; line-height: 1; animation: pop .5s both; }
.player-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 700px; flex: 1; max-height: 60vh; }
.player-answers.two { grid-template-columns: 1fr 1fr; }
.player-answers button {
  border: 0; border-radius: 20px; color: #fff; font: inherit; font-weight: 900; font-size: 20px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px;
  box-shadow: 0 7px 0 rgba(0,0,0,.2); min-height: 110px; transition: transform .08s;
}
.player-answers button .shape { font-size: 42px; }
.player-answers button:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.player-q { background: rgba(255,255,255,.95); color: var(--text); border-radius: 16px; padding: 14px 18px; font-weight: 800; font-size: 20px; text-align: center; width: 100%; max-width: 700px; }
.player-q img { max-width: 100%; max-height: 160px; border-radius: 10px; display: block; margin: 10px auto 0; }
.result-screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; z-index: 2; }
.result-screen.good { background: linear-gradient(160deg, #22c55e, #0d9488); }
.result-screen.bad { background: linear-gradient(160deg, #f43f5e, #b91c1c); }
.result-screen.none { background: linear-gradient(160deg, #64748b, #334155); }
.points-badge { background: rgba(0,0,0,.18); padding: 10px 22px; border-radius: 14px; font-size: 28px; font-weight: 900; }
.player-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; background: rgba(0,0,0,.15); font-weight: 800; gap: 10px; }
.team-tag { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: 999px; color: #fff; font-weight: 800; }
.host-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.errline { color: var(--bad); font-weight: 800; min-height: 1.4em; margin-top: 6px; }

/* hisobot */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { text-align: center; }
.stat b { font-size: 32px; display: block; color: var(--brand); }
.pbar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 80px; }
.pbar div { height: 100%; background: var(--ok); }
.cell-ok { color: var(--ok); font-weight: 900; }
.cell-bad { color: var(--bad); font-weight: 900; }

@media (max-width: 700px) {
  .choices-edit { grid-template-columns: 1fr; }
  .answer-grid { grid-template-columns: 1fr; }
  .q-middle { flex-wrap: wrap; justify-content: center; }
  .timer { width: 80px; height: 80px; font-size: 34px; }
  .team-bar .label { width: 120px; font-size: 16px; }
  .nav { padding: 12px 16px; }
}
