/* 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, #e3f2fd 0%, #f3e5f5 100%);
    min-height: 100vh;
    padding: 10px;
}

/* Container styles - responsive height management */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 15px;
    height: 450px; /* Default iframe height */
    overflow-y: auto;
    position: relative;
}

/* Detect if running in new tab vs iframe */
@media (min-height: 600px) {
    .container {
        height: 90vh;
    }
}

/* Progress section */
.progress-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    min-width: 80px;
}

/* Help button */
.help-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #2196f3;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.help-btn:hover {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

/* Animals container */
.animals-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
    min-height: 60px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px dashed #ddd;
}

/* Animal cards */
.animal-card {
    background: white;
    border-radius: 10px;
    padding: 8px;
    min-width: 80px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    user-select: none;
    touch-action: none;
}

.animal-card:active {
    cursor: grabbing;
}

.animal-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.animal-card.dragging {
    opacity: 0.8;
    transform: rotate(5deg) scale(1.05);
    z-index: 1000;
}

.animal-card.correct {
    border-color: #4caf50;
    background: #e8f5e8;
}

.animal-card.incorrect {
    border-color: #ff9800;
    background: #fff3e0;
    animation: gentle-shake 0.5s ease-in-out;
}

.animal-emoji {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
}

.animal-name {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

/* Classification container */
.classification-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.classification-box {
    background: white;
    border-radius: 12px;
    padding: 10px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
    min-height: 120px;
}

.classification-box:hover {
    border-color: #2196f3;
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.2);
}

.classification-box.drag-over {
    border-color: #4caf50;
    background: #e8f5e8;
    transform: scale(1.02);
}

.box-icon {
    font-size: 20px;
    text-align: center;
    margin-bottom: 5px;
}

.box-label {
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    color: #333;
    margin-bottom: 8px;
}

.drop-zone {
    min-height: 60px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 5px;
    align-items: flex-start;
    align-content: flex-start;
}

.drop-zone.has-animals {
    border-color: #4caf50;
    background: #f1f8e9;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.control-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.control-btn:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#tryAgainBtn {
    background: #ff9800;
}

#tryAgainBtn:hover {
    background: #f57c00;
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.3);
}

/* Results */
.results {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-top: 10px;
}

.score-display {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.encouragement {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

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

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

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

.close:hover {
    color: #333;
}

.help-examples {
    margin-top: 15px;
}

.help-item {
    margin-bottom: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
}

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

.tooltip.show {
    opacity: 1;
}

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

@keyframes celebration {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.celebrate {
    animation: celebration 0.6s ease-in-out;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .classification-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .animal-card {
        min-width: 70px;
        padding: 6px;
    }
    
    .animal-emoji {
        font-size: 20px;
    }
    
    .animal-name {
        font-size: 10px;
    }
    
    .box-label {
        font-size: 12px;
    }
    
    .control-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .classification-container {
        grid-template-columns: 1fr;
    }
    
    .animals-container {
        gap: 6px;
    }
    
    .progress-text {
        font-size: 11px;
        min-width: 70px;
    }
}