/* CSS Reset and Normalize for Cross-Browser Compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure consistent font rendering across browsers */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-synthesis: none;
}

body {
    /* Professional rounded font stack for educational software */
    font-family: 'Nunito', 'Quicksand', 'Trebuchet MS', 'Arial Rounded MT Bold', 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    font-size: 16px;
    /* Prevent horizontal scroll on mobile */
    overflow-x: hidden;
    /* Better text rendering */
    text-rendering: optimizeLegibility;
    -webkit-font-feature-settings: 'kern' 1;
    font-feature-settings: 'kern' 1;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.header-buttons {
    margin-top: 15px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    gap: 15px;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    
    /* Fallback for browsers that don't support gap */
    margin: -7.5px;
}

.header-buttons > * {
    margin: 7.5px;
}

/* Explanation Section */
.explanation-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.explanation-section h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a5568;
    font-size: 1.8rem;
}

.explanation-content {
    /* Fallback for older browsers */
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 25px;
    
    /* Modern CSS Grid with fallback */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    
    /* Fallback for browsers that don't support gap */
    margin: -12.5px;
}

.explanation-content > * {
    margin: 12.5px;
    -webkit-box-flex: 1;
    -ms-flex: 1 1 300px;
    flex: 1 1 300px;
    min-width: 300px;
}

.explanation-item {
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.explanation-item:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.explanation-item:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
}

.explanation-item h3 {
    color: #2d3748;
    font-size: 1.3rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.explanation-item p {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 15px;
}

.explanation-item ul {
    color: #4a5568;
    padding-left: 20px;
    line-height: 1.6;
}

.explanation-item li {
    margin-bottom: 8px;
}

.explanation-item strong {
    color: #2d3748;
    font-weight: bold;
}

/* Explanation section visibility is controlled by JavaScript */

/* Configuration Panel */
.config-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.config-panel h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a5568;
    font-size: 1.8rem;
}

.config-row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 10px;
    
    /* Better mobile handling */
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 10px;
}

.config-row label {
    font-weight: bold;
    color: #2d3748;
    font-size: 1.1rem;
}

.config-row input {
    width: 100px;
    min-width: 80px;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
    -webkit-transition: border-color 0.3s ease, box-shadow 0.3s ease;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    /* Better mobile input handling */
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    font-family: inherit;
    line-height: 1.4;
}

.config-row input:focus {
    outline: none;
    border-color: #667eea;
    -webkit-box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Remove number input spinners for better cross-browser consistency */
.config-row input[type="number"]::-webkit-outer-spin-button,
.config-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.config-row input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.config-section {
    margin: 20px 0;
    padding: 20px;
    background: #f8fafc;
    border-radius: 15px;
    border: 2px solid #e2e8f0;
}

.config-section h3 {
    margin-bottom: 15px;
    color: #2d3748;
    font-size: 1.3rem;
    text-align: center;
}

.operations-grid {
    /* Fallback for older browsers */
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: -7.5px;
    margin-top: 15px;
    
    /* Modern CSS Grid with fallback */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.operations-grid > * {
    margin: 7.5px;
    -webkit-box-flex: 1;
    -ms-flex: 1 1 200px;
    flex: 1 1 200px;
    min-width: 200px;
}

.operation-option {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.operation-option:hover {
    border-color: #667eea;
    background: #f7fafc;
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.operation-option:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
}

.operation-option input[type="checkbox"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    accent-color: #667eea;
    cursor: pointer;
}

.operation-option input[type="checkbox"]:checked + .operation-label {
    color: #667eea;
    font-weight: bold;
}

.operation-option:has(input[type="checkbox"]:checked) {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff, #e6f3ff);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}

.operation-label {
    font-size: 1.1rem;
    color: #4a5568;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* Game Panel */
.game-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.game-header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    margin-bottom: 30px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    /* Fallback for older browsers */
    background: #667eea;
    border-radius: 15px;
    color: white;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 15px;
    
    /* Fallback for browsers that don't support gap */
    margin: -7.5px;
}

.game-header > * {
    margin: 7.5px;
}

.score, .progress, .operations {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    flex: 1;
    min-width: 150px;
}

.operations {
    font-size: 1.1rem;
    color: white;
}

#operations-display {
    font-size: 1.3rem;
    margin-left: 5px;
    color: inherit;
}

.question-container {
    text-align: center;
    margin-bottom: 30px;
}

.question {
    font-size: 3rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 15px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.answer-container {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 15px;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    
    /* Fallback for browsers that don't support gap */
    margin: -7.5px;
}

.answer-container > * {
    margin: 7.5px;
}

#user-answer {
    width: 200px;
    min-width: 150px;
    padding: 15px 20px;
    border: 3px solid #e2e8f0;
    border-radius: 15px;
    font-size: 1.5rem;
    text-align: center;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    /* Better mobile input handling */
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    font-family: inherit;
    line-height: 1.4;
    /* Prevent zoom on iOS */
    font-size: 16px;
}

/* Remove number input spinners */
#user-answer::-webkit-outer-spin-button,
#user-answer::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#user-answer {
    -moz-appearance: textfield;
    appearance: textfield;
}

#user-answer:focus {
    outline: none;
    border-color: #667eea;
    -webkit-box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    -webkit-transform: scale(1.05);
    -ms-transform: scale(1.05);
    transform: scale(1.05);
}

/* Buttons */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    font-family: inherit;
    /* Better touch targets on mobile */
    min-height: 44px;
    min-width: 44px;
    /* Prevent text selection on buttons */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Better button rendering */
    -webkit-appearance: none;
    appearance: none;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-primary:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.btn-submit {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
}

.btn-submit:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 6px 20px rgba(79, 172, 254, 0.6);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.6);
}

.btn-submit:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 10px rgba(79, 172, 254, 0.4);
    box-shadow: 0 2px 10px rgba(79, 172, 254, 0.4);
}

.btn-submit:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-submit:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-next {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: white;
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.4);
}

.btn-next:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 6px 20px rgba(67, 233, 123, 0.6);
    box-shadow: 0 6px 20px rgba(67, 233, 123, 0.6);
}

.btn-next:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 10px rgba(67, 233, 123, 0.4);
    box-shadow: 0 2px 10px rgba(67, 233, 123, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #fa709a, #fee140);
    color: white;
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.4);
}

.btn-secondary:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 6px 20px rgba(250, 112, 154, 0.6);
    box-shadow: 0 6px 20px rgba(250, 112, 154, 0.6);
}

.btn-secondary:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 10px rgba(250, 112, 154, 0.4);
    box-shadow: 0 2px 10px rgba(250, 112, 154, 0.4);
}

.btn-test {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    border: 2px solid #5a67d8;
}

.btn-test:hover {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-test:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

/* Feedback */
.feedback {
    text-align: center;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
    animation: slideIn 0.5s ease;
}

.feedback.correct {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: white;
}

.feedback.incorrect {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.feedback-content {
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: bold;
}

.answer-comparison {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.answer-box {
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 120px;
}

.user-answer-box {
    background: #ff6b6b;
    color: white;
    border: 2px solid #e53e3e;
}

.correct-answer-box {
    background: #43e97b;
    color: white;
    border: 2px solid #38a169;
}

.correct-answer-input {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

#correct-answer-input {
    width: 200px;
    padding: 12px 16px;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1.2rem;
    text-align: center;
    transition: all 0.3s ease;
}

#correct-answer-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.btn-verify {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    padding: 12px 20px;
    font-size: 1rem;
}

.btn-verify:hover:not(:disabled) {
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-verify:active:not(:disabled) {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -webkit-box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.btn-verify:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-verify.btn-success {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: white;
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.4);
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { 
        -webkit-transform: scale(1);
        -ms-transform: scale(1);
        transform: scale(1); 
    }
    50% { 
        -webkit-transform: scale(1.05);
        -ms-transform: scale(1.05);
        transform: scale(1.05); 
    }
    100% { 
        -webkit-transform: scale(1);
        -ms-transform: scale(1);
        transform: scale(1); 
    }
}

/* Results Panel */
.results-panel {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
}

/* History Panel */
.history-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.history-panel h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a5568;
    font-size: 1.8rem;
}

.history-content {
    margin-bottom: 30px;
}

.no-history {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 40px;
}

.day-summary {
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 5px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.day-summary:hover {
    background: #edf2f7;
    -webkit-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    transform: translateY(-2px);
    -webkit-box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.day-summary:active {
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
}

.day-summary.passed {
    border-left-color: #43e97b;
    background: linear-gradient(135deg, #f0fff4, #e6fffa);
}

.day-summary.failed {
    border-left-color: #ff6b6b;
    background: linear-gradient(135deg, #fff5f5, #ffeaa7);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.day-date {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2d3748;
}

.day-status {
    font-size: 1.1rem;
    font-weight: bold;
    padding: 5px 15px;
    border-radius: 20px;
}

.day-status.passed {
    background: #43e97b;
    color: white;
}

.day-status.failed {
    background: #ff6b6b;
    color: white;
}

.day-stats {
    color: #718096;
    font-size: 1rem;
}

.test-runs {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.test-run {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.test-run:hover {
    border-color: #667eea;
    -webkit-box-shadow: 0 2px 10px rgba(102, 126, 234, 0.1);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.1);
}

.test-run:active {
    -webkit-transform: translateY(1px);
    -ms-transform: translateY(1px);
    transform: translateY(1px);
}

.test-run-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.test-time {
    font-weight: bold;
    color: #4a5568;
}

.test-score {
    font-size: 1.1rem;
    font-weight: bold;
}

.test-score.passed {
    color: #43e97b;
}

.test-score.failed {
    color: #ff6b6b;
}

.test-summary {
    color: #718096;
    font-size: 0.9rem;
}

/* Test Detail Panel */
.test-detail-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

/* Test Results Panel */
.test-results-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
    text-align: center;
}

.test-results-panel h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a5568;
    font-size: 1.8rem;
}

.test-summary {
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
}

.test-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
}

.test-details {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    background: #f8fafc;
}

.test-result-item {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    border-left: 4px solid #e2e8f0;
}

.test-result-item.passed {
    background: #f0fff4;
    border-left-color: #43e97b;
}

.test-result-item.failed {
    background: #fff5f5;
    border-left-color: #ff6b6b;
}

.test-result-message {
    font-weight: 500;
    margin-bottom: 4px;
}

.test-result-timestamp {
    font-size: 0.8rem;
    color: #718096;
}

.test-detail-panel h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a5568;
    font-size: 1.8rem;
}

.test-detail-content {
    margin-bottom: 30px;
}

.test-overview {
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.test-overview h3 {
    margin-bottom: 15px;
    color: #2d3748;
}

.test-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4a5568;
}

.stat-label {
    font-size: 0.9rem;
    color: #718096;
    margin-top: 5px;
}

.failed-questions {
    margin-top: 25px;
}

.failed-questions h3 {
    margin-bottom: 15px;
    color: #2d3748;
}

.question-item {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 8px;
}

.question-answers {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.answer-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
}

.user-answer {
    background: #fed7d7;
    color: #c53030;
}

.correct-answer {
    background: #c6f6d5;
    color: #2f855a;
}

.second-chance-message {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.second-chance-message p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    text-align: center;
}

.results-panel h2 {
    font-size: 3rem;
    margin-bottom: 20px;
}

.results-panel.pass h2 {
    color: #43e97b;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.results-panel.fail h2 {
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.results-stats {
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: #4a5568;
}

.results-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Error Display */
.config-error {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-top: 15px;
    text-align: center;
    font-weight: bold;
    animation: slideIn 0.3s ease;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        -webkit-transform: translateY(20px);
        -ms-transform: translateY(20px);
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        -ms-transform: translateY(0);
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        -webkit-transform: translateY(0);
        -ms-transform: translateY(0);
        transform: translateY(0);
    }
    40% {
        -webkit-transform: translateY(-10px);
        -ms-transform: translateY(-10px);
        transform: translateY(-10px);
    }
    60% {
        -webkit-transform: translateY(-5px);
        -ms-transform: translateY(-5px);
        transform: translateY(-5px);
    }
}

.bounce {
    animation: bounce 1s;
}

/* Enhanced Responsive Design */
/* Small screen optimizations */
@media (max-width: 768px) {
    /* Ensure question is visible and properly positioned */
    .question-container {
        margin-bottom: 20px;
        padding: 15px;
        /* Ensure container stays visible when keyboard appears */
        position: relative;
        z-index: 10;
    }
    
    .question {
        font-size: 2.2rem;
        padding: 15px;
        margin-bottom: 20px;
        /* Ensure question stays visible when keyboard appears */
        position: relative;
        z-index: 5;
        /* Prevent question from being hidden behind keyboard */
        min-height: 80px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .answer-container {
        /* Keep input accessible but not covering question */
        margin-top: 15px;
        padding: 10px;
        /* Ensure container stays visible */
        position: relative;
        z-index: 10;
    }
    
    #user-answer {
        font-size: 18px;
        padding: 15px 18px;
        width: 100%;
        max-width: 300px;
        /* Ensure input is always accessible */
        position: relative;
        z-index: 15;
    }
    
    /* Ensure submit button is always visible */
    #submit-answer {
        position: relative;
        z-index: 15;
        /* Make button more prominent on mobile */
        min-height: 50px;
        font-size: 1.2rem;
    }
}

/* Mobile First Approach */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.8rem;
        line-height: 1.2;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .question {
        font-size: 1.8rem;
        padding: 15px;
        /* Ensure question is always visible on very small screens */
        min-height: 70px;
        font-size: 1.6rem;
    }
    
    .answer-container {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        /* Ensure proper spacing on very small screens */
        gap: 15px;
    }
    
    #user-answer {
        width: 100%;
        max-width: 280px;
        font-size: 1.2rem;
        padding: 12px 16px;
        /* Ensure input is prominent on very small screens */
        min-height: 50px;
    }
    
    /* Make submit button more prominent on very small screens */
    #submit-answer {
        min-height: 55px;
        font-size: 1.3rem;
        width: 100%;
        max-width: 280px;
    }
    
    .config-row {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        -webkit-box-align: stretch;
        -ms-flex-align: stretch;
        align-items: stretch;
        text-align: center;
    }
    
    .config-row input {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    
    .results-buttons {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
        margin: 5px 0;
    }
    
    .explanation-content {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .explanation-item {
        min-width: auto;
        width: 100%;
    }
    
    .operations-grid {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .operation-option {
        min-width: auto;
        width: 100%;
    }
    
    .game-header {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        text-align: center;
    }
    
    .score, .progress, .operations {
        min-width: auto;
        width: 100%;
        margin: 5px 0;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .question {
        font-size: 2.2rem;
    }
    
    .answer-container {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    #user-answer {
        width: 100%;
        max-width: 300px;
    }
    
    .config-row {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        gap: 10px;
    }
    
    .config-row input {
        width: 100%;
        max-width: 150px;
    }
    
    .results-buttons {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 20px;
    }
    
    .explanation-content {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .operations-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (min-width: 1025px) {
    .container {
        max-width: 900px;
    }
    
    .explanation-content {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
}

/* High DPI / Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .question {
        text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    }
    
    header h1 {
        text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .btn, .header-buttons {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .question {
        background: white !important;
        color: black !important;
        border: 2px solid black;
    }
}
