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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #333;
    overflow-x: hidden;
    /* Responsive height based on environment */
    height: 450px;
}

/* Check if in iframe or standalone */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
}

/* Control panel styles */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.controls-left {
    display: flex;
    gap: 8px;
}

.controls-center {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 36px;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-secondary {
    background: #2196F3;
    color: white;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-control label {
    font-size: 16px;
}

#zoomSlider {
    width: 80px;
}

.progress-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

#progressText {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.progress-bar {
    width: 120px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

#progressFill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.5s ease;
}

/* Timeline container */
.timeline-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.timeline {
    position: relative;
    height: 120px;
    min-width: 800px;
    background: linear-gradient(to right, #f0f8ff 0%, #e6f3ff 100%);
    border-radius: 8px;
    border: 2px solid #ddd;
    transform-origin: left center;
    transition: transform 0.3s ease;
}

/* Decade markers */
.decade-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #333;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.decade-marker::after {
    content: attr(data-year);
    position: absolute;
    bottom: -25px;
    font-weight: bold;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
}

/* Drop zones */
.drop-zone {
    position: absolute;
    top: 10px;
    bottom: 30px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px dashed #ccc;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    transform: scale(1.02);
}

.drop-zone-label {
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-top: 5px;
}

/* Events container */
.events-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    max-height: 180px;
    overflow-y: auto;
}

.events-header h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
    text-align: center;
}

.event-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* Event card styles */
.event-card {
    background: white;
    border-radius: 8px;
    padding: 8px;
    min-width: 140px;
    max-width: 160px;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid;
    position: relative;
}

.event-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.event-card.dragging {
    opacity: 0.7;
    transform: rotate(5deg);
    cursor: grabbing;
    z-index: 1000;
}

.event-card.placed {
    opacity: 0.5;
    transform: scale(0.9);
    cursor: default;
}

.event-card.correct {
    border-left-color: #4CAF50;
    background: linear-gradient(135deg, #e8f5e8, #f1f8e9);
}

.event-card.incorrect {
    border-left-color: #ff9800;
    background: linear-gradient(135deg, #fff3e0, #ffeaa7);
}

/* Event card content */
.event-icon {
    font-size: 24px;
    text-align: center;
    margin-bottom: 5px;
}

.event-year {
    font-weight: bold;
    font-size: 14px;
    color: #333;
    margin-bottom: 3px;
}

.event-title {
    font-size: 12px;
    color: #666;
    line-height: 1.2;
    text-align: center;
}

/* Color coding for event types */
.event-card[data-type="first"] { border-left-color: #2196F3; }
.event-card[data-type="moon"] { border-left-color: #FFD700; }
.event-card[data-type="accident"] { border-left-color: #f44336; }
.event-card[data-type="cooperation"] { border-left-color: #4CAF50; }

/* Timeline event (placed on timeline) */
.timeline-event {
    position: absolute;
    width: 60px;
    height: 80px;
    background: white;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid;
    top: 15px;
}

.timeline-event:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.timeline-event .event-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

.timeline-event .event-year {
    font-size: 10px;
    margin-bottom: 2px;
}

.timeline-event .event-title {
    font-size: 9px;
    line-height: 1.1;
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close:hover {
    color: #000;
}

/* Success modal styles */
.success-modal .modal-content {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.rocket-animation {
    font-size: 60px;
    animation: rocketFly 2s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes rocketFly {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.celebration h2 {
    margin-bottom: 15px;
    font-size: 28px;
}

.celebration p {
    margin-bottom: 20px;
    font-size: 16px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 5px;
        gap: 5px;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    .controls-left {
        order: 2;
    }
    
    .controls-center {
        order: 1;
        flex-direction: column;
        gap: 8px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .event-cards {
        gap: 6px;
    }
    
    .event-card {
        min-width: 120px;
        max-width: 140px;
        padding: 10px;
    }
    
    .timeline {
        min-width: 600px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 15px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }
    
    .event-card:hover {
        transform: none;
    }
    
    .timeline-event:hover {
        transform: none;
    }
}