/* Shared Systems CSS - Audio & Rewards */

:root {
    --star-gold: #FFD700;
    --star-empty: #E0E0E0;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --primary-kids: #FF6B6B;
}

/* Speaker & Music Buttons */
.system-controls {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.speaker-btn, .music-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 4px solid var(--primary-kids);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
    .speaker-btn:hover, .music-toggle:hover {
        transform: scale(1.1);
    }
}

.speaker-btn:active, .music-toggle:active {
    transform: scale(0.9);
}

.music-toggle.muted {
    border-color: #999;
    filter: grayscale(1);
}

/* Reward Stars */
.reward-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.reward-star {
    font-size: 50px;
    color: var(--star-empty);
    text-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s;
    transform: scale(0);
}

.reward-star.active {
    color: var(--star-gold);
    transform: scale(1);
    animation: star-pop 0.5s forwards;
}

@keyframes star-pop {
    0% { transform: scale(0) rotate(-30deg); }
    70% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.reward-star:nth-child(2) { animation-delay: 0.2s; }
.reward-star:nth-child(3) { animation-delay: 0.4s; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .speaker-btn, .music-toggle {
        width: 50px;
        height: 50px;
        font-size: 24px;
        top: 10px;
        left: 10px;
    }

    .reward-star {
        font-size: 40px;
    }
}

@media (max-width: 480px) {
    .speaker-btn, .music-toggle {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 8px;
        left: 8px;
    }

    .reward-star {
        font-size: 32px;
    }
}

/* --- Global UX Polish --- */
button, .choice-card, .card, .shape, .object-emoji, .shadow-card, .emoji-cell, .thumbnail-wrapper, .puzzle-piece {
    -webkit-tap-highlight-color: transparent;
}

/* --- Unified Modal System --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Fallback for games using .hidden from previous versions */
.modal.hidden {
    display: none !important;
}

/* If active is present, never hide it with hidden (transition support) */
.modal.active.hidden {
    display: flex !important;
}

.modal-content {
    background-color: white;
    padding: 2.5rem;
    border-radius: 40px;
    text-align: center;
    border: 8px solid var(--primary-kids);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 90%;
    width: 450px;
    transform: scale(0.7);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.5rem;
        border-radius: 30px;
        border: 6px solid var(--primary-kids);
        width: 95%;
    }

    .modal-title {
        font-size: 2rem;
    }

    .modal-text {
        font-size: 1.2rem;
        margin-bottom: 1.5rem;
    }

    .btn-modal {
        padding: 12px 30px;
        font-size: 1.2rem;
        width: 90%;
    }
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 3rem;
    color: var(--primary-kids);
    margin-bottom: 0.5rem;
    font-family: 'FbSpacer', 'Nunito', sans-serif;
    line-height: 1.2;
}

.modal-text {
    font-size: 1.6rem;
    font-weight: 800;
    color: #333;
    margin-bottom: 2rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* Standardized Buttons */
.btn-modal {
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 80%;
    max-width: 300px;
    text-decoration: none;
    display: inline-block;
    touch-action: manipulation;
}

.btn-modal-primary {
    background-color: #2ed573;
    color: white;
    box-shadow: 0 8px 0 #21a351, 0 15px 20px rgba(46, 213, 115, 0.2);
}

.btn-modal-secondary {
    background-color: #70a1ff;
    color: white;
    box-shadow: 0 8px 0 #4776d0, 0 15px 20px rgba(112, 161, 255, 0.2);
}

.btn-modal-danger {
    background-color: #ff4757;
    color: white;
    box-shadow: 0 8px 0 #d93846, 0 15px 20px rgba(255, 71, 87, 0.2);
}

@media (hover: hover) and (pointer: fine) {
    .btn-modal:hover {
        transform: translateY(-2px);
    }
}

.btn-modal:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0 currentColor;
}

/* --- Standardized Navigation --- */
.btn-back-hub {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--primary-kids);
    color: white;
    text-decoration: none;
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 10000; /* Above everything */
    display: flex;
    align-items: center;
    gap: 8px;
    touch-action: manipulation;
    min-height: 44px;
}

@media (hover: hover) and (pointer: fine) {
    .btn-back-hub:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
    }
}



@media (max-width: 768px) {
    .btn-back-hub {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .btn-back-hub {
        top: 8px;
        right: 8px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* Confetti Container */
.confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
}

.confetti.hidden {
    display: none;
}

/* Bounce Animation */
.bounce {
    animation: bounce 0.6s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* =============================================
   HOME BUTTON — Global reusable component
   ============================================= */
.home-btn {
    position: fixed;
    top: 4px;
    right: 20px;
    z-index: 10000;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 25px;
    background-color: #f7f7f7;
    color: #4a86d9;
    border: 3px solid #4a86d9;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(74, 134, 217, 0.2);
    direction: ltr;           /* keeps icon on the right */
    min-height: 44px;
    touch-action: manipulation;
}

.home-btn:hover {
    background-color: #e8f0fb;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 134, 217, 0.3);
}

.home-btn__text {
    direction: rtl;           /* Hebrew text renders correctly */
    white-space: nowrap;
}

.home-btn__icon {
    font-size: 1.2rem;
}

/* Mobile — circular icon-only button */
@media (max-width: 768px) {
    .home-btn {
        top: 10px;
        right: 10px;
        width: 55px;
        height: 55px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        gap: 0;
    }

    .home-btn__text {
        display: none;
    }

    .home-btn__icon {
        font-size: 1.6rem;
    }
}
