/* Dynamic theme system */
:root {
    --theme-background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    --theme-primary: #ee5a6f;
    --theme-secondary: #ff6b6b;
    --theme-accent: #ff8787;
    --theme-success: #4ade80;
    --theme-danger: #ef4444;
    --theme-info: #3b82f6;
    --theme-question: linear-gradient(135deg, #ffe0e0 0%, #ffd6d6 100%);
    --theme-shadow: rgba(0, 0, 0, 0.1);
}

/* Theme variations */
.theme-red {
    --theme-background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    --theme-primary: #ee5a6f;
    --theme-secondary: #ff6b6b;
    --theme-accent: #ff8787;
    --theme-question: linear-gradient(135deg, #ffe0e0 0%, #ffd6d6 100%);
}

.theme-orange {
    --theme-background: linear-gradient(135deg, #ff9f43 0%, #ff6348 100%);
    --theme-primary: #ff6348;
    --theme-secondary: #ff9f43;
    --theme-accent: #ffb976;
    --theme-question: linear-gradient(135deg, #ffe8d6 0%, #ffd9c4 100%);
}

.theme-amber {
    --theme-background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    --theme-primary: #ff9800;
    --theme-secondary: #ffc107;
    --theme-accent: #ffd54f;
    --theme-question: linear-gradient(135deg, #fff3cd 0%, #ffe8b3 100%);
}

.theme-yellow {
    --theme-background: linear-gradient(135deg, #ffd93d 0%, #ffb800 100%);
    --theme-primary: #ffb800;
    --theme-secondary: #ffd93d;
    --theme-accent: #ffe66d;
    --theme-question: linear-gradient(135deg, #fff9db 0%, #fff3c4 100%);
}

.theme-lime {
    --theme-background: linear-gradient(135deg, #cddc39 0%, #9ccc65 100%);
    --theme-primary: #9ccc65;
    --theme-secondary: #cddc39;
    --theme-accent: #d4e157;
    --theme-question: linear-gradient(135deg, #f0f4c3 0%, #e6ee9c 100%);
}

.theme-green {
    --theme-background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    --theme-primary: #43a047;
    --theme-secondary: #66bb6a;
    --theme-accent: #81c784;
    --theme-question: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
}

.theme-emerald {
    --theme-background: linear-gradient(135deg, #26a69a 0%, #00897b 100%);
    --theme-primary: #00897b;
    --theme-secondary: #26a69a;
    --theme-accent: #4db6ac;
    --theme-question: linear-gradient(135deg, #b2dfdb 0%, #80cbc4 100%);
}

.theme-teal {
    --theme-background: linear-gradient(135deg, #26c6da 0%, #00acc1 100%);
    --theme-primary: #00acc1;
    --theme-secondary: #26c6da;
    --theme-accent: #4dd0e1;
    --theme-question: linear-gradient(135deg, #b2ebf2 0%, #80deea 100%);
}

.theme-cyan {
    --theme-background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);
    --theme-primary: #0097a7;
    --theme-secondary: #00bcd4;
    --theme-accent: #26c6da;
    --theme-question: linear-gradient(135deg, #b2ebf2 0%, #80deea 100%);
}

.theme-sky {
    --theme-background: linear-gradient(135deg, #29b6f6 0%, #039be5 100%);
    --theme-primary: #039be5;
    --theme-secondary: #29b6f6;
    --theme-accent: #4fc3f7;
    --theme-question: linear-gradient(135deg, #b3e5fc 0%, #81d4fa 100%);
}

.theme-blue {
    --theme-background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
    --theme-primary: #1e88e5;
    --theme-secondary: #42a5f5;
    --theme-accent: #64b5f6;
    --theme-question: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
}

.theme-indigo {
    --theme-background: linear-gradient(135deg, #5c6bc0 0%, #3f51b5 100%);
    --theme-primary: #3f51b5;
    --theme-secondary: #5c6bc0;
    --theme-accent: #7986cb;
    --theme-question: linear-gradient(135deg, #c5cae9 0%, #9fa8da 100%);
}

.theme-violet {
    --theme-background: linear-gradient(135deg, #7e57c2 0%, #673ab7 100%);
    --theme-primary: #673ab7;
    --theme-secondary: #7e57c2;
    --theme-accent: #9575cd;
    --theme-question: linear-gradient(135deg, #d1c4e9 0%, #b39ddb 100%);
}

.theme-purple {
    --theme-background: linear-gradient(135deg, #ab47bc 0%, #9c27b0 100%);
    --theme-primary: #9c27b0;
    --theme-secondary: #ab47bc;
    --theme-accent: #ba68c8;
    --theme-question: linear-gradient(135deg, #e1bee7 0%, #ce93d8 100%);
}

.theme-fuchsia {
    --theme-background: linear-gradient(135deg, #ec407a 0%, #e91e63 100%);
    --theme-primary: #e91e63;
    --theme-secondary: #ec407a;
    --theme-accent: #f06292;
    --theme-question: linear-gradient(135deg, #f8bbd0 0%, #f48fb1 100%);
}

.theme-pink {
    --theme-background: linear-gradient(135deg, #f06292 0%, #ec407a 100%);
    --theme-primary: #ec407a;
    --theme-secondary: #f06292;
    --theme-accent: #f48fb1;
    --theme-question: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
}

.theme-rose {
    --theme-background: linear-gradient(135deg, #ff5252 0%, #f44336 100%);
    --theme-primary: #f44336;
    --theme-secondary: #ff5252;
    --theme-accent: #ff8a80;
    --theme-question: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

/* Base styles */
body {
    background: var(--theme-background);
    min-height: 100vh;
    font-family: 'Nunito', sans-serif;
    display: flex;
    flex-direction: column;
    margin: 0;
}

/* Main content wrapper */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Game container */
.game-container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px var(--theme-shadow);
}

/* Subtraction display */
.subtraction-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 2rem 0;
}

.fingers-cell {
    background: white;
    border: 3px solid var(--theme-accent);
    border-radius: 15px;
    padding: 1.5rem;
    height: 150px;
    min-width: 180px;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--theme-shadow);
    transition: transform 0.3s ease;
}

.fingers-cell:hover {
    transform: translateY(-2px);
}

.finger-image {
    height: 100px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.minus-sign {
    font-size: 3.5rem;
    font-weight: 400;
    color: var(--theme-primary);
    text-shadow: 2px 2px 4px var(--theme-shadow);
}

/* Progress bar */
.progress-info {
    margin-bottom: 2rem;
}

.progress-bar-container {
    margin-bottom: 1rem;
}

.progress-bar {
    height: 30px;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    border-radius: 15px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-timer {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 400;
    color: #333;
}

/* Answer controls */
.answer-controls {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 2rem 0;
}

#answer-input {
    width: 150px;
    font-size: 1.5rem;
    font-weight: 400;
    text-align: center;
    border: 3px solid var(--theme-accent);
    border-radius: 10px 0 0 10px;
    border-right: none;
    height: 50px;
    font-family: 'Fredoka', sans-serif;
    -moz-appearance: textfield;
    -webkit-appearance: none;
}

#answer-input::-webkit-inner-spin-button,
#answer-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#answer-input:focus {
    outline: none;
    box-shadow: 0 0 0 0.125rem rgba(var(--theme-primary), 0.25);
}

#submit-btn {
    font-size: 1.2rem;
    font-weight: 400;
    border-radius: 0 10px 10px 0;
    height: 50px;
    padding: 0 1.5rem;
    background: linear-gradient(45deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    border: none;
    color: white;
    font-family: 'Fredoka', sans-serif;
}

#submit-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

#submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Question styling */
.question-container {
    background: var(--theme-question);
    padding: 2rem;
    padding-bottom: 1rem !important;
    border-radius: 20px;
    margin-bottom: 2rem;
}

.subtitle.is-3 {
    color: var(--theme-primary) !important;
    font-family: 'Fredoka', sans-serif;
    font-weight: 400 !important;
    margin-bottom: 1rem !important;
}

/* Title styling */
.title.is-2 {
    color: var(--theme-primary) !important;
    font-family: 'Fredoka', sans-serif;
    font-weight: 400;
    margin-bottom: 2rem !important;
}

/* Feedback messages */
.notification {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 400;
    border-radius: 15px;
    box-shadow: 0 4px 12px var(--theme-shadow);
}

.notification.is-success {
    background: #d1f2eb;
    color: #00695c;
}

.notification.is-danger {
    background: #ffebee;
    color: #c62828;
}

/* Result screen */
.result-card {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--theme-shadow);
    text-align: center;
}

.result-message {
    font-size: 1.25rem;
    color: var(--theme-primary);
    margin: 2rem 0;
    font-family: 'Fredoka', sans-serif;
}

/* Buttons */
.button {
    font-family: 'Fredoka', sans-serif;
    font-weight: 400;
    transition: all 0.3s ease;
}

.button.is-info {
    background: var(--theme-info);
    color: white;
}

.button.is-primary {
    background: linear-gradient(45deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    color: white;
}

#next-btn-container {
    margin-top: 1.5rem;
}

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

.correct-animation {
    animation: bounce 0.5s ease-in-out;
}

.incorrect-animation {
    animation: shake 0.5s ease-in-out;
}

/* Responsive design */
@media (max-width: 768px) {
    .game-container {
        padding: 1rem;
    }
    
    .title.is-2 {
        font-size: 1.5rem !important;
    }
    
    .subtitle.is-3 {
        font-size: 1.5rem !important;
    }
    
    .subtraction-display {
        gap: 1rem;
    }
    
    .fingers-cell {
        height: 120px;
        min-width: 150px;
        width: auto;
        padding: 1rem;
    }
    
    .finger-image {
        height: 80px;
    }
    
    .minus-sign {
        font-size: 2.5rem;
    }
    
    #answer-input {
        width: 120px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .subtraction-display {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .fingers-cell {
        width: 200px;
        min-height: 100px;
    }
    
    .finger-image {
        height: 80px;
    }
    
    .minus-sign {
        font-size: 2.5rem;
        margin: 0.5rem 0;
    }
    
    #answer-input {
        width: 100px;
    }
}