/* ==============================================
   WS Card Game — ws-card-game.css
   ============================================== */

/* Overlay */
.wscg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 37, 88, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.wscg-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Modal */
.wscg-modal {
    background: linear-gradient(160deg, var(--wscg-primary, #1565C0) 0%, #2196F3 60%, #64B5F6 100%);
    border-radius: 24px;
    padding: 1.5rem;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
}
.wscg-overlay.is-open .wscg-modal {
    transform: scale(1) translateY(0);
}

/* Close button */
.wscg-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
    line-height: 1;
    padding: 0;
}
.wscg-close:hover { background: rgba(255, 80, 80, 0.7); }

/* Header */
.wscg-header { text-align: center; margin-bottom: 1rem; }
.wscg-header__deco { font-size: 1.5rem; letter-spacing: 0.5rem; margin-bottom: 0.4rem; }
.wscg-title {
    font-size: clamp(1.3rem, 4vw, 1.9rem);
    color: var(--wscg-accent, #FFD740);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    margin: 0 0 0.25rem;
    font-weight: 700;
}
.wscg-subtitle {
    color: rgba(255,255,255,0.9);
    font-size: 0.95rem;
    margin: 0;
}

/* Score bar */
.wscg-scorebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.wscg-stat { color: rgba(255,255,255,0.85); font-size: 0.9rem; }
.wscg-stat strong { color: var(--wscg-accent, #FFD740); font-size: 1rem; }

/* Buttons */
.wscg-btn {
    background: var(--wscg-accent, #FFD740);
    color: #0D2558;
    border: none;
    border-radius: 20px;
    padding: 0.35rem 0.9rem;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
}
.wscg-btn:hover { background: #fff; transform: scale(1.05); }
.wscg-btn--restart { }

/* Card grid */
.wscg-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Card */
.wscg-card {
    aspect-ratio: 1;
    cursor: pointer;
    perspective: 600px;
    border-radius: 12px;
    list-style: none;
}
.wscg-card__inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(0.4, 0.2, 0.2, 1);
    border-radius: 12px;
}
.wscg-card.is-flipped .wscg-card__inner { transform: rotateY(180deg); }
.wscg-card__front,
.wscg-card__back {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.wscg-card__back {
    background: var(--wscg-card-back, #1976D2);
    border: 3px solid rgba(255,255,255,0.3);
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: box-shadow 0.2s;
    color: rgba(255,255,255,0.8);
}
.wscg-card:hover:not(.is-flipped):not(.is-matched) .wscg-card__back {
    box-shadow: 0 0 0 3px var(--wscg-accent, #FFD740), 0 4px 16px rgba(0,0,0,0.3);
}
.wscg-card__front {
    background: #fff;
    border: 3px solid rgba(255,255,255,0.6);
    transform: rotateY(180deg);
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.wscg-card.is-matched .wscg-card__front {
    background: linear-gradient(135deg, #56C870, #43A047);
    border-color: var(--wscg-accent, #FFD740);
    animation: wscgCardMatch 0.4s ease forwards;
}
@keyframes wscgCardMatch {
    0%   { transform: rotateY(180deg) scale(1);    }
    50%  { transform: rotateY(180deg) scale(1.15); }
    100% { transform: rotateY(180deg) scale(1);    }
}

/* Win screen */
.wscg-win {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: linear-gradient(135deg, #0D2558 0%, #1565C0 50%, #42AADF 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 5;
    overflow: hidden;
}
.wscg-win.is-visible { opacity: 1; pointer-events: auto; }
.wscg-win__content { text-align: center; position: relative; z-index: 2; padding: 2rem; }
.wscg-win__emoji {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    display: block;
    animation: wscgBounce 0.8s ease infinite alternate;
}
@keyframes wscgBounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-10px); }
}
.wscg-win__title { font-size: 2rem; color: var(--wscg-accent, #FFD740); margin: 0 0 0.5rem; font-weight: 700; }
.wscg-win__msg { color: rgba(255,255,255,0.9); font-size: 1rem; margin-bottom: 1.5rem; }
.wscg-win__content .wscg-btn { font-size: 1rem; padding: 0.65rem 1.5rem; }

/* Confetti */
.wscg-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.wscg-confetti-piece {
    position: absolute;
    animation: wscgConfettiFall linear forwards;
}
@keyframes wscgConfettiFall {
    0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
    100% { transform: translateY(600px) rotate(720deg); opacity: 0; }
}

/* Mobile */
@media (max-width: 480px) {
    .wscg-grid { gap: 0.4rem; }
    .wscg-card__back { font-size: 1rem; }
    .wscg-card__front { font-size: 1.3rem; }
    .wscg-title { font-size: 1.2rem; }
    .wscg-scorebar { gap: 0.3rem; }
}
