/* Quiz Live — giao diện chung, tông xanh lá đậm */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 20% -10%, #14432B 0%, #0B2E1D 55%, #061F13 100%);
  background-attachment: fixed;
  color: #EFFBF3;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 24px 16px 70px; }
.wrap.wide { max-width: 960px; }

.logo { text-align: center; margin: 6px 0 20px; }
.logo .big { font-size: 38px; font-weight: 900; letter-spacing: -1px; color: #fff; }
.logo .small-title { font-size: 21px; font-weight: 900; color: #fff; }
.logo .sigma { color: #FFD166; }
.logo .grad {
  background: linear-gradient(90deg, #6EE7B7, #FFD166);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.logo .sub { opacity: .7; margin-top: 4px; font-size: 15px; }

.card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 18px;
  padding: 20px;
}
.btn {
  border: none; border-radius: 12px; padding: 12px 22px;
  font-size: 16px; font-weight: 700; cursor: pointer; color: #fff;
  background: #059669; transition: transform .08s, filter .15s;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: rgba(255,255,255,.12); }
.btn.green { background: linear-gradient(135deg, #10B981, #047857); }
.btn.gold { background: linear-gradient(135deg, #F5B93B, #D97706); color: #123322; }
.btn.orange { background: linear-gradient(135deg, #F59E0B, #F97316); }
.btn.danger { background: rgba(226,27,60,.3); color: #FCA5A5; }
.btn.big { font-size: 19px; padding: 15px 30px; border-radius: 14px; }
.btn.full { width: 100%; }
.btn.sm { padding: 8px 13px; font-size: 14px; border-radius: 10px; }

.input, textarea.input, select.input {
  width: 100%; background: rgba(255,255,255,.94); color: #0B2E1D;
  border: 2px solid transparent; border-radius: 10px;
  padding: 11px 14px; font-size: 16px; font-weight: 600; outline: none;
  font-family: inherit;
}
.input:focus { border-color: #10B981; }
.input.auto { width: auto; }
.label {
  font-size: 13px; font-weight: 700; letter-spacing: .6px;
  opacity: .75; text-transform: uppercase; margin-bottom: 6px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.center { text-align: center; }
.muted { opacity: .7; }
.gold { color: #FFD166; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.pin-display {
  font-size: 62px; font-weight: 900; letter-spacing: 10px;
  color: #FFD166; text-shadow: 0 4px 30px rgba(255,209,102,.35);
  margin: 8px 0;
}
.player-chip {
  background: rgba(255,255,255,.1); border-radius: 999px;
  padding: 8px 18px; font-weight: 800; font-size: 16px;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.6); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.q-text { font-size: 22px; font-weight: 800; line-height: 1.55; }
.q-text .katex { font-size: 1.12em; }
.q-img { max-width: 100%; max-height: 340px; border-radius: 12px; display: block; margin: 14px auto 0; background: #fff; }

.mc-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 18px; }
@media (max-width: 520px) { .mc-grid { grid-template-columns: 1fr; } }
.mc-opt {
  border: none; border-radius: 14px; padding: 18px 14px; color: #fff;
  font-weight: 900; font-size: 17px; cursor: pointer; min-height: 76px;
  line-height: 1.4; font-family: inherit; text-align: center;
}
.mc-static { cursor: default; }
.mc-opt .shape { font-size: 21px; display: block; margin-bottom: 4px; }
.tf-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 18px; }
.tf-btn { min-height: 100px; font-size: 24px; }

.ta-inputs { display: grid; gap: 10px; margin-top: 16px; }
.ta-row { display: flex; align-items: center; gap: 10px; }
.ta-num {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center; font-weight: 900; flex-shrink: 0;
}

.rank-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 16px; font-weight: 800; font-size: 16px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.13);
  border-radius: 14px;
}
.rank-row.top3 { background: linear-gradient(90deg, rgba(255,209,102,.18), rgba(255,255,255,.05)); }
.rank-row.me { border: 2px solid #FFD166; }
.rank-pos { width: 44px; opacity: .8; }
.rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-delta { font-size: 13px; opacity: .85; min-width: 58px; text-align: right; }
.rank-up { color: #6EE7B7; } .rank-down { color: #F87171; }

.ring-wrap { position: relative; display: inline-block; }
.ring-num {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-weight: 900;
}
.ring-urgent { animation: pulse 1s ease infinite; }
@keyframes pulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.06) } }

.correct-box {
  font-size: 18px; font-weight: 900; color: #6EE7B7;
  background: rgba(110,231,183,.12); border-radius: 10px; padding: 10px 14px;
}
.dist-bar { height: 24px; border-radius: 6px; transition: width .5s; min-width: 8px; }

.result-good { background: linear-gradient(135deg, rgba(16,185,129,.4), rgba(16,185,129,.12)) !important; }
.result-mid  { background: linear-gradient(135deg, rgba(245,185,59,.35), rgba(245,185,59,.1)) !important; }
.result-bad  { background: linear-gradient(135deg, rgba(226,27,60,.35), rgba(226,27,60,.1)) !important; }

.q-editor { margin-bottom: 16px; }
.q-num {
  width: 34px; height: 34px; border-radius: 10px; background: #059669;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 900;
}
.opt-editor { display: flex; align-items: flex-start; gap: 8px; border-radius: 10px; padding: 6px 10px; }
.opt-editor input.input::placeholder { color: rgba(11,46,29,.4); font-weight: 500; font-style: italic; }
.opt-editor input[type=radio] { width: 20px; height: 20px; cursor: pointer; flex-shrink: 0; }
/* Nút tròn to đánh dấu đáp án đúng — trống = vòng trắng rỗng, tick = xanh lá có dấu ✓ */
.opt-editor input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  margin-top: 3px; cursor: pointer;
  border: 3.5px solid #fff; background: rgba(255,255,255,.14);
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  transition: background .12s, transform .08s;
}
.opt-editor input[type=checkbox]:hover { background: rgba(255,255,255,.32); transform: scale(1.06); }
.opt-editor input[type=checkbox]:checked {
  background: #26890C url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M5 12.5l4.5 4.5L19 7.5" fill="none" stroke="white" stroke-width="3.6" stroke-linecap="round" stroke-linejoin="round"/%3E%3C/svg%3E') center/66% no-repeat;
}
.opt-editor input[type=checkbox]:focus-visible { outline: 3px solid rgba(255,255,255,.75); outline-offset: 2px; }
.opt-editor .shape { font-weight: 900; flex-shrink: 0; margin-top: 9px; }
.opt-editor > .btn { margin-top: 3px; }
.opt-prev {
  min-height: 18px; margin-top: 4px; padding: 0 2px; font-size: 13.5px; line-height: 1.35;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.45); word-break: break-word;
}
.opt-prev .katex { font-size: 1.05em; }
.opts-grid { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .opts-grid { grid-template-columns: 1fr; } }

.math-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 6px; }
.math-toolbar button {
  background: rgba(255,255,255,.13); color: #EFFBF3; border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 14px; font-weight: 700;
}
.math-toolbar button:hover { background: rgba(255,255,255,.22); }
.preview-box {
  background: rgba(255,255,255,.9); color: #0B2E1D; border-radius: 10px;
  padding: 10px 14px; margin-top: 8px; min-height: 24px; font-weight: 600; line-height: 1.55;
}
.preview-box:empty::before { content: "Xem trước đề bài hiện ở đây…"; opacity: .45; font-weight: 500; }

.badge-public {
  display: inline-block; font-size: 12px; font-weight: 800; color: #123322;
  background: linear-gradient(135deg, #6EE7B7, #10B981); border-radius: 999px;
  padding: 2px 10px; vertical-align: middle; margin-left: 4px;
}

.folder-row {
  display: flex; gap: 12px; align-items: center; padding: 13px 18px;
  background: rgba(255,209,102,.09); border: 1px solid rgba(255,209,102,.25);
  border-radius: 14px; margin-bottom: 10px; cursor: pointer; font-weight: 800;
}
.folder-row:hover { background: rgba(255,209,102,.16); }
.breadcrumb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 700; margin-bottom: 14px; }
.breadcrumb a { color: #6EE7B7; cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* Lưu ý: KHÔNG đặt tên class này là "overlay" — KaTeX dùng class .overlay bên trong
   công thức (mũi tên \vec, dấu \ce...), trùng tên sẽ làm mất mũi tên vector. */
.mb-overlay {
  position: fixed; inset: 0; background: rgba(3,20,12,.75); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.mb-overlay .card { max-width: 440px; width: 100%; max-height: 80vh; overflow-y: auto; background: #0F3823; }

.report-table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.report-table th, .report-table td {
  border: 1px solid rgba(255,255,255,.15); padding: 8px 10px; text-align: center; white-space: nowrap;
}
.report-table th { background: rgba(255,255,255,.09); font-weight: 800; }
.report-table td.name-cell { text-align: left; font-weight: 800; position: sticky; left: 0; background: #0F3823; }
.report-table th.name-cell { position: sticky; left: 0; background: #145233; z-index: 2; }
.cell-c { background: rgba(16,185,129,.3); color: #A7F3D0; font-weight: 900; }
.cell-p { background: rgba(245,185,59,.25); color: #FDE68A; font-weight: 900; }
.cell-w { background: rgba(226,27,60,.25); color: #FCA5A5; font-weight: 900; }
.cell-s { opacity: .45; }
.table-scroll { overflow-x: auto; border-radius: 12px; }

.hint { font-size: 12.5px; opacity: .65; margin-top: 6px; }
.err {
  color: #FECACA; background: rgba(226,27,60,.15);
  border: 1px solid rgba(252,165,165,.4); border-radius: 12px;
  padding: 12px 16px; font-weight: 700; margin: 12px 0;
}
.big-emoji { font-size: 44px; }
.img-preview { max-height: 130px; border-radius: 10px; display: block; background: #fff; }
.mute-btn {
  position: fixed; bottom: 16px; right: 16px; z-index: 40;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12); color: #fff; font-size: 20px; cursor: pointer;
}

/* Xem trước đáp án toán (dưới ô nhập) */
.ans-prev { min-height: 22px; margin-top: 4px; padding-left: 4px; font-size: 17px; color: #A7F3D0; }
.ans-prev .katex { font-size: 1.05em; }
.ans-sep { opacity: .55; padding: 0 4px; }
.correct-box .katex, .result-good .katex, .result-bad .katex, .result-mid .katex { color: inherit; }

/* Tay nắm kéo-thả câu hỏi */
.drag-handle {
  cursor: grab; font-size: 18px; opacity: .5; padding: 4px 6px;
  user-select: none; border-radius: 8px; touch-action: none;
}
.drag-handle:hover { opacity: 1; background: rgba(255,255,255,.1); }
.q-editor.dragging { opacity: .45; }
.q-editor.drag-over { outline: 3px dashed #6EE7B7; outline-offset: 3px; }

/* Nút loa tắt/bật âm thanh */
.mute-btn {
  position: fixed; top: 12px; right: 12px; z-index: 999;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25);
  background: rgba(20,40,30,.75); font-size: 20px; cursor: pointer;
  backdrop-filter: blur(4px);
}
.mute-btn:hover { background: rgba(255,255,255,.15); }

/* Đếm ngược 3-2-1 */
.cd321 {
  position: fixed; inset: 0; z-index: 998; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.cd-num {
  font-size: 130px; font-weight: 900; color: #FFD166;
  text-shadow: 0 8px 50px rgba(0,0,0,.6);
  animation: cdpop .75s ease both;
}
.cd-go { color: #6EE7B7; font-size: 110px; }
@keyframes cdpop {
  0% { transform: scale(2.2); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: scale(.85); opacity: 0; }
}

/* Pháo giấy */
.confetti-canvas { position: fixed; inset: 0; z-index: 997; pointer-events: none; }

/* Khung chọn avatar */
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 6px; }
.avatar-btn {
  font-size: 24px; padding: 6px 0; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 2px solid transparent; transition: transform .1s;
}
.avatar-btn:hover { transform: scale(1.15); background: rgba(255,255,255,.16); }
.avatar-btn.sel { border-color: #FFD166; background: rgba(255,209,102,.2); }

/* Huy hiệu chuỗi lửa */
.streak-badge {
  display: inline-block; margin-top: 10px; padding: 8px 18px; border-radius: 999px;
  background: linear-gradient(90deg, #F97316, #DC2626); font-weight: 900; font-size: 16px;
  animation: streakpulse 1s ease infinite alternate;
}
@keyframes streakpulse { from { transform: scale(1); } to { transform: scale(1.07); } }

/* Bục vinh danh */
.podium {
  display: flex; align-items: flex-end; justify-content: center; gap: 10px;
  max-width: 640px; margin: 24px auto 6px; min-height: 260px;
}
.pod-slot { flex: 1; max-width: 120px; text-align: center; opacity: 0; transform: translateY(40px); transition: opacity .5s, transform .5s; }
.pod-slot.show { opacity: 1; transform: translateY(0); }
.pod-name { font-weight: 900; font-size: 15px; margin-bottom: 8px; line-height: 1.4; word-break: break-word; }
.pod-col {
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #34D399, #065F46);
  border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 8px;
  box-shadow: 0 -4px 30px rgba(52,211,153,.25);
}
#pod-0 .pod-col { background: linear-gradient(180deg, #FFD166, #B45309); box-shadow: 0 -4px 40px rgba(255,209,102,.4); }
#pod-1 .pod-col { background: linear-gradient(180deg, #E5E7EB, #6B7280); }
#pod-2 .pod-col { background: linear-gradient(180deg, #F59E0B, #92400E); }
.pod-medal { font-size: 26px; font-weight: 900; }
