/* =========================================================
   ESTILOS - JUEGA Y APRENDE | STAND UNIÓN EUROPEA 2026
   Optimizados para Tablets Gigantes y Tótems Táctiles 9:16
   ========================================================= */

:root {
  --eu-blue: #023399;
  --eu-blue-dark: #032874;
  --eu-blue-deep: #00095e;
  --eu-wood-blue: #187ec1;
  --eu-wood-dark: #125f94;
  --eu-yellow: #ffcd00;
  --eu-yellow-warm: #ffbc5b;
  --eu-sky-light: #91c6de;
  --eu-white: #ffffff;
  --eu-bg-card: rgba(255, 255, 255, 0.96);
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-error: #dc2626;
  --color-error-bg: #fee2e2;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 10px 20px -3px rgba(3, 40, 116, 0.25);
  --shadow-lg: 0 20px 30px -5px rgba(3, 40, 116, 0.35);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 32px;
  --radius-pill: 9999px;
  --font-main: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Montserrat', system-ui, sans-serif;
}

/* Reset y base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: var(--font-main);
  background-color: var(--eu-wood-dark);
  color: var(--eu-blue-dark);
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  position: relative;
  background-image: radial-gradient(circle at 50% 20%, rgba(24, 126, 193, 0.35) 0%, rgba(2, 51, 153, 0.8) 100%);
}

/* Canvas de Confeti */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* Contenedor Principal (Tótem / Tablet Vertical) */
.totem-container {
  width: 100%;
  max-width: 620px;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--eu-wood-blue) url('assets/wood_texture.png') repeat-y center top;
  background-size: cover;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Barra superior externa: "Pared de juega y aprende" */
.top-pill-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px 8px;
  z-index: 20;
}

.pill-badge {
  background: var(--eu-yellow);
  color: var(--eu-blue-dark);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: -0.2px;
  padding: 8px 24px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: var(--eu-white);
  border-radius: var(--radius-pill);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.45);
}

/* Cabecera Oficial (Slide 54) */
.stand-header-banner {
  width: 100%;
  padding: 6px 16px 12px;
  display: flex;
  justify-content: center;
  z-index: 15;
}

.stand-header-img {
  width: 100%;
  max-width: 580px;
  height: auto;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 6px 16px rgba(0, 9, 94, 0.35));
}

/* Doodles flotantes decorativos */
.doodle {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
  opacity: 0.85;
}

.doodle-sol {
  top: 15px;
  left: -20px;
  width: 110px;
  animation: spinSlow 40s linear infinite;
}

.doodle-viento {
  top: 130px;
  right: -30px;
  width: 130px;
  animation: floatWind 6s ease-in-out infinite alternate;
}

.doodle-mariposa {
  top: 240px;
  left: 10px;
  width: 45px;
  animation: flutter 4s ease-in-out infinite;
}

.doodle-paraba {
  bottom: 80px;
  right: 10px;
  width: 95px;
  animation: bobbing 5s ease-in-out infinite alternate;
}

.doodle-palma {
  bottom: 10px;
  left: 5px;
  width: 85px;
  opacity: 0.65;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes floatWind {
  from { transform: translateX(0) scale(1); }
  to { transform: translateX(-15px) scale(1.05); }
}

@keyframes flutter {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(8deg); }
}

@keyframes bobbing {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

/* Área de contenido del juego */
.game-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 20px;
  z-index: 10;
  position: relative;
}

/* Pantallas / Vistas */
.screen-view {
  display: none;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.screen-view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   PANTALLA 1: INICIO & SELECCIÓN DE CATEGORÍA
   ========================================================= */
.welcome-hero {
  text-align: center;
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  padding: 20px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 3px solid rgba(255, 255, 255, 0.8);
}

.welcome-badge {
  display: inline-block;
  background: var(--eu-blue);
  color: var(--eu-white);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 10px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--eu-blue-dark);
  line-height: 1.2;
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 1.05rem;
  color: #334155;
  line-height: 1.4;
  font-weight: 600;
}

/* Grilla de Categorías */
.categories-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.cat-card {
  background: var(--eu-bg-card);
  border: 3px solid transparent;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  position: relative;
  overflow: hidden;
}

.cat-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

.cat-card::after {
  content: '➔';
  position: absolute;
  right: 18px;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--eu-blue);
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.cat-card:active::after {
  transform: translateX(4px);
  opacity: 1;
}

.cat-icon-wrap {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.cat-svg-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.quiz-cat-icon-svg {
  width: 26px;
  height: 26px;
  object-fit: contain;
  margin-right: 4px;
}

.cat-details {
  flex: 1;
  padding-right: 20px;
}

.cat-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--eu-blue-dark);
  margin-bottom: 4px;
}

.cat-desc {
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.35;
  font-weight: 500;
}

.cat-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--eu-blue-dark);
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  margin-top: 5px;
}

/* Variaciones por categoría con paleta oficial UE */
.cat-card[data-cat="energias_renovables"] {
  border: 2.5px solid rgba(255, 205, 0, 0.4);
}
.cat-card[data-cat="energias_renovables"] .cat-icon-wrap {
  background: #032874;
  border: 2px solid #FFCD00;
}

.cat-card[data-cat="medio_ambiente"] {
  border: 2.5px solid rgba(22, 163, 74, 0.4);
}
.cat-card[data-cat="medio_ambiente"] .cat-icon-wrap {
  background: #064e3b;
  border: 2px solid #22c55e;
}

.cat-card[data-cat="global_gateway"] {
  border: 2.5px solid rgba(2, 51, 153, 0.4);
}
.cat-card[data-cat="global_gateway"] .cat-icon-wrap {
  background: #023399;
  border: 2px solid #38bdf8;
}

.cat-card[data-cat="unidos_somos_futuro"] {
  border: 2.5px solid rgba(3, 40, 116, 0.4);
}
.cat-card[data-cat="unidos_somos_futuro"] .cat-icon-wrap {
  background: #00095e;
  border: 2px solid #FFCD00;
}

.cat-card-mixed {
  background: linear-gradient(135deg, #032874, #023399);
  border: 3px solid #ffcd00;
  color: var(--eu-white);
}

.cat-card-mixed .cat-name {
  color: var(--eu-yellow);
}

.cat-card-mixed .cat-desc {
  color: #e2e8f0;
}

.cat-card-mixed .cat-icon-wrap {
  background: #032874;
  border: 2px solid #ffcd00;
}

.cat-card-mixed .cat-count {
  background: rgba(255, 255, 255, 0.2);
  color: var(--eu-white);
}

.cat-card-mixed::after {
  color: var(--eu-yellow);
  opacity: 0.9;
}

/* Footer con logo Unidos Somos Futuro */
.totem-footer {
  margin-top: auto;
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(3, 40, 116, 0.85);
  backdrop-filter: blur(10px);
  z-index: 15;
}

.footer-kv-img {
  height: 48px;
  width: auto;
  filter: brightness(0) invert(1) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* =========================================================
   PANTALLA 2: PREGUNTA ACTIVA (QUIZ)
   ========================================================= */
.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.quiz-cat-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--eu-blue-dark);
}

.quiz-score-pill {
  background: var(--eu-yellow);
  color: var(--eu-blue-dark);
  font-weight: 900;
  font-size: 0.95rem;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
}

/* Barra de Progreso */
.quiz-progress-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.quiz-progress-fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, var(--eu-yellow), #f59e0b);
  border-radius: var(--radius-pill);
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tarjeta de la Pregunta */
.question-card {
  background: var(--eu-white);
  border-radius: var(--radius-md);
  padding: 24px 22px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
  border: 3px solid rgba(2, 51, 153, 0.15);
  position: relative;
}

.question-counter {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--eu-blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.question-text {
  font-family: var(--font-display);
  font-size: 1.38rem;
  font-weight: 800;
  color: var(--eu-blue-dark);
  line-height: 1.35;
}

/* Opciones de Respuesta */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.option-btn {
  background: var(--eu-white);
  border: 3px solid rgba(2, 51, 153, 0.2);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-main);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--eu-blue-dark);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
}

.option-btn:active:not(:disabled) {
  transform: scale(0.98);
  border-color: var(--eu-blue);
  background: #f8fafc;
}

.opt-letter {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  background: #e2e8f0;
  color: var(--eu-blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.opt-text {
  flex: 1;
  line-height: 1.3;
}

/* Estados de respuesta */
.option-btn.correct {
  background: var(--color-success-bg) !important;
  border-color: var(--color-success) !important;
  color: #14532d !important;
  box-shadow: 0 0 15px rgba(22, 163, 74, 0.35);
}

.option-btn.correct .opt-letter {
  background: var(--color-success);
  color: var(--eu-white);
}

.option-btn.wrong {
  background: var(--color-error-bg) !important;
  border-color: var(--color-error) !important;
  color: #7f1d1d !important;
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.25);
}

.option-btn.wrong .opt-letter {
  background: var(--color-error);
  color: var(--eu-white);
}

.option-btn:disabled {
  cursor: default;
}

/* Píldora Didáctica ("¿Sabías que...?") */
.didactic-pill {
  display: none;
  background: #eff6ff;
  border-left: 6px solid var(--eu-blue);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.didactic-pill.active {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.didactic-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--eu-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}

.didactic-text {
  font-size: 1rem;
  color: #1e293b;
  line-height: 1.45;
  font-weight: 600;
}

/* Botón Siguiente */
.next-action-wrap {
  display: none;
  justify-content: center;
  margin-top: 6px;
}

.next-action-wrap.active {
  display: flex;
}

.btn-primary {
  background: linear-gradient(135deg, var(--eu-yellow), #f59e0b);
  color: var(--eu-blue-dark);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-pill);
  padding: 18px 36px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* =========================================================
   PANTALLA 3: RESULTADOS Y EVALUACIÓN
   ========================================================= */
.results-card {
  background: var(--eu-white);
  border-radius: var(--radius-md);
  padding: 30px 22px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--eu-yellow);
  margin-bottom: 18px;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.results-badge-icon {
  font-size: 4.5rem;
  line-height: 1;
  margin-bottom: 14px;
  display: inline-block;
  animation: bounceSlow 2s infinite ease-in-out;
}

@keyframes bounceSlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.results-level-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--eu-blue-dark);
  margin-bottom: 10px;
}

.results-score-display {
  display: inline-block;
  background: #f1f5f9;
  border-radius: var(--radius-pill);
  padding: 8px 24px;
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--eu-blue);
  margin-bottom: 16px;
  border: 2px solid #cbd5e1;
}

.results-feedback-box {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #334155;
  line-height: 1.45;
  border: 2px dashed #cbd5e1;
  margin-bottom: 18px;
}

/* Acciones Finales */
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--eu-blue-dark);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  border: 2px solid var(--eu-blue);
  border-radius: var(--radius-pill);
  padding: 14px 28px;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:active {
  background: #e2e8f0;
  transform: scale(0.98);
}

.auto-reset-notice {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Ajustes Responsivos para Tablets Muy Grandes */
@media (min-width: 900px) {
  .totem-container {
    max-width: 760px;
  }
  .question-text {
    font-size: 1.55rem;
  }
  .option-btn {
    font-size: 1.25rem;
    padding: 18px 24px;
  }
  .welcome-title {
    font-size: 2.1rem;
  }
}
