:root {
    --primary-color: #4361ee; --primary-light: #4895ef; --primary-dark: #3f37c9; --accent-color: #f72585; --success-color: #38b000; --warning-color: #ff9e00; --danger-color: #d90429; --neutral-light: #f8f9fa; --neutral-medium: #e9ecef; --neutral-dark: #495057;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08); --shadow-md: 0 4px 12px rgba(0,0,0,0.12); --shadow-lg: 0 8px 24px rgba(0,0,0,0.15); --border-radius: 12px;
}
* {
    margin: 0; padding: 0; box-sizing: border-box; font-feature-settings: "liga" 1, "calt" 1; text-rendering: optimizeLegibility;
}
body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: 'Noto Sans Sinhala', 'Iskoola Pota', 'Poppins', sans-serif; min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 10px; line-height: 1.6;
    color: #333;
}
.quiz-container {
    background-color: white; border-radius: var(--border-radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 950px; overflow: hidden; position: relative;
}
.quiz-header {
    background: linear-gradient(to right, var(--primary-color), var(--primary-light)); color: white; padding: 20px; text-align: center; position: relative;
}
.quiz-header h2 {
    font-weight: 700; font-size: 1.5rem; margin-bottom: 10px; letter-spacing: 0.5px;
}
.quiz-content { padding: 20px; }
.user-info-section {
    background-color: var(--neutral-light); padding: 20px; border-radius: var(--border-radius); margin-bottom: 25px; box-shadow: var(--shadow-sm);
}
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block; margin-bottom: 8px; font-weight: 500; color: var(--neutral-dark);
}
.user-input, .user-select {
    width: 100%; padding: 10px 15px; border: 1px solid var(--neutral-medium); border-radius: 8px; font-size: 1rem; font-family: 'Poppins', 'Noto Sans Sinhala', sans-serif;
    transition: border-color 0.2s ease; background-color: white; 
}
.user-input:focus, .user-select:focus {
    outline: none; border-color: var(--primary-color);
}
.timer-container {
    display: flex; justify-content: space-between; align-items: center; background-color: var(--neutral-light); padding: 15px 20px; border-radius: var(--border-radius); margin-bottom: 25px; box-shadow: var(--shadow-sm); font-weight: 500;
}
.timer-label { display: flex; align-items: center; gap: 8px; }
.timer-icon { width: 20px; height: 20px; fill: var(--primary-color); }
#time {
    font-size: 1.2rem; font-weight: 600; color: var(--primary-dark); background: var(--neutral-medium); padding: 5px 12px; border-radius: 20px;
}
.time-running-low { color: var(--danger-color) !important; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
.progress-bar {
    height: 6px; background-color: var(--neutral-medium); border-radius: 3px; overflow: hidden; margin-bottom: 25px;
}
.progress-fill {
    height: 100%; background: linear-gradient(to right, var(--primary-color), var(--primary-light)); transition: width 1s linear; width: 100%;
}
.question {
    background-color: white; border-radius: var(--border-radius); padding: 25px; margin-bottom: 25px; box-shadow: var(--shadow-sm); border: 1px solid var(--neutral-medium); transition: all 0.3s ease;
}
.question:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.question-header { display: flex; margin-bottom: 15px; gap: 10px; }
.question-number {
    background-color: var(--primary-color); color: white; min-width: 30px; height: 30px; display: flex; justify-content: center; align-items: center; border-radius: 50%; font-weight: bold; flex-shrink: 0;
}
.question-text { font-weight: 500; font-size: 1.05rem; text-align: justify; }
.options { display: flex; flex-direction: column; gap: 12px; margin-top: 15px; }
.option-container { position: relative; }
.option-container input[type="radio"] { opacity: 0; position: absolute; top: 0; left: 0; }
.option-container label {
    display: flex; align-items: center; padding: 12px 15px; background-color: var(--neutral-light); border-radius: 8px; cursor: pointer; transition: all 0.2s ease; border: 2px solid transparent;
    font-size: 0.95rem;
}
.option-container label:before {
    content: ""; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--neutral-dark); margin-right: 10px; transition: all 0.2s ease; flex-shrink: 0;
}
.option-container input[type="radio"]:checked + label {
    background-color: rgba(67, 97, 238, 0.1); border-color: var(--primary-color);
}
.option-container input[type="radio"]:checked + label:before {
    border-color: var(--primary-color); background-color: var(--primary-color); box-shadow: inset 0 0 0 4px white;
}
.option-container:hover label { background-color: rgba(67, 97, 238, 0.05); }
.submit-button {
    background: linear-gradient(to right, var(--primary-color), var(--primary-light)); color: white; border: none; padding: 14px 25px; border-radius: 30px; font-size: 1rem; font-weight: 600; cursor: pointer; display: block; width: 100%;
    max-width: 300px; margin: 30px auto 10px; transition: all 0.3s ease; box-shadow: var(--shadow-sm);
}
.submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.submit-button:hover:not(:disabled) {
    transform: translateY(-2px); box-shadow: var(--shadow-md); background: linear-gradient(to right, var(--primary-dark), var(--primary-color));
}
.results-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.results-overlay.active { opacity: 1; pointer-events: auto; }
.results-card { background: white; border-radius: 20px; padding: 30px; max-width: 500px; width: 90%; text-align: center; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); animation: slideIn 0.5s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-50px); } to { opacity: 1; transform: translateY(0); } }
.user-info-display { background: #f8f9fa; padding: 15px; border-radius: 10px; margin-bottom: 20px; text-align: left; }
.user-info-display p { margin: 8px 0; font-size: 16px; color: #555; }
.user-info-display strong { color: #333; }
.score-display { font-size: 72px; font-weight: bold; color: #4CAF50; margin: 20px 0 10px 0; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); }
.score-label { font-size: 18px; color: #666; margin-bottom: 20px; }
.star-rating { margin-top: 15px; margin-bottom: 20px; font-size: 40px; }
.star-rating .star { color: #ddd; transition: color 0.3s; }
.star-rating .star.active { color: #ffd700; }
.achievement-text { font-size: 18px; font-weight: bold; color: #667eea; margin: 20px 0; padding: 10px; background: #f0f2ff; border-radius: 10px; min-height: 25px; }
.score-details { display: flex; justify-content: space-around; margin: 30px 0; background: #f8f9fa; padding: 20px; border-radius: 15px; }
.score-item { text-align: center; }
.score-item-value { font-size: 36px; font-weight: bold; margin-bottom: 5px; }
.correct-answers { color: #4CAF50; }
.wrong-answers { color: #f44336; }
.score-item div:last-child { font-size: 14px; color: #666; }
.results-buttons { display: flex; flex-direction: column; align-items: center; gap: 15px; margin-top: 30px; }
.results-button { padding: 15px 25px; border: none; border-radius: 10px; font-size: 16px; font-weight: bold; cursor: pointer; transition: all 0.3s; text-decoration: none; display: block; text-align: center; width: 100%; max-width: 250px; }
.results-button:disabled { background: linear-gradient(to right, #BDBDBD, #9E9E9E); color: #757575; cursor: not-allowed; box-shadow: none; transform: none; }
.view-solutions-button { background: #2196F3; color: white; }
.view-solutions-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); background: #1976D2; }
.retry-button { background: #FF9800; color: white; }
.retry-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); background: #F57C00; }
.chat-teacher-button { background-color: #673AB7; color: white; }
.chat-teacher-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); background-color: #512DA8; }
.solution-card { margin-bottom: 30px; text-align: left; }
.solution-content { background-color: var(--neutral-light); padding: 15px; border-radius: 10px; margin-top: 15px; }
.user-answer { padding: 10px; border-radius: 8px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.user-answer.correct { background-color: rgba(56, 176, 0, 0.1); color: var(--success-color); }
.user-answer.incorrect { background-color: rgba(217, 4, 41, 0.1); color: var(--danger-color); }
.correct-answer-text { color: var(--success-color); font-weight: 500; margin-bottom: 15px; }
.check-icon, .wrong-icon { width: 20px; height: 20px; vertical-align: middle; margin-left: 10px; flex-shrink: 0; }
.check-icon { fill: var(--success-color); }
.wrong-icon { fill: var(--danger-color); }
.section-title { text-align: center; margin-bottom: 25px; position: relative; color: var(--primary-dark); font-weight: 700; padding-bottom: 15px; }
.section-title:after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 80px; height: 4px; background: var(--primary-color); border-radius: 2px; }
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; z-index: 1001; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.loading-overlay.active { opacity: 1; pointer-events: auto; }
.loading-spinner { border: 8px solid #f3f3f3; border-top: 8px solid var(--primary-color); border-radius: 50%; width: 60px; height: 60px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.message-box { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 25px 35px; border-radius: 15px; box-shadow: var(--shadow-lg); z-index: 1002; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease; max-width: 80%; }
.message-box.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.message-box h3 { margin-bottom: 15px; color: var(--primary-dark); }
.message-box p { margin-bottom: 20px; color: #555; }
.message-box button { background-color: var(--primary-color); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 1rem; transition: background-color 0.2s; }
.message-box button:hover { background-color: var(--primary-dark); }
.message-box.success h3 { color: var(--success-color); }
.message-box.error h3 { color: var(--danger-color); }
@media (max-width: 600px) { body { padding: 0; } .results-card { padding: 15px; margin: 10px; } .score-display { font-size: 50px; margin: 15px 0 8px 0; } .score-label { font-size: 16px; margin-bottom: 15px; } .star-rating { font-size: 35px; margin-top: 10px; margin-bottom: 15px; } .achievement-text { font-size: 16px; margin: 15px 0; padding: 8px; } .score-details { flex-direction: row; justify-content: space-around; gap: 5px; margin: 20px 0; padding: 10px; } .score-item { flex: 1; min-width: 0; } .score-item-value { font-size: 28px; } .score-item div:last-child { font-size: 12px; } .results-buttons { flex-direction: column; gap: 10px; margin-top: 20px; } .results-button { padding: 12px 20px; font-size: 15px; } .question { padding: 10px; } .question-text { font-size: 1rem; } .options label { padding: 8px 10px; font-size: 0.9rem; } .quiz-container { width: 100%; max-width: 100%; padding: 0 5px; } }