/* Main container styling - optimized for iframe */
body {
    margin: 0;
    padding: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 450px; /* Default iframe height */
    overflow-y: auto;
    box-sizing: border-box;
}

/* Responsive height adjustment */
@media (min-height: 600px) {
    body {
        height: 90vh;
    }
}

#gameContainer {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header section with score and progress */
#gameHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#gameHeader > div {
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    cursor: help;
    transition: all 0.3s ease;
}

#gameHeader > div:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Question area styling */
#questionArea {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

#questionText {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    cursor: help;
}

#equation {
    font-size: 2em;
    font-weight: bold;
    color: #2196F3;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

#steps {
    font-size: 1em;
    color: #666;
    margin-top: 10px;
    min-height: 30px;
}

/* Answer input section */
#answerSection {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

#inputGroup {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#inputGroup label {
    font-weight: bold;
    color: #495057;
    white-space: nowrap;
}

#answerInput {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #ced4da;
    border-radius: 25px;
    font-size: 1em;
    min-width: 120px;
    transition: all 0.3s ease;
}

#answerInput:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

#submitBtn {
    padding: 10px 20px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

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

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

#hintBtn {
    background: #FF9800;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-block;
    font-size: 0.9em;
    transition: all 0.3s ease;
    align-self: flex-start;
}

#hintBtn:hover {
    background: #F57C00;
    transform: translateY(-2px);
}

/* Feedback area */
#feedbackArea {
    padding: 15px 20px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#feedback {
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

#feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#nextBtn {
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#nextBtn:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Analytics panel */
#analyticsPanel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

#analyticsToggle {
    padding: 10px 15px;
    background: #6c757d;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

#analyticsToggle:hover {
    background: #5a6268;
}

#analyticsContent {
    position: absolute;
    top: 100%;
    right: 0;
    width: 300px;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-top: 5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#analyticsContent h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1em;
}

.metric {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
}

.label {
    font-weight: bold;
    color: #495057;
}

#errorTypes {
    font-size: 0.9em;
    color: #dc3545;
}

#questionHistory {
    margin-top: 15px;
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    padding: 5px;
    margin-bottom: 5px;
    border-radius: 5px;
    font-size: 0.8em;
}

.history-item.correct {
    background: #d4edda;
    color: #155724;
}

.history-item.incorrect {
    background: #f8d7da;
    color: #721c24;
}

/* Game completion screen */
#gameComplete {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

#gameComplete h2 {
    color: #2196F3;
    margin-bottom: 20px;
}

#finalScore {
    font-size: 1.5em;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 15px;
}

#finalAnalytics {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    max-width: 300px;
}

#restartBtn {
    padding: 12px 25px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
}

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

/* Tooltip styling */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    z-index: 2000;
    pointer-events: none;
    max-width: 200px;
    word-wrap: break-word;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
    #inputGroup {
        flex-direction: column;
        align-items: stretch;
    }
    
    #inputGroup label {
        text-align: center;
    }
    
    #analyticsContent {
        width: 250px;
    }
    
    #equation {
        font-size: 1.5em;
    }
}