:root {
    --primary-color: #4285F4;
    --secondary-color: #34A853;
    --accent-color: #FBBC05;
    --danger-color: #EA4335;
    --light-color: #F8F9FA;
    --dark-color: #202124;
}

* {
    box-sizing: border-box;
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: #f0f8ff;
    color: var(--dark-color);
}

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

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

h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--secondary-color);
    font-size: 1.2rem;
}

/* Operator Selection */
.operator-selection {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.operator-btn {
    width: 100px;
    height: 100px;
    border-radius: 15px;
    border: none;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 10px;
}

.operator-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.operator-btn.active {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.operator-btn span {
    font-size: 3rem;
}

.operator-btn p {
    margin: 5px 0 0;
    font-size: 0.9rem;
}

.add-btn {
    background-color: var(--primary-color);
    color: white;
}

.subtract-btn {
    background-color: var(--danger-color);
    color: white;
}

.multiply-btn {
    background-color: var(--secondary-color);
    color: white;
}

.divide-btn {
    background-color: var(--accent-color);
    color: var(--dark-color);
}

/* Variable Controls */
.variable-controls {
    background-color: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.slider-container {
    margin-bottom: 20px;
}

.slider-container label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

.slider-wrapper {
    display: flex;
    align-items: center;
}

.slider {
    flex-grow: 1;
    height: 25px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    outline: none;
    border-radius: 15px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 4px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 4px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider-value {
    width: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-left: 15px;
    padding: 5px;
    border-radius: 10px;
    background-color: var(--light-color);
}

/* Mode Selection */
.mode-selection {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.mode-btn {
    width: 150px;
    height: 60px;
    border-radius: 10px;
    border: none;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin: 10px;
}

.mode-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.mode-btn.active {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.learn-btn {
    background-color: #9C27B0;
    color: white;
}

.practice-btn {
    background-color: #FF9800;
    color: var(--dark-color);
}

.test-btn {
    background-color: #795548;
    color: white;
}

/* Main Display Area */
.main-display {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    min-height: 300px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.equation {
    font-size: 3rem;
    margin-bottom: 20px;
}

.explanation {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #555;
}

.visual-aid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.visual-item {
    width: 30px;
    height: 30px;
    margin: 5px;
    border-radius: 50%;
    background-color: var(--primary-color);
}

/* Practice Mode */
.practice-input {
    font-size: 2rem;
    width: 100px;
    text-align: center;
    padding: 10px;
    border: 3px solid var(--accent-color);
    border-radius: 10px;
    margin: 0 10px;
}

.check-btn {
    padding: 10px 20px;
    font-size: 1.2rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 20px;
}

.feedback {
    font-size: 1.5rem;
    margin-top: 20px;
    font-weight: bold;
}

.correct {
    color: var(--secondary-color);
}

.incorrect {
    color: var(--danger-color);
}

/* Test Mode */
.test-container {
    width: 100%;
}

.test-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.timer {
    font-size: 1.5rem;
    color: var(--danger-color);
    font-weight: bold;
}

.progress {
    font-size: 1.2rem;
}

.question {
    font-size: 2rem;
    margin-bottom: 20px;
}

.options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.option-btn {
    padding: 15px;
    font-size: 1.5rem;
    background-color: var(--light-color);
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.option-btn:hover {
    background-color: #e9ecef;
}

.test-input {
    font-size: 2rem;
    width: 100px;
    text-align: center;
    padding: 10px;
    border: 3px solid var(--accent-color);
    border-radius: 10px;
    margin: 0 10px;
}

.next-btn {
    padding: 10px 20px;
    font-size: 1.2rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 20px;
}

/* Results */
.results {
    text-align: center;
}

.score {
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.retry-btn {
    padding: 10px 20px;
    font-size: 1.2rem;
    background-color: var(--accent-color);
    color: var(--dark-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-right: 10px;
}

.back-btn {
    padding: 10px 20px;
    font-size: 1.2rem;
    background-color: var(--light-color);
    color: var(--dark-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

/* Settings */
.settings-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--dark-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.settings-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 300px;
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: scale(0);
    transform-origin: bottom right;
    transition: transform 0.3s;
    z-index: 1000;
}

.settings-panel.active {
    transform: scale(1);
}

.settings-group {
    margin-bottom: 15px;
}

.settings-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.settings-group select, .settings-group input {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.close-settings {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--danger-color);
}

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

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

.bounce {
    animation: bounce 0.8s;
}

@keyframes pulsate {
    0% {transform: scale(1);}
    50% {transform: scale(1.1);}
    100% {transform: scale(1);}
}

.pulsate {
    animation: pulsate 0.5s infinite;
}

@keyframes shake {
    0%, 100% {transform: translateX(0);}
    10%, 30%, 50%, 70%, 90% {transform: translateX(-5px);}
    20%, 40%, 60%, 80% {transform: translateX(5px);}
}

.shake {
    animation: shake 0.5s;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .operator-btn {
        width: 80px;
        height: 80px;
        font-size: 1.5rem;
    }
    
    .operator-btn span {
        font-size: 2.2rem;
    }
    
    .equation {
        font-size: 2.2rem;
    }
    
    .options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .operator-btn {
        width: 70px;
        height: 70px;
    }
    
    .mode-btn {
        width: 120px;
        height: 50px;
        font-size: 1.1rem;
    }
    
    .equation {
        font-size: 1.8rem;
    }
}


.random-btn {
    padding: 8px 12px;
    background-color: var(--accent-color);
    color: var(--dark-color);
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.2s;
}

.random-btn:hover {
    background-color: #e0a800;
}

.slider-wrapper {
    display: flex;
    align-items: center;
}

/* Ensure the slider value has some space before the random button */
.slider-value {
    margin-right: 10px;
}

.random-btn {
    padding: 8px 12px;
    background-color: var(--accent-color);
    color: var(--dark-color);
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.2s;
}

.random-btn:hover {
    background-color: #e0a800;
}

.slider-wrapper {
    display: flex;
    align-items: center;
}

/* Ensure the slider value has some space before the random button */
.slider-value {
    margin-right: 10px;
}

/* Range display styles */
.range-display {
    margin-top: 10px;
    font-weight: bold;
    color: var(--primary-color);
    padding: 5px;
    border-radius: 5px;
    background-color: #f5f5f5;
    display: inline-block;
    margin-bottom: 10px;
}

/* Range buttons container */
.range-btn-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

/* Range buttons */
.range-btn {
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

#set-min-btn {
    background-color: #9C27B0; /* Purple for min */
}

#set-max-btn {
    background-color: #2196F3; /* Blue for max */
}

.range-btn:hover {
    filter: brightness(110%);
}


/* Question Timer Display */
.question-timer {
    background-color: #673AB7; /* Purple background */
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Make the test header flex to accommodate the new timer */
.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Adjust the test timer and progress to align properly */
.timer, .progress {
    display: inline-block;
}

/* Animation for question timer when time is running low */
@keyframes questionPulsate {
    0% {transform: scale(1); background-color: #673AB7;}
    50% {transform: scale(1.1); background-color: #F44336;} /* Red when pulsating */
    100% {transform: scale(1); background-color: #673AB7;}
}

.question-timer.pulsate {
    animation: questionPulsate 0.5s infinite;
}