/* ==========================================================================
   Super Kid Math Adventure - CSS Design System & Aesthetics
   Target Audience: 7-Year-Old Kids (Grade 1-3)
   ========================================================================== */

:root {
    /* Color Palette - Soft Friendly Pastels */
    --bg-canvas: #FAF6F0;
    --card-bg: #FFFFFF;
    --text-dark: #2C3E50;
    --text-muted: #7F8C8D;

    /* Primary & Accents */
    --primary-blue: #4FC3F7;
    --primary-blue-dark: #0288D1;
    --accent-yellow: #FFF59D;
    --accent-pink: #F8BBD0;
    --accent-purple: #E1BEE7;
    --accent-green: #C8E6C9;

    /* Feedback States */
    --success-green: #81C784;
    --success-bg: #E8F5E9;
    --error-red: #E57373;
    --error-bg: #FFEBEE;

    /* Shadows & Radius */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-pill: 50px;
    --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-active: 0 12px 30px rgba(79, 195, 247, 0.35);
    --shadow-jelly: 0 6px 0 rgba(0, 0, 0, 0.12);
    --shadow-jelly-press: 0 2px 0 rgba(0, 0, 0, 0.12);

    /* Typography */
    --font-heading: 'Fredoka', 'Quicksand', system-ui, sans-serif;
    --font-body: 'Quicksand', system-ui, sans-serif;
}

/* Reset & Box Sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-canvas);
    background-image:
        radial-gradient(#E2E8F0 1.5px, transparent 1.5px),
        radial-gradient(#E2E8F0 1.5px, var(--bg-canvas) 1.5px);
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
    color: var(--text-dark);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    padding-bottom: 370px;
    /* Space for sticky 3-column virtual keyboard + floating progress bar */
}

/* Modal Lock Scroll State */
body.modal-open {
    overflow: hidden !important;
    height: 100vh;
    touch-action: none;
}

/* Story Mode & Gambar Mode Layout Adjustments */
body.mode-cerita,
body.mode-gambar {
    padding-bottom: 2.5rem;
}

body.mode-cerita .virtual-keyboard-container,
body.mode-gambar .virtual-keyboard-container {
    display: none !important;
}

/* Decorative Background Elements */
.bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.cloud,
.star,
.balloon {
    position: absolute;
    opacity: 0.5;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
    animation: floatAnim 6s ease-in-out infinite alternate;
}

.cloud-1 {
    top: 4%;
    left: 3%;
    font-size: 3rem;
    animation-duration: 8s;
}

.cloud-2 {
    top: 8%;
    right: 4%;
    font-size: 3.5rem;
    animation-duration: 10s;
}

.star-1 {
    top: 25%;
    left: 85%;
    font-size: 2rem;
    animation-duration: 5s;
}

.star-2 {
    top: 60%;
    left: 2%;
    font-size: 2.2rem;
    animation-duration: 7s;
}

.balloon-1 {
    top: 40%;
    right: 2%;
    font-size: 3rem;
    animation-duration: 9s;
}

@keyframes floatAnim {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    100% {
        transform: translateY(-15px) rotate(3deg);
    }
}

/* Main Container Layout */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    position: relative;
    z-index: 1;
}

/* Header Banner */
.app-header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.header-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.header-left-bar {
    display: flex;
    align-items: center;
}

.header-right-bar {
    display: flex;
    align-items: center;
}

.mode-select {
    background: #FFFFFF;
    border: 2.5px solid #B3E5FC;
    border-radius: var(--radius-pill);
    padding: 0.4rem 1rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: #0288D1;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(2, 136, 209, 0.12);
    outline: none;
    transition: all 0.2s ease;
}

.mode-select:hover {
    background: #E1F5FE;
    border-color: #4FC3F7;
    transform: translateY(-1px);
}

.mode-select:focus {
    border-color: #0288D1;
}

/* Mode Selection Cards inside Start Modal */
.mode-selection-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin: 1rem 0;
}

.mode-choice-btn {
    background: #FFFFFF;
    border: 2.5px solid #E0F2FE;
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
    width: 100%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.mode-choice-btn:hover {
    border-color: #4FC3F7;
    background: #E1F5FE;
    transform: translateY(-2px);
}

.mode-choice-btn.active {
    background: #E1F5FE;
    border-color: #0288D1;
    box-shadow: 0 4px 14px rgba(2, 136, 209, 0.2);
}

.mode-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
}

.mode-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.mode-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #0288D1;
}

.mode-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Loading Mode State inside Worksheet Grid */
.loading-mode-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    border: 3.5px solid #B3E5FC;
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 480px;
    margin: 2rem auto;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.spinner-mascot {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    animation: pulseSpin 1s infinite alternate ease-in-out;
}

@keyframes pulseSpin {
    0% { transform: scale(1) rotate(-6deg); }
    100% { transform: scale(1.15) rotate(6deg); }
}

.loading-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: #0288D1;
    margin-bottom: 0.35rem;
}

.loading-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.loading-progress-bar {
    width: 80%;
    height: 12px;
    background: #E0F2FE;
    border-radius: var(--radius-pill);
    overflow: hidden;
    position: relative;
    border: 1px solid #B3E5FC;
}

.loading-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4FC3F7, #66BB6A);
    border-radius: var(--radius-pill);
    animation: loadFill 1.5s ease-in-out forwards;
}

@keyframes loadFill {
    0% { width: 0%; }
    100% { width: 100%; }
}

.timer-badge {
    background: #FFFDE7;
    border: 2px solid #FFF59D;
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.9rem;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: #F57F17;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    margin-right: 0.5rem;
}

.btn-audio-toggle {
    background: #FFFFFF;
    border: 2px solid #B3E5FC;
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.95rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: #0288D1;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.btn-audio-toggle:hover {
    background: #E1F5FE;
    transform: translateY(-1px);
}

.btn-audio-toggle.muted {
    background: #FFF3E0;
    border-color: #FFE082;
    color: #E65100;
}

.logo-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: #FFFFFF;
    padding: 0.6rem 1.6rem;
    border-radius: var(--radius-pill);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    border: 3px solid var(--primary-blue);
}

.logo-icon {
    font-size: 2.2rem;
    animation: pulseLogo 2s infinite alternate;
}

@keyframes pulseLogo {
    0% {
        transform: scale(1) rotate(-5deg);
    }

    100% {
        transform: scale(1.15) rotate(5deg);
    }
}

.app-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: #0288D1;
    letter-spacing: 0.5px;
}

.app-title span {
    color: #FF7043;
}

.app-subtitle {
    margin-top: 0.4rem;
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Progress Tracker Bar */
.progress-section {
    background: #FFFFFF;
    box-shadow: var(--shadow-card);
    border: 2px solid #E0F7FA;
    transition: opacity 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),
        transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),
        max-height 0.35s ease,
        margin 0.35s ease,
        padding 0.35s ease;
}

/* Top Progress Tracker Bar (Under Header) */
.progress-section.top-progress {
    border-radius: var(--radius-lg);
    padding: 0.9rem 1.25rem;
    margin-bottom: 1.5rem;
}

/* Floating Progress Tracker Bar (Floats at top of viewport when scrolling down) */
.progress-section.floating-progress {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 860px;
    border-radius: var(--radius-md);
    padding: 0.6rem 1.1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.progress-section.floating-progress.hidden {
    opacity: 0;
    transform: translate(-50%, -20px);
    pointer-events: none;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    font-weight: 700;
}

.progress-text {
    font-size: 0.95rem;
    color: #37474F;
}

.progress-timer {
    font-size: 0.95rem;
    color: #F57F17;
    font-family: var(--font-heading);
    font-weight: 700;
    background: #FFFDE7;
    padding: 0.15rem 0.65rem;
    border-radius: var(--radius-pill);
    border: 1.5px solid #FFF59D;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.progress-percent {
    font-size: 0.95rem;
    color: var(--primary-blue-dark);
}

.progress-bar-track {
    height: 16px;
    background: #ECEFF1;
    border-radius: var(--radius-pill);
    position: relative;
    overflow: visible;
    padding: 2px;
    border: 1.5px solid #CFD8DC;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4FC3F7, #81C784);
    border-radius: var(--radius-pill);
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.progress-trophy {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    z-index: 2;
}

/* Quick Jump & Filter Navigation Bar */
.filter-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0 2.5rem 0;
    flex-wrap: wrap;
}

.filter-chip {
    background: #FFFFFF;
    border: 2px solid #E0F2FE;
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.9rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    background: #E1F5FE;
    color: #0288D1;
}

.filter-chip.active {
    background: #4FC3F7;
    color: #FFFFFF;
    border-color: #0288D1;
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.3);
}

/* Worksheet Flex Layout */
.worksheet-wrapper {
    margin-top: 0.5rem;
    width: 100%;
}

.worksheet-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.25rem;
}

/* Card Component */
.card-problem {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow-card);
    border: 3px solid #E2E8F0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 200px;
    max-width: 250px;
    min-width: 160px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: visible;
}

/* Problem Card Header Badge */
.card-header-badge {
    position: absolute;
    top: -14px;
    left: 16px;
    background: #E1F5FE;
    color: #0288D1;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-pill);
    border: 2px solid #B3E5FC;
    white-space: nowrap;
    z-index: 3;
}

/* Voice Speaker Button (Aligned with card-header-badge on right side) */
.btn-speech {
    position: absolute;
    top: -14px;
    right: 16px;
    background: #FFFFFF;
    color: #0288D1;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-pill);
    border: 2px solid #B3E5FC;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(2, 136, 209, 0.12);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 4;
    outline: none;
    line-height: 1;
}

.btn-speech:hover {
    background: #E1F5FE;
    color: #01579B;
    border-color: #4FC3F7;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 14px rgba(2, 136, 209, 0.22);
}

.btn-speech:active {
    transform: translateY(1px) scale(0.98);
}

/* Story Problem Card Layout (Hitung Cerita) */
.story-text-box {
    background: #F4FBF7;
    border: 2px dashed #A5D6A7;
    border-radius: var(--radius-md);
    padding: 1.1rem 1.25rem;
    margin: 0.75rem 0 1rem 0;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.6;
    color: #2E7D32;
    text-align: left;
    width: 100%;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.02);
}

.choices-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    width: 100%;
    margin-top: 0.35rem;
}

.choice-btn {
    flex: 1 1 0;
    min-width: 0;
    background: #FFFFFF;
    border: 2.5px solid #E0F2FE;
    border-radius: var(--radius-md);
    padding: 0.6rem 0.4rem;
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 700;
    color: #37474F;
    cursor: pointer;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
    white-space: nowrap;
}

.choice-btn:hover {
    background: #E1F5FE;
    border-color: #81D4FA;
    color: #0288D1;
    transform: translateY(-2px);
}

.choice-btn:active {
    transform: translateY(1px);
}

.choice-badge {
    background: #0288D1;
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(2, 136, 209, 0.3);
}

.choice-btn.selected-success {
    background: #E8F5E9;
    border-color: #66BB6A;
    color: #2E7D32;
}

.choice-btn.selected-success .choice-badge {
    background: #4CAF50;
}

.choice-btn.selected-error {
    background: #FFEBEE;
    border-color: #EF5350;
    color: #C62828;
}

.choice-btn.selected-error .choice-badge {
    background: #E53935;
}

/* Hint System */
.btn-hint-trigger {
    margin-top: 0.5rem;
    background: #FFFDE7;
    border: 2px dashed #FBC02D;
    color: #E65100;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-hint-trigger:hover {
    background: #FFF9C4;
    transform: scale(1.05);
}

.hint-bubble-box {
    margin-top: 0.4rem;
    background: #FFFDE7;
    border: 2px solid #FFF59D;
    border-radius: var(--radius-md);
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: #E65100;
    text-align: center;
    width: 100%;
}

/* Card States */
.card-problem.active {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-active);
    transform: translateY(-4px);
    animation: pulseGlow 2s infinite alternate;
}

.card-problem.active .card-header-badge {
    background: var(--primary-blue);
    color: #FFFFFF;
    border-color: var(--primary-blue-dark);
}

.card-problem.success {
    border-color: var(--success-green);
    background: var(--success-bg);
    animation: bouncePop 0.5s ease-out;
}

.card-problem.success .card-header-badge {
    background: var(--success-green);
    color: #FFFFFF;
    border-color: #66BB6A;
}

.card-problem.error {
    border-color: var(--error-red);
    background: var(--error-bg);
    animation: shakeCard 0.4s ease-in-out;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 8px 20px rgba(79, 195, 247, 0.3);
    }

    100% {
        box-shadow: 0 14px 32px rgba(79, 195, 247, 0.6);
    }
}

@keyframes bouncePop {
    0% {
        transform: scale(0.95);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes shakeCard {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-10px);
    }

    40% {
        transform: translateX(10px);
    }

    60% {
        transform: translateX(-8px);
    }

    80% {
        transform: translateX(8px);
    }
}

/* Vertical Math Column Layout */
.math-column {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: #263238;
    margin: 1rem 0 0.5rem 0;
    width: 140px;
}

.math-num-top {
    padding-right: 0.5rem;
    letter-spacing: 4px;
}

.math-row-bottom {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    margin-top: -0.2rem;
}

.math-operator {
    color: #FF7043;
    font-size: 2.2rem;
    padding-left: 0.2rem;
}

.math-num-bottom {
    padding-right: 0.5rem;
    letter-spacing: 4px;
}

.math-line {
    width: 100%;
    height: 4px;
    background: #37474F;
    border-radius: 2px;
    margin: 0.4rem 0 0.8rem 0;
}

/* Math Grid Worksheet (Hitung Susun Boxed Column Grid Layout) */
.math-grid-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0.6rem 0;
    user-select: none;
    width: 100%;
}

.math-grid-table {
    display: inline-grid;
    grid-template-columns: 32px repeat(var(--grid-cols, 3), 42px);
    gap: 4px;
    align-items: center;
    justify-items: center;
}

.grid-cell-op-placeholder {
    width: 32px;
    height: 42px;
}

/* Carry / Borrow Circle Input Row */
.carry-circle-input {
    width: 28px;
    height: 28px;
    border: 1.5px dashed #A5D6A7;
    border-radius: 50%;
    background: #F1F8E9;
    color: #2E7D32;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    outline: none;
    padding: 0;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.carry-circle-input:focus {
    border-style: solid;
    border-color: #4CAF50;
    background: #FFFFFF;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.carry-circle-input::placeholder {
    color: #A5D6A7;
    font-weight: 400;
}

/* Digit Box Cells - 1px dashed subtle gray border */
.digit-box-cell {
    width: 42px;
    height: 42px;
    border: 1px dashed #CFD8DC;
    border-radius: 8px;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: #263238;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.digit-box-cell.empty-cell {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.operator-cell {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: #E65100;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Line separator */
.math-grid-line {
    grid-column: 1 / -1;
    width: 100%;
    height: 3.5px;
    background: #37474F;
    border-radius: 2px;
    margin: 4px 0 6px 0;
}

/* Scaled Down Grid for 4+ Digits (Ribuan / Thousands) */
.math-grid-container.is-thousands .math-grid-table {
    grid-template-columns: 26px repeat(var(--grid-cols, 4), 34px);
    gap: 3px;
}

.math-grid-container.is-thousands .grid-cell-op-placeholder {
    width: 26px;
    height: 34px;
}

.math-grid-container.is-thousands .carry-circle-input {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
}

.math-grid-container.is-thousands .digit-box-cell,
.math-grid-container.is-thousands .answer-box-cell {
    width: 34px;
    height: 34px;
    font-size: 1.15rem;
    border-radius: 6px;
}

.math-grid-container.is-thousands .operator-cell {
    font-size: 1.3rem;
}

/* Answer Digit Box Inputs */
.answer-box-cell {
    width: 42px;
    height: 42px;
    border: 2.5px solid #0288D1;
    border-radius: 8px;
    background: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: #0288D1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.card-problem.success .answer-box-cell {
    border-color: #4CAF50;
    background: #E8F5E9;
    color: #2E7D32;
}

.answer-box-cell.filled {
    background: #E1F5FE;
}

.answer-box-cell.active-box {
    border-color: #FF9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
    animation: activeGlow 1.2s infinite alternate ease-in-out;
}

/* Answer Input Field */
.math-input-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.math-input {
    width: 100%;
    height: 54px;
    background: #F4F6F8;
    border: 3px dashed #B0BEC5;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    color: #1E88E5;
    outline: none;
    transition: all 0.2s ease;
    caret-color: #1E88E5;
}

.card-problem.active .math-input {
    background: #FFFFFF;
    border: 3px solid var(--primary-blue);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

.card-problem.success .math-input {
    background: #FFFFFF;
    border: 3px solid var(--success-green);
    color: #2E7D32;
}

.card-problem.error .math-input {
    background: #FFFFFF;
    border: 3px solid var(--error-red);
    color: #C62828;
}

/* Character Mascot & Speech Bubble Feedback Overlay */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 1rem;
}

.feedback-overlay.show {
    opacity: 1;
    visibility: visible;
}

.mascot-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.4) translateY(20px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.mascot-avatar {
    font-size: 3.5rem;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.12));
}

.speech-bubble {
    position: relative;
    background: #FFFFFF;
    border: 3px solid #37474F;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.speech-bubble.bubble-success {
    background: #E8F5E9;
    border-color: #4CAF50;
    color: #1B5E20;
}

.speech-bubble.bubble-error {
    background: #FFEBEE;
    border-color: #EF5350;
    color: #B71C1C;
}

/* Virtual Keyboard Container */
.virtual-keyboard-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 3px solid #E0F2FE;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
    padding: 0.5rem 1rem 0.75rem 1rem;
    z-index: 100;
    display: flex;
    justify-content: center;
}

.keyboard-inner {
    width: 100%;
    max-width: 420px;
}

.keyboard-header {
    text-align: center;
    margin-bottom: 0.35rem;
}

.keyboard-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.keyboard-keys {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
}

/* Jelly Bean Key Buttons - 43px Height & Dark Charcoal (#2f2f2f) Font Color */
.jelly-btn {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    height: 43px !important;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2f2f2f !important;
    outline: none;
}

.jelly-btn:hover {
    filter: brightness(1.05);
}

.jelly-btn:active,
.jelly-btn.pressed {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* Key Colors - Harmonious Pastel Palette with Dark Charcoal Text */
.jelly-btn[data-key="1"] { background: #FFE082; color: #2f2f2f !important; }
.jelly-btn[data-key="2"] { background: #A5D6A7; color: #2f2f2f !important; }
.jelly-btn[data-key="3"] { background: #81D4FA; color: #2f2f2f !important; }
.jelly-btn[data-key="4"] { background: #CE93D8; color: #2f2f2f !important; }
.jelly-btn[data-key="5"] { background: #FFAB91; color: #2f2f2f !important; }
.jelly-btn[data-key="6"] { background: #80DEEA; color: #2f2f2f !important; }
.jelly-btn[data-key="7"] { background: #F48FB1; color: #2f2f2f !important; }
.jelly-btn[data-key="8"] { background: #C5E1A5; color: #2f2f2f !important; }
.jelly-btn[data-key="9"] { background: #FFCC80; color: #2f2f2f !important; }
.jelly-btn[data-key="0"] { background: #FFF59D; color: #2f2f2f !important; }

.key-backspace {
    background: #FFCDD2;
    color: #2f2f2f !important;
    font-size: 1.35rem;
}

.key-clear {
    background: #FFE082;
    color: #2f2f2f !important;
    font-size: 1.35rem;
}

.key-enter {
    background: #B2DFDB;
    color: #2f2f2f !important;
    font-size: 1.35rem;
}

.span-3-cols {
    grid-column: span 3;
    font-size: 1.5rem;
}

.key-submit {
    background: #66BB6A;
    color: #FFFFFF;
    font-size: 1.8rem;
}

/* Celebration End Screen Overlay */
.end-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 62, 80, 0.7);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.end-screen-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.celebration-card {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    padding: 2.2rem 2rem;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    border: 4px solid var(--primary-blue);
    position: relative;
    z-index: 10;
    animation: modalPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.celebration-badge {
    font-size: 4.5rem;
    margin-bottom: 0.5rem;
    animation: bounceTrophy 1.5s infinite alternate ease-in-out;
}

@keyframes bounceTrophy {
    0% {
        transform: translateY(0) scale(1);
    }

    100% {
        transform: translateY(-12px) scale(1.1);
    }
}

.celebration-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    color: #0288D1;
    margin-bottom: 0.4rem;
}

.celebration-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    font-weight: 600;
}

.stars-display {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Collectible Achievement Stickers */
.achievements-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.achievement-sticker {
    background: #FFFDE7;
    border: 2px solid #FFF59D;
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.85rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: #E65100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    animation: popIn 0.4s ease-out;
}

.star-item {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
    animation: starPop 0.6s ease forwards;
}

.score-card-box {
    background: #F4F8FB;
    border-radius: var(--radius-md);
    padding: 1rem 1.2rem;
    margin-bottom: 1.8rem;
    border: 2px dashed #B3E5FC;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.score-label {
    color: var(--text-muted);
}

.score-value {
    color: #0288D1;
}

.score-success-text {
    color: #2E7D32 !important;
}

.score-error-text {
    color: #C62828 !important;
}

.celebration-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.btn-review {
    background: #E1F5FE;
    color: #0288D1;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.85rem 1.8rem;
    border: 2.5px solid #B3E5FC;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(2, 136, 209, 0.12);
    transition: all 0.15s ease;
    width: 100%;
}

.btn-review:hover {
    background: #B3E5FC;
    color: #01579B;
    transform: translateY(-2px);
}

.btn-restart {
    background: linear-gradient(135deg, #4FC3F7, #0288D1);
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(2, 136, 209, 0.4), 0 4px 0 #01579B;
    transition: all 0.15s ease;
    width: 100%;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(2, 136, 209, 0.5), 0 6px 0 #01579B;
}

.btn-restart:active {
    transform: translateY(2px);
    box-shadow: 0 4px 10px rgba(2, 136, 209, 0.4), 0 2px 0 #01579B;
}

/* Confetti Particle CSS */
.confetti-piece {
    position: absolute;
    width: 12px;
    height: 18px;
    top: -20px;
    opacity: 0.9;
    animation: confettiFall 3s linear infinite;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(105vh) rotate(720deg);
        opacity: 0;
    }
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 768px) {
    /* Story Mode & Gambar Mode 1 Column Mobile Layout */
    body.mode-cerita .worksheet-grid,
    body.mode-gambar .worksheet-grid {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    body.mode-cerita .card-problem,
    body.mode-gambar .card-problem {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: 100% !important;
    }

    .story-text-box {
        font-size: 1.3rem !important;
        padding: 1rem 1.1rem;
    }
}

@media (max-width: 600px) {
    body {
        padding-bottom: 370px;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 1.6rem;
    }

    .worksheet-grid {
        gap: 0.75rem;
        justify-content: space-between;
    }

    .card-problem {
        flex: 1 1 calc(50% - 0.375rem);
        max-width: calc(50% - 0.375rem);
        min-width: 130px;
        padding: 0.9rem 0.4rem;
    }

    .card-header-badge {
        font-size: 0.75rem;
        padding: 0.15rem 0.6rem;
        left: 10px;
        top: -12px;
    }

    .math-column {
        font-size: 1.8rem;
        width: 105px;
        margin: 0.8rem 0 0.4rem 0;
    }

    .math-operator {
        font-size: 1.5rem;
    }

    .math-input {
        height: 44px;
        font-size: 1.6rem;
    }

    .jelly-btn {
        height: 50px;
        font-size: 1.5rem;
    }

    .celebration-card {
        padding: 1.5rem 1.25rem;
    }

    .celebration-title {
        font-size: 1.7rem;
    }
}

/* Large Desktop screens (4-5 columns per row) */
@media (min-width: 1025px) {
    .app-container {
        max-width: 1100px;
    }

    .card-problem {
        flex: 1 1 210px;
        max-width: 240px;
    }
}

/* Interactive Object Box (Hitung Bergambar) */
.interactive-object-box {
    background: #FFFDE7;
    border: 2.5px dashed #FBC02D;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 0.75rem 0 1rem 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
}

.picture-story-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #5D4037;
    text-align: center;
    line-height: 1.5;
    margin: 0;
}

.emoji-groups-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.emoji-group-card {
    background: #FFFFFF;
    border: 2px solid #FFF59D;
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.emoji-group-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #F57F17;
    background: #FFF9C4;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
}

.emoji-items-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.emoji-item {
    font-size: 2.2rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease, opacity 0.2s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

.emoji-item:hover {
    transform: scale(1.18);
    background: rgba(255, 235, 59, 0.2);
}

.emoji-item.tapped {
    transform: scale(1.25);
    background: #FFF9C4;
    box-shadow: 0 4px 10px rgba(245, 127, 23, 0.25);
}

.emoji-item .tap-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF9800;
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.emoji-item.reduced {
    opacity: 0.35;
    filter: grayscale(80%);
}

.emoji-item.reduced::after {
    content: '❌';
    position: absolute;
    font-size: 1.3rem;
    color: #E53935;
}

/* Mode Switcher CSS for mode-gambar */
body.mode-gambar .virtual-keyboard-container {
    display: none !important;
}

body.mode-gambar .worksheet-wrapper {
    padding-bottom: 2rem !important;
}

/* Story Mode & Gambar Mode 2 Column Desktop Layout (Layar Besar) */
@media (min-width: 769px) {
    body.mode-cerita .worksheet-grid,
    body.mode-gambar .worksheet-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.25rem;
        width: 100%;
        max-width: 920px;
        margin: 0 auto;
    }

    body.mode-cerita .card-problem,
    body.mode-gambar .card-problem {
        flex: 1 1 calc(50% - 0.75rem) !important;
        max-width: calc(50% - 0.75rem) !important;
        width: calc(50% - 0.75rem) !important;
        min-width: 320px !important;
    }
}