/* Base styles */
:root {
    --primary: #FF6B6B;     /* Coral pink */
    --secondary: #4ECDC4;   /* Turquoise */
    --accent: #FFE66D;      /* Sunny yellow */
    --background: #F7F9FC;  /* Light grayish blue */
    --text: #2C3E50;        /* Dark blue gray */
    --success: #2ECC71;     /* Emerald green */
    --error: #E74C3C;       /* Soft red */
    --info: #3498DB;        /* Calm blue */
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    background-color: var(--background);
    color: var(--text);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    background-color: #FFF;
    border-radius: 25px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin: 20px auto;
    width: 90%;
    max-width: 800px;
    border: 3px solid var(--primary);
}

/* Typography */
h1, h2 {
    color: var(--primary);
    text-align: center;
    font-size: 2.5em;
    margin: 0 0 10px;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.hint {
    text-align: center;
    color: #7F8C8D;
    margin: 0 0 15px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.backLink {
    color: var(--primary);
    font-size: 1.3em;
    text-decoration: none;
    transition: color 0.3s ease;
}

.backLink:hover {
    color: var(--secondary);
}

#score {
    font-size: 1.3em;
    color: var(--primary);
    font-weight: bold;
    margin: 0;
}

/* Buttons */
button {
    background-color: var(--secondary);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 15px 30px;
    font-size: 1.5em;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    font-weight: bold;
    margin: 0;
}

button:hover,
button:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

#newQuestion {
    background-color: var(--primary);
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0;
}

/* Settings */
.setting-group {
    text-align: center;
    margin: 15px 0;
}

.setting-title {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
}

.settings-error {
    display: none;
    text-align: center;
    color: var(--error);
    font-size: 1.2em;
    font-weight: bold;
}

.checkboxLabel {
    display: inline-block;
    margin: 8px;
    cursor: pointer;
}

.checkboxLabel input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.checkboxLabel span {
    display: inline-block;
    padding: 10px 20px;
    background-color: white;
    border: 3px solid var(--secondary);
    border-radius: 15px;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.checkboxLabel input:checked + span {
    background-color: var(--secondary);
    color: white;
    transform: scale(1.05);
}

.checkboxLabel input:focus-visible + span {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Game panel is revealed by the Start button */
#game {
    display: none;
}

/* Questions and answers */
#question {
    text-align: center;
    font-size: 2em;
    margin: 20px 0;
    word-wrap: break-word;
}

#answerInputs {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px auto;
    width: 100%;
}

input[type="number"], input[type="text"] {
    border: 3px solid var(--secondary);
    border-radius: 15px;
    padding: 15px;
    font-size: 1.2em;
    font-family: inherit;
    background-color: white;
    text-align: center;
    max-width: 100%;
    transition: border-color 0.3s ease;
}

input[type="number"]:focus, input[type="text"]:focus {
    border-color: var(--primary);
    outline: none;
}

/* Hide spinner buttons on number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

/* Feedback messages */
#feedback {
    display: none;
    font-size: 2em;
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    border-radius: 15px;
    animation: bounce 0.5s ease 3;
}

#feedback.correct { color: var(--success); }
#feedback.wrong { color: var(--error); }
#feedback.info { color: var(--info); font-size: 1.4em; animation: none; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Logs */
.logs {
    margin-top: 20px;
}

#logs {
    color: var(--text);
    text-decoration: none;
}

#logsModal {
    display: none;
    margin-top: 10px;
    padding: 15px;
    border: 3px solid var(--primary);
    border-radius: 15px;
    max-height: 300px;
    overflow-y: auto;
}

#logsContent p {
    margin: 5px 0;
}

/* Badges (sort activity) */
.badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 10px;
    color: white;
    font-size: 0.6em;
    vertical-align: middle;
}

.badge-success { background-color: var(--success); }
.badge-danger { background-color: var(--error); }

/* Flash cards (words / Arabic letters) */
.flashcard {
    min-height: 1.4em;
}

#words #question {
    font-size: 4.5em;
}

#question.arabic-letter {
    font-size: 195px;
    line-height: 1.3;
}

/* Clock */
.clock {
    width: 300px;
    height: 300px;
    border: 8px solid var(--primary);
    border-radius: 50%;
    margin: 20px auto;
    position: relative;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    box-sizing: content-box;
}

.clock .number {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 1.8em;
    font-weight: bold;
    line-height: 1;
    color: var(--text);
}

.clock .hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: 50% 100%;
    border-radius: 5px;
}

.clock .hour-hand {
    width: 8px;
    margin-left: -4px;
    height: 28%;
    background-color: var(--text);
}

.clock .minute-hand {
    width: 4px;
    margin-left: -2px;
    height: 40%;
    background-color: var(--primary);
}

/* Center dot */
.clock::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    background-color: var(--text);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.clock-inputs label {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: bold;
}

.clock-inputs input {
    width: 110px;
}

.clock-colon {
    font-size: 2em;
    font-weight: bold;
    align-self: flex-end;
    padding-bottom: 5px;
}

/* Fraction display - shared between questions and inputs */
.fraction-display, .fraction-input {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 1.5em;
}

.fraction-number {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.fraction-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
}

.fraction-display .fraction-part .numerator {
    border-bottom: 3px solid var(--primary);
    width: 100%;
}

.fraction-input {
    gap: 20px;
    background-color: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.fraction-part hr {
    width: 100%;
    margin: 5px 0;
    border: none;
    border-top: 3px solid var(--primary);
}

.fraction-input input[type="number"] {
    width: 90px;
    padding: 8px;
    border: 2px solid var(--secondary);
    border-radius: 8px;
    font-size: 0.8em;
}

/* Name the fraction canvas */
#shapeCanvas {
    max-width: 100%;
    height: auto;
}

/* Long division bracket */
.long-division #question {
    font-size: 4em;
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
}

.long-division .divisor {
    padding: 5px 10px;
}

.long-division .dividend {
    padding: 5px 10px;
    border-top: 4px solid var(--text);
    border-left: 4px solid var(--text);
    border-top-left-radius: 20px;
}

.long-division #answerInputs input {
    width: 170px;
}

/* Home page */
.splash-container {
    max-width: 600px;
    margin: 40px auto;
    padding: 20px;
    text-align: center;
}

.intro-text {
    font-size: 1.5em;
    color: var(--text);
    margin-bottom: 30px;
    text-align: center;
}

.activity-stack {
    max-width: 400px;
    margin: 0 auto;
    padding: 10px;
}

.stack-btn {
    display: block;
    text-decoration: none;
    padding: 15px 30px;
    margin: 15px auto;
    font-size: 1.3em;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    width: 80%;
    text-transform: uppercase;
}

.stack-btn:hover,
.stack-btn:focus-visible {
    transform: translateX(10px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.ar-alpha-btn { background-color: #FF6B6B; text-transform: none; }
.math-btn { background-color: #4ECDC4; }
.fraction-btn { background-color: #FFE66D; color: var(--text); }
.clock-btn { background-color: #5DC9B5; }
.operations-btn { background-color: #7FCFA9; }
.fractions-btn { background-color: #FF8B94; }
.words-btn { background-color: #DCEDC1; color: var(--text); }
.long-division-btn { background-color: #F7A09A; }
.before-after-btn { background-color: #A897F5; }
.sort-btn { background-color: #F5A65B; }

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        width: 100%;
        padding: 15px;
    }

    h1, h2 {
        font-size: 2em;
    }

    button {
        font-size: 1.2em;
        padding: 12px 20px;
    }

    .clock {
        width: 250px;
        height: 250px;
    }

    .fraction-input {
        padding: 15px;
        gap: 15px;
    }

    .fraction-input input[type="number"] {
        width: 70px;
    }

    #question.arabic-letter {
        font-size: 140px;
    }

    #words #question,
    .long-division #question {
        font-size: 3em;
    }

    .splash-container {
        padding: 10px;
    }

    .stack-btn {
        width: 90%;
        font-size: 1.2em;
        padding: 12px 20px;
    }
}
