/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    width: 100%;
    height: 450px;
    overflow: hidden;
    position: relative;
}

/* Responsive height for different contexts */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main container */
.main-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    position: relative;
}

/* Step indicator at the top */
.step-indicator {
    background: white;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.step-indicator span {
    font-weight: bold;
    color: #1976d2;
    font-size: 14px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    width: 0%;
    transition: width 0.3s ease;
}

/* Problem area - main mathematical display */
.problem-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
}

/* Column headers (T for Tens, O for Ones) */
.column-headers {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    gap: 60px;
}

.column-header {
    font-weight: bold;
    font-size: 16px;
    color: #666;
    width: 40px;
    text-align: center;
}

/* Number rows styling */
.number-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
    gap: 20px;
    position: relative;
}

/* Digit containers for proper alignment */
.digit-container {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #f8f9fa;
}

/* Main digits */
.digit {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    transition: all 0.3s ease;
}

/* Crossed out numbers (when borrowing) */
.crossed-out {
    position: absolute;
    font-size: 20px;
    color: #999;
    text-decoration: line-through;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Borrowed numbers (small numbers above) */
.borrowed {
    position: absolute;
    top: -8px;
    left: -8px;
    font-size: 14px;
    color: #f44336;
    background: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: 1px solid #f44336;
}

/* Borrowed to numbers (regrouped values) */
.borrowed-to {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 14px;
    color: #4caf50;
    background: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: 1px solid #4caf50;
}

/* Operation symbol */
.operation-symbol {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    width: 20px;
    text-align: center;
}

/* Separator line */
.separator-line {
    width: 120px;
    height: 2px;
    background: #333;
    margin: 5px 0;
}

/* Answer digits */
.answer-digit {
    color: #4caf50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Control buttons */
.controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #1976d2;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    white-space: nowrap;
}

.control-btn:hover:not(:disabled) {
    background: #1565c0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Explanation area */
.explanation {
    background: #fff3e0;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    border-left: 4px solid #ff9800;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.explanation p {
    font-size: 13px;
    color: #e65100;
    margin: 0;
    line-height: 1.3;
}

/* Character illustration */
.character {
    position: absolute;
    bottom: 15px;
    left: 15px;
    width: 40px;
    height: 50px;
}

.character-face {
    width: 30px;
    height: 30px;
    background: #ffeb3b;
    border-radius: 50%;
    position: relative;
    border: 2px solid #f57f17;
}

.eyes {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
}

.eye {
    width: 4px;
    height: 4px;
    background: #333;
    border-radius: 50%;
}

.mouth {
    width: 8px;
    height: 4px;
    border: 1px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.character-body {
    width: 20px;
    height: 20px;
    background: #4caf50;
    border-radius: 0 0 10px 10px;
    margin: 2px auto 0;
    border: 2px solid #388e3c;
}

/* Highlight animations for interactive states */
.highlight {
    background: #fff3e0 !important;
    border-color: #ff9800 !important;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.3);
}

/* Show states for step-by-step revelation */
.show-crossed {
    opacity: 1 !important;
}

.show-borrowed {
    opacity: 1 !important;
}

.show-answer {
    opacity: 1 !important;
}

/* Responsive adjustments for very small heights */
@media (max-height: 400px) {
    .problem-area {
        padding: 15px;
    }
    
    .digit {
        font-size: 20px;
    }
    
    .digit-container {
        width: 35px;
        height: 35px;
    }
    
    .explanation {
        min-height: 35px;
    }
    
    .character {
        width: 35px;
        height: 45px;
    }
}