:root {
        --primary-color: #89c4f4;
        --secondary-color: #b7d9f8;
        --accent-color: #ffffff;
        --light-color: #d4e6f9;
        --success-color: #4caf50;
        --error-color: #f44336;
        --text-color: #333333;
        --white: #ffffff;
        --dark-blue: #5d8aa8;
      }

      /* Estilos del Header mejorado */
      .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: linear-gradient(
          135deg,
          var(--primary-color),
          var(--secondary-color)
        );
        padding: 0 10%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border-bottom: 2px solid #fff;
        transition: all 0.3s ease;
      }

      .header:hover {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
      }

      .logo {
        font-size: 28px;
        font-family: "Montserrat", sans-serif;
        font-weight: 700;
        color: var(--white);
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
        letter-spacing: 1px;
      }

      .navigation ul {
        list-style: none;
        margin: 0;
        padding: 0;
      }

      .header .navigation ul li {
        float: left;
        position: relative;
      }

      .header .navigation ul li a {
        font-family: "Poppins", sans-serif;
        font-size: 16px;
        font-weight: 500;
        color: var(--white);
        text-decoration: none;
        padding: 22px 20px;
        display: block;
        transition: all 0.3s ease;
      }

      .header .navigation ul li a:hover {
        background-color: rgba(255, 255, 255, 0.733);
        color: var(--dark-blue);
        transform: translateY(-2px);
      }

      .header .navigation ul li ul {
        position: absolute;
        right: 0;
        width: 220px;
        background: rgba(255, 255, 255, 0.589);
        border-radius: 0 0 8px 8px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        display: none;
        overflow: hidden;
      }

      .header .navigation ul li ul li a {
        color: var(--text-color);
        padding: 12px 20px;
        font-size: 14px;
      }

      .header .navigation ul li ul li a:hover {
        background-color: var(--light-color);
        color: var(--dark-blue);
      }

      .header .navigation ul li:hover > ul {
        display: initial;
        animation: fadeIn 0.3s ease-out;
      }

      #toggle,
      .header label {
        display: none;
        cursor: pointer;
      }

      .menu {
        width: 28px;
        height: 28px;
        filter: brightness(0) invert(1);
      }

      @media (max-width: 950px) {
        .header label {
          display: initial;
        }

        .header {
          padding: 15px 10%;
        }

        .header .navigation {
          position: absolute;
          top: 100%;
          left: 0;
          right: 0;
          background: var(--primary-color);
          display: none;
          border-radius: 0 0 12px 12px;
        }

        .header .navigation ul li {
          width: 100%;
        }

        .header .navigation ul li a {
          padding: 12px 20px;
          font-size: 18px; /* Más grande en móvil */
        }

        .header .navigation ul li ul {
          position: relative;
          width: 100%;
          left: 0;
          background: rgba(255, 255, 255, 0.1);
        }

        .header .navigation ul li ul li a {
          padding-left: 30px;
          font-size: 16px; /* Más grande en móvil */
        }

        #toggle:checked ~ .navigation {
          display: block;
          animation: slideDown 0.4s ease-out;
        }
      }

      /* Estilos del cuerpo y fondo */
      body {
        font-family: "Poppins", sans-serif;
        background: linear-gradient(135deg, #d4e6f9, #b7d9f8, #89c4f4);
        margin: 0;
        padding: 0;
        padding-top: 80px;
        min-height: 100vh;
        color: var(--text-color);
        background-size: 400% 400%;
        animation: gradientBG 15s ease infinite;
      }

      /* Animación de fondo */
      @keyframes gradientBG {
        0% {
          background-position: 0% 50%;
        }
        50% {
          background-position: 100% 50%;
        }
        100% {
          background-position: 0% 50%;
        }
      }

      /* Animaciones */
      @keyframes fadeIn {
        from {
          opacity: 0;
          transform: translateY(-10px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      @keyframes slideDown {
        from {
          opacity: 0;
          transform: translateY(-20px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      @keyframes pulse {
        0% {
          transform: scale(1);
        }
        50% {
          transform: scale(1.05);
        }
        100% {
          transform: scale(1);
        }
      }

      @keyframes bounce {
        0%,
        20%,
        50%,
        80%,
        100% {
          transform: translateY(0);
        }
        40% {
          transform: translateY(-15px);
        }
        60% {
          transform: translateY(-7px);
        }
      }

      @keyframes confetti {
        0% {
          transform: translateY(0) rotate(0deg);
          opacity: 1;
        }
        100% {
          transform: translateY(100vh) rotate(360deg);
          opacity: 0;
        }
      }

      @keyframes celebrate {
        0%,
        100% {
          transform: scale(1);
        }
        50% {
          transform: scale(1.1);
        }
      }

      /* Contenedor principal */
      .contenedor-principal {
        width: 95%;
        max-width: 1200px;
        margin: 20px auto;
        padding: 20px;
        background-color: rgb(255, 255, 255);
        border-radius: 12px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        position: relative;
      }

      .contenedor-principal:hover {
        transform: translateY(-5px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
      }

      .titulo-actividad {
        text-align: center;
        color: var(--dark-blue);
        margin-bottom: 20px;
        font-family: "Montserrat", sans-serif;
        font-weight: 600;
        font-size: clamp(24px, 5vw, 32px); /* Tamaño responsive */
      }

      .instrucciones {
        text-align: center;
        margin-bottom: 25px;
        color: var(--text-color);
        font-size: clamp(16px, 4vw, 18px); /* Tamaño responsive */
        line-height: 1.5;
        padding: 0 10px;
      }

      /* Contenedor de la actividad */
      .contenedor-actividad {
        display: flex;
        flex-direction: column;
        gap: 25px;
      }

      /* Contenedor para imágenes (arriba) */
      .contenedor-imagenes {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        justify-items: center;
      }

      /* Contenedor para frases (abajo) */
      .contenedor-frases {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
      }

      .tarjeta-frase {
        background-color: var(--secondary-color);
        border-radius: 8px;
        padding: 8px 5px;
        text-align: center;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 40px;
        font-weight: 600;
        color: var(--text-color);
        font-size: 14px;
        touch-action: manipulation; /* Mejor comportamiento táctil */
      }

      .tarjeta-frase:hover {
        background-color: var(--primary-color);
      }

      .tarjeta-frase.seleccionada {
        box-shadow: 0 0 0 3px var(--primary-color);
      }

      .tarjeta-frase.correcto {
        background-color: #c8e6c9;
        color: #2e7d32;
        pointer-events: none;
      }

      .tarjeta-frase.incorrecto {
        background-color: #ffcdd2;
        color: #c62828;
      }

      .tarjeta-imagen {
        background-color: var(--white);
        border-radius: 10px;
        padding: 10px;
        text-align: center;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 130px;
        position: relative;
        touch-action: manipulation; /* Mejor comportamiento táctil */
        width: 90%; /* Reducir un poco el tamaño */
      }

      .tarjeta-imagen:hover {
        background-color: #f0f8ff;
      }

      .tarjeta-imagen.seleccionada {
        box-shadow: 0 0 0 3px var(--primary-color);
      }

      .tarjeta-imagen.correcto {
        background-color: #e8f5e9;
        border: 2px solid #4caf50;
        pointer-events: none;
      }

      .tarjeta-imagen.incorrecto {
        background-color: #ffcdd2;
        border: 2px solid #f44336;
      }

      .espacio-imagen {
        width: 120px; /* Reducido */
        height: 120px; /* Reducido */
        background-color: rgba(255, 255, 255, 0.7);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 8px;
        border: 2px dashed var(--primary-color);
        overflow: hidden;
      }

      .espacio-imagen img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
      }

      .contenedor-resultado {
        margin-top: 25px;
        text-align: center;
        padding: 20px;
        background-color: var(--light-color);
        border-radius: 8px;
        display: none;
        position: relative;
        overflow: hidden;
      }

      .contenedor-resultado.mostrar {
        display: block;
        animation: fadeIn 0.5s ease-out;
      }

      .boton-reiniciar {
        background-color: var(--primary-color);
        color: white;
        border: none;
        padding: 14px 28px;
        border-radius: 8px;
        font-size: clamp(16px, 4vw, 18px);
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease;
        margin-top: 20px;
        min-height: 50px; /* Más fácil de tocar */
        display: block;
        margin-left: auto;
        margin-right: auto;
      }

      .boton-reiniciar:hover {
        background-color: var(--dark-blue);
        transform: translateY(-3px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
      }

      .mensaje-felicidades {
        font-size: clamp(20px, 5vw, 24px);
        font-weight: 600;
        color: var(--dark-blue);
        margin-bottom: 15px;
        animation: celebrate 1s ease infinite;
      }

      .confetti {
        position: absolute;
        width: 10px;
        height: 10px;
        background-color: #f00;
        opacity: 0;
      }

      .indicador-click {
        position: absolute;
        top: 8px;
        right: 8px;
        font-size: 16px;
        opacity: 0.6;
      }

      /* Contador de pares */
      .contador-pares {
        position: absolute;
        top: 20px;
        right: 20px;
        background-color: var(--primary-color);
        color: white;
        padding: 10px 15px;
        border-radius: 20px;
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        gap: 8px;
      }

      .contador-pares span {
        font-size: 18px;
      }

      /* MEJORAS ESPECÍFICAS PARA MÓVIL */
      @media (max-width: 1024px) {
        .espacio-imagen {
          width: 110px;
          height: 110px;
        }

        .tarjeta-imagen {
          min-height: 150px;
          padding: 10px;
        }
      }

      @media (max-width: 768px) {
        .contenedor-frases {
          grid-template-columns: repeat(2, 1fr);
        }

        .espacio-imagen {
          width: 100px;
          height: 100px;
        }

        .tarjeta-imagen {
          min-height: 140px;
          padding: 8px;
        }

        .tarjeta-frase {
          padding: 10px 5px;
          min-height: 35px;
          font-size: 13px;
        }

        body {
          padding-top: 70px; /* Menos espacio para header en móvil */
        }

        .contador-pares {
          position: relative;
          top: auto;
          right: auto;
          margin: 0 auto 20px auto;
          width: fit-content;
        }
      }

      @media (max-width: 480px) {
        .contenedor-principal {
          width: 98%;
          padding: 15px;
          margin: 10px auto;
        }

        .logo {
          font-size: 20px;
        }

        .titulo-actividad {
          font-size: 22px;
          margin-bottom: 15px;
        }

        .espacio-imagen {
          width: 90px;
          height: 90px;
        }

        .tarjeta-imagen {
          min-height: 130px;
        }

        .tarjeta-frase {
          min-height: 30px;
          font-size: 12px;
        }

        .instrucciones {
          font-size: 16px;
          margin-bottom: 20px;
        }
      }

      /* Para pantallas muy pequeñas */
      @media (max-width: 360px) {
        .tarjeta-imagen {
          padding: 8px;
        }

        .espacio-imagen {
          width: 80px;
          height: 80px;
        }

        .tarjeta-frase {
          font-size: 11px;
          padding: 8px 4px;
        }

        .contenedor-frases {
          grid-template-columns: 1fr;
        }
      }