/* SANQUIZZ: paleta propia, derivada de la paleta institucional HSDA y del logo. */
:root {
  --ink: #33394c;          /* azul oscuro HSDA: texto y títulos */
  --blue: #3c5775;         /* azul medio HSDA */
  --blue-soft: #a5b7cf;    /* azul claro HSDA */
  --cream: #f8f4ef;        /* crema HSDA: fondo cálido */
  --paper: #ffffff;
  --teal: #03848d;         /* acento del logo */
  --turq: #01a5a6;         /* acento del logo */
  --coral: #e4572e;        /* respuesta 1 */
  --amber: #f2a541;        /* respuesta 2 */
  --sea: #01a5a6;          /* respuesta 3 */
  --night: #33394c;        /* respuesta 4 */
  --ok: #1b7f4b;
  --bad: #b3261e;
  --radius: 14px;
  --radius-ctl: 10px;      /* botones y campos comparten la misma esquina */
  --white: #ffffff;
  --on-amber: #33394c;
  --font: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, sans-serif;
  --chip-bg: #e3eaf3;
  --danger-line: #b3261e;
  --low-bg: #fde2dd; --low-ink: #8f2a14;
  --mid-bg: #fdecc8; --mid-ink: #7a4a00;
  --high-bg: #d4f1ef; --high-ink: #04585b;
  --ok-text: #1b7f4b;
  --bad-text: #b3261e;
  --focus: #01a5a6;
  --field-line: #6c829f;
  --primary: #03848d;
  --primary-hover: #026a72;
  --muted: #3c5775;
  --link: #3c5775;
  --shadow: 0 6px 22px rgba(51, 57, 76, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f8f4ef;
    --cream: #1c2030;
    --paper: #262b3d;
    --blue-soft: #7f93b0;
    --muted: #b8c6da;
    --link: #8fd0d3;
    --ok-text: #62d99b;
    --bad-text: #ff8a80;
    --focus: #7ee8e8;
    --field-line: #8da1bd;
    --chip-bg: #384262;
    --danger-line: #ff8a80;
    --low-bg: #4a2a2a; --low-ink: #ffc2b8;
    --mid-bg: #4a3d22; --mid-ink: #ffdf9a;
    --high-bg: #1f4547; --high-ink: #9be6e2;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #f8f4ef;
  --cream: #1c2030;
  --paper: #262b3d;
  --blue-soft: #7f93b0;
  --muted: #b8c6da;
  --link: #8fd0d3;
  --ok-text: #62d99b;
  --bad-text: #ff8a80;
  --focus: #7ee8e8;
  --field-line: #8da1bd;
  --chip-bg: #384262;
  --danger-line: #ff8a80;
  --low-bg: #4a2a2a; --low-ink: #ffc2b8;
  --mid-bg: #4a3d22; --mid-ink: #ffdf9a;
  --high-bg: #1f4547; --high-ink: #9be6e2;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.45;
  min-height: 100vh;
  padding: 0 16px 40px;
}
h1, h2, h3 { text-wrap: balance; overflow-wrap: break-word; min-width: 0; font-weight: 800; margin: 0.4em 0 0.3em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.7rem); }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 0; border-radius: var(--radius-ctl); padding: 12px 24px; cursor: pointer;
  background: var(--primary); color: var(--white); font-weight: 700; min-height: 44px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:hover { background-color: var(--primary-hover); }
button.ghost:hover { background-color: color-mix(in srgb, var(--blue-soft) 22%, transparent); }
button.danger:hover { background-color: var(--bad); opacity: 0.92; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.chip, .avatar-grid button { border-radius: 999px; }
.avatar-grid button { border-radius: 16px; }
button.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--blue-soft); }
button.danger { background: var(--bad); }
input, select, textarea {
  width: 100%; padding: 12px 16px; border-radius: 10px; border: 2px solid var(--field-line);
  background: var(--paper); min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
label { display: block; font-weight: 700; margin: 12px 0 8px; font-size: 0.95rem; }
.card {
  color: var(--ink);
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 28px); margin: 16px auto; max-width: 880px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.row > .grow { flex: 1 1 260px; }
.muted { color: var(--muted); font-size: 0.95rem; }
h1 + .muted { margin: 0 0 20px; }
.error { color: var(--bad-text); font-weight: 700; min-height: 1.2em; }
.ok { color: var(--ok-text); font-weight: 700; }
.brand { display: flex; align-items: center; gap: 12px; margin: 8px auto 4px; max-width: 880px; }
.brand img { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; background: var(--white); }
.brand strong { font-size: 1.25rem; letter-spacing: 0.3px; }
.brand .spacer { flex: 1; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--chip-bg); color: var(--ink); font-weight: 700; font-size: 0.85rem; }
.pin { font-size: clamp(3rem, 14vw, 7rem); font-weight: 900; letter-spacing: 0.08em; text-align: center; color: var(--ink); margin: 0; }
.center { text-align: center; }
.qr { display: block; margin: 12px auto; width: min(320px, 70vw); height: auto; border-radius: 12px; background: var(--white); padding: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--blue-soft); }
.timer { font-size: clamp(2.5rem, 10vw, 4.5rem); font-weight: 900; text-align: center; }
.timer-bar { height: 12px; border-radius: 999px; background: var(--blue-soft); overflow: hidden; }
.timer-bar > span { display: block; height: 100%; width: 100%; background: var(--turq); transform-origin: left center; transition: transform 0.2s linear; }

/* Botones de respuesta: color + forma + texto, para no depender solo del color. */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.answer {
  min-height: 120px; border-radius: var(--radius); color: var(--white); font-size: clamp(1.05rem, 3.4vw, 1.4rem);
  font-weight: 800; display: flex; align-items: center; gap: 12px; padding: 16px; text-align: left;
  border: 0; box-shadow: var(--shadow); justify-content: flex-start;
}
.answer .shape { font-size: 1.8rem; line-height: 1; flex: 0 0 auto; }
.answer.k0 { background: var(--coral); }
.answer.k1 { background: var(--amber); color: var(--on-amber); }
.answer.k2 { background: var(--sea); }
.answer.k3 { background: var(--night); }
.answer.picked { outline: 5px solid var(--ink); }
.answer:disabled { opacity: 0.55; filter: grayscale(0.6); cursor: not-allowed; }
.answer.correct { box-shadow: 0 0 0 5px var(--ok), var(--shadow); opacity: 1; }
.answer.wrong { opacity: 0.4; }

.bars { display: grid; gap: 12px; margin: 12px 0; }
.bar { display: grid; grid-template-columns: 120px 1fr 44px; gap: 12px; align-items: center; }
.bar .track { background: var(--blue-soft); border-radius: 999px; height: 22px; overflow: hidden; }
.bar .fill { height: 100%; width: 100%; border-radius: 999px; transform-origin: left center; transition: transform 0.4s ease; }

.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.avatar-grid button { background: transparent; padding: 4px; border-radius: 16px; box-shadow: inset 0 0 0 3px transparent; min-height: 0; }
.avatar-grid button[aria-checked="true"] { box-shadow: inset 0 0 0 4px var(--turq); }
.avatar-grid svg, .avatar-badge svg { width: 100%; height: auto; display: block; }
.avatar-badge { width: 120px; margin: 0 auto 8px; }
.avatar-chip { width: 36px; height: 36px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.avatar-chip svg { width: 100%; height: 100%; }

/* Modo tranquilo: sin animaciones y con más contraste. */
body.calm * { animation: none !important; transition: none !important; }
body.calm { --shadow: none; }
body.calm .answer { box-shadow: 0 0 0 3px var(--ink); }

.hidden { display: none !important; }
.stack > * + * { margin-top: 12px; }

@media (max-width: 560px) {
  .answers { grid-template-columns: 1fr; }
  .answer { min-height: 96px; }
  .bar { grid-template-columns: 90px 1fr 38px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===== Panel del profesor ===== */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button.link { background: none; color: var(--link); padding: 0; min-height: 0; font-weight: 700; text-decoration: underline; border-radius: 4px; }
.panel-wrap { max-width: 1100px; margin: 16px auto; }
.panel-head { align-items: flex-end; margin-bottom: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 16px; }
.stat .label { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.stat .value { font-variant-numeric: tabular-nums; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 900; line-height: 1.1; margin-top: 4px; }
.stat .sub { font-size: 0.8rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.tile { margin: 0 0 16px; max-width: none; }
.tile h2 { margin-top: 0; font-size: 1.15rem; }
.badge { display: inline-block; padding: 2px 12px; border-radius: 999px; font-weight: 800; font-size: 0.85rem; background: var(--chip-bg); color: var(--ink); white-space: nowrap; }
.badge.low { background: var(--low-bg); color: var(--low-ink); }
.badge.mid { background: var(--mid-bg); color: var(--mid-ink); }
.badge.high { background: var(--high-bg); color: var(--high-ink); }
.meter { height: 10px; border-radius: 999px; background: var(--blue-soft); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; border-radius: 999px; }
.meter .low { background: var(--amber); } .meter .high { background: var(--turq); }
.item { display: grid; gap: 2px; }
.item .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* ===== Cuestionarios como tarjetas ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { background: var(--paper); background-color: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 2px var(--blue-soft); padding: 8px 16px; min-height: 36px; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--amber); color: var(--on-amber); box-shadow: none; }
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 8px; }
.quiz-card { color: var(--ink); background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.quiz-card .cover { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; font-weight: 900; color: var(--white); }
.quiz-card .body { padding: 12px 16px 16px; display: grid; gap: 8px; flex: 1; }
.quiz-card h3 { margin: 0; font-size: 1.05rem; }
.quiz-card .meta { font-size: 0.85rem; color: var(--muted); }
.quiz-card .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.quiz-card .actions > :first-child, .quiz-card .actions > :last-child { grid-column: 1 / -1; }
.quiz-card .actions button { min-width: 0; padding: 8px 8px; min-height: 40px; font-size: 0.9rem; }
.cover-preview { width: 160px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--blue-soft); flex: 0 0 auto; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Botón peligroso en forma de contorno: texto legible sobre fondo claro u oscuro. */
button.ghost.danger { background: transparent; color: var(--bad-text); box-shadow: inset 0 0 0 2px var(--danger-line); }

/* Resultado de la pregunta para el jugador */
#v-result.res-good h1 { color: var(--ok-text); animation: pop 0.5s ease-out; }
#v-result.res-bad h1 { color: var(--bad-text); }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* Editor de preguntas: filas de opciones, tiempo y explicación, y pie con el botón de quitar */
.opt-row { display: grid; grid-template-columns: 22px 22px 1fr; align-items: center; gap: 12px; margin: 8px 0; font-weight: 400; }
.opt-row input[type=radio] { margin: 0; width: 20px; height: 20px; accent-color: var(--teal); }
.opt-shape { text-align: center; font-size: 1.1rem; }
.q-meta { display: grid; grid-template-columns: 140px 1fr; gap: 16px 16px; margin-top: 16px; }
.q-meta label { margin-bottom: 8px; }
.q-foot { display: flex; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--blue-soft); }
button.btn-remove { border-radius: 10px; padding: 12px 16px; font-size: 0.95rem; }
@media (max-width: 560px) { .q-meta { grid-template-columns: 1fr; } .q-foot { justify-content: stretch; } button.btn-remove { width: 100%; } }

/* ===== Sistema común de formularios y botones (todas las pantallas) ===== */
.field + .field { margin-top: 16px; }
.field > label:first-child, .stack > div > label:first-child { margin-top: 0; }
select { cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; align-items: center; margin-top: 24px; }
.actions .push { margin-right: auto; display: flex; flex-wrap: wrap; gap: 12px; }
.actions button, .actions .btn { min-width: 140px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 12px 20px; border-radius: var(--radius-ctl); white-space: nowrap; font-weight: 700; text-decoration: none; background: var(--primary); color: var(--white); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--blue-soft); }
.btn.sm { min-height: 36px; padding: 8px 12px; font-size: 0.9rem; }
.form-note { margin: 16px 0 0; }
@media (max-width: 560px) {
  .actions { flex-direction: column-reverse; align-items: stretch; }
  .actions .push { margin-right: 0; flex-direction: column; }
  .actions button, .actions .btn { width: 100%; }
}

.choice { display: flex; align-items: center; gap: 12px; margin: 8px 0; font-weight: 400; cursor: pointer; }
.choice.strong { font-weight: 700; margin: 0; flex: 0 0 auto; }
.choice input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: 0 0 auto; accent-color: var(--teal); }
.card h2 { margin-top: 1.4em; }
.card h1 + h2, .card .row h2, .tile h2 { margin-top: 0.4em; }

.stat .value, .timer, .pin, .bar > span:last-child, td { font-variant-numeric: tabular-nums; }

/* Foco visible en todo lo interactivo, aparece al instante */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; transition: none; }

#nav-teacher button[aria-current="page"] { background: var(--primary); color: var(--white); box-shadow: none; }
.panel-box { border: 2px solid var(--blue-soft); border-radius: var(--radius); padding: clamp(16px, 3vw, 24px); margin: 0 0 16px; }
.panel-box h2 { margin-top: 0; }
header.brand .btn { white-space: nowrap; }
button.sm { min-height: 36px; padding: 8px 16px; font-size: 0.9rem; white-space: nowrap; }

/* Competencia: quién va ganando, ranking y despedida */
.leader-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; padding: 12px 16px; border-radius: var(--radius); background: var(--chip-bg); font-weight: 700; text-align: left; }
.leader-banner .avatar-chip { width: 48px; height: 48px; margin: 0; }
.leader-banner .new { background: var(--amber); color: var(--on-amber); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; font-weight: 800; }
.mini-board { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.mini-board li { display: grid; grid-template-columns: 28px 36px 1fr auto; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-ctl); background: var(--chip-bg); font-variant-numeric: tabular-nums; }
.mini-board li.me { box-shadow: inset 0 0 0 3px var(--focus); }
.mini-board .avatar-chip { width: 36px; height: 36px; margin: 0; }
.mini-board .place { font-weight: 800; text-align: center; }
.podium-avatar { width: 56px; height: 56px; margin: 0 auto 8px; }
.goodbye { text-align: center; font-size: 1.2rem; font-weight: 700; margin: 20px 0 0; }
