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

:root {
  --mat: #e74c3c;
  --ipa: #27ae60;
  --ips: #f39c12;
  --bin: #9b59b6;
  --eng: #3498db;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.screen { display: none; width: 100%; max-width: 680px; }
.screen.active { display: block; }

.card {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 40px;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
  color: #fff;
}

h1.title {
  font-size: 2.6rem;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(90deg, #f093fb, #f5576c, #fda085);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
.subtitle {
  text-align: center;
  color: rgba(255,255,255,0.55);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
  font-size: 0.9rem;
}
.input-wrap { margin-bottom: 22px; }
.text-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s;
}
.text-input:focus { border-color: #f5576c; }
.text-input::placeholder { color: rgba(255,255,255,0.35); }
.text-input.correct { border-color: #27ae60; background: rgba(39,174,96,0.18); }
.text-input.wrong   { border-color: #e74c3c; background: rgba(231,76,60,0.18); }

/* Chip buttons */
.chip-grid { display: grid; gap: 9px; margin-bottom: 22px; }
.chip-grid.cat { grid-template-columns: repeat(3, 1fr); }
.chip-grid.num { grid-template-columns: repeat(4, 1fr); }

.chip {
  padding: 11px 8px;
  border-radius: 11px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.6);
  transition: all 0.25s;
  text-align: center;
  user-select: none;
}
.chip:hover { background: rgba(255,255,255,0.13); }
.chip.all  { color: #fda085; }
.chip.mat  { color: var(--mat); }
.chip.ipa  { color: var(--ipa); }
.chip.ips  { color: var(--ips); }
.chip.bin  { color: var(--bin); }
.chip.eng  { color: var(--eng); }
.chip.num  { color: #a29bfe; }
.chip.active { border-color: currentColor; background: rgba(255,255,255,0.13); color: #fff; }
.chip.mat.active  { color: var(--mat); }
.chip.ipa.active  { color: var(--ipa); }
.chip.ips.active  { color: var(--ips); }
.chip.bin.active  { color: var(--bin); }
.chip.eng.active  { color: var(--eng); }
.chip.all.active  { color: #fda085; }
.chip.num.active  { color: #a29bfe; }

/* Buttons */
.btn {
  width: 100%;
  padding: 15px;
  border-radius: 13px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.28s;
  margin-top: 10px;
}
.btn-primary {
  background: linear-gradient(135deg, #f5576c, #f093fb);
  color: #fff;
  letter-spacing: 0.4px;
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(245,87,108,0.45); }
.btn-outline {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.85);
}
.btn-outline:hover { background: rgba(255,255,255,0.09); }
.btn-danger {
  background: transparent;
  border: 2px solid rgba(231,76,60,0.5);
  color: #e74c3c;
}
.btn-danger:hover { background: rgba(231,76,60,0.12); }
.btn-sm { padding: 12px 15px; font-size: 0.95rem; }

/* Question screen */
.progress-wrap {
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  height: 7px;
  margin-bottom: 24px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #f5576c, #f093fb);
  transition: width 0.5s ease;
}

.q-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.subj-badge {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.q-num { color: rgba(255,255,255,0.55); font-size: 0.88rem; }

.type-chip {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  margin-bottom: 12px;
}
.q-text { font-size: 1.18rem; font-weight: 600; line-height: 1.65; margin-bottom: 26px; }

.options-list { display: grid; gap: 11px; }
.opt-btn {
  padding: 14px 18px;
  border-radius: 13px;
  border: 2px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.05);
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 0.97rem;
  transition: all 0.22s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.opt-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.35);
  transform: translateX(4px);
}
.opt-btn.correct { background: rgba(39,174,96,0.28); border-color: #27ae60; }
.opt-btn.wrong   { background: rgba(231,76,60,0.28); border-color: #e74c3c; }
.opt-btn:disabled { cursor: default; }
.opt-letter {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.13);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem;
  flex-shrink: 0;
}

.isian-row { display: flex; gap: 10px; align-items: stretch; }
.isian-row .text-input { flex: 1; }
.isian-row .btn-sm { width: auto; padding: 0 22px; margin-top: 0; border-radius: 12px; }

.feedback {
  margin-top: 14px;
  padding: 11px 15px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
}
.feedback.show { display: block; }
.feedback.ok  { background: rgba(39,174,96,0.2); color: #2ecc71; }
.feedback.err { background: rgba(231,76,60,0.2); color: #ff7675; }

.next-btn { margin-top: 20px; display: none; }
.next-btn.show { display: block; }

/* Timer */
.timer-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.timer-bar-track {
  flex: 1;
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.timer-bar-fill {
  height: 100%;
  border-radius: 8px;
  background: #27ae60;
  transition: width 1s linear, background 0.5s;
}
.timer-bar-fill.warn  { background: #f39c12; }
.timer-bar-fill.danger { background: #e74c3c; }
.timer-num {
  min-width: 38px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #27ae60;
  transition: color 0.5s;
}
.timer-num.warn   { color: #f39c12; }
.timer-num.danger { color: #e74c3c; }

/* Result screen */
.result-header { text-align: center; margin-bottom: 26px; }
.result-header h2 { font-size: 1.5rem; margin-bottom: 4px; }
.result-header p { color: rgba(255,255,255,0.5); }

.score-ring {
  width: 148px; height: 148px;
  border-radius: 50%;
  border: 6px solid;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto 22px;
}
.score-ring .big { font-size: 2.6rem; font-weight: 800; }
.score-ring .lbl { font-size: 0.78rem; opacity: 0.65; margin-top: -2px; }

.grade-line { text-align: center; margin-bottom: 24px; }
.grade-line .emoji { font-size: 2rem; display: block; margin-bottom: 5px; }
.grade-line .txt { color: rgba(255,255,255,0.65); font-size: 0.95rem; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-box {
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 15px 10px;
  text-align: center;
}
.stat-box .val { font-size: 1.6rem; font-weight: 700; }
.stat-box .key { font-size: 0.73rem; color: rgba(255,255,255,0.55); margin-top: 3px; }

.subj-bars { margin-bottom: 22px; }
.subj-bars-title { font-size: 0.82rem; color: rgba(255,255,255,0.45); margin-bottom: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 100px; font-size: 0.82rem; color: rgba(255,255,255,0.65); flex-shrink: 0; }
.bar-track { flex: 1; background: rgba(255,255,255,0.09); border-radius: 5px; height: 9px; }
.bar-fill  { height: 100%; border-radius: 5px; transition: width 1s ease; }
.bar-pct   { width: 38px; text-align: right; font-size: 0.82rem; font-weight: 700; }

/* Leaderboard */
.lb-title { text-align: center; margin-bottom: 6px; font-size: 1.7rem; }
.lb-sub   { text-align: center; color: rgba(255,255,255,0.45); margin-bottom: 22px; font-size: 0.88rem; }
.lb-list  { margin-bottom: 18px; }
.lb-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px;
  border-radius: 12px;
  margin-bottom: 9px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.09);
}
.lb-item.r1 { background: rgba(253,180,133,0.14); border-color: rgba(253,180,133,0.35); }
.lb-item.r2 { background: rgba(189,195,199,0.11); border-color: rgba(189,195,199,0.28); }
.lb-item.r3 { background: rgba(205,127,50,0.11);  border-color: rgba(205,127,50,0.28); }
.lb-rank { font-size: 1.25rem; width: 34px; text-align: center; flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 700; font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-detail { font-size: 0.75rem; color: rgba(255,255,255,0.45); margin-top: 2px; }
.lb-score-val { font-size: 1.3rem; font-weight: 800; color: #fda085; flex-shrink: 0; }
.lb-empty { text-align: center; color: rgba(255,255,255,0.35); padding: 30px 0; line-height: 2; }

@media (max-width: 480px) {
  .card { padding: 26px 18px; }
  h1.title { font-size: 2rem; }
  .chip-grid.cat { grid-template-columns: repeat(2, 1fr); }
  .isian-row { flex-direction: column; }
  .isian-row .btn-sm { width: 100%; padding: 12px; }
}

/* ══ Multiplayer button ══════════════════════════════════════ */
.btn-mp {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  letter-spacing: 0.4px;
}
.btn-mp:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(108,92,231,0.45); }

/* ══ Divider ═════════════════════════════════════════════════ */
.divider {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,0.3); font-size: 0.82rem;
  margin: 16px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1;
  border-top: 1px solid rgba(255,255,255,0.15);
}

/* ══ Room code box ═══════════════════════════════════════════ */
.room-code-box {
  text-align: center;
  background: rgba(255,255,255,0.07);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 22px;
  border: 1px solid rgba(255,255,255,0.12);
}
.rc-label { font-size: 0.78rem; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 1px; }
.rc-code  {
  font-size: 3.2rem; font-weight: 900; letter-spacing: 12px;
  color: #a29bfe; margin: 6px 0 4px;
  font-family: 'Courier New', monospace;
}
.rc-hint  { font-size: 0.78rem; color: rgba(255,255,255,0.4); }

/* ══ Waiting room ════════════════════════════════════════════ */
.waiting-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-size: 0.85rem; color: rgba(255,255,255,0.6);
}
.waiting-dot { color: #2ecc71; font-size: 0.78rem; }

.waiting-players { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; min-height: 60px; }

.waiting-player {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}
.wp-icon  { font-size: 1.3rem; flex-shrink: 0; }
.wp-info  { flex: 1; min-width: 0; }
.wp-name  { font-weight: 700; font-size: 0.9rem; }
.wp-school{ font-size: 0.75rem; color: rgba(255,255,255,0.45); margin-top: 1px; }
.wp-dot   { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.wp-dot.on  { background: #2ecc71; }
.wp-dot.off { background: #e74c3c; }

.waiting-msg {
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 0.88rem;
  padding: 10px 0;
  font-style: italic;
}

/* ══ Babak bar (in-game) ═════════════════════════════════════ */
.babak-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
#babak-label { font-weight: 700; font-size: 0.85rem; color: #a29bfe; }
.answer-count {
  font-size: 0.78rem;
  background: rgba(255,255,255,0.1);
  padding: 3px 10px;
  border-radius: 10px;
  color: rgba(255,255,255,0.6);
}

/* ══ Selected answer (MP, before reveal) ════════════════════ */
.opt-btn.selected-mp {
  background: rgba(162,155,254,0.25);
  border-color: #a29bfe;
}

/* ══ Podium ══════════════════════════════════════════════════ */
.podium-row {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 12px; margin-bottom: 18px;
}
.podium-item {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 14px 12px 10px;
  border: 1px solid rgba(255,255,255,0.12);
  min-width: 90px;
}
.pod-1 { transform: scale(1.08); background: rgba(253,180,133,0.15); border-color: rgba(253,180,133,0.4); }
.pod-2 { background: rgba(189,195,199,0.12); border-color: rgba(189,195,199,0.3); }
.pod-3 { background: rgba(205,127,50,0.12);  border-color: rgba(205,127,50,0.3); }
.pod-medal  { font-size: 2rem; margin-bottom: 6px; }
.pod-name   { font-weight: 700; font-size: 0.88rem; text-align: center; }
.pod-school { font-size: 0.7rem; color: rgba(255,255,255,0.45); margin-top: 2px; text-align:center; }
.pod-score  { font-size: 1.3rem; font-weight: 800; color: #fda085; margin-top: 6px; }

/* ══ Minimalist Home Screen ══════════════════════════════════ */
#s-home .card {
  background: #ffffff;
  backdrop-filter: none;
  border: 1px solid #f0f1f3;
  box-shadow: 0 4px 32px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.05);
  color: #1a1a2e;
}

#s-home .subtitle {
  color: #8e9aaf;
  font-size: 0.88rem;
  margin-bottom: 28px;
}

#s-home .label {
  color: #6b7280;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#s-home .text-input {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #1a1a2e;
}
#s-home .text-input::placeholder { color: #c4cad4; }
#s-home .text-input:focus {
  background: #ffffff;
  border-color: #f5576c;
  box-shadow: 0 0 0 3px rgba(245,87,108,0.08);
}

#s-home .chip {
  background: #f3f4f6;
  border-color: #f3f4f6;
  color: #6b7280;
}
#s-home .chip:hover         { background: #e9ebee; border-color: #e9ebee; }
#s-home .chip.active        { background: #ffffff; border-color: currentColor; }
#s-home .chip.all           { color: #fda085; }
#s-home .chip.mat           { color: var(--mat); }
#s-home .chip.ipa           { color: var(--ipa); }
#s-home .chip.ips           { color: var(--ips); }
#s-home .chip.bin           { color: var(--bin); }
#s-home .chip.eng           { color: var(--eng); }
#s-home .chip.num           { color: #6c5ce7; }

#s-home .btn-outline {
  border-color: #e5e7eb;
  color: #6b7280;
}
#s-home .btn-outline:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #374151;
}

.credit {
  text-align: center;
  margin-top: 22px;
  font-size: 0.75rem;
  color: #c4cad4;
  letter-spacing: 0.3px;
}
