/* ==========================================================================
   QuizArena — design system
   ========================================================================== */
:root {
  --bg: #0b0a1f;
  --bg-2: #141234;
  --surface: rgba(255, 255, 255, .055);
  --surface-2: rgba(255, 255, 255, .09);
  --surface-solid: #1a1840;
  --line: rgba(255, 255, 255, .12);
  --line-2: rgba(255, 255, 255, .2);
  --text: #f5f3ff;
  --text-2: #c9c5ee;
  --muted: #9a96c8;
  --brand: #7c5cff;
  --brand-2: #c43cf0;
  --brand-3: #ff5c8a;
  --gold: #ffc53d;
  --ok: #19d38a;
  --bad: #ff4d6a;
  --warn: #ffb020;
  --a0: #e8356d;
  --a1: #7c4dff;
  --a2: #ff9f1c;
  --a3: #14b8a6;
  --grad: linear-gradient(135deg, #7c5cff 0%, #c43cf0 55%, #ff5c8a 100%);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(6, 4, 30, .45);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: #b9a8ff; text-decoration: none; }
a:hover { color: #fff; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grow { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Animated background ---------------------------------------------------- */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(1200px 800px at 80% -10%, #2a1c7a 0%, transparent 60%), radial-gradient(900px 700px at -10% 110%, #3b0f5c 0%, transparent 60%), var(--bg); }
.bg-orbs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .45; animation: orb 22s ease-in-out infinite alternate; }
.bg-orbs i:nth-child(1) { width: 420px; height: 420px; background: #6d4bff; top: -120px; left: -80px; }
.bg-orbs i:nth-child(2) { width: 360px; height: 360px; background: #d63cf0; bottom: -120px; right: -60px; animation-duration: 26s; }
.bg-orbs i:nth-child(3) { width: 280px; height: 280px; background: #ff5c8a; top: 40%; left: 55%; opacity: .25; animation-duration: 30s; }
@keyframes orb { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(60px, 40px) scale(1.12); } 100% { transform: translate(-40px, 80px) scale(.95); } }
#fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }

/* Buttons ---------------------------------------------------------------- */
.btn {
  --bgc: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bgc); color: var(--text); font: inherit; font-weight: 700; font-size: .95rem;
  cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
  text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--grad); border-color: transparent; box-shadow: 0 8px 24px rgba(124, 92, 255, .35); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); box-shadow: 0 10px 30px rgba(196, 60, 240, .45); }
.btn-white { background: #fff; color: #1b1740; border-color: #fff; }
.btn-white:hover { background: #f1eeff; color: #1b1740; }
.btn-danger { background: rgba(255, 77, 106, .14); border-color: rgba(255, 77, 106, .4); color: #ff9fb0; }
.btn-danger:hover { background: rgba(255, 77, 106, .25); color: #fff; }
.btn-ok { background: linear-gradient(135deg, #12b981, #19d38a); border-color: transparent; color: #04261a; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn-xl { padding: 18px 34px; font-size: 1.3rem; border-radius: 16px; }
.btn-block { width: 100%; }
.icon-btn { width: 42px; height: 42px; padding: 0; border-radius: 12px; }
.btn svg, .icon-btn svg { width: 18px; height: 18px; flex: none; }

/* Forms ------------------------------------------------------------------ */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; color: var(--text-2); }
label > svg { width: 15px; height: 15px; vertical-align: -2px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(8, 6, 30, .55); color: var(--text); font: inherit; font-size: 1rem;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: #7470a3; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(124, 92, 255, .22); background: rgba(8, 6, 30, .75); }
textarea.input { resize: vertical; min-height: 90px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b9b4e8' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
select.input option { background: #1a1840; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.field + .field { margin-top: 16px; }
.field.err .input { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-weight: 600; color: var(--text); margin: 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 44px; height: 26px; border-radius: 99px; background: rgba(255, 255, 255, .16); position: relative; transition: background .2s; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s cubic-bezier(.3, 1.4, .5, 1); box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(124, 92, 255, .3); }
.switch small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }

.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: rgba(8, 6, 30, .55); border: 1px solid var(--line); gap: 4px; flex-wrap: wrap; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: .85rem; color: var(--muted); transition: all .15s; }
.seg input:checked + span { background: var(--brand); color: #fff; }

/* Cards / surfaces ------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-h h2, .card-h h3 { margin: 0; }
.glass { background: rgba(20, 17, 55, .6); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; border: 1px solid; animation: slideDown .35s ease; }
.flash.ok { background: rgba(25, 211, 138, .12); border-color: rgba(25, 211, 138, .4); color: #8ff0c6; }
.flash.err { background: rgba(255, 77, 106, .12); border-color: rgba(255, 77, 106, .4); color: #ffb0bf; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 800; letter-spacing: .02em; background: var(--surface-2); color: var(--text-2); }
.badge.live { background: rgba(255, 77, 106, .18); color: #ff9fb0; }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff4d6a; animation: pulse 1.2s infinite; }
.badge.ok { background: rgba(25, 211, 138, .15); color: #7ff0bf; }
.badge.brand { background: rgba(124, 92, 255, .2); color: #c9bbff; }

/* Host panel layout ------------------------------------------------------ */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px; padding: 12px 24px; background: rgba(11, 10, 31, .72); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: #fff; letter-spacing: -.02em; }
.logo:hover { color: #fff; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(196, 60, 240, .4); }
.logo-mark svg { width: 20px; height: 20px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: .92rem; white-space: nowrap; }
.nav a:hover { color: #fff; background: var(--surface); }
.nav a.on { color: #fff; background: var(--surface-2); }
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .9rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-weight: 800; font-size: .85rem; color: #fff; flex: none; }
.lang-btn { font-weight: 800; font-size: .8rem; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--text-2); }
.lang-btn:hover { color: #fff; border-color: var(--line-2); }
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 80px; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-h h1 { font-size: 1.9rem; margin: 0; }
.page-h p { margin: 4px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: var(--grad); opacity: .14; }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-weight: 600; font-size: .88rem; }

.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.quiz-card { display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: transform .2s, border-color .2s, box-shadow .2s; }
.quiz-card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow); }
.quiz-cover { height: 110px; position: relative; display: flex; align-items: flex-end; padding: 14px 16px; background: var(--grad); overflow: hidden; }
.quiz-cover::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .35), transparent 40%), repeating-linear-gradient(45deg, rgba(255, 255, 255, .06) 0 12px, transparent 12px 24px); }
.quiz-cover .badge { position: relative; background: rgba(0, 0, 0, .28); color: #fff; }
.quiz-cover.t-ocean { background: linear-gradient(135deg, #1f6bff, #14b8a6); }
.quiz-cover.t-sunset { background: linear-gradient(135deg, #ff7a18, #ff3d77); }
.quiz-cover.t-forest { background: linear-gradient(135deg, #0f9d6b, #9ad934); }
.quiz-cover.t-night { background: linear-gradient(135deg, #283593, #6a1b9a); }
.quiz-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.quiz-body h3 { font-size: 1.1rem; margin: 0; }
.quiz-body p { color: var(--muted); font-size: .88rem; margin: 0; flex: 1; }
.quiz-actions { display: flex; gap: 8px; padding: 0 16px 16px; flex-wrap: wrap; }
.quiz-actions .btn-primary { flex: 1; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; padding: 12px 14px; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .06); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255, 255, 255, .025); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-pill { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 9px; font-weight: 800; background: var(--surface-2); }
.rank-pill.r1 { background: linear-gradient(135deg, #ffd66b, #ffb000); color: #3a2600; }
.rank-pill.r2 { background: linear-gradient(135deg, #eef1f6, #b8c0cc); color: #20242c; }
.rank-pill.r3 { background: linear-gradient(135deg, #f4b88a, #c97a45); color: #2e1606; }
.bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--grad); }
.live-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); border: 1.5px dashed var(--line-2); border-radius: var(--radius); }
.empty svg { width: 54px; height: 54px; opacity: .6; margin: 0 auto 12px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: #fff; border-color: var(--brand); }
.progress { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .4s ease; border-radius: inherit; }

/* Auth pages ------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .logo { justify-content: center; margin-bottom: 22px; font-size: 1.4rem; }

/* Modal ------------------------------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 4, 20, .7); backdrop-filter: blur(6px); }
.modal.open { display: flex; animation: fadeIn .2s ease; }
.modal-box { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); animation: popIn .3s cubic-bezier(.2, 1.4, .4, 1); }

/* Quiz builder ----------------------------------------------------------- */
.builder { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.q-list { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.q-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; transition: all .15s; }
.q-item:hover { border-color: var(--line-2); }
.q-item.on { border-color: var(--brand); background: rgba(124, 92, 255, .14); box-shadow: 0 0 0 3px rgba(124, 92, 255, .15); }
.q-item.dragging { opacity: .4; }
.q-item.drop-before { box-shadow: 0 -3px 0 var(--brand-3); }
.q-item .qn { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.q-item .qt { flex: 1; font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item .qt.empty-t { color: var(--muted); font-style: italic; }
.q-item .grip { cursor: grab; color: var(--muted); }
.q-item.bad { border-color: rgba(255, 77, 106, .6); }
.q-editor { display: flex; flex-direction: column; gap: 18px; }
.q-text { font-size: 1.35rem; font-weight: 700; text-align: center; min-height: 100px; padding: 18px; }
.q-media { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.q-img-prev { max-height: 200px; border-radius: 12px; border: 1px solid var(--line); }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; border: 2px solid transparent; transition: border-color .15s, box-shadow .15s; }
.opt.c0 { background: color-mix(in srgb, var(--a0) 22%, transparent); }
.opt.c1 { background: color-mix(in srgb, var(--a1) 22%, transparent); }
.opt.c2 { background: color-mix(in srgb, var(--a2) 22%, transparent); }
.opt.c3 { background: color-mix(in srgb, var(--a3) 22%, transparent); }
.opt .shape { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.opt .input { background: rgba(8, 6, 30, .45); border-color: transparent; }
.opt.is-correct { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(25, 211, 138, .15); }
.tick { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: transparent; display: grid; place-items: center; cursor: pointer; color: transparent; transition: all .15s; }
.tick svg { width: 18px; height: 18px; }
.tick:hover { border-color: #fff; }
.opt.is-correct .tick { background: var(--ok); border-color: var(--ok); color: #04261a; }
.q-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.save-bar { position: sticky; bottom: 16px; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; margin-top: 10px; box-shadow: var(--shadow); }

/* Answer shapes (shared) ------------------------------------------------- */
.bg-a0 { background: var(--a0); } .bg-a1 { background: var(--a1); } .bg-a2 { background: var(--a2); } .bg-a3 { background: var(--a3); }
.shape svg { width: 60%; height: 60%; fill: #fff; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }

/* ==========================================================================
   Player app
   ========================================================================== */
.play { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; font-weight: 700; }
.play-top .pill { padding: 6px 12px; border-radius: 99px; background: rgba(0, 0, 0, .28); font-size: .85rem; }
.play-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; text-align: center; position: relative; }
.play-bottom { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: rgba(255, 255, 255, .96); color: #1b1740; font-weight: 800; }
.play-bottom .score-chip { background: #1b1740; color: #fff; padding: 6px 14px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.screen { width: 100%; max-width: 480px; animation: popIn .45s cubic-bezier(.2, 1.3, .4, 1); }
.join-card { background: rgba(255, 255, 255, .97); color: #1b1740; border-radius: 22px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.join-card .input { background: #f3f1fb; border: 2px solid #e2def5; color: #1b1740; text-align: center; font-weight: 800; font-size: 1.25rem; padding: 14px; }
.join-card .input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(124, 92, 255, .18); }
.join-card .input::placeholder { color: #a19cc4; font-weight: 700; }
.join-card .btn { width: 100%; margin-top: 12px; background: #1b1740; color: #fff; border: 0; font-size: 1.15rem; padding: 15px; }
.join-card .btn:hover { background: #2b2566; }
.join-card .hint { color: #7a76a0; text-align: center; }
.join-card .err-msg { color: #d6334f; font-weight: 700; font-size: .9rem; margin-top: 10px; min-height: 1.2em; }
.pin-input { letter-spacing: .3em; font-size: 1.7rem !important; }
.pin-input:placeholder-shown { letter-spacing: .02em; font-size: 1.3rem !important; }
.hero-logo { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 2.3rem; font-weight: 800; margin-bottom: 26px; letter-spacing: -.03em; }
.hero-logo .logo-mark { width: 52px; height: 52px; border-radius: 15px; }
.hero-logo .logo-mark svg { width: 30px; height: 30px; }
.tagline { color: var(--text-2); margin-top: 18px; font-size: .95rem; }
.big-title { font-size: clamp(1.8rem, 7vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: 10px; }
.nick-badge { display: inline-block; margin-top: 14px; padding: 10px 22px; border-radius: 14px; background: rgba(255, 255, 255, .95); color: #1b1740; font-size: 1.4rem; font-weight: 800; animation: bob 2.4s ease-in-out infinite; }
.spinner-dots { display: inline-flex; gap: 8px; margin-top: 22px; }
.spinner-dots i { width: 12px; height: 12px; border-radius: 50%; background: #fff; animation: dot 1.2s infinite ease-in-out; }
.spinner-dots i:nth-child(2) { animation-delay: .15s; } .spinner-dots i:nth-child(3) { animation-delay: .3s; }

.q-card { background: rgba(255, 255, 255, .96); color: #1b1740; border-radius: 18px; padding: 18px; font-size: clamp(1.1rem, 4.4vw, 1.5rem); font-weight: 800; line-height: 1.3; box-shadow: 0 12px 36px rgba(0, 0, 0, .3); }
.q-card img { max-height: 28vh; margin: 12px auto 0; border-radius: 10px; object-fit: contain; }
.intro-bar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .2); overflow: hidden; margin-top: 18px; }
.intro-bar i { display: block; height: 100%; background: #fff; border-radius: inherit; width: 100%; transform-origin: left; }

.answer-wrap { width: 100%; max-width: 900px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.p-timer { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.p-timer i { display: block; height: 100%; background: linear-gradient(90deg, #19d38a, #ffc53d, #ff4d6a); background-size: 300% 100%; border-radius: inherit; width: 100%; }
.p-qtext { font-weight: 800; font-size: clamp(1rem, 3.8vw, 1.3rem); padding: 4px 6px; }
.answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 52vh; }
.answers.n2 { grid-template-columns: 1fr 1fr; }
.ans {
  position: relative; border: 0; border-radius: 16px; color: #fff; font: inherit; font-weight: 800;
  font-size: clamp(1rem, 4vw, 1.35rem); padding: 14px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; line-height: 1.25;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .22), 0 8px 20px rgba(0, 0, 0, .25);
  transition: transform .12s ease, filter .2s, opacity .3s; -webkit-tap-highlight-color: transparent; overflow: hidden;
}
.ans .shape { width: 56px; height: 56px; display: grid; place-items: center; }
.ans.has-text .shape { width: 38px; height: 38px; }
.ans:active { transform: scale(.96); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .22); }
.ans:hover { filter: brightness(1.08); }
.ans::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 255, 255, .45), transparent 45%); opacity: 0; transition: opacity .4s; }
.ans.tapped::after { opacity: 1; }
.answers.done .ans:not(.picked) { opacity: .25; filter: grayscale(.6); transform: scale(.96); }
.answers.done .ans.picked { transform: scale(1.02); box-shadow: 0 0 0 4px #fff, 0 12px 30px rgba(0, 0, 0, .35); }

.fb { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; animation: fadeIn .25s ease; }
.fb.good { background: radial-gradient(circle at 50% 35%, #2be39b 0%, #0e9f68 60%, #07744b 100%); }
.fb.bad { background: radial-gradient(circle at 50% 35%, #ff6b83 0%, #d9304f 60%, #9e1733 100%); }
.fb.none { background: radial-gradient(circle at 50% 35%, #6c68a8 0%, #3c3873 60%, #26234f 100%); }
.fb .fb-icon { width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .95); display: grid; place-items: center; animation: stamp .55s cubic-bezier(.2, 1.6, .4, 1); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.fb .fb-icon svg { width: 60px; height: 60px; }
.fb.good .fb-icon svg { stroke: #0e9f68; }
.fb.bad .fb-icon svg { stroke: #d9304f; }
.fb.none .fb-icon svg { stroke: #3c3873; }
.fb h2 { font-size: clamp(2rem, 9vw, 3rem); margin: 22px 0 6px; font-weight: 800; text-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.fb .streak { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 99px; background: rgba(0, 0, 0, .2); font-weight: 800; margin-top: 8px; }
.fb .streak .flame { display: inline-block; animation: flame .5s ease-in-out infinite alternate; }
.fb .gain { font-size: 2.2rem; font-weight: 800; margin-top: 14px; padding: 6px 22px; border-radius: 14px; background: rgba(0, 0, 0, .22); font-variant-numeric: tabular-nums; animation: popIn .5s .25s both cubic-bezier(.2, 1.6, .4, 1); }
.fb .rank-line { margin-top: 26px; font-size: 1.15rem; font-weight: 700; opacity: .95; animation: slideUp .5s .5s both ease; }
.fb .rank-line small { display: block; font-size: .95rem; opacity: .85; font-weight: 600; margin-top: 4px; }
.fb.shake .fb-icon { animation: stamp .55s cubic-bezier(.2, 1.6, .4, 1), shake .5s .5s ease; }

.rank-card { background: rgba(255, 255, 255, .96); color: #1b1740; border-radius: 22px; padding: 26px; box-shadow: 0 16px 50px rgba(0, 0, 0, .35); }
.rank-card .big { font-size: 4rem; font-weight: 800; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rank-card .mv { display: inline-flex; gap: 6px; align-items: center; font-weight: 800; padding: 4px 12px; border-radius: 99px; margin-top: 10px; }
.rank-card .mv.up { background: #d6f9e9; color: #0b7a4b; }
.rank-card .mv.down { background: #ffe0e6; color: #b3203c; }
.medal { font-size: 4.5rem; line-height: 1; animation: bob 2s ease-in-out infinite; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .3)); }
.final-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.final-stats div { background: #f3f1fb; border-radius: 14px; padding: 12px; }
.final-stats b { display: block; font-size: 1.5rem; }
.final-stats span { font-size: .8rem; color: #6b6890; font-weight: 700; }

.net-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100; text-align: center; padding: 8px; background: var(--warn); color: #3a2600; font-weight: 800; font-size: .9rem; transform: translateY(-100%); transition: transform .3s; }
.net-banner.show { transform: none; }
.sound-toggle { position: fixed; right: 14px; bottom: 70px; z-index: 30; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); color: #fff; display: grid; place-items: center; cursor: pointer; }
.sound-toggle svg { width: 20px; height: 20px; }

/* ==========================================================================
   Host live screen
   ========================================================================== */
.live-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.live-bar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; }
.live-bar .grow { flex: 1; }
.live-bar .ttl { font-weight: 800; font-size: 1.05rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-stage { flex: 1; display: flex; flex-direction: column; padding: 0 28px 24px; min-height: 0; }
.live-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: rgba(0, 0, 0, .25); border-top: 1px solid var(--line); }

.lobby-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; background: rgba(255, 255, 255, .97); color: #1b1740; border-radius: 22px; padding: 22px 28px; box-shadow: var(--shadow); animation: slideDown .5s ease; }
.lobby-head .join-line { font-size: clamp(1.1rem, 2vw, 1.6rem); font-weight: 700; color: #4a4770; }
.lobby-head .join-url { font-weight: 800; color: #1b1740; }
.lobby-head .pin-label { font-size: 1rem; font-weight: 800; color: #6b6890; text-transform: uppercase; letter-spacing: .12em; margin-top: 8px; }
.lobby-head .pin { font-size: clamp(3rem, 8vw, 6rem); font-weight: 800; letter-spacing: .06em; line-height: 1; font-variant-numeric: tabular-nums; }
.qr { background: #fff; padding: 8px; border-radius: 14px; border: 2px solid #eeebfa; }
.qr img, .qr canvas, .qr svg { width: clamp(120px, 14vw, 190px); height: auto; display: block; image-rendering: pixelated; }
.lobby-mid { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 14px; flex-wrap: wrap; }
.count-badge { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 14px; background: rgba(0, 0, 0, .3); font-size: 1.4rem; font-weight: 800; }
.count-badge svg { width: 26px; height: 26px; }
.count-badge b { font-variant-numeric: tabular-nums; }
.players-cloud { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 10px; padding: 6px; }
.p-chip { padding: 9px 16px; border-radius: 12px; background: rgba(255, 255, 255, .95); color: #1b1740; font-weight: 800; font-size: 1.05rem; cursor: pointer; animation: chipIn .5s cubic-bezier(.2, 1.6, .4, 1) both; transition: background .2s, transform .15s; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-chip:hover { background: #ffd9e1; text-decoration: line-through; transform: scale(1.04); }
.p-chip.more { background: rgba(255, 255, 255, .15); color: #fff; cursor: default; text-decoration: none; }
.waiting-big { font-size: 1.5rem; font-weight: 800; opacity: .85; margin: auto; text-align: center; }

.hq-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.hq-text { background: rgba(255, 255, 255, .97); color: #1b1740; border-radius: 20px; padding: 22px 28px; text-align: center; font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 800; line-height: 1.25; box-shadow: var(--shadow); animation: slideDown .45s ease; }
.hq-mid { flex: 1; display: grid; grid-template-columns: 170px minmax(0, 1fr) 170px; align-items: center; gap: 20px; min-height: 0; padding: 18px 0; }
.hq-img { display: flex; align-items: center; justify-content: center; min-height: 0; height: 100%; }
.hq-img img { max-height: 34vh; border-radius: 16px; box-shadow: var(--shadow); object-fit: contain; animation: popIn .5s ease; }
.hq-deco { display: flex; flex-direction: column; align-items: center; gap: 10px; opacity: .22; }
.hq-deco svg { width: clamp(80px, 12vw, 160px); height: auto; fill: #fff; animation: bob 3s ease-in-out infinite; }
.hq-deco span { font-size: 1.4rem; font-weight: 800; letter-spacing: .1em; }
.timer-ring { position: relative; width: 150px; height: 150px; justify-self: center; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 10; }
.timer-ring .trk { stroke: rgba(255, 255, 255, .15); }
.timer-ring .prg { stroke: #fff; stroke-linecap: round; transition: stroke .3s; }
.timer-ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 3.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-ring.hot .prg { stroke: #ff4d6a; }
.timer-ring.hot .val { animation: heartbeat .5s ease-in-out infinite; color: #ffb0bf; }
.ans-count { justify-self: center; text-align: center; }
.ans-count b { display: block; font-size: 3.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ans-count span { font-weight: 700; opacity: .8; }
.h-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.h-ans { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 16px; color: #fff; font-weight: 800; font-size: clamp(1.05rem, 2vw, 1.6rem); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2); animation: slideUp .45s both ease; position: relative; overflow: hidden; min-height: 76px; }
.h-ans:nth-child(2) { animation-delay: .07s; } .h-ans:nth-child(3) { animation-delay: .14s; } .h-ans:nth-child(4) { animation-delay: .21s; }
.h-ans .shape { flex: none; width: 44px; height: 44px; display: grid; place-items: center; }
.h-ans .txt { flex: 1; }
.h-ans .chk { flex: none; width: 40px; height: 40px; border-radius: 50%; background: #fff; display: grid; place-items: center; animation: stamp .5s cubic-bezier(.2, 1.6, .4, 1); }
.h-ans .chk svg { width: 24px; height: 24px; stroke: #0e9f68; }
.h-answers.revealed .h-ans.wrong { opacity: .3; filter: grayscale(.5); }
.h-answers.revealed .h-ans.right { box-shadow: 0 0 0 4px #fff, 0 0 40px rgba(255, 255, 255, .35); }
.intro-q { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; text-align: center; }
.intro-q .qnum { font-size: 1.3rem; font-weight: 800; padding: 8px 20px; border-radius: 99px; background: rgba(0, 0, 0, .3); animation: popIn .4s ease; }
.intro-q .hq-text { max-width: 1100px; font-size: clamp(1.8rem, 4vw, 3.4rem); }
.intro-q .intro-bar { width: min(600px, 80%); }
.q-flags { display: flex; gap: 8px; justify-content: center; }
.q-flags .badge { font-size: .9rem; padding: 6px 12px; }

.chart { display: flex; align-items: flex-end; justify-content: center; gap: clamp(14px, 3vw, 40px); height: 100%; min-height: 200px; padding: 0 10px; }
.chart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: clamp(70px, 10vw, 130px); }
.chart .col .cnt { font-size: 1.8rem; font-weight: 800; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.chart .col .cnt svg { width: 26px; height: 26px; stroke: #19d38a; }
.chart .col .barv { width: 100%; border-radius: 12px 12px 4px 4px; height: 6px; transition: height 1s cubic-bezier(.2, .9, .3, 1); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; min-height: 44px; }
.chart .col .barv .shape { width: 30px; height: 30px; display: grid; place-items: center; }
.chart .col.wrong { opacity: .4; }

.lb { max-width: 900px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; flex: 1; justify-content: center; }
.lb-title { text-align: center; font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; margin-bottom: 8px; animation: slideDown .4s ease; }
.lb-row { display: flex; align-items: center; gap: 16px; padding: 14px 22px; border-radius: 16px; background: rgba(255, 255, 255, .96); color: #1b1740; font-size: clamp(1.1rem, 2vw, 1.6rem); font-weight: 800; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: lbIn .6s both cubic-bezier(.2, 1.2, .4, 1); }
.lb-row .rk { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #efedfa; flex: none; }
.lb-row:nth-child(2) .rk { background: linear-gradient(135deg, #ffd66b, #ffb000); color: #3a2600; }
.lb-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .st { font-size: .85rem; color: #e0521f; display: flex; align-items: center; gap: 4px; }
.lb-row .mv { font-size: .85rem; color: #0b7a4b; }
.lb-row .mv.down { color: #b3203c; }
.lb-row .sc { font-variant-numeric: tabular-nums; min-width: 110px; text-align: right; }

.podium-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: clamp(10px, 2vw, 22px); width: 100%; max-width: 980px; }
.pod { flex: 1; display: flex; flex-direction: column; align-items: center; opacity: 0; transform: translateY(40px); transition: all .8s cubic-bezier(.2, 1.3, .4, 1); }
.pod.show { opacity: 1; transform: none; }
.pod .who { font-size: clamp(1.2rem, 2.4vw, 2rem); font-weight: 800; text-align: center; margin-bottom: 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pts { font-weight: 700; opacity: .85; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.pod .medal { font-size: clamp(3rem, 6vw, 5rem); margin-bottom: 6px; }
.pod .block { width: 100%; border-radius: 16px 16px 0 0; display: grid; place-items: start center; padding-top: 18px; font-size: clamp(2.5rem, 6vw, 5rem); font-weight: 800; color: rgba(255, 255, 255, .9); box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .15); }
.pod.p1 .block { height: 38vh; background: linear-gradient(180deg, #ffcf4d, #f59e0b); }
.pod.p2 .block { height: 27vh; background: linear-gradient(180deg, #d9dee8, #9aa3b3); }
.pod.p3 .block { height: 19vh; background: linear-gradient(180deg, #f0a877, #b8622d); }
.pod.p1 .who { color: #ffd66b; text-shadow: 0 0 30px rgba(255, 200, 60, .6); }
.finish-panel { max-width: 720px; width: 100%; margin: auto; text-align: center; }
.finish-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.finish-stats div { padding: 16px; border-radius: 16px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); }
.finish-stats b { display: block; font-size: 2rem; font-weight: 800; }
.finish-stats span { color: var(--muted); font-weight: 700; font-size: .9rem; }
.countdown { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; pointer-events: none; }
.countdown span { font-size: 38vh; font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 20px 60px rgba(0, 0, 0, .4); animation: countPop 1s ease forwards; }

/* Keyframes -------------------------------------------------------------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: none; } }
@keyframes chipIn { 0% { opacity: 0; transform: scale(.3) rotate(-8deg); } 100% { opacity: 1; transform: none; } }
@keyframes lbIn { from { opacity: 0; transform: translateX(-60px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes stamp { 0% { transform: scale(2.2); opacity: 0; } 60% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-14px) rotate(-4deg); } 40% { transform: translateX(12px) rotate(3deg); } 60% { transform: translateX(-8px); } 80% { transform: translateX(6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes dot { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes flame { from { transform: scale(1) rotate(-6deg); } to { transform: scale(1.2) rotate(6deg); } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes countPop { 0% { transform: scale(.3); opacity: 0; } 30% { transform: scale(1.1); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, .5); } 50% { box-shadow: 0 0 0 14px rgba(124, 92, 255, 0); } }
.glow { animation: glow 1.8s infinite; }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 960px) {
  .builder { grid-template-columns: 1fr; }
  .q-list { position: static; max-height: none; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .q-item { min-width: 170px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hq-mid { grid-template-columns: 110px minmax(0, 1fr) 110px; }
  .timer-ring { width: 104px; height: 104px; }
  .timer-ring .val { font-size: 2.2rem; }
}
@media (max-width: 680px) {
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar .nav { order: 3; width: 100%; flex: 1 1 100%; }
  .user-chip .uname { display: none; }
  .container { padding: 20px 16px 70px; }
  .form-grid, .q-settings { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
  .page-h h1 { font-size: 1.5rem; }
  .lobby-head { grid-template-columns: 1fr; text-align: center; padding: 18px; }
  .lobby-head .qr { justify-self: center; }
  .live-stage { padding: 0 14px 16px; }
  .h-answers { grid-template-columns: 1fr; }
  .hq-mid { grid-template-columns: 1fr 1fr; }
  .hq-mid .hq-img { grid-column: 1 / -1; order: -1; }
  .finish-stats { grid-template-columns: 1fr; }
  .answers { min-height: 58vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
