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

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

/* Container adapts to iframe or full screen */
.container {
    width: 100%;
    height: 100vh;
    max-height: 450px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
}

/* Media query for full screen mode */
@media (min-height: 500px) {
    .container {
        height: 90vh;
        max-height: none;
        padding: 20px;
    }
}

/* Tooltip for header information */
.tooltip-trigger {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: help;
    z-index: 100;
}

.info-icon {
    font-size: 18px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.info-icon:hover {
    opacity: 1;
}

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

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

.progress-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 4px;
    width: var(--progress, 0%);
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 14px;
    font-weight: bold;
    color: #666;
    min-width: 40px;
}

/* Main assessment area */
.assessment-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

/* Equation container */
.equation-container {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.equation {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 36px;
    font-weight: bold;
    color: #2c3e50;
}

.number, .operator, .equals, .result {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 60px;
}

/* Drop zone styling */
.drop-zone {
    min-width: 60px;
    height: 60px;
    border: 3px dashed #bdc3c7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    transition: all 0.3s ease;
    position: relative;
}

.drop-zone.drag-over {
    border-color: #3498db;
    background: #ebf3fd;
    transform: scale(1.05);
}

.drop-zone.correct {
    border-color: #27ae60;
    background: #d5f4e6;
    animation: correctPulse 0.6s ease;
}

.drop-zone.incorrect {
    border-color: #e74c3c;
    background: #fdeaea;
    animation: incorrectShake 0.6s ease;
}

.placeholder {
    font-size: 24px;
    color: #bdc3c7;
}

/* Feedback area */
.feedback-area {
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
}

#feedbackText {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.feedback-correct {
    color: #27ae60;
}

.feedback-incorrect {
    color: #e74c3c;
}

.feedback-hint {
    color: #f39c12;
}

/* Enhanced hint area styling */
.hint-area {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    animation: hintSlideIn 0.4s ease;
}

.hint-container {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
    max-width: 90%;
    text-align: center;
    animation: hintPulse 2s infinite;
}

.hint-icon {
    font-size: 20px;
    animation: hintIconBounce 1.5s infinite;
}

#hintText {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

/* Draggable numbers container */
.numbers-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 15px;
    background: #f1f2f6;
    border-radius: 12px;
    max-width: 100%;
}

/* Draggable number styling */
.draggable-number {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    user-select: none;
    touch-action: none;
}

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

.draggable-number:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.draggable-number.dragging {
    opacity: 0.7;
    transform: rotate(5deg) scale(1.1);
    z-index: 1000;
}

.draggable-number.used {
    opacity: 0.3;
    pointer-events: none;
    background: #95a5a6;
}

/* Enhanced draggable number highlighting for hints */
.draggable-number.hint-highlight {
    animation: hintNumberGlow 1.5s infinite;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
}

/* Button container */
.button-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* Action buttons */
.action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    white-space: nowrap;
    flex: 1;
    max-width: 150px;
}

.action-btn:not(.secondary):not(.hint-btn) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.secondary {
    background: #ecf0f1;
    color: #2c3e50;
    border: 2px solid #bdc3c7;
}

/* Enhanced hint button styling */
.action-btn.hint-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    position: relative;
    overflow: hidden;
}

.action-btn.hint-btn::before {
    content: '💡';
    margin-right: 5px;
}

.action-btn.hint-btn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

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

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Score container */
.score-container {
    text-align: center;
    margin-top: 10px;
}

.score-text {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

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

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 90%;
    animation: modalSlideIn 0.3s ease;
}

.modal-content h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 20px;
    font-size: 18px;
    color: #666;
}

/* Enhanced animations for hint system */
@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

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

@keyframes hintPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

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

@keyframes hintNumberGlow {
    0%, 100% { 
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 25px rgba(243, 156, 18, 0.8);
        transform: scale(1.05);
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .equation {
        font-size: 28px;
        gap: 10px;
    }
    
    .draggable-number {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .numbers-container {
        gap: 8px;
        padding: 10px;
    }
    
    .action-btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 40px;
        max-width: 120px;
    }
    
    .hint-container {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    #hintText {
        font-size: 13px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .draggable-number {
        width: 55px;
        height: 55px;
    }
    
    .drop-zone {
        min-width: 65px;
        height: 65px;
    }
    
    .action-btn {
        min-height: 48px;
        padding: 14px 20px;
    }
}