:root {
  --azul: #1d4ed8;
  --azul-osc: #1e3a8a;
  --azul-claro: #eff6ff;
  --verde: #16a34a;
  --verde-claro: #f0fdf4;
  --rojo: #dc2626;
  --rojo-claro: #fef2f2;
  --gris: #6b7280;
  --gris-claro: #f9fafb;
  --borde: #e2e5eb;
  --fondo: #f3f4f6;
  --radio: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: #111827;
  line-height: 1.45;
}

.contenedor {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.contenedor.estrecho { max-width: 560px; }

#vista-login.tarjeta { max-width: 420px; margin: 40px auto 0; }

.tarjeta {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
  margin-bottom: 18px;
}

h1, h2, h3 { margin-top: 0; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }

label { display: block; font-weight: 600; margin: 14px 0 5px; font-size: .85rem; color: #374151; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
textarea { resize: vertical; min-height: 64px; }

button {
  background: var(--azul);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: background .12s, opacity .12s;
}
button:hover { background: var(--azul-osc); }
button:disabled { opacity: .55; cursor: default; }
button.secundario { background: #fff; color: #374151; border: 1px solid #d1d5db; }
button.secundario:hover { background: var(--gris-claro); }
button.peligro { background: #fff; color: var(--rojo); border: 1px solid #fecaca; }
button.peligro:hover { background: var(--rojo-claro); }
button.chico { padding: 6px 12px; font-size: .8rem; margin-top: 0; }

.acciones { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.acciones > button { margin-top: 0; }

hr.separador { border: none; border-top: 1px solid var(--borde); margin: 20px 0; }

.franja {
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: .9rem;
}
.franja.error { background: #fee2e2; color: #991b1b; }
.franja.ok { background: #dcfce7; color: #166534; }

.opciones-lista { display: grid; gap: 10px; margin-top: 16px; }
.opcion-btn {
  background: #fff;
  color: #111827;
  border: 2px solid #d1d5db;
  text-align: left;
  padding: 14px;
  border-radius: 10px;
  font-size: 1.05rem;
}
.opcion-btn:hover { border-color: var(--azul); background: #eff6ff; }
.opcion-btn.correcta { border-color: var(--verde); background: #f0fdf4; }
.opcion-btn.incorrecta { border-color: var(--rojo); background: #fef2f2; }
.opcion-btn.seleccionada { border-color: var(--azul); background: var(--azul-claro); font-weight: 600; }

.cronometro {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 8px 0;
}

.barra-progreso { background: #e5e7eb; border-radius: 6px; overflow: hidden; height: 8px; margin-bottom: 8px; }
.barra-progreso > div { background: var(--azul); height: 100%; transition: width .2s linear; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #e5e7eb; font-size: .9rem; }

.codigo-sala {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .2em;
  text-align: center;
  color: var(--azul-osc);
}

nav.pestanas { display: flex; gap: 4px; flex-wrap: wrap; }
nav.pestanas a {
  color: var(--gris);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  padding: 8px 14px;
  border-radius: 8px;
}
nav.pestanas a:hover { background: var(--gris-claro); color: #111827; }
nav.pestanas a.activa { background: var(--azul-claro); color: var(--azul-osc); }

/* --- editor de opciones de una pregunta --- */
.opcion-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  margin-top: 8px;
  background: var(--gris-claro);
}
.opcion-fila:has(input[type="radio"]:checked) {
  border-color: var(--verde);
  background: var(--verde-claro);
}
.opcion-fila .opcion-numero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.opcion-fila:has(input[type="radio"]:checked) .opcion-numero { background: var(--verde); color: #fff; }
.opcion-fila input[type="radio"] { width: auto; flex-shrink: 0; accent-color: var(--verde); }
.opcion-fila input[type="text"] { flex: 1; background: #fff; }
.opcion-fila .btn-quitar-opcion {
  margin: 0;
  background: transparent;
  color: var(--gris);
  border: none;
  padding: 4px 8px;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}
.opcion-fila .btn-quitar-opcion:hover { color: var(--rojo); background: transparent; }
.ayuda-opciones { color: var(--gris); font-size: .8rem; margin-top: 6px; }

/* --- tarjeta de una pregunta ya guardada --- */
.pregunta-guardada {
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 10px;
  background: var(--gris-claro);
}
.pregunta-guardada .opciones-resumen { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.pregunta-guardada .opciones-resumen li { padding: 4px 8px; border-radius: 6px; font-size: .9rem; color: #4b5563; }
.pregunta-guardada .opciones-resumen li.correcta { background: var(--verde-claro); color: #166534; font-weight: 600; }
.pregunta-guardada .cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge.verde { background: var(--verde-claro); color: #166534; }
.badge.gris { background: #e5e7eb; color: #374151; }
.badge.azul { background: var(--azul-claro); color: var(--azul-osc); }

button.btn-icono {
  padding: 5px 9px;
  font-size: .95rem;
  line-height: 1;
}

/* --- fila expandible de detalle dentro de una tabla (p.ej. "Revisar") --- */
tr.fila-detalle > td {
  background: var(--gris-claro);
  padding: 14px;
}

/* --- gamificación de sesión (alumno) --- */

/* marca de agua discreta con el nombre del alumno: no evita una foto/captura,
   pero identifica de dónde salió si se comparte fuera de clase */
#marca-agua {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-content: space-around;
  justify-content: space-around;
  opacity: .06;
  transform: rotate(-25deg) scale(1.4);
}
#marca-agua span {
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  margin: 18px 26px;
  color: #111827;
}

/* texto de pregunta/opciones: no seleccionable a simple vista, con caracteres
   señuelo intercalados fuera de pantalla que sí entran en la selección. Un
   copiar/pegar (p.ej. a un chat de IA) trae basura en vez del enunciado. No
   evita una captura de pantalla o foto: eso no se puede bloquear desde el navegador. */
.txt-protegido { user-select: text; }
.txt-protegido .txt-decoy {
  position: fixed;
  left: -99999px;
  top: 0;
}
.txt-protegido {
  -webkit-touch-callout: none; /* evita el menú "Copiar" del long-press en móvil */
}

.racha-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  margin-left: 8px;
}

.puntos-ganados {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--azul-osc);
  margin: 6px 0 2px;
}

.clasificacion-mini { margin-top: 14px; }
.clasificacion-mini ol { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.clasificacion-mini li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--gris-claro);
  font-size: .9rem;
}
.clasificacion-mini li.eres-tu { background: var(--azul-claro); font-weight: 700; color: var(--azul-osc); }
.clasificacion-mini .tu-puesto {
  text-align: center;
  color: var(--gris);
  font-size: .85rem;
  margin-top: 8px;
}

.podio {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 18px 0;
}
.podio .puesto {
  flex: 1;
  max-width: 120px;
  text-align: center;
  border-radius: 10px 10px 0 0;
  padding: 10px 6px 12px;
  color: #fff;
  font-weight: 700;
}
.podio .puesto .nombre { font-size: .8rem; font-weight: 600; margin-bottom: 4px; word-break: break-word; }
.podio .puesto .pts { font-size: .85rem; opacity: .9; }
.podio .p1 { background: linear-gradient(#fbbf24,#d97706); height: 130px; order: 2; }
.podio .p2 { background: linear-gradient(#cbd5e1,#94a3b8); height: 100px; order: 1; }
.podio .p3 { background: linear-gradient(#f0b27a,#c2703d); height: 80px; order: 3; }
