/* ===============================================
   TABU GAME MOBILE & iOS SAFARI FIX
   Only game-specific fixes (utilities moved to portal-utilities.css)
   =============================================== */

/* === TABU GAME SPECIFIC FIXES === */

/* Ensure game screen fills viewport */
#tabuGameScreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 9998 !important;
    /* Below confetti, above bottom nav */
}

/* Timer visibility - ensure it's always visible */
#tabuTime {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #3b82f6 !important;
    font-weight: 900 !important;
}

#timerBar {
    display: block !important;
    visibility: visible !important;
    height: 100% !important;
    transition: width 1s linear !important;
}

/* Forbidden words container - ensure all 4 are visible */
#tabuCardContainer .space-y-2,
#tabuCardContainer .space-y-3,
#tabuCardContainer .space-y-4 {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
}

/* Individual forbidden word items */
#tabuCardContainer .space-y-2>div,
#tabuCardContainer .space-y-3>div,
#tabuCardContainer .space-y-4>div {
    display: flex !important;
    align-items: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 44px !important;
    /* Touch target */
}

/* Action buttons container - ensure visibility */
#tabuGameScreen>div:last-child {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 10 !important;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* Grid for action buttons */
.grid-cols-3 {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

/* === BOTTOM NAV OVERLAP FIX === */
@media (max-width: 768px) {

    /* Hide bottom nav when Tabu game is active */
    body:has(#tabuGameScreen) .bottom-nav {
        display: none !important;
    }

    /* Alternative: if :has() not supported, use z-index */
    .bottom-nav {
        z-index: 9997 !important;
        /* Below game screen */
    }

    /* Ensure game screen is above bottom nav */
    #tabuGameScreen {
        z-index: 9998 !important;
    }
}

/* === iOS SAFARI SPECIFIC FIXES === */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari detection */

    /* Fix viewport height on iOS */
    #tabuGameScreen {
        min-height: -webkit-fill-available !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
    }

    /* Prevent iOS Safari zoom on input focus */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Fix safe area on iOS */
    #tabuGameScreen>div:last-child {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 20px)) !important;
    }
}

/* === OVERFLOW AND SCROLLING FIXES === */
#tabuGameScreen .overflow-y-auto {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Prevent horizontal scroll */
#tabuGameScreen * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* === ANIMATION FALLBACKS === */
.animate-slide-in {
    animation: slideIn 0.3s ease-out forwards !important;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-word-pop {
    animation: wordPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards !important;
}

@keyframes wordPop {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 390px) {

    /* iPhone 12/13 Mini and smaller */
    #tabuCardContainer {
        padding: 0.5rem !important;
    }

    .text-3xl {
        font-size: 1.5rem !important;
    }
}

@media (max-width: 374px) {

    /* Very small screens */
    .text-2xl {
        font-size: 1.25rem !important;
    }

    .text-xl {
        font-size: 1.125rem !important;
    }
}

/* === CRITICAL: ENSURE VISIBILITY === */
#tabuTime,
#timerBar,
#tabuCardContainer,
#tabuGameScreen button {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure buttons are tappable */
#tabuGameScreen button {
    pointer-events: auto !important;
    cursor: pointer !important;
    min-height: 44px !important;
    min-width: 44px !important;
}