body {
    min-height: 100vh;
    margin: 0;
    font-family: Arial, sans-serif;
    color: #17324d;
    background:
        radial-gradient(circle at 12% 16%, rgba(255, 214, 102, 0.26), transparent 25%),
        radial-gradient(circle at 88% 10%, rgba(80, 200, 180, 0.2), transparent 25%),
        linear-gradient(135deg, #f8fbff 0%, #eef6f0 48%, #fff7e8 100%);
}

.arithmetic-app {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 14px;
}

h1 {
    margin: 0;
    text-align: center;
    font-size: clamp(28px, 5vw, 50px);
    color: #17324d;
}

.page-heading {
    margin: 0 0 18px;
    text-align: center;
}

.page-heading .framed-heading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 68px;
    margin: 0;
    padding: 10px 24px;
    border: 1px solid rgba(23, 50, 77, 0.14);
    border-radius: 8px;
    background: #ffffff;
    color: #17324d;
    font-size: clamp(28px, 5vw, 50px);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0;
    box-shadow: 0 12px 26px rgba(31, 41, 55, 0.1);
}

.tab-shell {
    border: 1px solid rgba(23, 50, 77, 0.14);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 16px 34px rgba(31, 41, 55, 0.12);
    overflow: hidden;
}

.practice-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 6px 6px 0;
    border-bottom: 1px solid rgba(23, 50, 77, 0.14);
    background: #ffffff;
}

.tab-button {
    position: relative;
    bottom: -1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    border: 1px solid rgba(23, 50, 77, 0.14);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: none;
    background: #eef3fb;
    color: #334155;
    white-space: normal;
}

.tab-button.is-active {
    background: #ffffff;
    color: #17324d;
    border-bottom-color: #ffffff;
    box-shadow: none;
}

.tab-number {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 15px;
    font-weight: 900;
}

.tab-button.is-active .tab-number {
    background: #0f766e;
}

.tab-panel[hidden] {
    display: none;
}

.tab-panel {
    padding: 18px;
    background: #ffffff;
}

.video-placeholder {
    display: block;
}

.video-frame {
    min-height: 340px;
    display: grid;
    place-items: center;
    border: 1px solid #ffffff;
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(219, 234, 254, 0.92), rgba(204, 251, 241, 0.86)),
        #dbeafe;
    box-shadow: none;
}

.video-frame span {
    color: #17324d;
    font-size: clamp(28px, 5vw, 54px);
    font-weight: 900;
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(31, 41, 55, 0.12);
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 11px 22px rgba(31, 41, 55, 0.16);
}

.back-button {
    background: #dbeafe;
    color: #164e8b;
}

.new-button {
    background: #b8f2c6;
    color: #14532d;
}

.check-button {
    background: #2563eb;
    color: #fff;
}

.ghost-button {
    background: #fff7d6;
    color: #7a4c00;
}

.practice-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 18px;
    align-items: start;
}

.task-area,
.answer-panel,
.method-panel,
.solution-panel,
.tip-panel {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(23, 50, 77, 0.12);
    border-radius: 8px;
    box-shadow: 0 16px 34px rgba(31, 41, 55, 0.12);
}

.task-area {
    padding: 28px;
}

.answer-panel,
.method-panel,
.solution-panel,
.tip-panel {
    padding: 18px;
}

.eyebrow {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
    color: #52616f;
}

.question {
    min-height: 86px;
    display: grid;
    place-items: center;
    margin: 0 0 20px;
    font-size: clamp(38px, 8vw, 78px);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0;
    color: #14213d;
    text-align: center;
}

.answer-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.answer-form-inline {
    grid-template-columns: auto minmax(120px, 220px) auto;
    justify-content: center;
    align-items: center;
}

.inline-question {
    color: #14213d;
    font-size: clamp(30px, 6vw, 58px);
    font-weight: 900;
    line-height: 1.1;
    white-space: nowrap;
}

.answer-form input {
    min-width: 0;
    height: 50px;
    border: 2px solid #bfd1e8;
    border-radius: 8px;
    padding: 8px 14px;
    color: #14213d;
    font-size: 24px;
    font-weight: 800;
    text-align: center;
}

.answer-form-inline input {
    height: 68px;
    font-size: clamp(30px, 6vw, 58px);
    line-height: 1.1;
}

.message {
    min-height: 28px;
    margin-top: 14px;
    font-size: 18px;
    font-weight: 700;
    color: #334155;
}

.message.good {
    color: #15803d;
}

.message.bad {
    color: #b91c1c;
}

.side-stack {
    display: grid;
    gap: 18px;
}

.tip-panel h2,
.method-panel h2,
.solution-panel h2 {
    margin: 0 0 10px;
    font-size: 20px;
    color: #17324d;
}

.tip-panel p {
    margin: 0;
    color: #334155;
    font-size: 17px;
    font-weight: 700;
}

.method-guide {
    display: grid;
    gap: 8px;
}

.method-guide p {
    margin: 0;
    padding: 9px 10px;
    border-left: 5px solid #78c2ad;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 15px;
    font-weight: 700;
}

.method-guide strong {
    color: #0f766e;
}

.method-panel {
    margin-top: 18px;
}

.method-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.method-header h2 {
    margin: 0;
}

.method-grid-wrap {
    overflow-x: auto;
    padding-bottom: 6px;
}

.method-grid {
    display: grid;
    grid-template-columns: 68px repeat(var(--cols), 54px);
    justify-content: center;
    align-items: center;
    gap: 7px;
    width: max-content;
    min-width: 100%;
    font-family: "Courier New", monospace;
}

.method-grid.is-compact {
    grid-template-columns: 52px repeat(var(--cols), 44px);
    column-gap: 5px;
    row-gap: 2px;
}

.method-label {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: #52616f;
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: 800;
    text-align: right;
}

.method-cell,
.method-input {
    width: 54px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
}

.method-cell {
    background: #f8fafc;
    color: #14213d;
}

.method-cell.is-soft {
    background: transparent;
}

.method-cell.is-operator {
    background: #dbeafe;
    color: #164e8b;
}

.method-cell.is-note {
    color: #b91c1c;
    background: #fff1f2;
    font-size: 19px;
}

.method-cell.is-problem {
    background: transparent;
    color: #14213d;
    font-family: Arial, sans-serif;
    font-size: clamp(24px, 4.4vw, 38px);
    letter-spacing: 0;
}

.method-cell.is-division-expression {
    justify-content: flex-start;
    padding-left: 2px;
    text-align: left;
    white-space: nowrap;
}

.method-problem {
    display: grid;
    grid-template-columns: repeat(3, 54px);
    justify-content: center;
    align-items: center;
    gap: 7px;
    color: #14213d;
    font-family: Arial, sans-serif;
    font-size: clamp(28px, 5vw, 44px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-align: center;
}

.method-line {
    display: block;
    width: 100%;
    height: 2px;
    align-self: center;
    background: #14213d;
}

.method-line.is-double {
    height: 7px;
    border-top: 2px solid #14213d;
    border-bottom: 2px solid #14213d;
    background: transparent;
}

.method-grid.is-compact .method-line {
    margin: 2px 0;
}

.method-input {
    border: 2px solid #bfd1e8;
    background: #fff;
    color: #14213d;
    font-family: "Courier New", monospace;
    text-align: center;
    box-shadow: none;
}

.method-input.is-small {
    width: 34px;
    height: 30px;
    justify-self: center;
    align-self: center;
    border-color: #ef4444;
    background: #fff1f2;
    color: #b91c1c;
    font-size: 17px;
    border-radius: 6px;
}

.method-cell.is-small {
    color: #b91c1c;
    background: #fff1f2;
}

.method-input.is-remainder {
    border-color: #60a5fa;
    background: #eff6ff;
    color: #1d4ed8;
}

.method-cell.is-remainder {
    color: #1d4ed8;
    background: #eff6ff;
}

.method-cell.is-struck {
    position: relative;
}

.method-cell.is-struck::before {
    content: "";
    position: absolute;
    left: 16%;
    right: 16%;
    top: 18px;
    height: 2px;
    border-radius: 999px;
    background: #b91c1c;
    transform: rotate(-28deg);
}

.method-field-wrap {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 36px;
}

.method-field-wrap .method-input {
    width: 100%;
    height: 100%;
}

.zero-checkmark {
    pointer-events: none;
    position: absolute;
    right: -8px;
    top: -9px;
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border-radius: 999px;
    background: #16a34a;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: 900;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.method-field-wrap.is-zero-remembered .zero-checkmark {
    opacity: 1;
    transform: scale(1);
}

.method-cell.is-span,
.method-input.is-span {
    width: 100%;
}

.method-grid.is-compact .method-cell,
.method-grid.is-compact .method-input,
.method-grid.is-compact .method-field-wrap {
    width: 44px;
    height: 36px;
    font-size: 23px;
}

.method-grid.is-compact .method-cell.is-problem {
    height: 34px;
}

.method-grid.is-compact .method-input.is-small {
    width: 28px;
    height: 22px;
    justify-self: center;
    align-self: center;
    border-color: #ef4444;
    background: #fff1f2;
    color: #b91c1c;
    font-size: 15px;
    border-radius: 6px;
}

.method-grid.is-compact .method-cell.is-small {
    color: #b91c1c;
    background: #fff1f2;
}

.method-grid.is-compact .method-input.is-remainder {
    border-color: #60a5fa;
    background: #eff6ff;
    color: #1d4ed8;
}

.method-grid.is-compact .method-cell.is-remainder {
    color: #1d4ed8;
    background: #eff6ff;
}

.method-grid.is-compact .method-cell.is-span,
.method-grid.is-compact .method-input.is-span {
    width: 100%;
}

.method-input:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
}

.method-input.is-ok {
    border-color: #22c55e;
    background: #ecfdf5;
}

.method-input.is-wrong {
    border-color: #ef4444;
    background: #fff1f2;
}

.method-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.solution-panel[hidden] {
    display: none;
}

.solution-panel {
    margin-top: 18px;
}

.status-message {
    margin-top: 18px;
    padding: 0 4px;
    text-align: center;
}

.test-card {
    width: min(760px, 100%);
    margin: 0 auto;
}

.effects {
    pointer-events: none;
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 20;
}

.sparkle,
.fog,
.confetti {
    position: absolute;
    border-radius: 999px;
}

.sparkle {
    width: 9px;
    height: 9px;
    background: #ffd166;
    animation: sparkle 780ms ease-out forwards;
}

.fog {
    width: 42px;
    height: 42px;
    background: rgba(110, 120, 130, 0.22);
    filter: blur(4px);
    animation: fog 820ms ease-out forwards;
}

.confetti {
    width: 11px;
    height: 18px;
    animation: confetti 1100ms ease-out forwards;
}

@keyframes sparkle {
    from {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(var(--x), var(--y)) scale(0.2);
    }
}

@keyframes fog {
    from {
        opacity: 0.75;
        transform: translate(-50%, -50%) scale(0.4);
    }
    to {
        opacity: 0;
        transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.5);
    }
}

@keyframes confetti {
    from {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    to {
        opacity: 0;
        transform: translateY(130px) rotate(420deg);
    }
}

@media (max-width: 840px) {
    .topbar {
        margin-bottom: 12px;
    }

    .practice-layout {
        grid-template-columns: 1fr;
    }

    .video-placeholder {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .arithmetic-app {
        width: min(100% - 16px, 1120px);
        padding-top: 16px;
    }

    .task-area {
        padding: 20px 12px;
    }

    .answer-form {
        grid-template-columns: 1fr;
    }

    .answer-form-inline {
        grid-template-columns: 1fr;
    }

    .inline-question {
        text-align: center;
        white-space: normal;
    }

    .practice-tabs {
        grid-template-columns: 1fr;
    }

    .method-grid {
        grid-template-columns: 54px repeat(var(--cols), 46px);
        gap: 5px;
    }

    .method-grid.is-compact {
        grid-template-columns: 48px repeat(var(--cols), 40px);
        row-gap: 2px;
    }

    .method-problem {
        grid-template-columns: repeat(3, 46px);
        gap: 5px;
        font-size: 28px;
    }

    .method-cell,
    .method-input {
        width: 46px;
        height: 38px;
        font-size: 22px;
    }

    .method-grid.is-compact .method-cell,
    .method-grid.is-compact .method-input,
    .method-grid.is-compact .method-field-wrap {
        width: 40px;
        height: 34px;
        font-size: 21px;
    }

    .method-grid.is-compact .method-input.is-small {
        width: 26px;
        height: 21px;
        font-size: 14px;
    }
}
