* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f4ff;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── TYPOGRAPHY ── */
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 19px; font-weight: 600; margin-bottom: 4px; }
h3 { font-size: 16px; font-weight: 600; }
p  { font-size: 14px; line-height: 1.6; }
.sub { font-size: 14px; color: #6b6b8a; margin-top: 4px; }

/* ── LAYOUT ── */
.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── CARDS ── */
.card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e8e6f8;
  padding: 20px 22px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ── BUTTONS ── */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid #d4d0f0;
  background: #fff;
  color: #1a1a2e;
  padding: 9px 18px;
  transition: background 0.15s, transform 0.1s;
}
button:hover { background: #f0effe; }
button:active { transform: scale(0.98); }

.btn-primary {
  background: #534AB7;
  color: #fff;
  border-color: #534AB7;
}
.btn-primary:hover { background: #3C3489; border-color: #3C3489; }

.btn-success {
  background: #1D9E75;
  color: #fff;
  border-color: #1D9E75;
}
.btn-success:hover { background: #0F6E56; }

.btn-danger {
  background: #fff;
  color: #A32D2D;
  border-color: #f09595;
}
.btn-danger:hover { background: #FCEBEB; }

.btn-large {
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ── INPUTS ── */
input, textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid #d4d0f0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #1a1a2e;
  margin-bottom: 10px;
}
input:focus, textarea:focus { outline: none; border-color: #534AB7; }
input.search-input { padding-left: 36px; }

.input-group {
  position: relative;
  margin-bottom: 10px;
}
.input-group .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: #9090b0;
}
.input-group input { margin-bottom: 0; padding-left: 34px; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.badge-purple { background: #EEEDFE; color: #3C3489; }
.badge-green  { background: #EAF3DE; color: #27500A; }
.badge-amber  { background: #FAEEDA; color: #633806; }
.badge-red    { background: #FCEBEB; color: #A32D2D; }
.badge-teal   { background: #E1F5EE; color: #085041; }

/* ── TABS ── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid #e8e6f8;
  margin-bottom: 18px;
}
.tab {
  padding: 9px 16px;
  font-size: 14px;
  border: none;
  background: none;
  color: #6b6b8a;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
}
.tab:hover { background: #f5f4ff; color: #534AB7; }
.tab.active { color: #534AB7; border-bottom-color: #534AB7; font-weight: 600; background: none; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── MESSAGES ── */
.msg-error   { font-size: 13px; color: #A32D2D; margin-top: 6px; min-height: 18px; }
.msg-success { font-size: 13px; color: #1D9E75; margin-top: 6px; }
.msg-info    { font-size: 13px; color: #534AB7; margin-top: 6px; }

/* ── ROLE SELECTOR ── */
.logo-box { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; margin-bottom: 10px; }

.role-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.role-card {
  width: 200px;
  padding: 28px 20px;
  text-align: center;
  border-radius: 16px;
  border: 1.5px solid #d4d0f0;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.role-card:hover { border-color: #534AB7; box-shadow: 0 4px 16px #534AB720; background: #fff; }
.role-icon  { font-size: 36px; margin-bottom: 10px; }
.role-label { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.role-desc  { font-size: 12px; color: #6b6b8a; }

/* ── STUDENT CHIPS ── */
.student-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid #e8e6f8;
  margin-bottom: 6px;
  font-size: 13px;
  background: #fff;
}
.student-row.highlight { border-color: #534AB7; background: #f5f4ff; }
.student-row .del-btn {
  border: none; background: none; padding: 0;
  color: #b0b0c8; font-size: 16px; cursor: pointer; line-height: 1;
}
.student-row .del-btn:hover { color: #A32D2D; background: none; }
mark { background: #FAC775; color: #412402; border-radius: 2px; padding: 0 2px; }

/* ── FORMAT BOX ── */
.format-box {
  background: #f5f4ff;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 13px;
}
.col-pill {
  display: inline-block;
  background: #EEEDFE;
  color: #3C3489;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin: 2px;
  font-family: monospace;
}

/* ── QUESTION PREVIEW ── */
.q-preview-card {
  background: #fff;
  border: 1px solid #e8e6f8;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.q-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.q-opts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.q-opt {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 7px;
  background: #f5f4ff;
  color: #6b6b8a;
}
.q-opt.correct { background: #EAF3DE; color: #27500A; }

/* ── METRICS ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.metric-box {
  background: #f5f4ff;
  border-radius: 10px;
  padding: 14px 16px;
}
.metric-val { font-size: 24px; font-weight: 700; color: #534AB7; }
.metric-lbl { font-size: 12px; color: #6b6b8a; margin-top: 2px; }

/* ── LOBBY ── */
.lobby-box {
  text-align: center;
  padding: 40px 24px;
}
.join-count {
  font-size: 64px;
  font-weight: 700;
  color: #534AB7;
  line-height: 1;
  margin: 16px 0 4px;
}
.join-label { font-size: 14px; color: #6b6b8a; margin-bottom: 32px; }

.waiting-box { text-align: center; padding: 48px 24px; }
.waiting-spinner {
  width: 48px; height: 48px;
  border: 4px solid #e8e6f8;
  border-top-color: #534AB7;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── QUIZ SCREEN ── */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.q-counter { font-size: 13px; color: #6b6b8a; }
.timer-display {
  font-size: 32px;
  font-weight: 700;
  color: #534AB7;
  min-width: 52px;
  text-align: center;
}
.timer-display.warn { color: #A32D2D; }

.progress-bar {
  height: 6px;
  background: #e8e6f8;
  border-radius: 3px;
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-fill {
  height: 6px;
  background: #534AB7;
  border-radius: 3px;
  transition: width 0.5s;
}

.q-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 18px;
}

.opt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.opt-btn {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid #e8e6f8;
  background: #fff;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}
.opt-btn:hover:not(:disabled) { border-color: #534AB7; background: #f5f4ff; }
.opt-btn:disabled { cursor: default; }
.opt-letter {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.opt-A .opt-letter { background: #EEEDFE; color: #3C3489; }
.opt-B .opt-letter { background: #E1F5EE; color: #085041; }
.opt-C .opt-letter { background: #FAEEDA; color: #633806; }
.opt-D .opt-letter { background: #FAECE7; color: #712B13; }

.opt-btn.selected  { border-color: #534AB7; background: #f5f4ff; }
.opt-btn.correct   { border-color: #1D9E75; background: #EAF3DE; }
.opt-btn.correct .opt-letter { background: #1D9E75; color: #fff; }
.opt-btn.wrong     { border-color: #A32D2D; background: #FCEBEB; }
.opt-btn.wrong .opt-letter { background: #A32D2D; color: #fff; }
.opt-btn.dimmed    { opacity: 0.45; }

.answered-wait {
  text-align: center;
  padding: 20px;
  font-size: 14px;
  color: #6b6b8a;
}

/* ── LEADERBOARD ── */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f0effe;
}
.lb-row:last-child { border-bottom: none; }
.lb-rank {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
  background: #f5f4ff;
  color: #6b6b8a;
}
.lb-rank.gold   { background: #FAEEDA; color: #633806; font-size: 18px; }
.lb-rank.silver { background: #F1EFE8; color: #444441; font-size: 16px; }
.lb-rank.bronze { background: #FAECE7; color: #712B13; font-size: 15px; }
.lb-name { flex: 1; font-size: 14px; }
.lb-name.you { font-weight: 600; color: #534AB7; }
.lb-score { font-size: 14px; font-weight: 600; }

/* ── PODIUM ── */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
}
.podium-col { text-align: center; }
.podium-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-size: 12px; color: #6b6b8a; margin-bottom: 6px; }
.podium-block {
  border-radius: 10px 10px 0 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  width: 90px;
}
.podium-1 .podium-block { height: 110px; background: #FAEEDA; }
.podium-2 .podium-block { height: 80px;  background: #F1EFE8; }
.podium-3 .podium-block { height: 60px;  background: #FAECE7; }

/* ── RESULTS TABLE ── */
.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th {
  text-align: left; padding: 8px 10px;
  border-bottom: 1.5px solid #e8e6f8;
  color: #6b6b8a; font-weight: 600; font-size: 12px;
}
.results-table td { padding: 9px 10px; border-bottom: 1px solid #f0effe; }
.results-table tr:last-child td { border-bottom: none; }

/* ── STATUS BAR (teacher quiz) ── */
.status-bar {
  background: #534AB7;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #5DCAA5;
  display: inline-block;
  margin-right: 6px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── TEACHER QUIZ CONTROLS ── */
.teacher-controls {
  background: #fff;
  border: 1px solid #e8e6f8;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  text-align: center;
}
.control-label { font-size: 12px; color: #6b6b8a; margin-bottom: 10px; }

/* ── ANSWER STATS BAR ── */
.answer-stats {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.ans-stat {
  flex: 1;
  min-width: 60px;
  text-align: center;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 12px;
}
.ans-stat .count { font-size: 20px; font-weight: 700; }
.ans-stat.opt-A-stat { background: #EEEDFE; color: #3C3489; }
.ans-stat.opt-B-stat { background: #E1F5EE; color: #085041; }
.ans-stat.opt-C-stat { background: #FAEEDA; color: #633806; }
.ans-stat.opt-D-stat { background: #FAECE7; color: #712B13; }
.ans-stat.no-ans-stat { background: #f5f4ff; color: #6b6b8a; }

/* ── SCREEN STATES ── */
.screen { display: none; }
.screen.active { display: block; }

.full-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

/* ── HEADER BAR ── */
.top-bar {
  background: #fff;
  border-bottom: 1px solid #e8e6f8;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}
.top-bar h2 { font-size: 16px; margin: 0; }

/* ── MISC ── */
.divider { border: none; border-top: 1px solid #e8e6f8; margin: 16px 0; }
.text-muted { color: #6b6b8a; font-size: 13px; }
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0  { margin-bottom: 0; }

@media (max-width: 520px) {
  .opt-grid { grid-template-columns: 1fr; }
  .podium-block { width: 70px; }
  .role-cards { flex-direction: column; align-items: center; }
}
