/* ============================================================
   EL CEDRO LAND – ESTILOS PRINCIPALES
   Café El Cedro | Mallama, Nariño, Colombia
   Paleta: #0b3d2e (verde bosque), #5c3a21 (madera), #f4e4c1 (pergamino)
   ============================================================ */

/* ---- RESET & VARIABLES ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --verde:         #0b3d2e;
  --verde-medio:   #1a6645;
  --verde-claro:   #2d9e6b;
  --verde-muy-claro: #a8d5b5;
  --madera:        #5c3a21;
  --madera-claro:  #8b5e3c;
  --pergamino:     #f4e4c1;
  --pergamino-osc: #e8cc99;
  --rojo-cereza:   #c0392b;
  --dorado:        #d4a017;
  --blanco:        #ffffff;
  --negro:         #0a0a0a;
  --gris-os:       #222222;
  --fuente-pixel:  'Press Start 2P', monospace;
  --fuente-ui:     'Nunito', sans-serif;
  --fuente-titulo: 'Lora', Georgia, 'Times New Roman', serif;
  --radio:         12px;
  --radio-sm:      6px;
  --sombra:        0 4px 20px rgba(0,0,0,0.5);
  --sombra-pixel:  4px 4px 0 rgba(0,0,0,0.6);
  --trans:         0.2s ease;

  /* Rellenos de barras de progreso */
  --barra-verde:  linear-gradient(180deg, #7ecb95 0%, #4ea86d 55%, #3b8a58 100%);
  --barra-ambar:  linear-gradient(180deg, #f0cd6a 0%, #d9a42c 55%, #b8831f 100%);
  --barra-roja:   linear-gradient(180deg, #e8806f 0%, #c0392b 55%, #96271c 100%);
  --barra-dorada: linear-gradient(180deg, #f3d98a 0%, #d4a017 55%, #a97b0e 100%);
  --barra-pista:  #e8d5b0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--verde);
  color: var(--blanco);
  font-family: var(--fuente-ui);
  font-size: 16px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

a { color: var(--verde-claro); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; border: none; outline: none; font-family: var(--fuente-ui); }

ul { list-style: none; }

.oculto { display: none !important; }

/* ============================================================
   PANTALLA DE CARGA
============================================================ */
#pantalla-carga {
  position: fixed;
  inset: 0;
  background: var(--verde);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 16px;
}

.carga-contenido {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.carga-logo {
  width: 100px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  animation: flotarLogo 2s ease-in-out infinite;
}

.carga-titulo {
  font-family: var(--fuente-pixel);
  font-size: clamp(14px, 4vw, 22px);
  color: var(--pergamino);
  text-shadow: var(--sombra-pixel);
  line-height: 1.6;
}

.carga-subtitulo {
  font-size: 14px;
  color: var(--verde-muy-claro);
  font-weight: 700;
}

.barra-carga-contenedor {
  width: 100%;
  height: 16px;
  background: var(--barra-pista);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(120, 85, 40, 0.4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
}

.barra-carga {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--barra-verde);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: width 0.4s ease;
}

/* Brillo superior del relleno (estilo referencia) */
.barra-carga::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 2px;
  height: 32%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.carga-texto {
  font-size: 12px;
  color: var(--verde-muy-claro);
  font-family: var(--fuente-pixel);
  font-size: clamp(8px, 2vw, 10px);
}

/* ============================================================
   PANTALLA DE INICIO
============================================================ */
#pantalla-inicio {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a6645 0%, #0b3d2e 70%, #061f17 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 16px;
}

.pantalla { display: flex; }

.inicio-caja {
  background: rgba(0,0,0,0.5);
  border: 3px solid var(--verde-claro);
  border-radius: var(--radio);
  padding: clamp(24px, 5vw, 48px);
  max-width: 520px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--sombra), 0 0 60px rgba(45,158,107,0.3);
}

.inicio-logo {
  width: clamp(80px, 20vw, 130px);
  height: auto;
  image-rendering: pixelated;
  animation: flotarLogo 2.5s ease-in-out infinite;
}

.inicio-titulo {
  font-family: var(--fuente-pixel);
  font-size: clamp(14px, 4vw, 22px);
  color: var(--pergamino);
  text-shadow: var(--sombra-pixel);
  line-height: 1.6;
}

.inicio-subtitulo {
  font-size: 15px;
  color: var(--verde-muy-claro);
  font-weight: 700;
}

.inicio-descripcion {
  background: rgba(255,255,255,0.05);
  border-radius: var(--radio-sm);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  color: var(--pergamino);
  line-height: 1.8;
}

.inicio-descripcion ul { margin-top: 6px; }
.inicio-descripcion li { margin: 4px 0; }

.inicio-controles {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13px;
  color: var(--verde-muy-claro);
}

.inicio-pie {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

/* ============================================================
   BOTONES
============================================================ */
.btn-principal {
  background: linear-gradient(180deg, #fdf3d8 0%, #f0d8a6 55%, #e3c289 100%);
  color: #4a2c14;
  font-family: var(--fuente-ui);
  font-weight: 900;
  font-size: clamp(14px, 2.6vw, 17px);
  padding: 14px 30px;
  border-radius: 999px;
  border: 2px solid #8a5a2a;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.75), 0 4px 0 #7a4f22, 0 8px 16px rgba(0,0,0,0.35);
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.08s ease;
  line-height: 1.3;
  text-align: center;
  display: inline-block;
  width: auto;
}

.btn-principal:hover {
  background: linear-gradient(180deg, #fff8e6 0%, #f6e2b8 55%, #ecd09b 100%);
  transform: translateY(-1px);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.8), 0 5px 0 #7a4f22, 0 10px 18px rgba(0,0,0,0.4);
}

.btn-principal:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.6), 0 2px 0 #7a4f22;
}

.btn-principal.btn-grande {
  font-size: clamp(15px, 2.8vw, 18px);
  padding: 16px 34px;
  width: 100%;
}

.btn-secundario {
  background: rgba(11, 61, 46, 0.65);
  color: var(--pergamino);
  font-family: var(--fuente-ui);
  font-size: 14px;
  font-weight: 900;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid rgba(212, 160, 23, 0.6);
  transition: background var(--trans), color var(--trans), transform 0.08s ease;
}

.btn-secundario:hover {
  background: rgba(26, 102, 69, 0.9);
  color: var(--blanco);
}

.btn-tienda {
  background: linear-gradient(135deg, var(--madera), var(--madera-claro));
  border-color: var(--madera);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-tienda:hover {
  background: linear-gradient(135deg, var(--dorado), #b8860b);
  text-decoration: none;
}

/* ============================================================
   LOGO FALLBACK
============================================================ */
.logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--fuente-pixel);
  font-size: clamp(12px, 3vw, 18px);
  color: var(--pergamino);
  background: var(--verde-medio);
  padding: 16px 24px;
  border-radius: var(--radio-sm);
  border: 2px solid var(--verde-claro);
}

/* ============================================================
   HUD
============================================================ */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: url('../assets/barra_superior.png') center / 100% 100% no-repeat;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.hud-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hud-logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
}

.hud-logo-txt {
  font-family: var(--fuente-pixel);
  font-size: clamp(7px, 2vw, 10px);
  color: #4a2c12;
  line-height: 1.4;
  display: none;
}

@media (min-width: 480px) {
  .hud-logo-txt { display: block; }
}

.hud-estaciones {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.hud-label {
  font-size: 9px;
  color: #7a5a2a;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 1px;
}

.hud-pasos {
  display: flex;
  gap: 4px;
}

.hud-paso {
  width: 38px;
  height: 38px;
  background: rgba(255, 249, 232, 0.75);
  border: 2px solid rgba(120, 85, 40, 0.45);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: all var(--trans);
  cursor: default;
}

/* Iconos de estación (sprite 4×2 de assets/iconos.png) */
.hud-paso-icono {
  width: 34px;
  height: 34px;
  background-image: url('../assets/iconos_hud.png');
  background-repeat: no-repeat;
  background-size: 400% 200%;
  image-rendering: pixelated;
}

.icono-1 { background-position:   0%     0%; }
.icono-2 { background-position:  33.333% 0%; }
.icono-3 { background-position:  66.667% 0%; }
.icono-4 { background-position: 100%     0%; }
.icono-5 { background-position:   0%   100%; }
.icono-6 { background-position:  33.333% 100%; }
.icono-7 { background-position: 100%   100%; } /* taza (cafetería) */
.icono-8 { background-position:  66.667% 100%; } /* trofeo */

.hud-paso.activo {
  opacity: 1;
  border-color: var(--dorado);
  background: rgba(212, 160, 23, 0.22);
  box-shadow: 0 0 10px rgba(212, 160, 23, 0.6);
  animation: pulsar 1.5s ease-in-out infinite;
}

.hud-paso.completado {
  opacity: 1;
  border-color: var(--verde-claro);
  background: rgba(45, 158, 107, 0.28);
}

/* Icono de premio (trofeo) al final de la fila */
.hud-paso-premio {
  margin-left: 8px;
}

.hud-puntaje {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: rgba(255, 249, 232, 0.75);
  border: 2px solid rgba(120, 85, 40, 0.45);
  border-radius: 999px;
  padding: 4px 12px;
}

.hud-valor {
  font-family: var(--fuente-pixel);
  font-size: clamp(12px, 3vw, 16px);
  color: #8a5a10;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

/* ============================================================
   CANVAS DEL JUEGO
============================================================ */
.canvas-contenedor {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: var(--verde);
}

#canvas-juego {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* ============================================================
   INDICADOR DE ESTACIÓN
============================================================ */
.estacion-indicador {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11,61,46,0.9);
  border: 2px solid var(--verde-claro);
  border-radius: var(--radio-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--pergamino);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--sombra);
  animation: aparecerIndicador 0.3s ease;
  z-index: 50;
}

.estacion-indicador kbd {
  background: var(--verde-claro);
  color: var(--blanco);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--fuente-pixel);
  font-size: 10px;
}

/* ============================================================
   JOYSTICK VIRTUAL
============================================================ */
.joystick-zona {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 110px;
  height: 110px;
  display: none; /* Se muestra solo en táctil vía JS */
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.joystick-base {
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.1);
  border: 3px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.joystick-palanca {
  width: 44px;
  height: 44px;
  background: radial-gradient(circle, var(--verde-claro), var(--verde-medio));
  border: 3px solid var(--blanco);
  border-radius: 50%;
  box-shadow: var(--sombra);
  transition: transform 0.05s;
  position: relative;
}

.btn-accion-movil {
  position: absolute;
  bottom: 24px;
  right: 20px;
  width: 76px;
  height: 76px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: url('../assets/circulo.jpg') center / 118% no-repeat;
  box-shadow: var(--sombra-pixel), 0 0 14px rgba(212, 160, 23, 0.55);
  z-index: 51;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
}

.btn-accion-movil:active {
  transform: scale(0.92);
}

/* ============================================================
   MODALES – BASE
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 12px;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease;
}

.modal-caja {
  background: linear-gradient(160deg, #0d4a35 0%, #0b3d2e 60%, #071e17 100%);
  border: 3px solid var(--verde-claro);
  border-radius: var(--radio);
  padding: clamp(16px, 4vw, 32px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sombra), 0 0 40px rgba(45,158,107,0.3);
  position: relative;
  width: 100%;
  animation: escalarEntrada 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-mediano { max-width: 540px; }
.modal-grande  { max-width: 700px; }
.modal-certificado { max-width: 520px; }

/* Marco ornamentado para los recuadros de juego */
#modal-caja,
#modal-minijuego-caja,
#modal-trivia-caja {
  background: transparent;
  border: 30px solid transparent;
  border-image: url('../assets/marco_acciones.png') 40 fill stretch;
  border-radius: 0;
  padding: clamp(10px, 2.5vw, 20px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

@media (max-width: 600px) {
  #modal-caja,
  #modal-minijuego-caja,
  #modal-trivia-caja {
    border-width: 18px;
    padding: 8px;
  }
}

.modal-cerrar {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.1);
  color: var(--blanco);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans);
  z-index: 10;
}

.modal-cerrar:hover { background: rgba(192,57,43,0.7); }

.modal-titulo {
  font-family: var(--fuente-titulo);
  font-size: clamp(18px, 3.4vw, 24px);
  font-weight: 700;
  color: var(--dorado);
  line-height: 1.3;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.certificado-header h2,
#trivia-final-titulo {
  font-family: var(--fuente-titulo);
  font-weight: 700;
  color: var(--dorado);
}

/* ============================================================
   MODAL – MINIJUEGO
============================================================ */
.minijuego-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.minijuego-hud {
  display: flex;
  gap: 16px;
  font-family: var(--fuente-pixel);
  font-size: clamp(9px, 2.5vw, 11px);
  color: var(--dorado);
}

.minijuego-area {
  min-height: 260px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radio-sm);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.minijuego-instrucciones {
  font-size: 13px;
  color: var(--verde-muy-claro);
  text-align: center;
  margin-top: 10px;
  min-height: 36px;
  font-weight: 700;
}

.minijuego-resultado {
  text-align: center;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#mj-resultado-texto {
  font-size: 15px;
  color: var(--pergamino);
  font-weight: 700;
}

/* Estilos específicos para los minijuegos */
.mj-canvas {
  width: 100%;
  max-width: 580px;
  height: 220px;
  border-radius: var(--radio-sm);
  display: block;
  image-rendering: pixelated;
}

.mj-seed-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 400px;
}

.mj-seed-cell {
  aspect-ratio: 1;
  background: rgba(255,255,255,0.08);
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 5vw, 32px);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.mj-seed-cell:hover { background: rgba(255,255,255,0.15); transform: scale(1.05); }
.mj-seed-cell.activa { background: rgba(45,158,107,0.3); border-color: var(--verde-claro); }
.mj-seed-cell.completada { background: rgba(212,160,23,0.3); border-color: var(--dorado); }

/* Estados de la chapola (sprite 4×2 de assets/chapolas_hud.png) */
.chapola {
  width: 94%;
  height: 94%;
  background-image: url('../assets/chapolas_hud.png');
  background-repeat: no-repeat;
  background-size: 400% 200%;
}
.chapola-0 { background-position:   0%     0%; } /* tierra vacía */
.chapola-1 { background-position:  33.333% 0%; } /* semilla */
.chapola-2 { background-position:  66.667% 0%; } /* semilla regada */
.chapola-3 { background-position: 100%     0%; } /* brote */
.chapola-4 { background-position:   0%   100%; } /* brote regado */
.chapola-5 { background-position:  33.333% 100%; } /* plántula */
.chapola-6 { background-position:  66.667% 100%; } /* chapola lista */
.chapola-7 { background-position: 100%   100%; } /* seca */

.mj-boton-accion {
  background: linear-gradient(180deg, #fdf3d8 0%, #f0d8a6 55%, #e3c289 100%);
  color: #4a2c14;
  font-family: var(--fuente-ui);
  font-weight: 900;
  font-size: clamp(13px, 2.4vw, 16px);
  padding: 12px 26px;
  border-radius: 999px;
  border: 2px solid #8a5a2a;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.75), 0 4px 0 #7a4f22, 0 8px 16px rgba(0,0,0,0.35);
  transition: transform 0.08s ease, filter 0.15s ease;
  line-height: 1.3;
  margin: 4px;
}

.mj-boton-accion:hover {
  background: linear-gradient(180deg, #fff8e6 0%, #f6e2b8 55%, #ecd09b 100%);
  transform: translateY(-1px);
}

.mj-boton-accion:active {
  transform: translateY(2px);
}

/* Botón de detener tueste conserva su rojo con texto claro */
#btn-detener-tueste {
  color: #fff6e8;
  border-color: #7a1e14;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 0 4px 0 #5c140d, 0 8px 16px rgba(0,0,0,0.35);
}

.mj-progreso-barra {
  width: 100%;
  height: 16px;
  background: var(--barra-pista);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(120, 85, 40, 0.4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
}

.mj-progreso-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease, background 0.5s ease;
  background: var(--barra-verde);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.mj-progreso-fill::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 2px;
  height: 32%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.mj-estado {
  font-size: 24px;
  font-weight: 900;
  font-family: var(--fuente-pixel);
  font-size: clamp(12px, 3.5vw, 18px);
  color: var(--pergamino);
}

.mj-cerezas-area {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 420px;
}

.mj-cereza {
  aspect-ratio: 1;
  font-size: clamp(20px, 5vw, 36px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
  user-select: none;
  border: 2px solid transparent;
}
.mj-cereza:hover { transform: scale(1.1); }
.mj-cereza.madura  { background: rgba(192,57,43,0.2); border-color: rgba(192,57,43,0.5); }
.mj-cereza.verde   { background: rgba(45,158,107,0.15); border-color: rgba(45,158,107,0.3); }
.mj-cereza.sobremadura { background: rgba(100,20,10,0.3); border-color: rgba(100,20,10,0.5); }

/* Frutos (sprite 3×1 de assets/frutos_hud.png) */
.fruto {
  width: 92%;
  height: 92%;
  background-image: url('../assets/frutos_hud.png');
  background-repeat: no-repeat;
  background-size: 300% 100%;
}
.fruto-verde       { background-position:   0% 50%; }
.fruto-madura      { background-position:  50% 50%; }
.fruto-sobremadura { background-position: 100% 50%; }

/* Granos de café (sprite 4×1 de assets/granos_cafe_hud.png) */
.grano {
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  vertical-align: -0.35em;
  background-image: url('../assets/granos_cafe_hud.png');
  background-repeat: no-repeat;
  background-size: 400% 100%;
}
.grano-verde     { background-position:   0% 50%; }
.grano-maduro    { background-position:  33.333% 50%; }
.grano-pergamino { background-position:  66.667% 50%; }
.grano-tostado   { background-position: 100% 50%; }

/* Estados del tueste (sprite 6×1 de assets/granos_tostados_hud.png) */
.tueste {
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  vertical-align: -0.35em;
  background-image: url('../assets/granos_tostados_hud.png');
  background-repeat: no-repeat;
  background-size: 600% 100%;
}
.tueste-0 { background-position:   0% 50%; } /* pergamino 0-149 °C */
.tueste-1 { background-position:  20% 50%; } /* tostado inicial 150-189 °C */
.tueste-2 { background-position:  40% 50%; } /* primer crack 190 °C */
.tueste-3 { background-position:  60% 50%; } /* tostado óptimo 200-220 °C */
.tueste-4 { background-position:  80% 50%; } /* pasando el punto >220 °C */
.tueste-5 { background-position: 100% 50%; } /* quemado 300 °C */

.mj-score-popup {
  position: absolute;
  font-family: var(--fuente-pixel);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  animation: subirFadeOut 1s ease forwards;
  z-index: 10;
}

.mj-gauge-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.mj-gauge-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--verde-muy-claro);
  text-align: center;
}

.mj-gauge-track {
  width: 100%;
  height: 34px;
  background: var(--barra-pista);
  border-radius: 999px;
  border: 1px solid rgba(120, 85, 40, 0.4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  position: relative;
}

.mj-gauge-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.1s linear, background 0.3s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
}

.mj-gauge-fill::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 3px;
  height: 28%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.mj-zona-optima {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(212,160,23,0.3);
  border-left: 2px dashed var(--dorado);
  border-right: 2px dashed var(--dorado);
  pointer-events: none;
}

.mj-pasos-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.mj-paso-item {
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radio-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  color: var(--pergamino);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mj-paso-item:hover { background: rgba(255,255,255,0.1); border-color: var(--verde-claro); }
.mj-paso-item.correcto { background: rgba(45,158,107,0.3); border-color: var(--verde-claro); color: var(--verde-muy-claro); }
.mj-paso-item.incorrecto { background: rgba(192,57,43,0.2); border-color: var(--rojo-cereza); }
.mj-paso-item.completado { opacity: 0.5; cursor: default; }

/* ============================================================
   MODAL – TRIVIA
============================================================ */
.trivia-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.trivia-progreso {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 13px;
  color: var(--dorado);
  font-weight: 700;
  flex-shrink: 0;
}

.trivia-pregunta-wrap { margin-bottom: 16px; }

.trivia-pregunta {
  font-size: clamp(14px, 3.5vw, 17px);
  color: var(--pergamino);
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 16px;
  min-height: 48px;
}

.trivia-opciones {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trivia-opcion {
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 700;
  color: var(--blanco);
  text-align: left;
  transition: all var(--trans);
  cursor: pointer;
  line-height: 1.4;
  font-family: var(--fuente-ui);
}

.trivia-opcion:hover:not(:disabled) {
  background: rgba(45,158,107,0.25);
  border-color: var(--verde-claro);
  transform: translateX(4px);
}

.trivia-opcion.correcta {
  background: rgba(45,158,107,0.35);
  border-color: var(--verde-claro);
  color: var(--verde-muy-claro);
}

.trivia-opcion.incorrecta {
  background: rgba(192,57,43,0.25);
  border-color: var(--rojo-cereza);
  color: #f99;
}

.trivia-opcion:disabled { cursor: default; }

.trivia-retroalimentacion {
  background: rgba(0,0,0,0.3);
  border-radius: var(--radio-sm);
  border: 2px solid rgba(255,255,255,0.1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-top: 12px;
}

.trivia-fb-icono { font-size: 36px; }

#trivia-fb-texto {
  font-size: 14px;
  color: var(--pergamino);
  line-height: 1.6;
}

/* Panel final de trivia */
.trivia-final {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding-top: 8px;
}

.trivia-final-estrellas { font-size: 40px; letter-spacing: 8px; }

.trivia-final h3 {
  font-family: var(--fuente-pixel);
  font-size: clamp(10px, 3vw, 14px);
  color: var(--dorado);
  line-height: 1.6;
}

.trivia-final p {
  font-size: 14px;
  color: var(--verde-muy-claro);
  line-height: 1.6;
}

/* ============================================================
   MODAL – CERTIFICADO Y CUPÓN
============================================================ */
.certificado-header {
  text-align: center;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cert-logo {
  width: clamp(70px, 18vw, 100px);
  height: auto;
  image-rendering: pixelated;
  animation: flotarLogo 2.5s ease-in-out infinite;
}

.cert-subtitulo {
  font-size: 14px;
  color: var(--verde-muy-claro);
  line-height: 1.6;
}

.cert-puntaje-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--pergamino);
  margin-bottom: 8px;
}

.cert-puntaje-valor {
  font-family: var(--fuente-pixel);
  font-size: clamp(18px, 4vw, 24px);
  color: var(--dorado);
}

.cert-formulario-intro {
  font-size: 14px;
  color: var(--verde-muy-claro);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.6;
}

.cert-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.campo-grupo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.campo-grupo label {
  font-size: 12px;
  font-weight: 900;
  color: var(--verde-muy-claro);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.campo-grupo input {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: var(--radio-sm);
  padding: 12px 14px;
  font-size: 15px;
  color: var(--blanco);
  font-family: var(--fuente-ui);
  transition: border-color var(--trans), background var(--trans);
  width: 100%;
}

.campo-grupo input:focus {
  outline: none;
  border-color: var(--verde-claro);
  background: rgba(255,255,255,0.12);
}

.campo-grupo input::placeholder { color: rgba(255,255,255,0.3); }

.campo-error {
  font-size: 12px;
  color: #f99;
  min-height: 16px;
  font-weight: 700;
}

.cert-pie {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  margin-top: 8px;
}

/* Cupón generado */
.cert-medalla { font-size: 56px; line-height: 1; }
.cert-medalla img {
  width: 96px;
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.4));
}

.cupon-caja {
  background: var(--pergamino);
  border: 3px solid var(--dorado);
  border-radius: var(--radio);
  padding: 20px;
  text-align: center;
  margin: 16px 0;
  box-shadow: var(--sombra-pixel);
}

.cupon-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--madera);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.cupon-codigo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.cupon-codigo {
  font-family: var(--fuente-pixel);
  font-size: clamp(14px, 4vw, 20px);
  color: var(--verde);
  letter-spacing: 3px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
}

.btn-copiar {
  background: var(--verde);
  color: var(--blanco);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans);
}

.btn-copiar:hover { background: var(--verde-claro); }
.btn-copiar.copiado { background: var(--dorado); }

.cupon-descuento {
  font-size: 15px;
  font-weight: 900;
  color: var(--verde);
  margin-top: 10px;
}

.cupon-vigencia {
  font-size: 12px;
  color: var(--madera);
  margin-top: 4px;
}

/* ============================================================
   TOAST NOTIFICACIONES
============================================================ */
.toast-contenedor {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9000;
  pointer-events: none;
  max-width: 300px;
}

.toast {
  background: rgba(11,61,46,0.95);
  border: 2px solid var(--verde-claro);
  border-radius: var(--radio-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--pergamino);
  box-shadow: var(--sombra);
  animation: aparecerToast 0.3s ease;
  line-height: 1.4;
}

.toast.exito   { border-color: var(--verde-claro); }
.toast.error   { border-color: var(--rojo-cereza); background: rgba(192,57,43,0.9); }
.toast.info    { border-color: var(--dorado); }

/* ============================================================
   ANIMACIONES
============================================================ */
@keyframes flotarLogo {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

@keyframes pulsar {
  0%, 100% { box-shadow: 0 0 10px rgba(212,160,23,0.5); }
  50%       { box-shadow: 0 0 20px rgba(212,160,23,0.9); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes escalarEntrada {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes aparecerIndicador {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes aparecerToast {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes subirFadeOut {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

@keyframes brilloDorado {
  0%, 100% { text-shadow: 0 0 8px var(--dorado); }
  50%       { text-shadow: 0 0 24px var(--dorado), 0 0 40px rgba(212,160,23,0.5); }
}

/* ============================================================
   RESPONSIVE
============================================================ */

/* Ocultar joystick en escritorio; mostrar en táctil (gestionado por JS) */
@media (hover: none) and (pointer: coarse) {
  .joystick-zona { display: flex; }
  .btn-accion-movil { display: flex; }
}

/* Tablets */
@media (max-width: 768px) {
  .hud { height: 56px; }
  .canvas-contenedor { top: 56px; }
  .hud-paso { width: 32px; height: 32px; }
  .hud-paso-icono { width: 28px; height: 28px; }
  .modal-caja { padding: 16px; }
  .mj-cerezas-area { grid-template-columns: repeat(5, 1fr); }
}

/* Móviles pequeños */
@media (max-width: 400px) {
  .hud-pasos { gap: 2px; }
  .hud-paso { width: 28px; height: 28px; }
  .hud-paso-icono { width: 24px; height: 24px; }
  .inicio-caja { padding: 20px 14px; }
  .mj-cerezas-area { grid-template-columns: repeat(4, 1fr); }
}

/* Accesibilidad: reducir animaciones */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   SCROLLBAR PERSONALIZADO
============================================================ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--verde-medio); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--verde-claro); }
