:root {
  --azul-profundo: #0B2545;   /* fondo principal — cielo nocturno de 1811 */
  --azul-medio:    #123A6B;   /* paneles y superficies elevadas */
  --azul-borde:    #1F4E8C;   /* bordes y divisores sobre azul */
  --papel:         #F3E9D2;   /* tarjetas tipo "mapa/pergamino" */
  --tinta:         #1C1608;   /* texto sobre papel */
  --amarillo:      #F4B400;   /* acento — tema amarillo / oro llanero */
  --amarillo-oscuro: #C98D00;
  --rojo:          #C81D25;   /* acento — tema rojo / alertas / examen */
  --azul-tema:     #2E6DB4;   /* acento — tema azul (distinto del fondo) */
  --hueso:         #FBF8F1;   /* texto sobre azul profundo */
  --hueso-tenue:   rgba(251, 248, 241, 0.72);

  /* Tipografía */
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Public Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;

  /* Layout */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-card: 0 10px 30px rgba(6, 16, 33, 0.35);
  --max-width: 720px;
}

/* ---------- RESET BÁSICO ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--azul-profundo);
  color: var(--hueso);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0 0 0.5em;
  line-height: 1.15;
}

p { margin: 0 0 1em; line-height: 1.5; }

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--amarillo);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  vertical-align: middle;
}

/* ---------- UTILIDADES DE BOTÓN ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--amarillo);
  color: var(--tinta);
  box-shadow: 0 6px 16px rgba(244, 180, 0, 0.35);
}

.btn-primary:hover { transform: translateY(-2px); }

.btn-primary:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.link-btn {
  background: none;
  border: none;
  color: var(--amarillo);
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
}

.icon-btn {
  background: var(--azul-medio);
  border: 1px solid var(--azul-borde);
  color: var(--hueso);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- SCREEN: BIENVENIDA ---------- */
#welcome-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(244, 180, 0, 0.10), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(200, 29, 37, 0.12), transparent 45%),
    var(--azul-profundo);
}

.welcome-card {
  width: 100%;
  max-width: var(--max-width);
  background: var(--azul-medio);
  border: 1px solid var(--azul-borde);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
}

.welcome-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--azul-borde);
  transition: background 0.2s ease, transform 0.2s ease;
}

.dot.is-active {
  background: var(--amarillo);
  transform: scale(1.3);
}

.welcome-slide {
  display: none;
  text-align: center;
  animation: fade-in 0.35s ease;
}

.welcome-slide.is-active { display: block; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-media {
  width: 96px;
  height: 96px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--papel);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 6px var(--amarillo);
}

.welcome-media .material-symbols-outlined {
  font-size: 44px;
  color: var(--azul-profundo);
}

.welcome-title {
  font-size: 1.6rem;
  color: var(--hueso);
}

.welcome-text {
  color: var(--hueso-tenue);
  font-size: 1rem;
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
}

.btn-next, .btn-start {
  margin-top: 8px;
}

/* Selector de año (ventana 4) */
.year-picker {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 24px 0;
}

.year-chip {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--azul-borde);
  background: var(--azul-profundo);
  color: var(--hueso);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.year-chip:hover { transform: translateY(-2px); }

.year-chip[aria-checked="true"] {
  background: var(--amarillo);
  border-color: var(--amarillo);
  color: var(--tinta);
}

/* ---------- TOP BAR ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--azul-medio);
  border-bottom: 1px solid var(--azul-borde);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 50px;
  height: 58px;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.lives-display {
  display: flex;
  gap: 3px;
}

.life-icon {
  color: var(--rojo);
  font-size: 20px;
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

.life-icon.is-lost {
  color: var(--azul-borde);
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* ---------- MENÚ PRINCIPAL ---------- */
.screen-panel {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.year-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--hueso-tenue);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.year-indicator .material-symbols-outlined {
  font-size: 20px;
  color: var(--amarillo);
}

.platform-info {
  background: var(--azul-medio);
  border: 1px solid var(--azul-borde);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 24px;
}

.platform-info h2 {
  font-size: 1.1rem;
  color: var(--amarillo);
}

.platform-info p {
  color: var(--hueso-tenue);
  margin: 0;
  font-size: 0.92rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--hueso-tenue);
  padding: 40px 16px;
  border: 1px dashed var(--azul-borde);
  border-radius: var(--radius-md);
}

.empty-state .material-symbols-outlined {
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--amarillo);
}

/* Tarjeta de nivel — el color lo define el TEMA, no la categoría */
.level-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: var(--papel);
  color: var(--tinta);
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 120px;
  text-align: left;
  box-shadow: var(--shadow-card);
  border-top: 6px solid var(--azul-tema); /* color por defecto; JS lo sobreescribe por tema */
  transition: transform 0.15s ease;
}

.level-card:hover { transform: translateY(-3px); }

.level-card[data-theme-color="amarillo"] { border-top-color: var(--amarillo); }
.level-card[data-theme-color="azul"]     { border-top-color: var(--azul-tema); }
.level-card[data-theme-color="rojo"]     { border-top-color: var(--rojo); }

.level-card__icon {
  font-size: 30px;
  color: var(--azul-profundo);
}

.level-card__topic {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.level-card__category {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--azul-medio);
}

/* ---------- VISTA DE NIVEL ---------- */
#level-view {
  position: relative;
}

.exit-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  background: var(--azul-medio);
  border: 1px solid var(--azul-borde);
  color: var(--hueso);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-view__title {
  text-align: center;
  padding-top: 8px;
  font-size: 1.3rem;
}

.level-content {
  background: var(--papel);
  color: var(--tinta);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 280px;
}

.level-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  min-height: 240px;
  gap: 12px;
  color: var(--azul-medio);
}

.level-placeholder .material-symbols-outlined {
  font-size: 40px;
  color: var(--azul-tema);
}

.level-placeholder p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.level-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--azul-medio);
  border: 1px solid var(--azul-borde);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
}

.level-footer__lives, .level-footer__score {
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-footer__lives .material-symbols-outlined { color: var(--rojo); }
.level-footer__score .material-symbols-outlined { color: var(--amarillo); }

/* --- Aprendizaje --- */
.video-wrapper {
  aspect-ratio: 16 / 9;
  background: var(--tinta);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.video-frame { width: 100%; height: 100%; }
.video-frame iframe { width: 100%; height: 100%; display: block; border: 0; }

.video-support-text {
  font-size: 0.92rem;
  color: var(--tinta);
}

.level-learning__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- Examen --- */
.exam-progress {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--azul-medio);
  margin-bottom: 8px;
}

.exam-tally {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.tally {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.tally--correct { color: #1E7A34; }
.tally--incorrect { color: var(--rojo); }

.exam-question {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.exam-options {
  display: grid;
  gap: 10px;
}

/* --- Línea de tiempo --- */
.timeline-instruction {
  font-weight: 600;
  margin-bottom: 14px;
}

.timeline-slots {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.timeline-slot {
  position: relative;
  min-height: 56px;
  border: 2px dashed var(--azul-borde);
  border-radius: var(--radius-sm);
  background: rgba(31, 78, 140, 0.06);
  display: flex;
  align-items: center;
  padding: 10px 14px 10px 44px;
  font-weight: 600;
  color: var(--tinta);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.timeline-slot__number {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--azul-tema);
  color: var(--hueso);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-slot.is-filled {
  border-style: solid;
  border-color: var(--azul-tema);
  background: var(--papel);
}

.timeline-slot.is-empty {
  color: var(--hueso-tenue);
  font-weight: 400;
  font-style: italic;
}

.timeline-pool {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.timeline-card {
  border: 2px solid var(--azul-borde);
  border-radius: var(--radius-sm);
  background: var(--hueso);
  color: var(--tinta);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-family: var(--font-body);
}

.timeline-card.is-selected {
  border-color: var(--amarillo);
  background: rgba(244, 180, 0, 0.15);
}

.timeline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-secondary {
  background: transparent;
  color: var(--azul-medio);
  border: 2px solid var(--azul-borde);
}

.btn-secondary:hover { transform: translateY(-2px); }

/* --- Clasificación --- */
.clasificacion-text {
  font-weight: 600;
  margin-bottom: 14px;
}

.clasificacion-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.clasificacion-column__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--azul-medio);
  margin: 0 0 8px;
}

.clasificacion-column[data-column="correcto"] .clasificacion-column__title .material-symbols-outlined {
  color: #1E7A34;
}

.clasificacion-column[data-column="incorrecto"] .clasificacion-column__title .material-symbols-outlined {
  color: var(--rojo);
}

.clasificacion-column__drop {
  min-height: 120px;
  border: 2px dashed var(--azul-borde);
  border-radius: var(--radius-sm);
  background: rgba(31, 78, 140, 0.06);
  padding: 10px;
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.clasificacion-drop-hint {
  border: 1px dashed var(--azul-borde);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--hueso-tenue);
  cursor: pointer;
}

/* ---------- MODAL DE RESULTADO ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--papel);
  color: var(--tinta);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.modal-icon {
  font-size: 48px;
  color: var(--amarillo-oscuro);
}

.modal-title {
  font-size: 1.4rem;
}

.modal-score {
  font-family: var(--font-mono);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

#result-modal.is-win .modal-icon {
  color: var(--amarillo);
}

#result-modal.is-loss .modal-icon {
  color: var(--rojo);
}

#result-modal.is-loss .modal-card {
  border: 2px solid var(--rojo);
}

#lockout-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#welcome-screen[hidden],
#lockout-screen[hidden] {
  display: none;
}

.lockout-card {
  max-width: 420px;
  text-align: center;
}

.lockout-icon {
  font-size: 56px;
  color: var(--rojo);
}

.lockout-title { font-size: 1.5rem; }

.lockout-subtitle { color: var(--hueso-tenue); }

.lockout-timer {
  font-family: var(--font-mono);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--amarillo);
  margin: 8px 0 24px;
}

.curiosity-box {
  background: var(--azul-medio);
  border: 1px solid var(--azul-borde);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.curiosity-box .material-symbols-outlined {
  color: var(--amarillo);
  margin-bottom: 6px;
}

@keyframes ghc-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

#curiosity-text.is-fading {
  animation: ghc-fade-in 0.4s ease;
}

@media (min-width: 720px) {
  .welcome-card { padding: 48px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

.characters-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.characters-column {
  display: grid;
  gap: 10px;
}

/* --- Tarjetas de imagen (cubren la tarjeta completa, sin círculo) --- */
.btn-character-name {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 3px;
  border: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--azul-borde);
}

.btn-character-name img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-sm) - 3px);
  transition: filter 0.2s ease, opacity 0.2s ease;
}

.btn-character-name.is-glowing {
  background: linear-gradient(90deg, var(--amarillo), var(--azul-medio), #C0C0C0, var(--rojo), var(--amarillo));
  background-size: 300% 300%;
  animation: characters-glow 2.5s linear infinite;
}

.btn-character-name.is-selected {
  background: var(--amarillo-oscuro);
}

.btn-character-name.is-dimmed img {
  filter: grayscale(1);
  opacity: 0.5;
}

/* --- Tarjetas de texto --- */
.btn-character-fact {
  min-height: 64px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.85rem;
  color: var(--tinta);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 3px solid var(--azul-borde);
  background: rgba(31, 78, 140, 0.06);
}

.btn-character-fact.is-glowing {
  border-color: transparent;
  background:
    linear-gradient(rgba(31, 78, 140, 0.06), rgba(31, 78, 140, 0.06)) padding-box,
    linear-gradient(90deg, var(--amarillo), var(--azul-medio), #C0C0C0, var(--rojo), var(--amarillo)) border-box;
  background-size: 100% 100%, 300% 300%;
  animation: characters-glow-border 2.5s linear infinite;
}

.btn-character-fact.is-selected {
  border-color: var(--amarillo-oscuro);
}

/* --- Estados compartidos --- */
.btn-character-name:disabled,
.btn-character-fact:disabled {
  cursor: default;
}

.btn-character-name.is-matched {
  background: #1E7A34;
}

.btn-character-fact.is-matched {
  border-color: #1E7A34;
  background: #1E7A34;
  color: #fff;
}

.btn-character-name.is-wrong {
  background: var(--rojo);
  animation: characters-shake 0.4s ease;
}

.btn-character-fact.is-wrong {
  border-color: var(--rojo);
  background: rgba(196, 30, 30, 0.15);
  animation: characters-shake 0.4s ease;
}

@keyframes characters-glow {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

@keyframes characters-glow-border {
  0% { background-position: 0% 0%, 0% 50%; }
  100% { background-position: 0% 0%, 300% 50%; }
}

@keyframes characters-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.welcome-media__icon {
  width: 96px;
  height: 96px;
  object-fit: contain;
}