body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    background-color: #f0f8ff; /* Soft AliceBlue background */
    color: #333;
}

.long-division-container {
    display: grid;
    grid-template-columns: 45px 25px 45px 45px 45px; 
    grid-template-rows: repeat(8, 40px);    
    font-family: monospace;
    font-size: 24px;
    margin-bottom: 20px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 5px;
}

.grid-item { 
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    position: relative;
    border: 1px solid #f0f0f0; /* Lighter grid lines */
}

.grid-item.division-bracket-cell,
.grid-item.dividend-roof,
.grid-item.subtraction-sign {
    border: none;
}
.grid-item.dividend-roof {
    border-top: 2px solid black;
}


.input-style {
    font-family: monospace;
    font-size: 20px;
    text-align: center;
    border: 1px solid #a0a0a0;
    width: 100%;
    height: 100%; 
    box-sizing: border-box;
    background-color: #f9f9f9;
    cursor: pointer;
    padding: 0 5px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.input-style:focus {
    outline: 2px solid #1890ff; 
    background-color: #e6f7ff;
    border-color: #1890ff;
}

.input-style:disabled { 
    background-color: transparent; 
    color: #333; 
    border: 1px solid #f0f0f0; /* Match lighter grid border */
    cursor: default;
    opacity: 1; 
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none; 
}

/* --- NEW KID-FRIENDLY HIGHLIGHT --- */
.highlight-active {
    background-color: #fffbe6 !important; /* Soft yellow */
    border-color: #ffe58f !important;  /* Golden yellow border */
    border-style: solid !important; 
    border-width: 1px !important;
    box-shadow: 0 0 8px rgba(255, 229, 143, 0.7);
}

select.input-style:disabled.highlight-active {
     border: 1px solid #ffe58f !important;
}

.subtraction-sign {
    visibility: hidden; 
    justify-content: flex-end; 
    padding-right: 3px;
}

.animate-bring-down {
    animation: bringDownAnimation 2s ease-out forwards;
    opacity: 0; 
}

@keyframes bringDownAnimation {
    0% { opacity: 0; transform: translateY(-150%); }
    25% { opacity: 0.01; transform: translateY(0%); }
    50% { opacity: 0.5; transform: translateY(0%); }
    100% { opacity: 1; transform: translateY(0%); }
}

/* --- NEW BUTTON STYLES --- */
.controls button {
    padding: 10px 18px;
    font-size: 16px;
    font-weight: bold;
    margin: 0 5px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #1890ff; /* Friendly blue */
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: background-color 0.2s, transform 0.2s;
}
.controls button:hover {
    background-color: #40a9ff;
    transform: translateY(-2px);
}
.controls button:disabled {
    background-color: #b0b0b0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- NEW PROMPT & TTS BUTTON STYLES --- */
.explanation-prompts { 
    margin-top: 15px; 
    text-align: center; 
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    max-width: 550px;
}

#promptText { 
    margin: 0 10px 10px 0;
    min-height: 2em; 
    font-style: italic; 
    font-size: 1.1em;
    color: #0056b3;
    flex-grow: 1;
    text-align: right;
}

#speakBtn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 10px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
#speakBtn:hover {
    transform: scale(1.2);
}

#userExplanationArea { 
    display: none; /* --- HIDES THE TEXT AREA --- */
}

/* Grid Area Definitions */
#q1_val { grid-area: 1 / 3; } #q2_val { grid-area: 1 / 4; } #q3_val { grid-area: 1 / 5; }
#divisorInput { grid-area: 2 / 1; } 
.division-bracket-cell { grid-area: 2 / 2; font-size: 32px; padding-bottom: 5px; }
.dividend-roof { grid-area: 2 / 3 / span 1 / span 3; align-self: start; }
#d1_val { grid-area: 2 / 3; } #d2_val { grid-area: 2 / 4; } #d3_val { grid-area: 2 / 5; }
#subSign1 { grid-area: 3 / 2; } #m1_val { grid-area: 3 / 3; }
#line1 { grid-area: 3 / 3; align-self: end; width: 100%; border-bottom: 1px solid black; visibility: hidden;}
#s1_res_val { grid-area: 4 / 3; } #d2_brought_val { grid-area: 4 / 4; }
#subSign2 { grid-area: 5 / 2; }
#m2_val_tens { grid-area: 5 / 3; } #m2_val_ones { grid-area: 5 / 4; }
#line2 { grid-area: 5 / 3 / auto / 5; align-self: end; width: 100%; border-bottom: 1px solid black; visibility: hidden;}
#s2_res_val { grid-area: 6 / 4; } #d3_brought_val { grid-area: 6 / 5; }
#subSign3 { grid-area: 7 / 3; } 
#m3_val_tens { grid-area: 7 / 4; } #m3_val_ones { grid-area: 7 / 5; }
#line3 { grid-area: 7 / 4 / auto / 6; align-self: end; width: 100%; border-bottom: 1px solid black; visibility: hidden;}
#s3_res_val { grid-area: 8 / 5; }


/* --- NEW CREDITS STYLES --- */
.credits {
    margin-top: 30px;
    text-align: center;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.credits p {
    margin: 5px 0;
}

.credits a {
    color: #1890ff;
    text-decoration: none;
}

.credits a:hover {
    text-decoration: underline;
}