/* Paleta aplicada */
:root {
    --principal-celeste: #5EC0CF;
    --principal-violeta: #9A8BC2;
    --principal-blanco: #F4F4F4;

    --secundario-oscuro: #004F66;
    --secundario-rosa: #C8A2C9;
    --secundario-gris: #4D4D4D;
    --secundario-lila: #E8E6FB;
    --accent-naranja: #ff7043;
    --accent-naranja-hover: #ff5722;
    --verde-match: #4caf50;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Gotham Rounded','Gotham Rounded', 'Nunito Sans', sans-serif;
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    position: relative;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    width: 100%;
    max-width: 600px;
}

.title {
    color: var(--principal-violeta);
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.size-btn {
    background: var(--principal-celeste);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(94, 192, 207, 0.3);
    min-height: 44px; /* Touch-friendly minimum size */
}

.size-btn:hover {
    background: #4AA8B6;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(94, 192, 207, 0.4);
}

.size-btn.active {
    background: var(--secundario-oscuro);
    transform: scale(1.05);
}

.stats {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.stat {
    background: var(--principal-blanco);
    padding: 15px 25px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
    min-width: 120px;
}

.stat-label {
    color: var(--secundario-oscuro);
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-value {
    color: var(--principal-celeste);
    font-size: 1.8rem;
    font-weight: bold;
}

.game-board {
    display: grid;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    max-width: 100%;
    overflow: hidden;
}

.game-board.size-3 {
    grid-template-columns: repeat(3, 1fr);
}

.game-board.size-4 {
    grid-template-columns: repeat(4, 1fr);
}

.game-board.size-5 {
    grid-template-columns: repeat(5, 1fr);
}

.card {
    width: 80px;
    height: 80px;
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    transition: transform 0.18s cubic-bezier(.4,1.3,.6,1), box-shadow 0.18s cubic-bezier(.4,1.3,.6,1);
    touch-action: manipulation; /* Better touch handling */
}

.card:hover:not(.flipped):not(.matched) {
    transform: scale(1.01) translateY(-1px);
    box-shadow: 0 8px 24px rgba(94, 192, 207, 0.25);
    z-index: 2;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.card-front {
    background: var(--principal-celeste);
    background-image: url('../statics/img/flor-blanco.png');
    background-size: 50%;
    background-repeat: no-repeat;
    background-position: center;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secundario-oscuro);
}

.card.matched .card-back {
    background: var(--verde-match);
    color: white;
}

.card.matched {
    cursor: default;
}

.reset-btn {
    margin-top: 30px;
    background: var(--accent-naranja);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 112, 67, 0.3);
    min-height: 44px; /* Touch-friendly minimum size */
}

.reset-btn:hover {
    background: var(--accent-naranja-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 112, 67, 0.4);
}

.victory-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    z-index: 1000;
    display: none;
    max-width: 90vw;
    width: 400px;
}

.victory-message.show {
    display: block;
    animation: victoryPop 0.5s ease-out;
}

@keyframes victoryPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.victory-title {
    color: var(--verde-match);
    font-size: 2rem;
    margin-bottom: 15px;
    font-family: 'Ghotam Rounded Light'
}

.victory-stats {
    color: var(--secundario-oscuro);
    font-size: 1.1rem;
    margin-bottom: 20px;
}

footer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    color: #004F66;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
    z-index: 100;
}

footer p {
    margin: 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ---------- Responsive: PANTALLA GRANDE (≈52 pulgadas, 4K) ---------- */
@media (min-width: 3840px) {
    html { font-size: 2rem; }
    .header { text-align: center; margin-bottom: 30px; width: 100%; max-width: 4000px;}
    .title { font-size: 3.6rem; padding-bottom: 80px;}
    .controls { gap: 100px; width: 3900px; height: 150px; padding-bottom: 200px;}
    .size-btn { padding: 45px 100px; font-size: 1.9rem; border-radius: 28px; }
    .stats { gap: 100px; width: 100%; height: 120px; padding-bottom: 320px;}
    .stat { padding: 50px 100px; min-width: 180px; }
    .stat-label { color: var(--secundario-oscuro);font-size: 1.9rem;font-weight: bold;margin-bottom: 50px;}
    .stat-value { font-size: 2.6rem; }
    .game-board { gap: 50px; padding: 32px; max-width: 1600px; }
    .card { width: 230px; height: 230px; }
    .card-back { font-size: 2.4rem; }
    .reset-btn {
        padding: 30px 90px;
        font-size: 1.8rem;
        min-height: 60px;
    }
    .victory-message { width: 1500px; padding: 90px; }
    .victory-title { font-size: 3.0rem; }
    .victory-stats { font-size: 2.0rem; padding: 20px;}
    footer { bottom: 36px; right: 36px; font-size: 1.2rem; }
    footer p { padding: 12px 150px; border-radius: 18px; }
}

/* Responsive Design - Mobile First Approach */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .game-board {
        gap: 12px;
        padding: 18px;
    }
    
    .card {
        width: 75px;
        height: 75px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .title {
        font-size: 2.2rem;
        margin-bottom: 15px;
    }
    
    .controls {
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .size-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .stats {
        gap: 20px;
        margin-bottom: 25px;
    }
    
    .stat {
        padding: 12px 20px;
        min-width: 100px;
    }
    
    .stat-value {
        font-size: 1.6rem;
    }
    
    .game-board {
        gap: 10px;
        padding: 15px;
    }
    
    .card {
        width: 70px;
        height: 70px;
    }
    
    .card-back {
        font-size: 1.3rem;
    }
    
    .reset-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    footer {
        bottom: 15px;
        right: 15px;
        font-size: 0.8rem;
    }
}

/* Mobile phones */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .header {
        margin-bottom: 20px;
    }
    
    .title {
        font-size: 1.8rem;
        margin-bottom: 12px;
    }
    
    .controls {
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .size-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
        border-radius: 20px;
    }
    
    .stats {
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .stat {
        padding: 10px 15px;
        min-width: 80px;
        border-radius: 15px;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .game-board {
        gap: 8px;
        padding: 12px;
        border-radius: 15px;
    }
    
    .card {
        width: 60px;
        height: 60px;
    }
    
    .card-front, .card-back {
        border-radius: 12px;
    }
    
    .card-back {
        font-size: 1.1rem;
    }
    
    .reset-btn {
        margin-top: 20px;
        padding: 10px 20px;
        font-size: 0.9rem;
        border-radius: 20px;
    }
    
    .victory-message {
        padding: 20px;
        border-radius: 15px;
        width: 90vw;
        max-width: 350px;
    }
    
    .victory-title {
        font-size: 1.6rem;
    }
    
    .victory-stats {
        font-size: 1rem;
    }
}

/* Small mobile phones */
@media (max-width: 480px) {
    .title {
        font-size: 1.6rem;
    }
    
    .controls {
        flex-direction: row;
        justify-content: center;
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .size-btn {
        width: auto;
        min-width: 80px;
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    .stats {
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .stat {
        width: auto;
        min-width: 70px;
        padding: 8px 12px;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .game-board.size-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .game-board.size-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.size-5 {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .card {
        width: 50px;
        height: 50px;
    }
    
    .card-back {
        font-size: 0.9rem;
    }
    
    .victory-message {
        padding: 15px;
        width: 95vw;
    }
    
    .victory-title {
        font-size: 1.4rem;
    }

    footer {
        bottom: 10px;
        right: 10px;
        font-size: 0.75rem;
    }

    footer p {
        padding: 6px 10px;
        border-radius: 12px;
    }
}

/* Extra small mobile phones */
@media (max-width: 360px) {
    .title {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    .controls {
        gap: 4px;
    }
    
    .size-btn {
        min-width: 70px;
        padding: 6px 10px;
        font-size: 0.7rem;
    }
    
    .stats {
        gap: 6px;
    }
    
    .stat {
        min-width: 60px;
        padding: 6px 10px;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .card {
        width: 45px;
        height: 45px;
    }
    
    .card-back {
        font-size: 0.8rem;
    }
    
    .game-board {
        gap: 6px;
        padding: 10px;
    }
    
    .reset-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    footer {
        bottom: 8px;
        right: 8px;
        font-size: 0.7rem;
    }

    footer p {
        padding: 5px 8px;
        border-radius: 10px;
    }
}

/* Very small mobile phones */
@media (max-width: 320px) {
    .title {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
    
    .controls {
        gap: 3px;
    }
    
    .size-btn {
        min-width: 60px;
        padding: 5px 8px;
        font-size: 0.65rem;
    }
    
    .stats {
        gap: 4px;
    }
    
    .stat {
        min-width: 50px;
        padding: 5px 8px;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .card {
        width: 40px;
        height: 40px;
    }
    
    .card-back {
        font-size: 0.7rem;
    }
    
    .game-board {
        gap: 4px;
        padding: 8px;
    }
    
    .reset-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    footer {
        bottom: 5px;
        right: 5px;
        font-size: 0.65rem;
    }

    footer p {
        padding: 4px 6px;
        border-radius: 8px;
    }
}

/* Landscape orientation for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
    
    .header {
        margin-bottom: 15px;
    }
    
    .title {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .controls {
        margin-bottom: 8px;
    }
    
    .stats {
        margin-bottom: 15px;
    }
    
    .game-board {
        gap: 6px;
        padding: 10px;
    }
    
    .card {
        width: 40px;
        height: 40px;
    }
    
    .card-back {
        font-size: 0.7rem;
    }
    
    .reset-btn {
        margin-top: 15px;
        padding: 8px 16px;
        font-size: 0.8rem;
    }
}

/* --------- Responsive: 2160 x 3800 (por ejemplo, pantalla 4K vertical) --------- */
@media (min-width: 2160px) and (min-height: 3800px) {
    html { font-size: 2.2rem; }
    body { padding: 60px; }
    .header { text-align: center; margin-bottom: 60px; width: 100%; max-width: 2100px;}
    .title { font-size: 4.2rem; padding-bottom: 100px; }
    .controls { gap: 120px; width: 2100px; height: 180px; padding-bottom: 250px; }
    .size-btn { padding: 60px 120px; font-size: 2.2rem; border-radius: 32px; }
    .stats { gap: 120px; width: 100%; }
    .stat { min-width: 220px; }
    .stat-label { color: var(--secundario-oscuro); font-size: 2.2rem; font-weight: bold; margin-bottom: 60px; }
    .stat-value { font-size: 3.2rem; }
    .game-board { gap: 70px; padding: 50px; max-width: 2000px; }
    .card { width: 300px; height: 300px; }
    .card-back { font-size: 3.2rem; }
    .reset-btn {
        padding: 40px 120px;
        font-size: 2.2rem;
        min-height: 80px;
    }
    .victory-message { 
        width: 90vw; 
        max-width: 2400px; 
        padding: 8vh 6vw; 
        border-radius: 40px;
        box-shadow: 0 20px 80px rgba(0,0,0,0.4);
    }
    .victory-title { 
        font-size: clamp(4.5rem, 6vw, 7rem); 
        margin-bottom: 4vh;
        font-weight: 900;
    }
    .victory-stats { 
        font-size: clamp(2.8rem, 4vw, 5rem); 
        padding: 3vh 2vw;
        line-height: 1.3;
    }
    footer { bottom: 60px; right: 60px; font-size: 1.6rem; }
    footer p { padding: 20px 200px; border-radius: 24px; }
}


/* ====== Watermark de fondo ====== */
:root {
    --wm-size: 1100px;       /* tamaño de la marca */
    --wm-rotate: -22deg;     /* inclinación */
    --wm-opacity: 0.14;      /* transparencia */
  }
  
  body {
    position: relative; /* necesario para el pseudo-elemento */
  }
  
  body::before {
    content: "";
    position: fixed; /* fijo en pantalla */
    top: 12vh;
    left: calc(-0.25 * var(--wm-size)); /* lo empuja hacia la izquierda */
    width: var(--wm-size);
    height: var(--wm-size);
    background: url("../statics/img/flor.png") no-repeat center / contain;
    opacity: var(--wm-opacity);
    transform: rotate(var(--wm-rotate));
    pointer-events: none; /* no bloquea clicks */
    z-index: 0; /* al fondo */
  }
  
  .container,
  footer {
    position: relative;
    z-index: 1; /* el contenido queda por encima */
  }
  
  /* Responsivo */
  @media (max-width: 1024px) {
    :root { --wm-size: 780px; }
    body::before {
      top: 18vh;
      left: calc(-0.35 * var(--wm-size));
    }
  }
  
  @media (max-width: 600px) {
    :root { --wm-size: 560px; }
    body::before {
      top: 24vh;
      left: calc(-0.40 * var(--wm-size));
    }
  }