/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Neue', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2d3748;
    overflow-x: hidden;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.diff-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 15px;
    border: none;
    border-radius: 10px;
    background: #f7fafc;
    font-family: 'Comic Neue', cursive;
    font-size: 0.95rem;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    width: 100%;
}

.diff-btn .emoji {
    font-size: 1.2rem;
}

.diff-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.diff-btn.active {
    background: linear-gradient(135deg, #4299e1, #667eea);
    color: white;
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.4);
}

/* ============================================
   MAIN WORKSPACE - 3 COLUMN LAYOUT
   ============================================ */
.main-workspace {
    display: grid;
    grid-template-columns: 280px 1fr 350px;
    gap: 0;
    height: 100vh;
    width: 100vw;
}

/* ============================================
   LEFT SIDEBAR - CONTROLS
   ============================================ */
.controls-sidebar {
    background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.app-logo {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
}

.app-logo h1 {
    font-size: 1.3rem;
    color: white;
    margin: 0;
    font-weight: 700;
}

.difficulty-section,
.controls-section,
.hint-usage-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-section h3,
.controls-section h3,
.hint-usage-section h3 {
    font-size: 0.9rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 5px 0;
    font-weight: 600;
}

/* Hint Usage Stats */
.hint-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.hint-stat-item {
    display: grid;
    grid-template-columns: 30px 40px 1fr;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.hint-icon {
    font-size: 1.2rem;
}

.hint-count {
    font-size: 1.3rem;
    font-weight: 700;
    color: #667eea;
    text-align: center;
}

.hint-label {
    font-size: 0.75rem;
    color: #4a5568;
    font-weight: 500;
}

.division-workspace {
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.instruction-banner {
    background: linear-gradient(135deg, #667eea15, #764ba215);
    border: 2px solid #667eea30;
    border-radius: 12px;
    padding: 15px 25px;
    margin-bottom: 20px;
    text-align: center;
    width: 100%;
    max-width: 700px;
}

.instruction-banner p {
    font-size: 1.1rem;
    font-weight: 600;
    color: #5a67d8;
    margin: 0;
}

/* ============================================
   LONG DIVISION DISPLAY - THE MAGIC HAPPENS HERE
   ============================================ */
.division-display {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.long-division {
    font-family: 'Roboto Mono', monospace;
    display: grid;
    /* grid-template-columns and rows set inline in JS */
    gap: 0;
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 3px solid #2d3748;
    max-height: calc(100vh - 180px);
    overflow: auto;
}

/* Grid cells - SHOW ALL BORDERS SO WE CAN SEE THE GRID */
.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e0;
    width: 60px;
    height: 65px;
    background: #f7fafc;
    box-sizing: border-box;
}

.grid-cell.empty {
    background: #fafafa;
    border: 1px solid #e2e8f0;
}

/* Divisor cell */
.grid-cell.divisor-cell {
    font-size: 2.5rem;
    font-weight: 700;
    color: #e53e3e;
    background: #fff5f5;
}

/* Bracket cell - vertical line on RIGHT edge + horizontal line on BOTTOM */
.grid-cell.divisor-cell.bracket-cell {
    border-right: 6px solid #2d3748 !important;
    border-bottom: 4px solid #2d3748 !important;
}

/* Horizontal line cells - line on TOP edge */
.grid-cell.h-line {
    border-top: 4px solid #2d3748 !important;
    background: white;
}

/* Quotient cells */
.grid-cell.quotient-cell {
    border: 2px solid #4299e1;
    background: white;
}

.grid-cell.quotient-cell.filled.zero-value input,
.grid-cell.quotient-cell.filled.zero-value .quotient-digit {
    opacity: 0;
}

.quotient-digit {
    width: 55px;
    height: 60px;
    border: 3px solid #cbd5e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    background: white;
    transition: all 0.3s ease;
}

.quotient-digit.editable {
    background: #fef5e7;
    border-color: #f6ad55;
    cursor: text;
    animation: pulse-glow 2s infinite;
}

.quotient-digit.editable:hover {
    border-color: #ed8936;
    transform: scale(1.05);
}

.quotient-digit input,
.grid-cell input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    color: inherit;
    outline: none;
}

.quotient-digit input:focus,
.grid-cell input:focus {
    outline: none;
}

.quotient-digit.filled {
    background: #c6f6d5;
    border-color: #48bb78;
    color: #2f855a;
}

.quotient-digit.error {
    background: #fed7d7;
    border-color: #fc8181;
    color: #c53030;
    animation: shake 0.5s;
}

/* Dividend cells */
.grid-cell.dividend-cell {
    border: 2px solid #3182ce;
    background: white;
}

.dividend-digit {
    font-size: 2rem;
    font-weight: 700;
    color: #3182ce;
    background: #ebf8ff;
    border: 2px solid #90cdf4;
    border-radius: 8px;
    width: 55px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dividend-digit.active {
    background: #bee3f8;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

/* Work cells - disabled by default until quotient filled */
.grid-cell.work-cell {
    background: #e5e7eb;
    border: 2px solid #9ca3af;
    cursor: not-allowed;
    transition: all 0.3s;
    opacity: 0.5;
}

/* Work cells become active when quotient is filled */
.grid-cell.work-cell.active {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    cursor: text;
    opacity: 1;
}

.grid-cell.work-cell.active:hover {
    background: #fde68a;
    transform: scale(1.05);
}

.grid-cell.work-cell.filled {
    background: #d1fae5;
    border: 2px solid #10b981;
    font-size: 2rem;
    font-weight: 700;
    color: #065f46;
    cursor: default;
}

/* Bring down cells */
.grid-cell.bringdown-cell {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    position: relative;
}

.bringdown-arrow-indicator {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    color: #f59e0b;
    font-weight: bold;
    animation: bounce 0.5s ease-in-out infinite;
    pointer-events: none;
}

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

.bringdown-digit {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #065f46;
}

.bringdown-digit.filled {
    background: #dbeafe;
    border-radius: 4px;
}

.bringdown-digit.animate-down {
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Minus sign cell */
.grid-cell.minus-cell {
    font-size: 2.5rem;
    font-weight: 700;
    color: #e53e3e;
    background: white;
}

/* Horizontal line at bottom of cell */
.grid-cell.h-line-bottom {
    background: white;
    border-bottom: 4px solid #2d3748 !important;
}

.work-step {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 0;
    opacity: 0;
    animation: fadeInDown 0.5s forwards;
}

.work-row {
    display: flex;
    gap: 3px;
    align-items: center;
}

.work-row.multiply-row {
    padding-left: 10px;
}

.work-row.subtract-row {
    padding-left: 10px;
    border-bottom: 3px solid #4a5568;
    padding-bottom: 8px;
    margin-bottom: 5px;
}

.work-row.result-row {
    padding-left: 15px;
}

.work-digit {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    border-radius: 6px;
}

.work-digit.multiply-result {
    background: #e6fffa;
    color: #234e52;
    border: 2px solid #81e6d9;
}

.work-digit.subtract-minuend {
    background: #feebc8;
    color: #7c2d12;
    border: 2px solid #f6ad55;
}

.work-digit.difference {
    background: #faf5ff;
    color: #44337a;
    border: 2px solid #b794f4;
}

.work-digit.brought-down {
    background: #bee3f8;
    color: #2c5282;
    border: 2px solid #4299e1;
    position: relative;
}

.work-digit.brought-down::before {
    content: '↓';
    position: absolute;
    top: -25px;
    font-size: 1.2rem;
    color: #4299e1;
}

.work-label {
    font-size: 0.9rem;
    color: #718096;
    margin-left: 10px;
    font-style: italic;
}

/* ============================================
   CONTROLS BUTTONS
   ============================================ */
.ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-family: 'Comic Neue', cursive;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.ctrl-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.ctrl-btn span {
    font-size: 1.2rem;
}

.ctrl-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.ctrl-btn.secondary {
    background: #ed8936;
    color: white;
}

.ctrl-btn.info {
    background: #0bc5ea;
    color: white;
}

.ctrl-btn.success {
    background: #48bb78;
    color: white;
}

.ctrl-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* ============================================
   HELP SIDEBAR
   ============================================ */
.help-sidebar {
    background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
    padding: 20px;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.help-card h3 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.help-content {
    min-height: 200px;
    max-height: 350px;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(135deg, #667eea15, #764ba215);
    border-radius: 10px;
    border: 2px solid #667eea30;
    margin-bottom: 15px;
}

.help-intro {
    color: #718096;
    text-align: center;
    font-size: 1.1rem;
    padding: 40px 20px;
}

.help-step-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #4299e1;
    margin-bottom: 15px;
}

.help-description {
    font-size: 1.05rem;
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 15px;
}

.help-example {
    background: white;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    color: #2d3748;
    border: 2px solid #cbd5e0;
    margin: 10px 0;
}

.hint-levels {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hint-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-family: 'Comic Neue', cursive;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hint-btn.level-1 {
    background: #bee3f8;
    color: #2c5282;
}

.hint-btn.level-2 {
    background: #fbd38d;
    color: #7c2d12;
}

.hint-btn.level-3 {
    background: #9ae6b4;
    color: #22543d;
}

.hint-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.progress-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.progress-card h3 {
    font-size: 1rem;
    color: #2d3748;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px;
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4299e1;
}

.stat-label {
    font-size: 0.75rem;
    color: #718096;
    text-align: center;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.badge {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s;
}

.badge:hover {
    transform: scale(1.1);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 20px 10px;
}

.help-list {
    list-style: none;
}

.help-list li {
    padding: 8px 0 8px 30px;
    position: relative;
    color: #4a5568;
    line-height: 1.6;
}

.help-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
    font-size: 1.2rem;
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 550px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalBounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 1.6rem;
    color: #2d3748;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2.5rem;
    color: #a0aec0;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #4a5568;
}

.step-question {
    font-size: 1.3rem;
    font-weight: 600;
    color: #4299e1;
    text-align: center;
    padding: 20px;
    background: rgba(66, 153, 225, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(66, 153, 225, 0.3);
    margin-bottom: 20px;
}

.step-visual {
    background: #f7fafc;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 25px;
    text-align: center;
    font-family: 'Roboto Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2d3748;
}

.input-area {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.step-input {
    flex: 1;
    padding: 15px 20px;
    border: 3px solid #cbd5e0;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    text-align: center;
    transition: all 0.3s;
}

.step-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.2);
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: 'Comic Neue', cursive;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-btn.primary {
    background: #4299e1;
    color: white;
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.3);
}

.modal-btn.primary:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

.hint-area {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-btn.info {
    flex: 1;
    background: #0bc5ea;
    color: white;
}

.modal-btn.secondary {
    flex: 1;
    background: #cbd5e0;
    color: #4a5568;
}

.step-feedback {
    min-height: 50px;
    padding: 15px;
    border-radius: 10px;
    font-weight: 600;
    text-align: center;
    font-size: 1.1rem;
}

.step-feedback.success {
    background: #c6f6d5;
    color: #2f855a;
    border: 3px solid #48bb78;
}

.step-feedback.error {
    background: #fed7d7;
    color: #c53030;
    border: 3px solid #fc8181;
}

.step-feedback.hint {
    background: #bee3f8;
    color: #2c5282;
    border: 3px solid #4299e1;
}

/* ============================================
   CELEBRATION
   ============================================ */
.celebration-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 280px; /* Start after left sidebar */
    right: 350px; /* End before right sidebar */
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.75), rgba(118, 75, 162, 0.75));
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.celebration-overlay.active {
    display: flex;
}

.celebration-content {
    text-align: center;
    color: white;
    animation: celebrationBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.celebration-content h2 {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.celebration-content p {
    font-size: 1.8rem;
    margin-bottom: 30px;
    font-weight: 600;
}

.celebrate-btn {
    padding: 18px 40px;
    border: none;
    border-radius: 15px;
    background: white;
    color: #667eea;
    font-family: 'Comic Neue', cursive;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

.celebrate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(246, 173, 85, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(246, 173, 85, 0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalBounceIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes celebrationBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 1024px) {
    .main-workspace {
        grid-template-columns: 250px 1fr 300px;
    }

    .controls-sidebar,
    .help-sidebar {
        padding: 15px;
    }

    .app-logo h1 {
        font-size: 1.1rem;
    }

    .long-division {
        grid-template-columns: repeat(8, 50px) !important;
        grid-template-rows: repeat(16, 55px) !important;
    }

    .grid-cell input {
        font-size: 1.3rem;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .main-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: 100vh;
        overflow: hidden;
    }

    .controls-sidebar {
        order: 1;
        padding: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        max-height: none;
    }

    .division-workspace {
        order: 2;
        overflow-x: auto;
        overflow-y: auto;
        padding: 10px;
    }

    .help-sidebar {
        order: 3;
        padding: 15px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        max-height: 250px;
        overflow-y: auto;
    }

    .app-logo {
        padding: 8px;
    }

    .app-logo h1 {
        font-size: 1rem;
    }

    .difficulty-section,
    .controls-section {
        gap: 8px;
    }

    .diff-btn,
    .ctrl-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .hint-usage-section {
        display: none;
    }

    .long-division {
        grid-template-columns: repeat(8, 45px) !important;
        grid-template-rows: repeat(16, 50px) !important;
        margin: 0 auto;
    }

    .grid-cell {
        width: 45px;
        height: 50px;
    }

    .grid-cell input {
        font-size: 1.2rem;
        width: 100%;
        height: 100%;
    }

    .divisor-cell {
        font-size: 1.3rem;
    }

    .help-content {
        max-height: none;
    }

    .help-step-title {
        font-size: 1rem;
    }

    .help-description {
        font-size: 0.9rem;
    }

    .hint-levels {
        flex-direction: column;
        gap: 8px;
    }

    .hint-btn {
        padding: 8px;
        font-size: 0.85rem;
    }

    .progress-card {
        padding: 10px;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .celebration-overlay {
        left: 0;
        right: 0;
    }

    .celebration-content {
        padding: 20px;
        max-width: 90%;
    }

    .celebration-content h2 {
        font-size: 2rem;
    }

    .instruction-banner {
        padding: 8px;
        font-size: 0.9rem;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE
   ============================================ */
@media (max-width: 480px) {
    .long-division {
        grid-template-columns: repeat(8, 38px) !important;
        grid-template-rows: repeat(16, 42px) !important;
    }

    .grid-cell {
        width: 38px;
        height: 42px;
    }

    .grid-cell input {
        font-size: 1rem;
    }

    .divisor-cell {
        font-size: 1.1rem;
    }

    .help-sidebar {
        max-height: 200px;
    }

    .stat-item {
        padding: 8px;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}
