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

body {
    background: #A69EFF;
    font-family: 'Segoe UI', sans-serif;
    min-height: 100vh;
}

.screen { display: none; width: 100%; min-height: 100vh; padding-left: 14px; padding-right: 14px; }
.screen.visible { display: flex; align-items: center; justify-content: center; }

/* универсальный inner — центрирует и ограничивает ширину */
.inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

#home-screen .inner { padding-top: 50px; gap: 28px; }
#exam-screen .inner { padding-top: 20px; }
#result-screen .inner { padding-top: 50px; gap: 20px; }

/* главный экран */
.title {
    font-family: 'Fredoka One', 'Comic Sans MS', 'Chalkboard SE', cursive, sans-serif;
    font-size: 3rem;
    font-weight: normal;
    color: #1a237e;
}
.home-stats {
    display: flex;
    gap: 24px;
    color: #555;
    font-size: 1.05rem;
    margin-top: 4px;
}
.home-stats b { color: #1a237e; }

/* кнопки общие */
.btn-disabled {
    background: #9e9e9e;
    color: #fff;
    padding: 14px 36px;
    font-size: 1.3rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    opacity: .55;
    pointer-events: none;
}
.btn-primary {
    background: #3f51b5;
    color: #fff;
    padding: 14px 36px;
    font-size: 1.3rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.btn-primary:hover { background: #303f9f; }

/* зелёная кнопка «Ответить» */
.btn-answer {
    background: #3B8241;
    color: #fff;
    width: 150px;
    height: 48px;
    font-size: 1.2rem;
    font-weight: bold;
    border: 4px solid #964609;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.btn-answer:hover { background: #2E6B35; }

/* шапка экзамена — УМНОЖАЛКА + статус-бар+звёзды в строку */
.exam-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
}
.title-text {
    font-family: 'Fredoka One', 'Comic Sans MS', 'Chalkboard SE', cursive, sans-serif;
    font-size: 2.6rem;
    font-weight: bold;
    color: #B75731;
    line-height: 1.2;
    margin-bottom: 8px;
}
.star-display {
    display: block;
    font-size: 2rem;
    white-space: nowrap;
    margin-bottom: 8px;
}
.progress-row {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
}
.progress-bar-wrap {
    flex: 1;
    height: 24px;
    background: #fff;
    border: 3px solid #E2BF22;
    border-radius: 12px;
    overflow: hidden;
}
#progress-bar {
    height: 100%;
    background: #3B8241;
    transition: width .3s;
}
.star-display { font-size: 2rem; white-space: nowrap; }

.counter { color: #555; margin-bottom: 20px; }

/* строка с примером + полем ввода */
#question-row {
    position: relative;
    margin-bottom: 28px;
    width: 100%;
    min-height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#expr-box { display: flex; align-items: center; }

.dcell {
    font-family: 'Arial Black', Arial, sans-serif;
    font-size: 3rem;
    font-weight: 900;
    color: #1a237e;
    background: #FFEACE;
    border: 4px solid #1a237e;
    border-radius: 12px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sym { font-family: Arial, sans-serif; font-size: 3rem; font-weight: bold; color: #1a237e; margin: 0 8px; }
.sym.eq { margin-left: 4px; margin-right: 12px; }

.answer-cell {
    font-family: 'Arial Black', Arial, sans-serif;
    font-size: 3rem;
    font-weight: 900;
    text-align: center;
    background: #ffffff;
    border: 4px solid #1a237e;
    border-radius: 12px;
    color: #1a237e;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

#fb-box {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: 900;
}

/* цифровая клавиатура */
#numpad { margin-bottom: 28px; width: 100%; max-width: 420px; }
.nrow { display: flex; gap: 10px; justify-content: center; margin-bottom: 8px; }
.nbtn, .bbtn {
    flex: 1 1 0;
    min-width: 0;
    max-width: 64px;
    height: 56px;
    font-size: 1.6rem; font-weight: bold;
    border: 3px solid #1a237e;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,.2);
}
.nbtn { color: #1a237e; background: #FFC9B2; }
.nbtn:hover { background: #ffb394; transform: translateY(-2px); }
.nbtn:active { transform: translateY(1px); }
.bbtn {
    color: #964609;
    background: #DEE2E6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.bbtn .bbtn-arrow {
    font-size: 2.6rem;
    font-weight: 900;
    line-height: 0.7;
    transform: translateY(-4px);
    text-shadow: 0 1px 0 currentColor, 0 -1px 0 currentColor;
}
.bbtn:hover { background: #CED4DA; transform: translateY(-2px); }
.bbtn:active { transform: translateY(1px); }

.home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 30px;
    margin-top: 24px;
    color: #3f51b5;
    background: #ffffff;
    border: 3px solid #3f51b5;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 3px 6px rgba(0,0,0,.15);
    transition: background .15s, transform .1s;
}
.home-link:hover { background: #eef1ff; transform: translateY(-2px); }
.home-link:active { transform: translateY(1px); }
.home-link.big { margin-top: 12px; }

/* результат */
#result-screen h1 { font-size: 2.2rem; color: #1a237e; }
#result-score { font-size: 1.4rem; }
#result-message { font-size: 1.2rem; }
.result-details {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.7;
    text-align: center;
}

.answer-correct { color: #3B8241; }
.answer-wrong { color: #dc3545; }
.wrong-answer-num { color: #7D7B7F !important; font-size: 1.2rem !important; }

/* --- небольшие экраны (смартфоны): компактнее ячейки и кнопки --- */
@media (max-width: 480px) {
    .dcell, .answer-cell {
        width: 60px;
        height: 60px;
        font-size: 2.2rem;
    }
    .sym { font-size: 2.2rem; margin: 0 5px; }
    .nbtn, .bbtn {
        height: 48px;
        font-size: 1.3rem;
        border-width: 2px;
    }
    .home-stats {
        gap: 12px;
        font-size: 0.9rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    .title { font-size: 2.3rem; }
    .title-text { font-size: 2rem; }
    .btn-primary, .btn-answer { font-size: 1.15rem; }
    #numpad { max-width: 360px; }
}
