* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Calibri, Segoe UI, Arial, sans-serif;
  background: #f4f5fb;
  color: #23264a;
}
.pantalla-centrada {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.tarjeta {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 4px 24px rgba(47, 60, 126, 0.08);
  width: 100%;
}
h1 { margin: 0 0 8px; }
.muted { color: #6a6f9e; font-size: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8daec;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.boton {
  display: inline-block;
  background: #2f3c7e;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.boton:hover { background: #263066; }
.boton-secundario { background: #f96167; }
.boton-secundario:hover { background: #e14b52; }
.boton-tenue {
  background: #eceefc;
  color: #2f3c7e;
}
.boton-tenue:hover { background: #dde0f7; }
.boton[disabled] { opacity: 0.5; cursor: not-allowed; }
.error { color: #c0392b; font-size: 13px; margin-top: 8px; }
.ok { color: #1f8a4c; font-size: 13px; margin-top: 8px; }
.fila { display: flex; gap: 12px; }
.fila > * { flex: 1; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; background: #fff; border-bottom: 1px solid #e4e5f2;
}
.contenedor { max-width: 900px; margin: 0 auto; padding: 24px; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eceefc; font-size: 14px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eceefc; color: #2f3c7e;
}
.badge-finalizada { background: #ffe1e2; color: #c0392b; }
.badge-vigente { background: #e3f6ea; color: #1f8a4c; }
.badge-no-vigente { background: #eceefc; color: #6a6f9e; }
.codigo-grande {
  font-size: 42px; font-weight: 800; letter-spacing: 4px; color: #2f3c7e;
  text-align: center; margin: 12px 0;
}
.pregunta-bloque {
  border: 1px solid #d8daec; border-radius: 10px; padding: 14px; margin-top: 12px;
}
.ranking-fila {
  display: flex; justify-content: space-between; padding: 10px 14px;
  border-radius: 8px; margin-top: 6px; background: #f7f7fb;
}
.ranking-fila:nth-child(1) { background: #fdf3d0; font-weight: 700; }

/* ============ Modo "juego en vivo" estilo Kahoot (jugar.html) ============ */
.juego-fondo {
  min-height: 100vh;
  background: linear-gradient(135deg, #46178f 0%, #7b2ff7 50%, #a13de0 100%);
  background-size: 200% 200%;
  animation: moverFondo 12s ease infinite;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; color: #fff;
}
@keyframes moverFondo {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.mascota-flotante {
  width: 140px; max-width: 40vw; margin-bottom: 8px;
  animation: flotar 2.4s ease-in-out infinite, aparecer 0.5s ease-out;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.25));
}
@keyframes flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes aparecer {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.mascota-grande { width: 220px; max-width: 60vw; }
.mascota-celebrando { animation: flotar 0.6s ease-in-out infinite, aparecer 0.5s ease-out; }

.juego-titulo {
  font-size: 28px; font-weight: 800; text-align: center; margin: 8px 0 4px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.juego-subtitulo { opacity: 0.85; text-align: center; margin-bottom: 8px; }

.juego-tarjeta-blanca {
  background: rgba(255,255,255,0.97); color: #23264a; border-radius: 20px;
  padding: 28px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  animation: aparecer 0.4s ease-out;
}
.juego-tarjeta-blanca input {
  text-align: center; font-size: 18px; font-weight: 700; letter-spacing: 2px;
}

.codigo-sala-kahoot {
  font-size: 56px; font-weight: 900; letter-spacing: 6px;
  background: #fff; color: #46178f; border-radius: 14px;
  padding: 10px 20px; margin: 14px 0; display: inline-block;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  animation: pulso 2s ease-in-out infinite;
}
@keyframes pulso {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Temporizador circular */
.temporizador-anillo { position: relative; width: 100px; height: 100px; margin: 0 auto 10px; }
.temporizador-anillo svg { transform: rotate(-90deg); }
.temporizador-anillo circle {
  fill: none; stroke-width: 8;
}
.temporizador-fondo { stroke: rgba(255,255,255,0.25); }
.temporizador-progreso {
  stroke: #ffd43b; stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.temporizador-progreso.urgente { stroke: #f96167; }
.temporizador-numero {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 900;
}

/* Pregunta */
.pregunta-titulo-kahoot {
  background: rgba(255,255,255,0.98); color: #23264a;
  border-radius: 16px; padding: 22px 28px; max-width: 700px; width: 100%;
  text-align: center; font-size: 22px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  margin: 10px 0 20px;
  animation: aparecer 0.35s ease-out;
}

.opciones-kahoot {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  max-width: 700px; width: 100%;
}
.opcion-kahoot {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 18px; border-radius: 14px; border: none;
  font-size: 17px; font-weight: 700; color: #fff; cursor: pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,0.2);
  transition: transform 0.12s ease, filter 0.15s ease;
  text-align: left;
  animation: aparecer 0.3s ease-out;
}
.opcion-kahoot:hover:not(:disabled) { transform: translateY(-3px); filter: brightness(1.08); }
.opcion-kahoot:disabled { cursor: default; }
.opcion-kahoot .forma { width: 26px; height: 26px; flex-shrink: 0; }
.op-roja { background: #e21b3c; }
.op-azul { background: #1368ce; }
.op-amarilla { background: #d89e00; }
.op-verde { background: #26890c; }

.opcion-kahoot.acertada { outline: 4px solid #fff; transform: scale(1.03); }
.opcion-kahoot.fallada { opacity: 0.35; }

.resultado-kahoot {
  margin-top: 18px; font-size: 22px; font-weight: 800; text-align: center;
  animation: aparecer 0.3s ease-out;
}

/* Confeti */
#lienzo-confeti {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
}

/* Formas de las opciones, con CSS puro */
.forma-triangulo {
  width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent;
  border-bottom: 22px solid #fff;
}
.forma-diamante { background: #fff; transform: rotate(45deg); }
.forma-circulo { background: #fff; border-radius: 50%; }
.forma-cuadrado { background: #fff; border-radius: 4px; }

@media (max-width: 480px) {
  .opciones-kahoot { grid-template-columns: 1fr; }
  .juego-titulo { font-size: 22px; }
  .codigo-sala-kahoot { font-size: 40px; letter-spacing: 3px; }
}

/* ============ Responsivo para el panel de administrador ============ */
@media (max-width: 700px) {
  .contenedor { padding: 14px; }
  .tarjeta { padding: 20px 16px; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar strong { font-size: 15px; }
  .fila { flex-direction: column; }
  .codigo-grande { font-size: 32px; letter-spacing: 2px; }

  /* Tablas: scroll horizontal en vez de desbordarse */
  #tabla-salas, #tabla-detalle {
    display: block;
  }
  .tarjeta:has(> table) { overflow-x: auto; }

  /* En la tabla de "Mis salas", los botones de acción se apilan */
  #tabla-salas-body td:last-child {
    display: flex; flex-direction: column; gap: 6px; min-width: 140px;
  }
  #tabla-salas-body .boton { width: 100%; text-align: center; }

  .pregunta-bloque input, .pregunta-bloque select { font-size: 16px; } /* evita zoom automático en iOS */
  .opciones-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .tarjeta h2 { font-size: 18px; }
  .boton { padding: 10px 14px; font-size: 13px; }
}

/* ============ Más color y vida ============ */
.boton {
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.2s ease;
}
.boton:not([disabled]):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(47, 60, 126, 0.25);
}
.boton:not([disabled]):active { transform: translateY(0); }

.tarjeta { transition: box-shadow 0.2s ease; }

@keyframes brilloSuave {
  0%, 100% { box-shadow: 0 0 0 rgba(38, 137, 12, 0); }
  50% { box-shadow: 0 0 24px rgba(38, 137, 12, 0.55); }
}
#btn-ver-resultados:not([disabled]) {
  animation: pulso 1.6s ease-in-out infinite, brilloSuave 1.6s ease-in-out infinite;
}

/* Pie de página "Desarrollado por" */
.pie-marca {
  text-align: center;
  font-size: 12px;
  padding: 14px 10px 18px;
  color: rgba(255,255,255,0.75);
}
.pie-marca strong { font-weight: 700; color: rgba(255,255,255,0.95); }
.pie-marca.pie-marca-clara { color: #8a8fb8; }
.pie-marca.pie-marca-clara strong { color: #2f3c7e; }
.pie-fijo { position: fixed; bottom: 2px; left: 0; right: 0; z-index: 5; pointer-events: none; }
.pie-marca-flotante {
  position: fixed; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(35,38,74,0.55); color: rgba(255,255,255,0.9);
  padding: 4px 12px; border-radius: 999px; font-size: 11px; z-index: 5; pointer-events: none;
}
.pie-marca-flotante strong { color: #fff; }
