:root {
    --primary-bg: #1a237e; /* Deep blue */
    --secondary-bg: #283593; /* Lighter blue */
    --text-color: #ffffff;
    --accent-color: #ffc107; /* Amber */
    --correct-color: #4caf50; /* Green */
    --incorrect-color: #f44336; /* Red */
    --font-family: 'Cairo', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--primary-bg);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 1rem;
}

.screen {
    display: none;
    width: 95%;
    max-width: 800px;
    padding: 0.8rem;
    background-color: var(--secondary-bg);
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.screen.active {
    display: block;
}

#start-screen.active {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.start-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.start-footer {
    border-top: 2px solid var(--accent-color);
    padding-top: 1.5rem;
    margin-top: 2rem;
}

.start-footer p {
    font-size: 1rem;
    margin-bottom: 0.3rem;
    color: rgba(255, 255, 255, 0.8);
}

h1, h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    font-weight: 900;
}

#start-screen h2 {
    margin-top: 1rem;
    font-size: 1.8rem;
}

p {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#level-selection {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.level-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-family: var(--font-family);
    font-weight: 700;
    color: var(--primary-bg);
    background-color: var(--accent-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 220px;
    height: 60px;
}

.level-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.4);
}

#admin-btn {
    margin-top: 1rem;
    padding: 0;
    font-size: 1.2rem;
    font-family: var(--font-family);
    font-weight: 700;
    color: var(--text-color);
    background-color: #9c27b0; /* Purple color */
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 160px;
    height: 50px;
}

#admin-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(156, 39, 176, 0.4);
    background-color: #ab47bc;
}

#admin-btn svg {
    width: 24px;
    height: 24px;
}

.star-icon {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

#problem-container {
    padding: 0.5rem 1rem;
    background-color: transparent;
    border-radius: 15px;
    position: relative;
    margin-bottom: 2rem;
}

#problem {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.3rem;
    line-height: 1.1;
    color: #000000;
}

#number-line-container {
    position: relative;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    background-color: #ffffff;
    border-radius: 15px;
    border: 3px solid var(--accent-color);
    height: 180px;
}

#color-palette {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    z-index: 5;
}

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active-color {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 2; /* Bring canvas on top of question and number line */
}

.number-line {
    width: 100%;
    height: 5px;
    background-color: #000000;
    position: relative;
}

.number-line::before, .number-line::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    transform: translateY(-50%);
}
.number-line::before {
    left: -10px;
    border-right: 20px solid #000000;
}
.number-line::after {
    right: -10px;
    border-left: 20px solid #000000;
}

#drawing-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.draw-tool {
    padding: 0.8rem;
    font-size: 1.2rem;
    font-family: var(--font-family);
    font-weight: 700;
    color: var(--text-color);
    background-color: #6c757d; /* Grey for inactive */
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.draw-tool.active {
    background-color: var(--accent-color);
    border-color: var(--secondary-bg);
    color: var(--primary-bg);
}

.draw-tool svg {
    stroke: currentColor;
}

#answer-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

#answer-input {
    width: 60%;
    padding: 0.8rem;
    font-size: 3rem;
    text-align: center;
    border: 3px solid var(--accent-color);
    border-radius: 10px;
    background-color: #fff;
    color: var(--primary-bg);
    font-family: var(--font-family);
    font-weight: 700;
}

#answer-input::placeholder {
    font-size: 1rem;
}

#submit-btn, #mic-btn, #restart-btn, #new-question-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1.2rem;
    font-family: var(--font-family);
    font-weight: 700;
    color: var(--primary-bg);
    background-color: var(--accent-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#mic-btn, #new-question-btn {
    padding: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mic-btn.recording {
    background-color: var(--incorrect-color);
    color: white;
}

#mic-btn svg {
    width: 24px;
    height: 24px;
}

#new-question-btn svg {
    width: 24px;
    height: 24px;
}

#submit-btn:hover, #restart-btn:hover {
    background-color: #ffd54f; /* Lighter amber */
}

#back-to-levels-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#back-to-levels-btn:hover {
    transform: scale(1.1);
}

#feedback {
    margin-top: 1rem;
    font-size: 1.8rem;
    font-weight: 700;
    height: 50px;
}

.feedback-correct {
    color: var(--correct-color);
    animation: pulse 0.5s;
}

.feedback-incorrect {
    color: var(--incorrect-color);
    animation: shake 0.5s;
}

#final-score {
    font-size: 1.5rem;
    margin: 1.5rem 0;
    line-height: 1.6;
}

#game-title {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 0.4rem;
    padding: 0.4rem 0;
    border-bottom: 2px solid var(--accent-color);
    display: block;
    position: relative;
    z-index: 10;
}

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

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

/* Admin Screen Styles */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
    text-align: right;
}

.admin-form fieldset {
    border: 2px solid var(--accent-color);
    border-radius: 10px;
    padding: 1.5rem;
}

.admin-form legend {
    padding: 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-group.checkbox-group {
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-end;
}

.form-group label {
    font-size: 1.2rem;
}

.form-group input[type="number"],
.form-group input[type="text"] {
    padding: 0.8rem;
    font-size: 1.2rem;
    font-family: var(--font-family);
    border-radius: 5px;
    border: 2px solid var(--primary-bg);
    background-color: var(--text-color);
    color: var(--primary-bg);
    direction: ltr;
    text-align: right;
}

.form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.admin-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

@media (max-width: 768px) {
    .screen {
        width: 98%;
        padding: 0.5rem;
    }
    
    #level-selection {
        flex-direction: column;
        align-items: center;
    }
    
    .level-btn {
        width: 100%;
        max-width: 300px;
    }
    
    #problem {
        font-size: 2.5rem;
        letter-spacing: 0.2rem;
    }
    
    #answer-input {
        font-size: 2rem;
        width: 70%;
    }
    
    #header {
        font-size: 0.9rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    #game-title {
        font-size: 1.2rem;
    }
    
    #number-line-container {
        height: 150px;
    }
}

.start-screen{
   padding: 1rem;
}