/* ============================================================
   styles.css · Kahoot propio
   Estilos base neutros (la identidad UAI se aplica en Pro).
   Paleta heredada del prototipo para mantener coherencia.
   ============================================================ */
:root {
  --bg: #0f172a;
  --bg2: #1e1b4b;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent2: #6366f1;
  --ok: #16a34a;
  --bad: #dc2626;
  --run: #d97706;
  --radius: 16px;
  /* Colores de las 4 alternativas (estilo Kahoot) */
  --a: #e21b3c;
  --b: #1368ce;
  --c: #d89e00;
  --d: #26890c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--ink);
  min-height: 100vh;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px; }
.topbar { color: #e2e8f0; padding: 8px 4px 18px; }
.brand { font-weight: 800; letter-spacing: .3px; font-size: 20px; }
.brand span { opacity: .7; font-weight: 500; font-size: 15px; }
.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}
h1 { font-size: 22px; margin: .1em 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.note {
  background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3;
  border-radius: 12px; padding: 10px 14px; font-size: 13px; margin: 4px 0 18px;
}
ul.estado { list-style: none; padding: 0; margin: 8px 0 0; }
ul.estado li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; margin-bottom: 8px; border-radius: 12px;
  background: #f8fafc; border: 1px solid var(--line);
  font-size: 14px; line-height: 1.4; font-weight: 500;
}
ul.estado li .ic { font-weight: 900; width: 18px; text-align: center; }
ul.estado li.ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
ul.estado li.ok .ic { color: var(--ok); }
ul.estado li.error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
ul.estado li.error .ic { color: var(--bad); }
ul.estado li.run .ic { color: var(--run); }
code { background: #eef2ff; color: #3730a3; padding: 1px 6px; border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.acciones { margin-top: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700;
  cursor: pointer; font-size: 15px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: #f1f5f9; color: var(--ink); }
#quien { font-size: 14px; color: var(--muted); }

/* ===================== App del profesor (F1) ===================== */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  color: #e2e8f0; padding: 4px 4px 16px;
}
.appbar .brand { font-size: 18px; }
.appbar .who { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.center { text-align: center; }
.login { padding: 40px 24px; }
.login .logo { font-size: 46px; }
.login h1 { margin: 6px 0 2px; }

.spinner {
  width: 34px; height: 34px; margin: 8px auto;
  border: 4px solid #c7d2fe; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Botones extra */
.btn.lg { padding: 14px 22px; font-size: 16px; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.danger:hover { background: #fecaca; }
.btn:disabled { opacity: .6; cursor: default; }

/* Formulario nuevo curso */
.form-inline {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; margin: 8px 0 18px;
}
.form-inline .grow { flex: 1 1 220px; }
.form-inline input[type=text] {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 15px;
}

/* Listas de cursos y preguntas */
.lista { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
}
.item.preg { align-items: flex-start; }
.item-main { min-width: 0; }
.item-title { font-weight: 700; font-size: 15px; }
.item-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item-actions { display: flex; gap: 8px; flex-shrink: 0; }
.empty { padding: 8px 2px; }

/* Preguntas: badges y alternativas */
.badges { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: 11px; font-weight: 700;
}
.badge.soft { background: #eef2ff; color: #3730a3; }
.ops { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.ops li {
  font-size: 13px; color: #475569; display: flex; align-items: center; gap: 8px;
}
.ops li.correcta { color: #14532d; font-weight: 700; }
.op-letra {
  width: 20px; height: 20px; border-radius: 6px; background: #e2e8f0;
  color: #334155; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.ops li.correcta .op-letra { background: #16a34a; color: #fff; }

.bloque { margin-top: 22px; }
.bloque h2 { font-size: 16px; margin: 0 0 6px; }
.bloque input[type=file] { margin: 6px 0; font-size: 14px; }

/* Avisos de importación */
.alert { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 10px 0; }
.alert.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #14532d; }
.alert.error { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #16a34a; }
.toast.error { background: #dc2626; }

a { color: var(--accent2); }

/* ===================== Lobby del profesor (F2) ===================== */
.lobby-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
}
.lobby-head h1 { margin: 2px 0; }
.pin-box {
  text-align: center; background: linear-gradient(160deg, #0f172a, #1e1b4b);
  color: #fff; border-radius: 16px; padding: 12px 22px; flex-shrink: 0;
}
.pin-label { font-size: 12px; letter-spacing: 4px; opacity: .7; }
.pin {
  font-size: 46px; font-weight: 900; letter-spacing: 8px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.join-row {
  display: flex; gap: 18px; align-items: center; justify-content: space-between;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 18px 0; flex-wrap: wrap;
}
.join-info { min-width: 0; }
.join-info p { margin: 3px 0; }
.break { word-break: break-all; }
.qr {
  width: 132px; height: 132px; background: #fff; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: 1px solid var(--line); overflow: hidden;
}
.qr img, .qr canvas { display: block; }
.sala-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 6px; flex-wrap: wrap;
}
.sala-bar h2 { font-size: 16px; margin: 0; }
.jugadores {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; min-height: 44px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe;
  border-radius: 999px; padding: 6px 8px 6px 14px; font-weight: 700;
  font-size: 14px; animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chip-x {
  border: 0; background: #c7d2fe; color: #3730a3; width: 20px; height: 20px;
  border-radius: 50%; cursor: pointer; font-weight: 900; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.chip-x:hover { background: #a5b4fc; }
.bloque.jugar {
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 12px;
  padding: 16px; margin-top: 8px;
}
.bloque.jugar h2 { color: #3730a3; }

/* ===================== Pantalla del alumno (F2) ===================== */
.wrap-narrow { max-width: 440px; }
.play-join, .play-espera { text-align: center; padding: 30px 22px; }
.play-join .logo { font-size: 44px; }
.play-join h1 { margin: 6px 0 14px; }
#fJoin label {
  display: block; text-align: left; font-size: 13px; color: var(--muted);
  font-weight: 600; margin: 0 0 2px 4px;
}
.pin-input {
  width: 100%; text-align: center; font-size: 34px; font-weight: 900;
  letter-spacing: 12px; padding: 12px; border: 2px solid var(--line);
  border-radius: 12px; margin: 0 0 14px; font-variant-numeric: tabular-nums;
}
.pin-input:focus, .name-input:focus { outline: none; border-color: var(--accent); }
.name-input {
  width: 100%; text-align: center; font-size: 18px; padding: 12px;
  border: 2px solid var(--line); border-radius: 12px; margin: 0 0 16px;
}
.full { width: 100%; }
.play-espera .big-check { font-size: 50px; }
.play-name { font-size: 24px; font-weight: 800; margin: 6px 0 4px; }
.play-espera .spinner { margin: 14px auto; }

/* ===================== Motor de juego (F3) ===================== */
.qmeta {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 14px; font-weight: 600;
}
.timer { font-size: 22px; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.timerbar { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 10px 0 16px; }
.timerbar > i { display: block; height: 100%; background: var(--accent); width: 100%; transition: width .25s linear; }
.qtext { font-size: 24px; font-weight: 800; margin: 8px 0 14px; line-height: 1.25; }
.qimg { width: 100%; max-height: 240px; object-fit: contain; background: #f8fafc; border-radius: 12px; margin-bottom: 14px; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answers.host { grid-template-columns: 1fr 1fr; }
.ans {
  border: 0; border-radius: 14px; color: #fff; font-weight: 700; font-size: 17px;
  padding: 20px 16px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  text-align: left; min-height: 74px; transition: transform .08s, opacity .2s; width: 100%;
}
.ans:active { transform: scale(.98); }
.ans .sh { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }
.ans .cnt { margin-left: auto; background: rgba(0,0,0,.22); border-radius: 999px; padding: 2px 12px; font-weight: 800; }
.ans.a { background: var(--a); } .ans.b { background: var(--b); }
.ans.c { background: var(--c); } .ans.d { background: var(--d); }
.ans.dim { opacity: .35; }
.ans.right { outline: 5px solid #22c55e; outline-offset: 2px; opacity: 1; }
.ans.picked { outline: 4px solid #0f172a; outline-offset: 2px; }
.ans[disabled] { cursor: default; }
.answers.host .ans { cursor: default; }

.host-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.countpill {
  background: #f1f5f9; border-radius: 10px; padding: 10px 14px; font-weight: 700;
  color: #334155; font-size: 15px; display: flex; gap: 10px;
}
.resp-hint { text-align: center; color: var(--muted); font-weight: 600; margin-top: 14px; }

/* Ranking / leaderboard */
.rk-title { font-size: 16px; margin: 18px 0 6px; }
.lead { list-style: none; padding: 0; margin: 8px 0 0; }
.lead li {
  display: flex; align-items: center; gap: 12px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 8px; font-weight: 600;
}
.lead .pos {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.lead .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead .pts { margin-left: auto; color: var(--accent); font-weight: 800; }

/* Podio */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 22px 0; }
.pcol { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pbar {
  width: 88px; border-radius: 12px 12px 0 0; background: var(--accent); color: #fff;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; font-weight: 900;
}
.pbar.g1 { height: 130px; background: #f59e0b; }
.pbar.g2 { height: 100px; background: #94a3b8; }
.pbar.g3 { height: 78px; background: #b45309; }

/* Feedback del alumno */
.feedback { border-radius: 14px; padding: 22px; text-align: center; color: #fff; font-weight: 800; font-size: 22px; }
.feedback.ok { background: var(--ok); }
.feedback.bad { background: var(--bad); }
.pts-won { text-align: center; font-size: 26px; font-weight: 900; color: var(--accent); margin-top: 12px; }
.big-emoji { font-size: 46px; }

/* ===================== Ranking, podio e histórico (F4) ===================== */
/* Puntos ganados en la ronda, dentro del ranking entre preguntas. */
.lead .delta {
  margin-left: auto; font-weight: 800; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lead .delta.up { color: var(--ok); }
.lead .delta + .pts { margin-left: 14px; }

/* Historial de partidas: tarjeta */
.item.hist .item-title { font-variant-numeric: tabular-nums; }

/* Tarjetas resumen (jugadores / preguntas / % acierto) */
.stat-cards { display: flex; gap: 12px; margin: 12px 0 4px; flex-wrap: wrap; }
.scard {
  flex: 1 1 90px; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; text-align: center;
}
.scard-n { font-size: 26px; font-weight: 900; color: var(--accent); line-height: 1.1; }
.scard-l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Estadística por pregunta (% de acierto con barra) */
.stats { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.stat {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.stat-head { display: flex; align-items: center; gap: 10px; }
.stat-idx {
  flex-shrink: 0; background: var(--accent); color: #fff; font-weight: 800;
  font-size: 12px; border-radius: 8px; padding: 3px 8px;
}
.stat-q {
  flex: 1; min-width: 0; font-weight: 700; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-pct { flex-shrink: 0; font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat-pct.good { color: var(--ok); }
.stat-pct.bad { color: var(--bad); }
.stat-bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.stat-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.stat-bar > i.good { background: var(--ok); }
.stat-bar > i.bad { background: var(--bad); }
.stat-sub { line-height: 1.4; }

@media (max-width: 520px) {
  .answers, .answers.host { grid-template-columns: 1fr; }
  .qtext { font-size: 20px; }
}
