/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    /* Changed: Singapore skyline background with vibrant colors */
    background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 25%, #45b7d1 50%, #f9ca24 75%, #f0932b 100%),
                url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 400"><defs><linearGradient id="sky" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:%23ff9a9e;stop-opacity:1" /><stop offset="100%" style="stop-color:%23fecfef;stop-opacity:1" /></linearGradient></defs><rect width="1200" height="400" fill="url(%23sky)"/><g fill="%23ffffff" opacity="0.1"><rect x="100" y="200" width="40" height="200"/><rect x="160" y="150" width="60" height="250"/><rect x="240" y="180" width="50" height="220"/><rect x="310" y="120" width="80" height="280"/><rect x="410" y="160" width="45" height="240"/><rect x="480" y="100" width="90" height="300"/><rect x="590" y="140" width="55" height="260"/><rect x="670" y="110" width="70" height="290"/><rect x="760" y="170" width="40" height="230"/><rect x="820" y="130" width="65" height="270"/><rect x="910" y="90" width="85" height="310"/><rect x="1020" y="160" width="50" height="240"/><rect x="1090" y="180" width="60" height="220"/></g><circle cx="1000" cy="80" r="40" fill="%23ffeb3b" opacity="0.8"/></svg>');
    background-size: cover;
    background-attachment: fixed;
    height: 100vh;
    overflow: hidden;
}

/* Container styles - responsive height for iframe vs full screen */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Changed: More vibrant background with Singapore flag colors */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(237, 28, 36, 0.05) 100%);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Full screen detection - when not in iframe */
@media screen and (min-height: 500px) {
    body:not(.iframe-mode) .container {
        height: 90vh;
        max-height: 90vh;
    }
}

/* Instructions panel */
.instructions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    /* Changed: Singapore flag inspired gradient */
    background: linear-gradient(135deg, #ed1c24 0%, #ffffff 50%, #ed1c24 100%);
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 16px rgba(237, 28, 36, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.instruction-text {
    font-size: 14px;
    font-weight: 700;
    /* Changed: Darker text for better contrast on colorful background */
    color: #2c3e50;
    flex: 1;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.reset-btn {
    /* Changed: More vibrant button colors */
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.3s ease;
    min-height: 40px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.reset-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}

/* Timeline container */
.timeline-container {
    position: relative;
    height: 120px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    /* Changed: Added subtle background pattern */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

/* Timeline line */
.timeline-line {
    position: absolute;
    top: 50%;
    left: 30px;
    right: 30px;
    height: 6px;
    /* Changed: More vibrant Singapore-inspired gradient */
    background: linear-gradient(90deg, #e74c3c 0%, #f39c12 25%, #2ecc71 50%, #3498db 75%, #9b59b6 100%);
    border-radius: 3px;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Timeline markers */
.timeline-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}

.marker-dot {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    /* Changed: More colorful border matching timeline */
    border: 4px solid #e74c3c;
    border-radius: 50%;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.marker-year {
    font-size: 11px;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    /* Changed: More vibrant background */
    background: linear-gradient(135deg, #ffffff 0%, #ecf0f1 100%);
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    border: 2px solid rgba(231, 76, 60, 0.3);
}

/* Drop zones */
.drop-zone {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    border: 3px dashed transparent;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Changed: Added subtle background */
    background: rgba(255, 255, 255, 0.1);
}

.drop-zone.drag-over {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.2);
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 16px rgba(46, 204, 113, 0.4);
}

.drop-zone.correct {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.3);
    box-shadow: 0 4px 16px rgba(39, 174, 96, 0.5);
}

.drop-zone.incorrect {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.3);
    animation: shake 0.5s ease-in-out;
    box-shadow: 0 4px 16px rgba(231, 76, 60, 0.5);
}

/* Events container */
.events-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    /* Changed: More colorful background */
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(155, 89, 182, 0.1) 100%);
    border-radius: 10px;
    min-height: 140px;
    align-content: flex-start;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
}

/* Event cards */
.event-card {
    /* Changed: More vibrant card backgrounds with different colors */
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 3px solid #3498db;
    border-radius: 12px;
    padding: 14px;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.3);
    flex: 1;
    min-width: 200px;
    max-width: calc(50% - 6px);
    position: relative;
    backdrop-filter: blur(5px);
}

/* Different colors for each event card */
.event-card[data-event="founding"] {
    border-color: #e74c3c;
    box-shadow: 0 4px 16px rgba(231, 76, 60, 0.3);
}

.event-card[data-event="occupation"] {
    border-color: #f39c12;
    box-shadow: 0 4px 16px rgba(243, 156, 18, 0.3);
}

.event-card[data-event="independence"] {
    border-color: #2ecc71;
    box-shadow: 0 4px 16px rgba(46, 204, 113, 0.3);
}

.event-card[data-event="nationbuilding"] {
    border-color: #9b59b6;
    box-shadow: 0 4px 16px rgba(155, 89, 182, 0.3);
}

.event-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.event-card:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.event-card.dragging {
    opacity: 0.8;
    transform: rotate(5deg) scale(0.95);
    z-index: 1000;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.event-card.placed {
    opacity: 0.6;
    pointer-events: none;
    background: linear-gradient(135deg, #ecf0f1 0%, #bdc3c7 100%);
}

.event-title {
    font-size: 14px;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 6px;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.event-description {
    font-size: 12px;
    color: #34495e;
    line-height: 1.4;
    font-weight: 500;
}

/* Feedback container */
.feedback-container {
    margin-top: auto;
    padding: 12px;
    text-align: center;
}

.feedback-message {
    font-size: 14px;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.feedback-message.success {
    /* Changed: More vibrant success colors */
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #27ae60;
    box-shadow: 0 4px 16px rgba(39, 174, 96, 0.3);
}

.feedback-message.error {
    /* Changed: More vibrant error colors */
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #e74c3c;
    box-shadow: 0 4px 16px rgba(231, 76, 60, 0.3);
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    /* Changed: More colorful tooltip */
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.95) 0%, rgba(52, 73, 94, 0.95) 100%);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.tooltip.show {
    opacity: 1;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(-50%) translateX(0); }
    25% { transform: translateX(-50%) translateX(-8px); }
    75% { transform: translateX(-50%) translateX(8px); }
}

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

.success-animation {
    animation: bounce 0.8s ease-in-out;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }
    
    .timeline-container {
        padding: 0 15px;
        height: 100px;
    }
    
    .marker-dot {
        width: 20px;
        height: 20px;
        border-width: 3px;
    }
    
    .marker-year {
        font-size: 10px;
        padding: 4px 6px;
    }
    
    .drop-zone {
        width: 60px;
        height: 60px;
        top: -30px;
    }
    
    .event-card {
        min-width: 150px;
        max-width: 100%;
        padding: 12px;
    }
    
    .event-title {
        font-size: 13px;
    }
    
    .event-description {
        font-size: 11px;
    }
    
    .instruction-text {
        font-size: 12px;
    }
    
    .reset-btn {
        padding: 8px 14px;
        font-size: 11px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .event-card {
        min-height: 44px; /* Minimum touch target size */
    }
    
    .reset-btn {
        min-height: 44px;
        padding: 12px 18px;
    }
    
    .marker-dot {
        width: 28px;
        height: 28px;
    }
    
    .drop-zone {
        width: 70px;
        height: 70px;
    }
}