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

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Main container with responsive height */
.main-container {
    width: 100%;
    height: 90vh;
    max-height: 450px;
    padding: 10px;
    position: relative;
}

/* Check if running in iframe and adjust height */
@media (max-height: 500px) {
    .main-container {
        height: 450px;
    }
}

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

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

/* Progress bar */
.progress-container {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 10px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Phase management */
.phase {
    display: none;
    height: calc(100% - 40px);
}

.phase.active {
    display: block;
}

/* Graph container */
.graph-container {
    height: calc(100% - 50px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Assessment container - Modified to accommodate graph reference */
.assessment-container {
    height: 100%;
    display: flex;
    gap: 10px;
}

/* Graph reference section - New styles for keeping graph visible during questions */
.graph-reference {
    flex: 0 0 40%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.reference-title {
    text-align: center;
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 8px;
    color: #333;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 4px;
}

.reference-columns {
    flex: 1;
    display: flex;
    gap: 4px;
    justify-content: space-between;
}

.reference-column {
    flex: 1;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.reference-header {
    text-align: center;
    font-weight: bold;
    font-size: 10px;
    padding: 3px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    margin-bottom: 4px;
}

.reference-grid {
    flex: 1;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 1px;
    padding: 3px;
    border: 1px dashed #ddd;
    border-radius: 3px;
    min-height: 60px;
}

/* Reference student avatars - Smaller versions for the reference graph */
.reference-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    user-select: none;
}

/* Columns container */
.columns-container {
    display: flex;
    gap: 8px;
    height: 60%;
    justify-content: space-between;
}

.column {
    flex: 1;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.column-header {
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    margin-bottom: 5px;
}

.column-grid {
    flex: 1;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 2px;
    padding: 5px;
    border: 2px dashed #ccc;
    border-radius: 4px;
    min-height: 100px;
    transition: all 0.3s ease;
}

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

/* Avatars container */
.avatars-container {
    height: 35%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.avatars-title {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 5px;
    text-align: center;
}

.avatars-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    height: calc(100% - 25px);
    overflow-y: auto;
    padding: 2px;
}

/* Student avatar styles */
.student-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    user-select: none;
}

.student-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.student-avatar:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.student-avatar.placed {
    width: 28px;
    height: 28px;
    font-size: 18px;
}

/* Button styles */
.complete-btn, .next-btn, .restart-btn {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

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

.complete-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.complete-btn:not(:disabled):hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

.next-btn:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.restart-btn {
    background: #FF9800;
    color: white;
}

.restart-btn:hover {
    background: #F57C00;
    transform: translateY(-2px);
}

/* Question container - Modified to work with graph reference */
.question-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.question-text {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    color: #333;
    line-height: 1.4;
}

.question-options {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

.option-btn {
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-btn:hover {
    border-color: #2196F3;
    background: rgba(33, 150, 243, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.option-btn.correct {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
    color: #2E7D32;
}

.option-btn.incorrect {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
}

/* Feedback styles */
.feedback {
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    padding: 10px;
    border-radius: 6px;
    min-height: 20px;
}

.feedback.correct {
    background: rgba(76, 175, 80, 0.2);
    color: #2E7D32;
}

.feedback.incorrect {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
}

/* Results container */
.results-container {
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.results-container h2 {
    color: #4CAF50;
    font-size: 24px;
    margin-bottom: 10px;
}

/* Hint system */
.hint-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 100;
}

.hint-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #FF9800;
    color: white;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.hint-btn:hover {
    background: #F57C00;
    transform: scale(1.1);
}

.hint-text {
    position: absolute;
    bottom: 50px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 200px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    text-align: left;
}

.hint-text.show {
    opacity: 1;
}

/* Count display for columns */
.column-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

/* Mobile responsiveness - Updated for new layout */
@media (max-width: 480px) {
    .assessment-container {
        flex-direction: column;
        gap: 5px;
    }
    
    .graph-reference {
        flex: 0 0 30%;
    }
    
    .reference-header {
        font-size: 9px;
    }
    
    .reference-avatar {
        width: 12px;
        height: 12px;
        font-size: 8px;
    }
    
    .columns-container {
        gap: 4px;
    }
    
    .column-header {
        font-size: 12px;
        padding: 3px;
    }
    
    .student-avatar {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .student-avatar.placed {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
    
    .question-text {
        font-size: 14px;
    }
    
    .option-btn {
        font-size: 12px;
        padding: 10px;
        min-height: 44px;
    }
}

/* Animation for correct answers */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.correct-animation {
    animation: bounce 0.6s ease;
}

/* Drag and drop visual feedback */
.dragging {
    opacity: 0.7;
    transform: rotate(5deg);
    z-index: 1000;
    pointer-events: none;
}

/* Column highlight during drag */
.column.highlight {
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid #4CAF50;
}