/* Out of Focus Game Styles - Modern Immersive UI */

/* Hide mobile bottom nav for full immersion */
.out-of-focus-container ~ .mobile-bottom-nav {
    display: none !important;
}

/* ===== Main Container ===== */
.out-of-focus-container {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 1000;
    overflow: hidden;
}

/* Subtle gradient overlay for depth */
.out-of-focus-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 0%, var(--bg-primary) 100%);
    opacity: 0.5;
    pointer-events: none;
}

/* ===== Back Button ===== */
.game-back-btn {
    position: absolute;
    top: max(1rem, env(safe-area-inset-top));
    left: max(1rem, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.25rem;
    background: rgba(128, 128, 128, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.game-back-btn:hover {
    color: var(--text-primary);
    background: rgba(128, 128, 128, 0.2);
    transform: scale(1.05);
}

.game-back-btn:active {
    transform: scale(0.95);
}

.game-back-btn span { display: none; }
.game-back-btn i { font-size: 1.2rem; }

/* ===== Full Poster Reveal Overlay ===== */
 .poster-reveal-overlay {
     position: absolute;
     inset: 0;
     display: flex;
     align-items: center;
     justify-content: center;
     padding: max(1rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
     background: rgba(0, 0, 0, 0.55);
     backdrop-filter: blur(18px);
     -webkit-backdrop-filter: blur(18px);
     z-index: 2000;
 }

 .poster-reveal-overlay.reveal-win {
     background:
         radial-gradient(1200px 800px at 50% 35%, rgba(34, 197, 94, 0.18) 0%, rgba(34, 197, 94, 0) 60%),
         rgba(0, 0, 0, 0.55);
 }

 .poster-reveal-overlay.reveal-lose {
     background:
         radial-gradient(1200px 800px at 50% 35%, rgba(239, 68, 68, 0.18) 0%, rgba(239, 68, 68, 0) 60%),
         rgba(0, 0, 0, 0.55);
 }

 .poster-reveal-inner {
     width: min(320px, 78vw);
     aspect-ratio: 2/3;
     border-radius: 22px;
     overflow: hidden;
     background: rgba(255, 255, 255, 0.04);
     box-shadow:
         0 40px 90px -20px rgba(0, 0, 0, 0.7),
         0 0 0 1px rgba(255, 255, 255, 0.08);
     transform: translateY(12px) scale(0.92);
     opacity: 0;
 }

 .poster-reveal-image {
     width: 100%;
     height: 100%;
     object-fit: cover;
     display: block;
     transform: scale(1.05);
 }

 .poster-reveal-overlay.reveal-win .poster-reveal-inner {
     animation: revealWinCard 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
 }

 .poster-reveal-overlay.reveal-lose .poster-reveal-inner {
     animation: revealLoseCard 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
 }

 .poster-reveal-overlay.reveal-win .poster-reveal-image {
     animation: revealWinImage 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
 }

 .poster-reveal-overlay.reveal-lose .poster-reveal-image {
     animation: revealLoseImage 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
 }

@keyframes revealWinCard {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.9);
        filter: saturate(1) brightness(1);
        box-shadow:
            0 40px 90px -20px rgba(0, 0, 0, 0.7),
            0 0 0 1px rgba(255, 255, 255, 0.08);
    }
    20% {
        opacity: 1;
        transform: translateY(0) scale(1);
        box-shadow:
            0 50px 110px -30px rgba(0, 0, 0, 0.75),
            0 0 0 1px rgba(74, 222, 128, 0.25);
    }
    70% {
        opacity: 1;
        transform: translateY(0) scale(1);
        box-shadow:
            0 50px 110px -30px rgba(0, 0, 0, 0.75),
            0 0 0 1px rgba(74, 222, 128, 0.35);
    }
    100% {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
        box-shadow:
            0 30px 80px -25px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(74, 222, 128, 0.15);
    }
}

@keyframes revealWinImage {
    0% {
        transform: scale(1.12);
        filter: blur(6px) saturate(0.9) brightness(0.9);
    }
    25% {
        transform: scale(1.03);
        filter: blur(0px) saturate(1.1) brightness(1);
    }
    70% {
        transform: scale(1);
        filter: blur(0px) saturate(1.15) brightness(1.05);
    }
    100% {
        transform: scale(0.995);
        filter: blur(0px) saturate(1.05) brightness(1);
    }
}

@keyframes revealLoseCard {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.9);
        box-shadow:
            0 40px 90px -20px rgba(0, 0, 0, 0.7),
            0 0 0 1px rgba(255, 255, 255, 0.08);
    }
    20% {
        opacity: 1;
        transform: translateY(0) scale(1);
        box-shadow:
            0 50px 110px -30px rgba(0, 0, 0, 0.75),
            0 0 0 1px rgba(248, 113, 113, 0.28);
    }
    55% {
        opacity: 1;
        transform: translateY(0) scale(1);
        box-shadow:
            0 50px 110px -30px rgba(0, 0, 0, 0.75),
            0 0 0 1px rgba(248, 113, 113, 0.38);
    }
    100% {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
        box-shadow:
            0 25px 70px -20px rgba(0, 0, 0, 0.6),
            0 0 0 1px rgba(248, 113, 113, 0.18);
    }
}

@keyframes revealLoseImage {
    0% {
        transform: scale(1.12);
        filter: blur(6px) saturate(0.85) brightness(0.85);
    }
    25% {
        transform: scale(1.02);
        filter: blur(0px) saturate(1) brightness(0.95);
    }
    55% {
        transform: scale(1);
        filter: blur(0px) saturate(0.95) brightness(0.9);
    }
    100% {
        transform: scale(1.03);
        filter: blur(2px) saturate(0.9) brightness(0.85);
    }
}

/* ===== Game Area ===== */
.game-area {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(1rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
    box-sizing: border-box;
}

/* ===== Game Content ===== */
.game-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    height: 100%;
    gap: 1.5rem;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Loading State ===== */
.game-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.loading-spinner-container {
    position: relative;
    width: 48px;
    height: 48px;
}

.loading-spinner {
    position: absolute;
    inset: 0;
    border: 2px solid var(--surface-border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner-ring {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.game-loading p {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0.02em;
}

/* ===== Poster Container ===== */
.poster-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 0;
    max-height: 28vh;
    flex-shrink: 0;
}

 .poster-placeholder {
     position: absolute;
     inset: 0;
     display: flex;
     align-items: center;
     justify-content: center;
     background: linear-gradient(135deg, rgba(128, 128, 128, 0.12) 0%, rgba(128, 128, 128, 0.06) 100%);
     border: 1px solid rgba(255, 255, 255, 0.06);
     color: var(--text-tertiary);
     z-index: 1;
 }

 .poster-placeholder i {
     font-size: 3rem;
     opacity: 0.7;
     filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.25));
 }

 .poster-wrapper.show-placeholder .poster-canvas,
 .poster-wrapper.show-placeholder .poster-overlay,
 .poster-wrapper.show-placeholder .poster-image {
     opacity: 0;
     pointer-events: none;
 }

 .poster-wrapper:not(.show-placeholder) .poster-placeholder {
     opacity: 0;
     pointer-events: none;
 }

.game-content.result-visible .poster-container {
    display: none;
}

.poster-wrapper {
    position: relative;
    height: 100%;
    aspect-ratio: 2/3;
    border-radius: 20px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(128,128,128,0.1) 0%, rgba(128,128,128,0.05) 100%);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

 .poster-wrapper .poster-canvas,
 .poster-wrapper .poster-overlay,
 .poster-wrapper .poster-image,
 .poster-wrapper .poster-placeholder {
     transition: opacity 0.25s ease;
 }

.poster-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 30px 60px -15px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}

.poster-image,
.poster-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poster-canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.poster-overlay {
    position: absolute;
    inset: 0;
    background: var(--surface-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.poster-overlay::after {
    content: '\F5A0';
    font-family: 'bootstrap-icons';
    font-size: 2.5rem;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.poster-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== Timer ===== */
.timer-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
    position: relative;
}

.timer-bar {
    flex: 1;
    height: 4px;
    background: rgba(128, 128, 128, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 2px;
    transition: width 0.1s linear, background 0.5s ease;
    width: 100%;
}

.timer-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.timer-fill.danger {
    background: linear-gradient(90deg, #ef4444, #f87171);
    animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.timer-container.time-penalty {
    animation: timePenalty 0.5s ease-out;
}

@keyframes timePenalty {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.timer-penalty-text {
    position: absolute;
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 700;
    animation: penaltyFade 0.8s ease-out forwards;
    white-space: nowrap;
}

@keyframes penaltyFade {
    0% { opacity: 0; transform: translateY(-50%) translateX(-10px); }
    20% { opacity: 1; transform: translateY(-50%) translateX(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-50%) translateX(10px); }
}

.timer-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ===== Game Actions ===== */
.game-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

.game-hint {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    text-align: center;
    margin: 0;
    max-width: 260px;
    line-height: 1.5;
    opacity: 0.8;
}

/* ===== Buttons ===== */
.game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 180px;
    text-decoration: none;
    letter-spacing: 0.01em;
}

 .game-btn:disabled {
     opacity: 0.65;
     cursor: not-allowed;
 }

 .game-btn.is-loading i {
     animation: spin 0.9s linear infinite;
 }

.game-btn i {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.game-btn:hover i {
    transform: scale(1.1);
}

.game-btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.game-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.game-btn-primary:active {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.game-btn-secondary {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(128, 128, 128, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.game-btn-secondary:hover {
    background: rgba(128, 128, 128, 0.15);
    border-color: rgba(128, 128, 128, 0.3);
}

/* ===== Multiple Choice ===== */
.choices-container {
    width: 100%;
    max-width: 340px;
    animation: fadeIn 0.4s ease-out;
}

.choices-header {
    display: flex;
    justify-content: center;
    margin-bottom: 0.6rem;
}

.guesses-remaining {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 500;
}

.guesses-remaining i {
    font-size: 0.9rem;
}

.guesses-remaining.warning {
    color: #f59e0b;
}

.guesses-remaining.danger {
    color: #ef4444;
}

.choices-grid {
    display: flex;
    flex-direction: column;
}

.choice-btn {
    width: 100%;
    padding: 0.7rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.choice-btn:hover:not(:disabled) {
    background: rgba(128, 128, 128, 0.15);
    border-color: rgba(128, 128, 128, 0.25);
    transform: translateX(4px);
}

.choice-btn:active:not(:disabled) {
    transform: translateX(2px);
}

.choice-btn:disabled {
    cursor: not-allowed;
}

.choice-btn.wrong {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: rgba(248, 113, 113, 0.6);
    text-decoration: line-through;
    animation: shakeWrong 0.4s ease-out forwards;
}

.choice-btn.wrong.slide-out {
    animation: slideOutLeft 0.35s ease-in-out forwards;
}

@keyframes shakeWrong {
    0% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(2px); }
    100% { transform: translateX(0); }
}

@keyframes slideOutLeft {
    0% { 
        transform: translateX(0); 
        opacity: 0.4; 
        max-height: 50px;
    }
    50% {
        transform: translateX(-100%);
        opacity: 0;
        max-height: 50px;
    }
    100% { 
        transform: translateX(-100%); 
        opacity: 0; 
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin: 0;
        border-width: 0;
    }
}

.choice-btn.correct {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
    animation: correctPulse 0.5s ease-out;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(74, 222, 128, 0.3); }
    100% { transform: scale(1); }
}

/* ===== Game Result ===== */
.game-result {
    text-align: center;
    animation: resultFade 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

 .result-poster-container {
     display: flex;
     justify-content: center;
     margin-bottom: 1rem;
 }

 .result-poster-wrapper {
     width: min(240px, 72vw);
     aspect-ratio: 2/3;
     border-radius: 18px;
     overflow: hidden;
     background: linear-gradient(135deg, rgba(128,128,128,0.1) 0%, rgba(128,128,128,0.05) 100%);
     box-shadow:
         0 25px 50px -12px rgba(0, 0, 0, 0.45),
         0 0 0 1px rgba(255, 255, 255, 0.06);
 }

 .result-poster {
     width: 100%;
     height: 100%;
     object-fit: cover;
     display: block;
 }

@keyframes resultFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.result-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: iconBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes iconBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.result-icon.correct i {
    color: #4ade80;
    filter: drop-shadow(0 0 20px rgba(74, 222, 128, 0.4));
}

.result-icon.incorrect i {
    color: #f87171;
    filter: drop-shadow(0 0 20px rgba(248, 113, 113, 0.4));
}

.result-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.result-film {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0 0 0.25rem;
}

.result-info {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin: 0 0 1rem;
    opacity: 0.8;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    border-bottom: 1px solid rgba(128, 128, 128, 0.15);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.result-actions .game-btn {
    min-width: 200px;
}

/* ===== Already Played ===== */
.already-played {
    display: none !important;
}

.already-played-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    width: 100%;
    height: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease-out;
}

.already-played-icon {
    font-size: 4rem;
    color: var(--text-tertiary);
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.already-played-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    letter-spacing: -0.02em;
}

.already-played-text {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0 0 2rem;
    opacity: 0.8;
}

.already-played-countdown {
    color: var(--text-tertiary);
    font-size: 0.95rem;
    margin: 0 0 2rem;
}

.already-played-countdown span {
    display: block;
    color: var(--text-primary);
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 2.5rem;
    margin-top: 0.75rem;
    letter-spacing: 0.1em;
}

/* ===== Responsive ===== */
@media (max-height: 700px) {
    .poster-container {
        max-height: 28vh;
    }
    
    .game-content {
        gap: 1rem;
    }
}

@media (max-width: 380px) {
    .game-btn {
        min-width: 160px;
        padding: 0.9rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .result-title {
        font-size: 1.5rem;
    }
    
    .already-played-countdown span {
        font-size: 2rem;
    }
}

@media (min-width: 768px) {
    .poster-container {
        max-height: 38vh;
    }
}
