*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen { display: none; width: 100%; max-width: 780px; padding: 20px; }
.screen.active { display: block; }

/* ---- MENU ---- */
.menu-header {
  text-align: center;
  margin-bottom: 36px;
}
.menu-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: -0.5px;
}
.menu-header p {
  color: #94a3b8;
  margin-top: 6px;
  font-size: 0.95rem;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  margin: 24px 0 10px;
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.exam-btn {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #cbd5e1;
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-size: 0.88rem;
}

.exam-btn .btn-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #f1f5f9;
  display: block;
  margin-bottom: 4px;
}
.exam-btn .btn-sub {
  color: #64748b;
  font-size: 0.78rem;
}

.random-btn {
  width: 100%;
  background: linear-gradient(135deg, #0369a1, #0284c7);
  border: none;
  border-radius: 10px;
  color: white;
  padding: 18px 24px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: opacity 0.15s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}

.random-btn .random-icon { font-size: 1.5rem; }

.stats-bar {
  margin-top: 28px;
  padding: 14px 18px;
  background: #1e293b;
  border-radius: 10px;
  display: flex;
  gap: 24px;
  font-size: 0.8rem;
  color: #64748b;
}
.stats-bar span { display: flex; align-items: center; gap: 6px; }
.stats-bar b { color: #94a3b8; }

/* ---- QUIZ ---- */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.quiz-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-display {
  display: flex;
  align-items: center;
  gap: 16px;
}

.score-box {
  background: #1e293b;
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
  min-width: 80px;
}
.score-box .score-label { font-size: 0.65rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.score-box .score-value { font-size: 1.3rem; font-weight: 700; color: #38bdf8; }

.progress-bar-wrap {
  background: #1e293b;
  border-radius: 100px;
  height: 6px;
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  transition: width 0.3s ease;
  border-radius: 100px;
}

/* ---- NAVIGATOR ---- */
.nav-panel { margin-bottom: 14px; }

.nav-toggle {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #94a3b8;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.12s;
}

.nav-toggle.open { border-color: #38bdf8; color: #e2e8f0; border-radius: 10px 10px 0 0; }
.nav-toggle-label { display: flex; align-items: center; gap: 8px; }
.nav-status { font-size: 0.73rem; color: #64748b; }
.nav-arrow { font-size: 0.75rem; transition: transform 0.2s; }
.nav-toggle.open .nav-arrow { transform: rotate(180deg); }

.nav-grid-wrap {
  background: #1e293b;
  border: 1px solid #38bdf8;
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 12px;
  display: none;
  max-height: 220px;
  overflow-y: auto;
}
.nav-grid-wrap.open { display: block; }
.nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.nav-q-btn {
  width: 34px;
  height: 30px;
  border-radius: 6px;
  border: 1.5px solid #334155;
  background: #0f172a;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
}

.nav-q-btn.current { border-color: #38bdf8 !important; color: #38bdf8 !important; background: #0c1a2e; }
.nav-q-btn.q-correct { border-color: #16a34a; color: #4ade80; background: #052e16; }
.nav-q-btn.q-wrong { border-color: #b91c1c; color: #f87171; background: #2d0808; }

/* ---- REVIEW BADGE ---- */
.review-badge {
  background: #1e3a5f;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: #93c5fd;
  margin-bottom: 12px;
  display: none;
  align-items: center;
  gap: 8px;
}
.review-badge.show { display: flex; }

.question-card {
  background: #1e293b;
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 20px;
}

.q-meta {
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.q-text {
  font-size: 1.05rem;
  line-height: 1.65;
  color: #f1f5f9;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.option-btn {
  background: #1e293b;
  border: 1.5px solid #334155;
  border-radius: 10px;
  color: #cbd5e1;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.5;
  transition: all 0.12s;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.option-btn .opt-letter {
  font-weight: 700;
  color: #38bdf8;
  min-width: 18px;
  flex-shrink: 0;
}
.option-btn:disabled { cursor: default; }

.option-btn.correct {
  background: #14532d;
  border-color: #22c55e;
  color: #bbf7d0;
}
.option-btn.correct .opt-letter { color: #22c55e; }

.option-btn.wrong {
  background: #450a0a;
  border-color: #ef4444;
  color: #fecaca;
}
.option-btn.wrong .opt-letter { color: #ef4444; }

.feedback-banner {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: none;
  align-items: center;
  gap: 10px;
}
.feedback-banner.correct {
  background: #14532d;
  border: 1px solid #22c55e;
  color: #bbf7d0;
}
.feedback-banner.wrong {
  background: #450a0a;
  border: 1px solid #ef4444;
  color: #fecaca;
}
.feedback-banner.show { display: flex; }

.quiz-footer {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-next {
  flex: 1;
  background: #0284c7;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  display: none;
}

.btn-next.show { display: block; }

.btn-home-small {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #64748b;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.12s;
  white-space: nowrap;
}


.btn-finish {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #64748b;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.12s;
  white-space: nowrap;
}


.score-delta {
  position: fixed;
  top: 50%;
  right: 30px;
  transform: translateY(-50%);
  font-size: 1.4rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.score-delta.pos { color: #22c55e; }
.score-delta.neg { color: #ef4444; }
.score-delta.show { opacity: 1; animation: fadeUp 0.8s forwards; }

@keyframes fadeUp {
  0% { opacity: 1; transform: translateY(-50%); }
  100% { opacity: 0; transform: translateY(calc(-50% - 30px)); }
}

/* ---- RESULTS ---- */
.results-card {
  background: #1e293b;
  border-radius: 14px;
  padding: 36px;
  text-align: center;
}
.results-card h2 { font-size: 1.5rem; color: #f1f5f9; margin-bottom: 8px; }
.results-card .exam-name { color: #64748b; font-size: 0.88rem; margin-bottom: 28px; }

.score-big {
  font-size: 4rem;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1;
  margin-bottom: 6px;
}
.score-big.good { color: #22c55e; }
.score-big.bad { color: #ef4444; }
.score-max { font-size: 1rem; color: #64748b; margin-bottom: 24px; }

.results-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 28px;
}
.stat-item { text-align: center; }
.stat-item .stat-val { font-size: 1.8rem; font-weight: 700; }
.stat-item .stat-lbl { font-size: 0.72rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-item.correct .stat-val { color: #22c55e; }
.stat-item.wrong .stat-val { color: #ef4444; }
.stat-item.skipped .stat-val { color: #94a3b8; }

.results-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-primary {
  background: #0284c7;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 13px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-secondary {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 13px 24px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.12s;
}


@media (max-width: 600px) {
  .screen { padding: 14px; }
  .question-card { padding: 18px; }
  .results-card { padding: 24px; }
  .score-big { font-size: 3rem; }
  .results-stats { gap: 16px; }
  .quiz-footer { flex-wrap: wrap; }
  .nav-q-btn { width: 30px; height: 28px; font-size: 0.65rem; }
}
.q-noentra{color:#ef4444;font-weight:800}
.feedback-banner.neutral{background:rgba(100,116,139,.18);color:#cbd5e1;border:1px solid #64748b}
.note-box{display:none;margin:10px 0;padding:10px 14px;border-radius:10px;background:rgba(245,158,11,.12);border:1px solid #f59e0b;color:#fbbf24;font-size:.88rem;line-height:1.45}
.note-box.show{display:block}
.nav-q-btn.q-neutral{background:#64748b;color:#fff}
.sound-btn{background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.2);color:inherit;border-radius:10px;padding:6px 10px;font-size:1.1rem;cursor:pointer}
.sound-btn.off{opacity:.55}
.timer-warn .score-value{color:#ef4444}
.titulo-wrap{display:inline-block;text-align:right}
.aro{display:inline-block;width:1em;height:1em;vertical-align:-.12em;margin-left:.12em}
.copyright{margin-top:2px;font-size:.85rem;letter-spacing:.03em;opacity:.8}
.menu-tools{margin-top:8px}

/* ---- utilidades y pantallas añadidas ---- */
.hidden { display: none !important; }
.random-btn .random-title { font-size: 1rem; }
.random-btn .random-sub { font-size: 0.78rem; opacity: 0.75; margin-top: 2px; }
.btn-linklike { display: inline-block; text-decoration: none; }
.menu-tools { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.menu-user { text-align: center; color: #64748b; font-size: 0.8rem; margin-top: 14px; }
.auth-card { background: #1e293b; border-radius: 14px; padding: 28px; max-width: 440px; margin: 0 auto; }
.auth-card h2 { font-size: 1.25rem; color: #f1f5f9; margin-bottom: 6px; }
.auth-card .auth-help { color: #94a3b8; font-size: 0.85rem; line-height: 1.5; margin-bottom: 18px; }
.form-group input[type="text"], .form-group input[type="email"], .form-group input[type="password"],
.form-group input[type="number"], .form-group input[type="date"] {
  width: 100%; background: #0f172a; border: 1.5px solid #334155; border-radius: 8px;
  color: #e2e8f0; padding: 10px 14px; font-size: 0.95rem; outline: none;
}
.form-group input:focus { border-color: #38bdf8; }
.auth-card .btn-primary { width: 100%; margin-top: 6px; }
.form-error { display: none; margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; font-size: 0.85rem;
  background: #450a0a; border: 1px solid #ef4444; color: #fecaca; }
.form-error.show { display: block; }
.form-ok { display: none; margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; font-size: 0.85rem;
  background: #14532d; border: 1px solid #22c55e; color: #bbf7d0; }
.form-ok.show { display: block; }
.qr-wrap { background: #fff; border-radius: 10px; padding: 10px; width: 220px; height: 220px; margin: 0 auto 14px; }
.qr-wrap img { width: 100%; height: 100%; display: block; }
.secret-text { font-family: ui-monospace, Menlo, Consolas, monospace; background: #0f172a; border: 1px solid #334155;
  border-radius: 8px; padding: 10px; text-align: center; letter-spacing: 2px; word-break: break-all; margin-bottom: 16px; color: #f1f5f9; user-select: all; }
.code-input { text-align: center; letter-spacing: 6px; font-size: 1.3rem !important; }
.link-btn { background: none; border: none; color: #64748b; cursor: pointer; font-size: 0.82rem; margin-top: 14px; text-decoration: underline; }

.center { text-align: center; }

/* marca de agua */
#watermark { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: .07; background-repeat: repeat; }

/* protecciones ligeras */
.question-card, .options-grid, .note-box, .feedback-banner { user-select: none; -webkit-user-select: none; }
@media print { body { display: none; } }

/* ---- administración ---- */
body.admin-body { align-items: flex-start; }
.admin-wrap { width: 100%; max-width: 1180px; padding: 20px; }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-top h1 { font-size: 1.5rem; color: #38bdf8; }
.admin-card { background: #1e293b; border-radius: 14px; padding: 20px; margin-bottom: 20px; overflow-x: auto; }
.admin-card h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 14px; }
.admin-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.admin-form .form-group { margin-bottom: 0; flex: 1 1 180px; }
.admin-form .btn-primary { padding: 11px 20px; }
.temp-pass { margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: rgba(245,158,11,.12); border: 1px solid #f59e0b; color: #fbbf24; font-size: .88rem; }
.temp-pass code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; color: #fde68a; user-select: all; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.tbl th { text-align: left; color: #64748b; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; border-bottom: 1px solid #334155; white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid #263349; vertical-align: top; color: #cbd5e1; }
.tbl input[type="date"], .tbl input[type="number"] { background: #0f172a; border: 1px solid #334155; border-radius: 6px; color: #e2e8f0; padding: 4px 6px; font-size: .8rem; }
.tbl input[type="number"] { width: 56px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-btn { background: #0f172a; border: 1px solid #334155; border-radius: 6px; color: #94a3b8; padding: 4px 9px; font-size: .75rem; cursor: pointer; }


.badge { display: inline-block; padding: 2px 8px; border-radius: 100px; font-size: .7rem; font-weight: 700; }
.badge.on { background: #14532d; color: #bbf7d0; }
.badge.off { background: #450a0a; color: #fecaca; }
.badge.neutral { background: #334155; color: #cbd5e1; }
.log-scroll { max-height: 340px; overflow-y: auto; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.random-btn .random-sub { font-weight: 400; }

/* aviso anti-captura */
#screenQuiz.guarded .question-card, #screenQuiz.guarded .options-grid, #screenQuiz.guarded .feedback-banner,
#screenQuiz.guarded .note-box, #screenQuiz.guarded .nav-panel { filter: blur(18px); }
.guard-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  pointer-events: none; font-size: 1.4rem; font-weight: 700; color: #f1f5f9; text-align: center; padding: 20px; text-shadow: 0 2px 12px #000; }
.capture-modal { position: fixed; inset: 0; z-index: 80; background: rgba(2,6,23,.75); display: flex; align-items: center; justify-content: center; padding: 20px; }
.capture-box { background: #1e293b; border: 1px solid #f59e0b; border-radius: 14px; padding: 24px; max-width: 420px; text-align: center; }
.capture-box p { color: #fbbf24; line-height: 1.5; margin-bottom: 16px; }

@media (hover: hover) {
  .exam-btn:hover {
  background: #293548;
  border-color: #38bdf8;
  color: #e2e8f0;
}
  .random-btn:hover { opacity: 0.9; }
  .nav-toggle:hover { border-color: #64748b; }
  .nav-q-btn:hover { border-color: #64748b; color: #94a3b8; }
  .option-btn:hover:not(:disabled) {
  background: #293548;
  border-color: #38bdf8;
  color: #f1f5f9;
}
  .btn-next:hover { opacity: 0.9; }
  .btn-home-small:hover { border-color: #64748b; color: #94a3b8; }
  .btn-finish:hover { border-color: #f59e0b; color: #f59e0b; }
  .btn-primary:hover { opacity: 0.9; }
  .btn-secondary:hover { border-color: #64748b; color: #e2e8f0; }
  .link-btn:hover { color: #94a3b8; }
  .mini-btn:hover { border-color: #38bdf8; color: #e2e8f0; }
  .mini-btn.danger:hover { border-color: #ef4444; color: #fca5a5; }
}

/* ================= RESPONSIVE (mobile-first sobre la base) ================= */
:root { color-scheme: dark; }
html { background: #0f172a; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-wrap: anywhere;
}
.screen { min-width: 0; padding: 14px; }
#screenMenu { max-width: 1100px; }
#screenQuiz, #screenResults { max-width: 860px; }
button, a.btn-secondary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, .btn-linklike { min-height: 44px; }
.exam-btn { min-height: 64px; }
.form-group input[type="text"], .form-group input[type="email"], .form-group input[type="password"],
.form-group input[type="number"], .form-group input[type="date"] { font-size: 1rem; min-height: 46px; }
.menu-header h1 { font-size: 1.5rem; }
.exam-grid { grid-template-columns: 1fr; }
.menu-tools .btn-secondary { min-width: 140px; }

/* cabecera del examen fija arriba */
.quiz-header {
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap; gap: 6px;
  background: #0f172a; padding: 8px 0; margin-bottom: 8px;
}
.quiz-title { flex: 1 1 100%; }
.score-display { width: 100%; gap: 8px; }
.score-box { flex: 1 1 0; min-width: 0; padding: 6px 8px; }
.score-box .score-value { font-size: 1.1rem; }
.sound-btn { min-width: 44px; min-height: 44px; }
.question-card { padding: 16px; }
.q-text { font-size: 1rem; }
.option-btn { min-height: 56px; padding: 14px 16px; font-size: 1rem; }
.nav-toggle { min-height: 44px; }
.nav-q-btn { width: 44px; height: 44px; font-size: 0.8rem; }
.nav-grid { gap: 6px; }
.nav-grid-wrap { max-height: 40vh; max-height: 40dvh; }
.quiz-footer {
  position: sticky; bottom: 0; z-index: 40; background: #0f172a;
  padding: 8px 0 8px; margin-top: 4px;
}
.btn-next, .btn-home-small, .btn-finish { min-height: 48px; }
.btn-primary, .btn-secondary { min-height: 48px; }
.kbd-hint { display: none; text-align: center; color: #64748b; font-size: 0.75rem; margin: 6px 0 2px; }
.score-delta { right: 12px; }
.results-card { padding: 24px 16px; }
.results-stats { gap: 14px; flex-wrap: wrap; }
.mini-btn { min-height: 36px; padding: 6px 10px; }
.capture-box { width: 100%; }

@media (min-width: 480px) {
  .menu-header h1 { font-size: 2rem; }
  .score-box .score-value { font-size: 1.3rem; }
  .score-box { padding: 8px 12px; }
  .exam-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (min-width: 768px) {
  .screen { padding: 24px; }
  .exam-grid { grid-template-columns: repeat(2, 1fr); }
  .quiz-header { flex-wrap: nowrap; }
  .quiz-title { flex: 1 1 auto; }
  .score-display { width: auto; }
  .score-box { flex: 0 0 auto; min-width: 84px; }
  .question-card { padding: 28px; }
  .option-btn { min-height: 52px; }
  .nav-q-btn { width: 38px; height: 34px; }
  .quiz-footer { position: static; padding: 0; }
  .kbd-hint { display: block; }
  .admin-wrap { padding: 28px; }
}
@media (min-width: 1100px) {
  .exam-grid { grid-template-columns: repeat(3, 1fr); }
  .screen { padding: 32px; }
}
@media (max-width: 767px) {
  .tbl input[type="date"], .tbl input[type="number"] { font-size: 16px; min-height: 40px; }
  .admin-form .form-group { flex: 1 1 100%; }
}
@media (hover: none) { .kbd-hint { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
