/**
 * Game Selector - Animated Graphical Menu
 * Fun, bouncy, toddler-friendly with NO plain icons or squares
 */

/* Overlay backdrop with playful gradient */
.game-selector-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(135, 206, 250, 0.95) 0%,
        rgba(255, 218, 185, 0.95) 50%,
        rgba(255, 182, 193, 0.95) 100%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: 20px 10px 40px;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-selector-overlay.is-active {
    opacity: 1;
    transform: scale(1);
}

/* Animated title with bouncing trucks */
.selector-header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.selector-title {
    font-size: 28px;
    font-weight: 900;
    color: #FF6B35;
    text-shadow:
        3px 3px 0 #fff,
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff;
    margin: 0;
    animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-8px) rotate(2deg); }
}

/* Decorative bouncing trucks in header */
.selector-header-trucks {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 10px;
}

.header-truck {
    width: 50px;
    height: 50px;
    animation: truckBounce 1.5s ease-in-out infinite;
}

.header-truck:nth-child(2) { animation-delay: 0.2s; }
.header-truck:nth-child(3) { animation-delay: 0.4s; }

@keyframes truckBounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-12px) rotate(5deg); }
}

/* Game cards grid - scrollable carousel feel */
.game-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 380px;
    padding: 10px;
}

/* Individual game card - FUN shaped, not square */
.game-card-selector {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(145deg, #fff 0%, #f0f8ff 100%);
    border-radius: 30px 30px 20px 20px;
    padding: 12px 8px 16px;
    border: none;
    cursor: pointer;
    box-shadow:
        0 8px 20px rgba(0,0,0,0.15),
        inset 0 2px 4px rgba(255,255,255,0.8);
    transform-origin: center bottom;
    transition: all 0.2s ease;
    overflow: visible;
}

/* Colorful top banner shape */
.game-card-selector::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    border-radius: 30px 30px 50% 50%;
    z-index: 0;
    transition: all 0.3s ease;
}

/* Different colors for each card */
.game-card-selector[data-game="M01"]::before { background: linear-gradient(135deg, #FF6B6B, #FF8E8E); }
.game-card-selector[data-game="M02"]::before { background: linear-gradient(135deg, #4ECDC4, #7EDDD6); }
.game-card-selector[data-game="M03"]::before { background: linear-gradient(135deg, #FFD93D, #FFE566); }
.game-card-selector[data-game="M04"]::before { background: linear-gradient(135deg, #6C5CE7, #A29BFE); }
.game-card-selector[data-game="M05"]::before { background: linear-gradient(135deg, #55E6C1, #7DFFCC); }
.game-card-selector[data-game="M06"]::before { background: linear-gradient(135deg, #FF9F43, #FFBE76); }
.game-card-selector[data-game="M07"]::before { background: linear-gradient(135deg, #54A0FF, #7EB8FF); }
.game-card-selector[data-game="M08"]::before { background: linear-gradient(135deg, #FF6B9D, #FF8FB3); }
.game-card-selector[data-game="M09"]::before { background: linear-gradient(135deg, #00D2D3, #54E6E7); }
.game-card-selector[data-game="M10"]::before { background: linear-gradient(135deg, #FF9FF3, #FFB8F8); }
.game-card-selector[data-game="M11"]::before { background: linear-gradient(135deg, #5F27CD, #845EF7); }
.game-card-selector[data-game="M12"]::before { background: linear-gradient(135deg, #EE5A24, #FF7F50); }

/* Floating entrance animation for cards */
.game-card-selector {
    animation: cardFloat 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.game-card-selector:nth-child(1) { animation-delay: 0.05s; }
.game-card-selector:nth-child(2) { animation-delay: 0.1s; }
.game-card-selector:nth-child(3) { animation-delay: 0.15s; }
.game-card-selector:nth-child(4) { animation-delay: 0.2s; }
.game-card-selector:nth-child(5) { animation-delay: 0.25s; }
.game-card-selector:nth-child(6) { animation-delay: 0.3s; }
.game-card-selector:nth-child(7) { animation-delay: 0.35s; }
.game-card-selector:nth-child(8) { animation-delay: 0.4s; }
.game-card-selector:nth-child(9) { animation-delay: 0.45s; }
.game-card-selector:nth-child(10) { animation-delay: 0.5s; }
.game-card-selector:nth-child(11) { animation-delay: 0.55s; }
.game-card-selector:nth-child(12) { animation-delay: 0.6s; }

@keyframes cardFloat {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.8) rotate(-10deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0);
    }
}

/* Idle wobble animation */
.game-card-selector {
    animation: cardFloat 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards,
               idleWobble 4s ease-in-out infinite;
}

@keyframes idleWobble {
    0%, 100% { transform: rotate(-1deg); }
    50% { transform: rotate(1deg); }
}

/* Different wobble timing per card */
.game-card-selector:nth-child(odd) { animation-delay: 0.05s, 0s; }
.game-card-selector:nth-child(even) { animation-delay: 0.1s, 2s; }

/* Game image - the STAR of the show */
.game-card-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    z-index: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Game title - fun font */
.game-card-title {
    font-size: 13px;
    font-weight: 800;
    color: #2C3E50;
    margin-top: 8px;
    text-align: center;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    line-height: 1.2;
}

/* Touch/hover effects */
.game-card-selector:active,
.game-card-selector:hover {
    transform: scale(1.08) rotate(0deg);
    box-shadow:
        0 12px 30px rgba(0,0,0,0.25),
        inset 0 2px 4px rgba(255,255,255,0.8);
}

.game-card-selector:active .game-card-image {
    transform: scale(1.15) rotate(-5deg);
}

/* Sparkle effect on tap */
.game-card-selector::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.game-card-selector:active::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Back to Frenzy button - big and fun */
.selector-back-btn {
    margin-top: 20px;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 800;
    color: white;
    background: linear-gradient(145deg, #FF6B35, #FF8C5A);
    border: 4px solid #E55A25;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
    transition: all 0.2s ease;
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.selector-back-btn:active {
    transform: scale(0.95);
    box-shadow: 0 3px 10px rgba(255, 107, 53, 0.4);
}

/* Decorative floating elements */
.selector-floaters {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 499;
}

.selector-floater {
    position: absolute;
    width: 30px;
    height: 30px;
    opacity: 0.6;
    animation: floaterDrift 8s ease-in-out infinite;
}

.selector-floater:nth-child(1) { left: 5%; top: 20%; animation-delay: 0s; }
.selector-floater:nth-child(2) { right: 8%; top: 15%; animation-delay: 1s; }
.selector-floater:nth-child(3) { left: 10%; bottom: 30%; animation-delay: 2s; }
.selector-floater:nth-child(4) { right: 12%; bottom: 25%; animation-delay: 3s; }
.selector-floater:nth-child(5) { left: 50%; top: 8%; animation-delay: 4s; }

@keyframes floaterDrift {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(10deg); }
    50% { transform: translateY(-5px) rotate(-5deg); }
    75% { transform: translateY(-20px) rotate(5deg); }
}

/* Stars decoration */
.selector-star {
    font-size: 24px;
    animation: starTwinkle 2s ease-in-out infinite;
}

@keyframes starTwinkle {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Frenzy mode quick-play button */
.frenzy-quick-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(145deg, #FFD700, #FFA500);
    border: 4px solid #FF8C00;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.5);
    z-index: 510;
    animation: frenzyPulse 1.5s ease-in-out infinite;
}

.frenzy-quick-btn img {
    width: 45px;
    height: 45px;
}

@keyframes frenzyPulse {
    0%, 100% { transform: scale(1) rotate(-5deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

/* Mobile adjustments */
@media (max-width: 400px) {
    .game-cards-grid {
        gap: 12px;
        padding: 8px;
    }

    .game-card-image {
        width: 85px;
        height: 85px;
    }

    .game-card-title {
        font-size: 12px;
    }

    .selector-title {
        font-size: 24px;
    }
}

/* Landscape mode */
@media (orientation: landscape) and (max-height: 500px) {
    .game-cards-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 100%;
    }

    .game-card-image {
        width: 70px;
        height: 70px;
    }

    .selector-header {
        margin-bottom: 10px;
    }
}
