:root {
  --fondo: #eef3f8;
  --tarjeta: #ffffff;
  --texto: #1e293b;
  --suave: #64748b;
  --borde: #cbd5e1;
  --azul: #1d4ed8;
  --azul-claro: #dbeafe;
  --verde: #15803d;
  --verde-claro: #dcfce7;
  --rojo: #b91c1c;
  --rojo-claro: #fee2e2;
  --ambar: #b45309;
  --ambar-claro: #fef3c7;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }
.contenedor { max-width: 860px; margin: 0 auto; padding: 16px; }
.ancho { max-width: 1200px; }
.cargando { text-align: center; color: var(--suave); margin-top: 40px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
button, input, select, textarea { font: inherit; }

.tarjeta { background: var(--tarjeta); border-radius: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); padding: 16px; margin-bottom: 14px; }

/* Cabecera del examen */
.cabecera { text-align: center; }
.cabecera img { width: 90px; height: auto; }
.cabecera .ue { font-size: 13px; letter-spacing: .08em; margin: 4px 0 0; color: var(--suave); }
.cabecera .colegio { font-size: 20px; font-weight: 800; margin: 2px 0 10px; }
.datos { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.datos td { border: 1px solid var(--borde); padding: 6px 8px; vertical-align: middle; }
.datos td.et { background: #f1f5f9; font-weight: 600; width: 1%; white-space: nowrap; }
.titulo-ev { margin: 14px 0 2px; font-size: 18px; font-weight: 800; text-align: center; color: var(--azul); }

/* Formularios */
label.campo { display: block; margin-bottom: 12px; }
label.campo span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=datetime-local], select, textarea { width: 100%; border: 1.5px solid var(--borde); border-radius: 10px; padding: 11px 12px; background: #fff; color: var(--texto); }
input:focus, select:focus { outline: 3px solid var(--azul-claro); border-color: var(--azul); }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 700; cursor: pointer; background: var(--azul); color: #fff; text-decoration: none; text-align: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.grande { width: 100%; font-size: 18px; padding: 15px; }
.btn.sec { background: #fff; color: var(--azul); border: 1.5px solid var(--azul); }
.btn.peligro { background: var(--rojo); }
.btn.chico { padding: 6px 10px; font-size: 13px; }
.aviso { border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 15px; }
.aviso.error { background: var(--rojo-claro); color: var(--rojo); }
.aviso.info { background: var(--azul-claro); color: #1e3a8a; }
.aviso.ok { background: var(--verde-claro); color: var(--verde); }
.aviso.ambar { background: var(--ambar-claro); color: var(--ambar); }

/* Materias para elegir */
.materias { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 14px; }
.materia { border: 2px solid var(--borde); border-radius: 12px; padding: 12px; background: #fff; cursor: pointer; text-align: left; font-weight: 700; }
.materia small { display: block; font-weight: 400; color: var(--suave); }
.materia.sel { border-color: var(--azul); background: var(--azul-claro); }

/* Preguntas */
.pregunta { position: relative; }
.pregunta .num { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border-radius: 50%; background: var(--azul); color: #fff; font-weight: 700; font-size: 14px; margin-right: 6px; flex-shrink: 0; }
.pregunta .enc { display: flex; align-items: flex-start; gap: 4px; font-weight: 600; font-size: 17px; }
.pregunta .valor { display: inline-block; margin: 4px 0 10px 34px; font-size: 13px; color: var(--ambar); background: var(--ambar-claro); border-radius: 999px; padding: 1px 10px; font-weight: 600; }
.pregunta img.ilustracion { display: block; max-width: 100%; height: auto; margin: 6px auto 12px; border-radius: 8px; }
.opcion { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--borde); border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; cursor: pointer; background: #fff; }
.opcion input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--azul); }
.opcion.sel { border-color: var(--azul); background: var(--azul-claro); }
.opcion-img { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.opcion-img .opcion { flex-direction: column; align-items: stretch; }
.opcion-img img { width: 100%; height: auto; }
.item { display: grid; grid-template-columns: 1fr minmax(140px, 46%); gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--borde); }
.item:last-child { border-bottom: 0; }
.item .t { font-size: 16px; }
.item select.vacio { border-color: var(--ambar); }
@media (max-width: 520px) { .item { grid-template-columns: 1fr; gap: 4px; } }
.lectura p { margin: 0 0 10px; font-size: 17px; }
.lectura h3 { text-align: center; color: var(--azul); }

/* Dibujo */
.lienzo-caja { border: 2px solid var(--borde); border-radius: 10px; overflow: hidden; background: #fff; touch-action: none; }
.lienzo-caja canvas { display: block; width: 100%; height: auto; touch-action: none; }
.paleta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.color { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--borde); cursor: pointer; }
.color.sel { box-shadow: 0 0 0 3px var(--azul); }

/* Resultado */
.nota { text-align: center; }
.nota p.grande { font-size: 64px; font-weight: 900; line-height: 1; margin: 8px 0; }
.nota .sobre { color: var(--suave); font-size: 18px; }
.barra-progreso { position: sticky; top: 0; z-index: 5; background: var(--fondo); padding: 8px 0; }
.barra-progreso .fondo { height: 8px; background: #dbe3ec; border-radius: 99px; overflow: hidden; }
.barra-progreso .lleno { height: 100%; background: var(--verde); transition: width .3s; }
.barra-progreso small { color: var(--suave); }

/* Panel de la docente */
.pestanas { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 14px; }
.pestanas button { border: 0; background: #fff; padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--suave); }
.pestanas button.sel { background: var(--azul); color: #fff; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.tabla th, table.tabla td { border-bottom: 1px solid #e2e8f0; padding: 7px 8px; text-align: left; vertical-align: middle; }
table.tabla th { background: #f1f5f9; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); position: sticky; top: 0; }
.desliza { overflow-x: auto; border-radius: 12px; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.chip { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip.verde { background: var(--verde-claro); color: var(--verde); }
.chip.rojo { background: var(--rojo-claro); color: var(--rojo); }
.chip.ambar { background: var(--ambar-claro); color: var(--ambar); }
.chip.gris { background: #e2e8f0; color: #475569; }
.nota-celda { cursor: pointer; font-weight: 700; }
.fila-flex { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.resumen { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.resumen div { background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.resumen b { display: block; font-size: 24px; }
.examen-fila { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.modo { display: flex; gap: 4px; flex-wrap: wrap; }
.modo button { border: 1.5px solid var(--borde); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
.modo button.sel.cerrado { background: #475569; color: #fff; border-color: #475569; }
.modo button.sel.abierto { background: var(--verde); color: #fff; border-color: var(--verde); }
.modo button.sel.fechas { background: var(--azul); color: #fff; border-color: var(--azul); }
.fondo-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 12px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; max-width: 760px; width: 100%; max-height: 92vh; overflow: auto; padding: 18px; }
.correcta { color: var(--verde); font-weight: 600; }
.incorrecta { color: var(--rojo); font-weight: 600; }
@media print { .no-imprimir { display: none !important; } body { background: #fff; } }

/* Lista de nombres para elegir */
.lista-nombres { max-height: 300px; overflow-y: auto; border: 1.5px solid var(--borde); border-radius: 10px; background: #fff; }
.lista-nombres .nombre { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #edf2f7; background: #fff; padding: 12px; cursor: pointer; font-size: 15px; }
.lista-nombres .nombre:last-child { border-bottom: 0; }
.lista-nombres .nombre.sel { background: var(--azul); color: #fff; font-weight: 700; }
.materia.hecha { border-color: var(--verde); background: var(--verde-claro); color: var(--verde); cursor: not-allowed; }
.materia.hecha small { color: var(--verde); font-weight: 700; }

/* ═══════════ Examen con adaptación: juego didáctico ═══════════ */
.juego { min-height: 100vh; margin: -16px; padding: 12px 12px 90px; background: linear-gradient(180deg, #e0f2fe 0%, #fef9c3 55%, #dcfce7 100%); }
.juego-cab { display: flex; align-items: center; gap: 10px; }
.buho { font-size: 40px; animation: saltito 2.2s ease-in-out infinite; }
@keyframes saltito { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
.juego-titulo { flex: 1; line-height: 1.15; }
.juego-titulo b { display: block; font-size: 17px; color: #1e3a8a; }
.juego-titulo small { color: #475569; }
.voz { border: 0; background: #fff; border-radius: 50%; width: 46px; height: 46px; font-size: 22px; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); cursor: pointer; }
.estrellas { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.estrella { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; background: #cbd5e1; color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.estrella.hecha { background: #fde68a; font-size: 18px; }
.estrella.actual { border-color: #2563eb; transform: scale(1.15); }
.nivel { background: #fff; border-radius: 22px; padding: 14px; box-shadow: 0 4px 14px rgba(30, 58, 138, .12); }
.globo { background: #eff6ff; border: 3px solid #93c5fd; border-radius: 18px; padding: 12px 14px; margin-bottom: 12px; }
.globo p { margin: 4px 0 8px; font-size: 21px; font-weight: 800; color: #1e293b; line-height: 1.25; }
.nivel-num { font-size: 13px; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: .04em; }
.globo-pie { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.repetir { border: 0; background: #2563eb; color: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.vale { font-size: 13px; font-weight: 700; color: #b45309; background: #fef3c7; border-radius: 999px; padding: 3px 10px; }
.juego-ilustracion { display: block; max-width: 100%; max-height: 260px; margin: 0 auto 12px; border-radius: 12px; }
.juego-emoji { text-align: center; font-size: 30px; font-weight: 800; margin: 0 0 12px; font-family: inherit; white-space: pre; color: #1e3a8a; }
.pista { text-align: center; color: #7c3aed; font-weight: 700; margin: 0 0 10px; }

.filas { display: grid; gap: 10px; }
.fila-juego { display: flex; gap: 10px; align-items: center; background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 16px; padding: 8px; }
.fila-dibujo { width: 104px; flex-shrink: 0; text-align: center; }
.fila-dibujo img { max-width: 100%; max-height: 100px; border-radius: 10px; }
.fila-dibujo .emo { font-size: 58px; line-height: 1; }
.fila-der { flex: 1; min-width: 0; }
.palabra { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: .03em; }
.hueco { display: inline-block; min-width: 46px; text-align: center; border-bottom: 4px dashed #f59e0b; color: #f59e0b; }
.hueco.lleno { border-bottom-style: solid; border-color: #16a34a; color: #16a34a; }
.fichas { display: flex; flex-wrap: wrap; gap: 6px; }
.ficha { min-width: 52px; min-height: 48px; border: 3px solid #c7d2fe; background: #fff; border-radius: 14px; font-size: 21px; font-weight: 800; color: #3730a3; cursor: pointer; padding: 4px 10px; transition: transform .1s; }
.ficha:active { transform: scale(.94); }
.ficha.sel { background: #4f46e5; color: #fff; border-color: #4f46e5; transform: scale(1.06); }
.fichas.con-dibujo .ficha { display: flex; flex-direction: column; align-items: center; font-size: 13px; flex: 1; min-width: 80px; }
.fichas.con-dibujo .ficha img { max-height: 70px; max-width: 100%; }
.fichas.con-dibujo .ficha .emo { font-size: 44px; line-height: 1.1; }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tarjetas.solo-texto { grid-template-columns: 1fr; }
.tarjeta-j { position: relative; border: 3px solid #e2e8f0; background: #fff; border-radius: 18px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 15px; color: #1e293b; }
.tarjeta-j img { max-width: 100%; max-height: 130px; border-radius: 10px; }
.tarjeta-j .emo { font-size: 56px; }
/* «Encerrar» en un círculo */
.tarjeta-j.sel { border-color: #ef4444; background: #fff1f2; }
.tarjeta-j.sel::after { content: ''; position: absolute; inset: -7px; border: 5px solid #ef4444; border-radius: 50%; pointer-events: none; animation: circulo .25s ease-out; }
@keyframes circulo { from { transform: scale(1.25); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.unir { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.unir .col { display: grid; gap: 10px; align-content: start; }
.par { position: relative; border: 4px solid #e2e8f0; background: #fff; border-radius: 16px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 800; font-size: 16px; color: #1e293b; min-height: 64px; justify-content: center; }
.par img { max-width: 100%; max-height: 110px; border-radius: 8px; }
.par.activo { border-color: #7c3aed; background: #f5f3ff; transform: scale(1.04); }
.par.espera { animation: latido 1s ease-in-out infinite; }
@keyframes latido { 50% { box-shadow: 0 0 0 4px #c4b5fd } }
.marca { position: absolute; top: -10px; right: -8px; color: #fff; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.par .marca + .marca { right: 20px; }

.laberinto { display: grid; gap: 2px; max-width: 380px; margin: 0 auto; background: #7c2d12; padding: 4px; border-radius: 12px; }
.celda { aspect-ratio: 1; background: #fef3c7; display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 6vw, 28px); border-radius: 4px; }
.celda.muro { background: #16a34a; }
.cruceta { display: grid; grid-template-columns: repeat(3, 70px); grid-template-rows: repeat(3, 60px); gap: 6px; justify-content: center; margin-top: 12px; }
.cruceta button { border: 0; border-radius: 14px; background: #2563eb; font-size: 28px; cursor: pointer; box-shadow: 0 3px 0 #1e40af; }
.cruceta button:active { transform: translateY(2px); box-shadow: none; }
.logro { text-align: center; font-size: 24px; font-weight: 800; color: #16a34a; }

.juego-pie { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .92); box-shadow: 0 -2px 10px rgba(0, 0, 0, .08); z-index: 20; }
.flecha { border: 0; border-radius: 16px; padding: 14px 18px; font-size: 18px; font-weight: 800; background: #e2e8f0; color: #334155; cursor: pointer; }
.flecha:disabled { opacity: .4; }
.flecha.chica { padding: 6px 12px; font-size: 14px; }
.flecha.siguiente { flex: 1; background: #94a3b8; color: #fff; }
.flecha.siguiente.listo { background: #16a34a; box-shadow: 0 4px 0 #15803d; }
.juego .paleta .color { width: 40px; height: 40px; }

.final { text-align: center; padding: 30px 16px; }
.grande-emoji { font-size: 64px; margin: 0; letter-spacing: 6px; animation: saltito 1.4s ease-in-out infinite; }
.final h2 { font-size: 26px; color: #1e3a8a; }
.nota-juego { font-size: 76px; font-weight: 900; color: #16a34a; margin: 0; line-height: 1; }
.mensaje-final { font-size: 19px; color: #475569; }
.final .flecha { margin-top: 18px; width: 100%; }
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* ═══════════ Pantalla adaptativa: celular · tablet · computadora ═══════════ */
.paso-titulo { font-weight: 600; margin: 14px 0 6px; }
.preguntas { display: grid; gap: 0 14px; grid-template-columns: minmax(0, 1fr); }
#app:has(.nota) > section { max-width: 760px; margin-left: auto; margin-right: auto; }

/* Tablet (desde 760 px): dos columnas donde conviene */
@media (min-width: 760px) {
  .contenedor { max-width: none; padding: 20px 24px; }
  .inicio { max-width: 1100px; margin: 0 auto; }
  .pasos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .paso-titulo { margin-top: 0; }
  .lista-nombres { max-height: 46vh; }
  .materias { grid-template-columns: 1fr; }
  .preguntas { max-width: 900px; margin: 0 auto; align-items: start; }
  .preguntas > .lectura, .preguntas > .ancha { grid-column: 1 / -1; }
  .entrega { max-width: 720px; margin: 0 auto 14px; }
  .opcion-img { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .item { grid-template-columns: 1fr minmax(140px, 52%); }
  /* Juego */
  .juego { margin: -20px -24px; padding: 16px 24px 100px; }
  .filas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tarjetas { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .tarjeta-j img { max-height: 160px; }
  .globo p { font-size: 24px; }
  .laberinto { max-width: min(62vh, 520px); }
  .juego-ilustracion { max-height: 320px; }
}

/* Computadora (desde 1100 px): toda la pantalla */
@media (min-width: 1100px) {
  body { font-size: 17px; }
  .contenedor, .contenedor.ancho { max-width: none; padding: 24px 40px; }
  .inicio { max-width: none; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2.4fr); gap: 20px; align-items: start; }
  .inicio .portada { position: sticky; top: 24px; padding: 28px 20px; }
  .inicio .portada img { width: 140px; }
  .lista-nombres { max-height: 62vh; }
  .materias { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preguntas { max-width: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pregunta .enc { font-size: 18px; }
  .datos { font-size: 15px; }
  /* Juego a pantalla completa */
  .juego { margin: -24px -40px; padding: 20px 40px 110px; }
  .juego-cab, .estrellas { max-width: 1400px; margin-left: auto; margin-right: auto; }
  .nivel { max-width: 1400px; margin: 0 auto; padding: 22px 26px; }
  .globo p { font-size: 27px; }
  .filas { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 14px; }
  .fila-dibujo { width: 140px; }
  .fila-dibujo img { max-height: 130px; }
  .fila-dibujo .emo { font-size: 74px; }
  .ficha { min-width: 64px; min-height: 58px; font-size: 25px; }
  .tarjetas { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .tarjeta-j img { max-height: 190px; }
  .unir { gap: 40px; max-width: 1100px; margin: 0 auto; }
  .par img { max-height: 150px; }
  .laberinto { max-width: min(64vh, 600px); }
  .juego-pie { padding-left: max(40px, calc((100vw - 1400px) / 2)); padding-right: max(40px, calc((100vw - 1400px) / 2)); }
  .lienzo-caja { max-width: 1000px; margin: 0 auto; }
}

/* Pantallas muy grandes */
@media (min-width: 1700px) {
  .preguntas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Panel de la docente en computadora: exámenes en dos columnas y ventanas más anchas */
@media (min-width: 1100px) {
  #contenido:has(> section[data-codigo]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; align-items: start; }
  #contenido > .aviso { grid-column: 1 / -1; }
  .modal { max-width: 1000px; }
}
