/* 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, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Detect if not in iframe and adjust height */
@media screen and (min-height: 500px) {
    .container:not(.in-iframe) {
        height: 90vh;
    }
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    max-width: 300px;
    text-align: center;
}

.container:hover .tooltip {
    opacity: 1;
}

/* Main quiz area */
.quiz-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 10px 10px;
    gap: 15px;
}

/* Controls section */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.lifecycle-selector {
    padding: 8px 12px;
    border: 2px solid #4CAF50;
    border-radius: 20px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 150px;
}

.lifecycle-selector:hover {
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    transform: translateY(-1px);
}

.reset-btn, .check-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    min-height: 36px;
    white-space: nowrap;
}

.reset-btn {
    background: #ff6b6b;
    color: white;
}

.reset-btn:hover {
    background: #ff5252;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

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

.check-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* Life cycle container */
.lifecycle-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.lifecycle-svg {
    width: 100%;
    max-width: 350px;
    height: auto;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Drop zones */
.drop-zone {
    fill: rgba(76, 175, 80, 0.1);
    stroke: #4CAF50;
    stroke-width: 2;
    stroke-dasharray: 5,5;
    cursor: pointer;
    transition: all 0.3s;
}

.drop-zone:hover {
    fill: rgba(76, 175, 80, 0.2);
    stroke-width: 3;
}

.drop-zone.drag-over {
    fill: rgba(76, 175, 80, 0.3);
    stroke: #2E7D32;
    stroke-width: 3;
}

.drop-zone.correct {
    fill: rgba(76, 175, 80, 0.3);
    stroke: #2E7D32;
    stroke-width: 3;
}

.drop-zone.incorrect {
    fill: rgba(244, 67, 54, 0.3);
    stroke: #D32F2F;
    stroke-width: 3;
}

/* Center label */
.center-label {
    font-size: 16px;
    font-weight: bold;
    fill: #333;
}

/* Stage labels */
.stage-label {
    font-size: 12px;
    fill: #333;
    text-anchor: middle;
    pointer-events: none;
}

/* Stages container */
.stages-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    margin: 0 10px;
    flex-wrap: wrap;
    min-height: 60px;
    align-items: center;
}

/* Draggable stages */
.stage-item {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: grab;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    user-select: none;
    touch-action: none;
}

.stage-item:active {
    cursor: grabbing;
    transform: scale(1.1);
    z-index: 1000;
}

.stage-item.dragging {
    opacity: 0.8;
    transform: scale(1.1);
    z-index: 1000;
}

/* Stage colors */
.stage-egg { background: #FFF9C4; }
.stage-larva { background: #C8E6C9; }
.stage-pupa { background: #FFCCBC; }
.stage-adult { background: #E1BEE7; }
.stage-tadpole { background: #B3E5FC; }
.stage-froglet { background: #DCEDC8; }
.stage-seed { background: #F3E5AB; }
.stage-seedling { background: #C8E6C9; }
.stage-flower { background: #F8BBD9; }
.stage-fruit { background: #FFCDD2; }

/* Analytics toggle button */
.analytics-toggle {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: #2196F3;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    z-index: 1001;
    transition: all 0.3s;
}

.analytics-toggle:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

/* Analytics panel */
.analytics-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #2196F3;
    max-height: 200px;
    transform: translateY(100%);
    transition: transform 0.3s;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.analytics-panel.show {
    transform: translateY(0);
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.analytics-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.clear-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
}

.analytics-content {
    padding: 10px 15px;
    max-height: 140px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.4;
}

.analytics-entry {
    margin-bottom: 8px;
    padding: 6px;
    border-radius: 4px;
    border-left: 3px solid #ddd;
}

.analytics-entry.correct {
    background: #e8f5e8;
    border-left-color: #4CAF50;
}

.analytics-entry.incorrect {
    background: #ffeaea;
    border-left-color: #f44336;
}

.analytics-info {
    color: #666;
    font-style: italic;
    text-align: center;
    margin: 20px 0;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .quiz-area {
        padding: 15px 5px 5px;
        gap: 10px;
    }
    
    .lifecycle-svg {
        max-width: 280px;
    }
    
    .stage-item {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .controls {
        gap: 8px;
    }
    
    .lifecycle-selector {
        font-size: 12px;
        padding: 6px 10px;
        min-width: 120px;
    }
    
    .reset-btn, .check-btn {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 32px;
    }
    
    .center-label {
        font-size: 14px;
    }
    
    .stage-label {
        font-size: 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .stage-item {
        width: 55px;
        height: 55px;
    }
    
    .drop-zone {
        stroke-width: 3;
    }
}