/* Timer System Styles for Times Table Animals */

/* Timer Container */
.timer-container {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    margin-left: auto;
}

.timer-container.hidden {
    display: none;
}

/* Enhanced pulsing animations for different urgency levels */
.timer-container.pulsing {
    animation: timerPulse 1s ease-in-out infinite;
}

.timer-container.pulsing.urgent {
    animation: timerPulseUrgent 0.8s ease-in-out infinite;
}

.timer-container.pulsing.critical {
    animation: timerPulseCritical 0.6s ease-in-out infinite;
}

.timer-container.pulsing.emergency {
    animation: timerPulseEmergency 0.4s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes timerPulseUrgent {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.08) rotate(1deg); }
}

@keyframes timerPulseCritical {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-1deg); }
    75% { transform: scale(1.1) rotate(1deg); }
}

@keyframes timerPulseEmergency {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.15) rotate(-2deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    75% { transform: scale(1.15) rotate(2deg); }
}

/* Timer Display */
.timer-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: "Comic Sans MS", cursive;
    font-weight: bold;
    font-size: 18px;
    color: #333;
}

#timerIcon {
    font-size: 20px;
    animation: timerTick 1s ease-in-out infinite;
}

@keyframes timerTick {
    0%, 50% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
    100% { transform: rotate(0deg); }
}

/* Timer Bar Container */
.timer-bar-container {
    position: relative;
    width: 200px;
    height: 12px;
    border-radius: 10px;
    overflow: hidden;
}

.timer-bar-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(200, 200, 200, 0.3);
    border-radius: 10px;
}

/* Timer Bar States */
.timer-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease, background-color 0.3s ease;
}

.timer-bar.safe {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

.timer-bar.warning {
    background: linear-gradient(90deg, #FF9800, #FFC107);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.4);
}

.timer-bar.danger {
    background: linear-gradient(90deg, #FF5722, #FF9800);
    box-shadow: 0 0 8px rgba(255, 87, 34, 0.4);
}

.timer-bar.critical {
    background: linear-gradient(90deg, #F44336, #E91E63);
    box-shadow: 0 0 12px rgba(244, 67, 54, 0.6);
    animation: criticalPulse 0.5s ease-in-out infinite;
}

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

/* Timer Warning Popup */
.timer-warning-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    /* Mobile-specific fixes */
    -webkit-transform: translate(-50%, -50%) scale(0.8);
    -moz-transform: translate(-50%, -50%) scale(0.8);
    -ms-transform: translate(-50%, -50%) scale(0.8);
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.timer-warning-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    -webkit-transform: translate(-50%, -50%) scale(1);
    -moz-transform: translate(-50%, -50%) scale(1);
    -ms-transform: translate(-50%, -50%) scale(1);
}

/* Enhanced warning popup styles based on urgency */
.timer-warning-popup.warning-mild .warning-content {
    background: linear-gradient(135deg, #FF9500, #FFB84D);
    animation: warningBounce 0.6s ease-out;
}

.timer-warning-popup.warning-moderate .warning-content {
    background: linear-gradient(135deg, #FF7A00, #FF9500);
    animation: warningBounce 0.5s ease-out, warningPulse 0.8s ease-in-out infinite;
}

.timer-warning-popup.warning-urgent .warning-content {
    background: linear-gradient(135deg, #FF5722, #FF7A00);
    animation: warningBounce 0.4s ease-out, warningShakeIntense 0.6s ease-in-out infinite;
}

.timer-warning-popup.warning-critical .warning-content {
    background: linear-gradient(135deg, #F44336, #FF5722);
    animation: warningBounce 0.3s ease-out, warningShakeIntense 0.4s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.8);
}

.timer-warning-popup.warning-emergency .warning-content {
    background: linear-gradient(135deg, #D32F2F, #F44336);
    animation: warningBounce 0.2s ease-out, warningEmergencyShake 0.2s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(211, 47, 47, 0.9);
}

.timer-warning-popup.warning-panic .warning-content {
    background: linear-gradient(135deg, #B71C1C, #D32F2F);
    animation: warningBounce 0.1s ease-out, warningPanicShake 0.1s ease-in-out infinite;
    box-shadow: 0 0 40px rgba(183, 28, 28, 1.0);
    border: 2px solid #FF1744;
}

.warning-content {
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    color: white;
    padding: 20px 30px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: "Comic Sans MS", cursive;
    font-size: 18px;
    font-weight: bold;
    animation: warningBounce 0.6s ease-out;
}

@keyframes warningBounce {
    0% { transform: scale(0.3); }
    50% { transform: scale(1.1); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.warning-icon {
    font-size: 24px;
    animation: warningShake 0.5s ease-in-out infinite;
}

@keyframes warningShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Enhanced warning animations */
@keyframes warningPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes warningShakeIntense {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(-3px) translateY(-1px); }
    50% { transform: translateX(3px) translateY(1px); }
    75% { transform: translateX(-2px) translateY(2px); }
}

@keyframes warningEmergencyShake {
    0%, 100% { transform: translateX(0) translateY(0) rotate(0deg); }
    20% { transform: translateX(-4px) translateY(-2px) rotate(-1deg); }
    40% { transform: translateX(4px) translateY(2px) rotate(1deg); }
    60% { transform: translateX(-3px) translateY(3px) rotate(-1deg); }
    80% { transform: translateX(3px) translateY(-3px) rotate(1deg); }
}

@keyframes warningPanicShake {
    0%, 100% { transform: translateX(0) translateY(0) rotate(0deg) scale(1); }
    10% { transform: translateX(-5px) translateY(-3px) rotate(-2deg) scale(1.05); }
    20% { transform: translateX(5px) translateY(3px) rotate(2deg) scale(0.95); }
    30% { transform: translateX(-4px) translateY(4px) rotate(-2deg) scale(1.05); }
    40% { transform: translateX(4px) translateY(-4px) rotate(2deg) scale(0.95); }
    50% { transform: translateX(-3px) translateY(3px) rotate(-1deg) scale(1.05); }
    60% { transform: translateX(3px) translateY(-3px) rotate(1deg) scale(0.95); }
    70% { transform: translateX(-2px) translateY(2px) rotate(-1deg) scale(1.05); }
    80% { transform: translateX(2px) translateY(-2px) rotate(1deg) scale(0.95); }
    90% { transform: translateX(-1px) translateY(1px) rotate(-1deg) scale(1.05); }
}

/* Ember particle animation */
@keyframes emberFloat {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translateY(-50vh) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Catastrophic Event Overlay */
.catastrophic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.catastrophic-overlay.hidden {
    display: none;
}

.catastrophic-overlay.show {
    opacity: 1;
}

.catastrophic-content {
    background: linear-gradient(135deg, #2C3E50, #34495E);
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 4px solid #E74C3C;
    animation: catastrophicEntrance 0.8s ease-out;
}

@keyframes catastrophicEntrance {
    0% {
        transform: scale(0.3) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.catastrophic-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: catastrophicIconPulse 2s ease-in-out infinite;
}

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

/* Volcano Image Styles */
.volcano-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    animation: catastrophicIconPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 69, 0, 0.8));
}

.warning-volcano-image {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
    filter: drop-shadow(0 0 5px rgba(255, 69, 0, 0.6));
}

.catastrophic-title {
    font-family: "Comic Sans MS", cursive;
    font-size: 36px;
    font-weight: bold;
    color: #E74C3C;
    margin: 0 0 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: catastrophicTextShake 0.5s ease-in-out infinite;
}

@keyframes catastrophicTextShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-1px); }
    75% { transform: translateX(1px); }
}

.catastrophic-message {
    font-family: "Comic Sans MS", cursive;
    font-size: 18px;
    color: #ECF0F1;
    margin: 0 0 30px 0;
    line-height: 1.4;
}

.catastrophic-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.catastrophic-btn {
    font-family: "Comic Sans MS", cursive;
    font-size: 16px;
    font-weight: bold;
    padding: 12px 24px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.catastrophic-btn.primary {
    background: linear-gradient(135deg, #27AE60, #2ECC71);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.catastrophic-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.6);
}

.catastrophic-btn.secondary {
    background: linear-gradient(135deg, #95A5A6, #BDC3C7);
    color: #2C3E50;
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.4);
}

.catastrophic-btn.secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.6);
}

/* Responsive Design */
@media (max-width: 768px) {
    .timer-container {
        gap: 10px;
        padding: 8px;
    }
    
    .timer-display {
        font-size: 16px;
    }
    
    .timer-bar-container {
        width: 150px;
        height: 10px;
    }
    
    /* Mobile-specific timer warning popup fixes */
    .timer-warning-popup {
        /* Use viewport units for better mobile positioning */
        top: 50vh;
        left: 50vw;
        /* Add mobile-specific positioning constraints */
        max-width: 90vw;
        max-height: 90vh;
        /* Ensure proper layering on mobile */
        z-index: 99999;
        /* Force hardware acceleration */
        transform: translate3d(-50%, -50%, 0) scale(0.8);
        -webkit-transform: translate3d(-50%, -50%, 0) scale(0.8);
    }
    
    .timer-warning-popup.show {
        transform: translate3d(-50%, -50%, 0) scale(1);
        -webkit-transform: translate3d(-50%, -50%, 0) scale(1);
    }
    
    .warning-content {
        padding: 15px 20px;
        font-size: 16px;
        max-width: 80vw;
        /* Ensure content doesn't overflow on small screens */
        word-wrap: break-word;
        /* Add mobile-specific border radius */
        border-radius: 15px;
        /* Enhanced shadow for better visibility */
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
    
    .warning-icon {
        font-size: 20px;
        /* Ensure emoji renders properly on mobile */
        line-height: 1;
    }
    
    .catastrophic-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .catastrophic-title {
        font-size: 28px;
    }
    
    .catastrophic-buttons {
        flex-direction: column;
    }
}

/* Additional mobile-specific fixes for very small screens */
@media (max-width: 480px) {
    .timer-warning-popup {
        /* Even more conservative sizing for small phones */
        max-width: 95vw;
        top: 40vh;
    }
    
    .warning-content {
        padding: 12px 15px;
        font-size: 14px;
        gap: 10px;
    }
    
    .warning-icon {
        font-size: 18px;
    }
}

/* Specific fixes for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .timer-warning-popup {
        /* iOS Safari specific positioning */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.8);
        -webkit-transform: translate(-50%, -50%) scale(0.8);
        /* Force layer creation for smooth animation */
        -webkit-transform-style: preserve-3d;
        transform-style: preserve-3d;
    }
    
    .timer-warning-popup.show {
        transform: translate(-50%, -50%) scale(1);
        -webkit-transform: translate(-50%, -50%) scale(1);
    }
}