/* base/variables.css */
:root {
  /* Colors */
  --color-primary: #3B82F6;
  --color-secondary: #6B7280;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-info: #3B82F6;
  
  /* Math operation colors */
  --color-addition: #10B981;
  --color-subtraction: #F59E0B;
  --color-multiplication: #EF4444;
  --color-division: #8B5CF6;
  --color-supermode: linear-gradient(45deg, #F59E0B, #EF4444, #8B5CF6);
  
  /* Block colors */
  --color-block-green: #4ADE80;
  --color-block-yellow: #FBBF24;
  --color-block-red: #F87171;
  --color-block-blue: #60A5FA;
  --color-block-purple: #A78BFA;
  
  /* Background colors */
  --bg-primary: #F9FAFB;
  --bg-secondary: #FFFFFF;
  --bg-success: #ECFDF5;
  --bg-warning: #FFFBEB;
  --bg-error: #FEF2F2;
  
  /* Text colors */
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 300ms ease-in-out;
  --transition-slow: 500ms ease-in-out;
  
  /* Font sizes */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-base: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;
  --font-5xl: 3rem;
  --font-6xl: 3.75rem;
  
  /* Animation durations */
  --animation-fast: 200ms;
  --animation-normal: 500ms;
  --animation-slow: 800ms;
  
  /* Z-index layers */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* base/typography.css */


body {
    font-family: 'Nunito', sans-serif;
    font-size: var(--font-base);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h1 {
    font-size: var(--font-6xl);
    font-weight: 900;
}

h2 {
    font-size: var(--font-4xl);
    font-weight: 700;
}

h3 {
    font-size: var(--font-3xl);
    font-weight: 700;
}

h4 {
    font-size: var(--font-2xl);
    font-weight: 700;
}

h5 {
    font-size: var(--font-xl);
    font-weight: 700;
}

h6 {
    font-size: var(--font-lg);
    font-weight: 700;
}

p {
    margin-bottom: var(--spacing-md);
}

.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-base { font-size: var(--font-base); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.text-2xl { font-size: var(--font-2xl); }
.text-3xl { font-size: var(--font-3xl); }
.text-4xl { font-size: var(--font-4xl); }
.text-5xl { font-size: var(--font-5xl); }
.text-6xl { font-size: var(--font-6xl); }

.font-normal { font-weight: 400; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Number display styles */
.number-display {
    font-size: var(--font-5xl);
    font-weight: 900;
    line-height: 1;
    text-align: center;
}

.operator {
    font-size: 4rem;
    font-weight: 900;
    color: var(--color-primary);
    line-height: 1;
}

/* Large number display for numbers > 99 */
.large-number-display {
    text-align: center;
    padding: var(--spacing-md);
}

.large-number-display .number-value {
    font-size: var(--font-4xl);
    font-weight: 900;
    margin-bottom: var(--spacing-xs);
}

.large-number-display .number-label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    font-weight: 400;
}

/* Score and level displays */
.score-display {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--color-primary);
}

.level-display {
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--color-division);
}

.streak-display {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--color-success);
}

/* Operation-specific text colors */
.text-addition { color: var(--color-addition); }
.text-subtraction { color: var(--color-subtraction); }
.text-multiplication { color: var(--color-multiplication); }
.text-division { color: var(--color-division); }

/* Achievement text styles */
.achievement-title {
    font-size: var(--font-2xl);
    font-weight: 900;
    margin-bottom: var(--spacing-sm);
}

.achievement-description {
    font-size: var(--font-base);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* Responsive typography */
@media (max-width: 768px) {
    h1 {
        font-size: var(--font-4xl);
    }
    
    .number-display {
        font-size: var(--font-4xl);
    }
    
    .operator {
        font-size: 3rem;
    }
    
    .large-number-display .number-value {
        font-size: var(--font-3xl);
    }
}

/* components/blocks.css */
.block {
    width: 2rem;
    height: 2rem;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    transition: all var(--animation-normal) ease-in-out;
    margin: 1px;
    display: inline-block;
    position: relative;
}

.block:hover {
    transform: scale(1.05);
    border-color: rgba(0, 0, 0, 0.4);
}

.ten-stack {
    display: flex;
    flex-direction: column-reverse;
    margin-right: var(--spacing-sm);
    align-items: center;
}

.block-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    min-height: 220px;
    padding: var(--spacing-md);
    gap: var(--spacing-xs);
}

/* Block colors */
.bg-green-400 {
    background-color: var(--color-block-green);
    border-color: #22C55E;
}

.bg-yellow-400 {
    background-color: var(--color-block-yellow);
    border-color: #F59E0B;
}

.bg-red-400 {
    background-color: var(--color-block-red);
    border-color: #EF4444;
}

.bg-blue-400 {
    background-color: var(--color-block-blue);
    border-color: #3B82F6;
}

.bg-purple-400 {
    background-color: var(--color-block-purple);
    border-color: #8B5CF6;
}

/* Animation states */
.block-enter {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

.block-enter-active {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    transition: all var(--animation-normal) ease-out;
}

.block-exit {
    opacity: 1;
    transform: scale(1);
}

.block-exit-active {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    transition: all var(--animation-normal) ease-in;
}

/* Special grouping containers for multiplication and division */
.multiplication-group {
    display: inline-block;
    margin: 0 var(--spacing-xs);
    padding: var(--spacing-xs);
    border: 2px dashed #D1D5DB;
    border-radius: var(--radius-md);
    background-color: rgba(255, 255, 255, 0.5);
    transition: all var(--transition-normal);
}

.multiplication-group:hover {
    border-color: #9CA3AF;
    background-color: rgba(255, 255, 255, 0.8);
}

.division-group {
    display: inline-block;
    margin: 0 var(--spacing-xs);
    padding: var(--spacing-xs);
    border: 2px solid #D1D5DB;
    border-radius: var(--radius-md);
    background-color: rgba(255, 255, 255, 0.9);
    min-height: 3rem;
    min-width: 3rem;
    text-align: center;
    transition: all var(--transition-normal);
}

.division-group .group-label {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
}

/* Block animation effects */
@keyframes blockPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes blockBounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

@keyframes blockSlideIn {
    from {
        transform: translateX(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.block.animate-pulse {
    animation: blockPulse 1s ease-in-out infinite;
}

.block.animate-bounce {
    animation: blockBounce 1s ease-in-out;
}

.block.animate-slide-in {
    animation: blockSlideIn var(--animation-normal) ease-out;
}

/* Highlighting effects for correct answers */
.block.highlight-correct {
    border-color: var(--color-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    animation: blockPulse 0.5s ease-in-out 2;
}

.block.highlight-incorrect {
    border-color: var(--color-error);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* Responsive block sizing */
@media (max-width: 768px) {
    .block {
        width: 1.5rem;
        height: 1.5rem;
    }
    
    .block-container {
        min-height: 180px;
        padding: var(--spacing-sm);
    }
    
    .ten-stack {
        margin-right: var(--spacing-xs);
    }
}

@media (min-width: 1024px) {
    .block {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .block-container {
        min-height: 280px;
        padding: var(--spacing-lg);
    }
}

/* Detective Mode - Mystery Box Styles */
.mystery-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 4rem;
    min-height: 4rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #fef3c7, #fed7aa);
    border: 3px dashed #f59e0b;
    position: relative;
    animation: mysteryBoxPulse 2s ease-in-out infinite;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.mystery-content {
    text-align: center;
    color: #92400e;
}

.mystery-symbol {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    animation: mysteryQuestionMark 1.5s ease-in-out infinite;
}

.mystery-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Detective Mode Animations */
@keyframes mysteryBoxPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
    }
}

@keyframes mysteryQuestionMark {
    0%, 100% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg) scale(1.1);
    }
}

@keyframes detective-reveal {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

@keyframes case-closed-popup {
    0% {
        transform: translateX(-50%) translateY(20px) scale(0);
        opacity: 0;
    }
    20% {
        transform: translateX(-50%) translateY(-20px) scale(1.2);
        opacity: 1;
    }
    40% {
        transform: translateX(-50%) translateY(-25px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(-30px) scale(1);
        opacity: 0;
    }
}

.case-closed-effect {
    animation: case-closed-popup 2s ease-out forwards;
}

/* Detective Mode Colors */
.bg-yellow-200 {
    background: linear-gradient(135deg, #fef3c7, #fed7aa);
}

/* iPad optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .block {
        width: 3rem;
        height: 3rem;
    }
    
    .block-container {
        min-height: 320px;
        padding: var(--spacing-lg);
    }
    
    .ten-stack {
        margin-right: var(--spacing-md);
    }
    
    .multiplication-group,
    .division-group {
        margin: 0 var(--spacing-sm);
        padding: var(--spacing-sm);
    }
    
    .mystery-box {
        min-width: 5rem;
        min-height: 5rem;
    }
    
    .mystery-symbol {
        font-size: 2.5rem;
    }
}

/* Mobile Mystery Box adjustments */
@media (max-width: 768px) {
    .mystery-box {
        min-width: 3rem;
        min-height: 3rem;
    }
    
    .mystery-symbol {
        font-size: 1.5rem;
    }
    
    .mystery-label {
        font-size: 0.625rem;
    }
}

/* components/buttons.css */
/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md) var(--spacing-xl);
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: var(--font-lg);
    line-height: 1;
    min-height: 48px; /* Touch target size */
    position: relative;
    overflow: hidden;
}

.btn:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

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

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

/* Button sizes */
.btn-sm {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-sm);
    min-height: 40px;
}

.btn-md {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-base);
    min-height: 44px;
}

.btn-lg {
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: var(--font-xl);
    min-height: 56px;
}

.btn-xl {
    padding: var(--spacing-xl) var(--spacing-2xl);
    font-size: var(--font-2xl);
    min-height: 64px;
}

/* Button variants */
.btn-primary {
    background-color: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    background-color: #2563EB;
}

.btn-success {
    background-color: var(--color-success);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
}

.btn-warning {
    background-color: var(--color-warning);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-warning:hover:not(:disabled) {
    background-color: #D97706;
}

.btn-error {
    background-color: var(--color-error);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-error:hover:not(:disabled) {
    background-color: #DC2626;
}

.btn-secondary {
    background-color: #F3F4F6;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #E5E7EB;
}

/* Operation-specific buttons */
.btn-addition {
    background-color: var(--color-addition);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-addition:hover:not(:disabled) {
    background-color: #059669;
    transform: scale(1.05);
}

.btn-subtraction {
    background-color: var(--color-subtraction);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-subtraction:hover:not(:disabled) {
    background-color: #D97706;
    transform: scale(1.05);
}

.btn-multiplication {
    background-color: var(--color-multiplication);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-multiplication:hover:not(:disabled) {
    background-color: #DC2626;
    transform: scale(1.05);
}

.btn-division {
    background-color: var(--color-division);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-division:hover:not(:disabled) {
    background-color: #7C3AED;
    transform: scale(1.05);
}

.btn-supermode {
    background: linear-gradient(45deg, var(--color-subtraction), var(--color-multiplication), var(--color-division));
    color: white;
    box-shadow: var(--shadow-md);
    position: relative;
}

.btn-supermode:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
}

.btn-supermode::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-supermode:hover::before {
    left: 100%;
}

/* Outline buttons */
.btn-outline {
    background-color: transparent;
    border: 2px solid currentColor;
    box-shadow: none;
}

.btn-outline-primary {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline-primary:hover:not(:disabled) {
    background-color: var(--color-primary);
    color: white;
}

/* Ghost buttons */
.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

/* Full width buttons */
.btn-full {
    width: 100%;
}

/* Icon buttons */
.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.btn-sm {
    width: 40px;
    height: 40px;
}

.btn-icon.btn-lg {
    width: 56px;
    height: 56px;
}

/* Floating action button */
.btn-fab {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    box-shadow: var(--shadow-xl);
    z-index: var(--z-fixed);
}

/* Button animations */
@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.btn.animate-pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.btn-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.btn-shine:hover::after {
    left: 100%;
}

/* Loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: buttonSpin 1s linear infinite;
}

@keyframes buttonSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Button groups */
.btn-group {
    display: inline-flex;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.btn-group .btn {
    border-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    margin: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: var(--radius-xl);
    border-bottom-left-radius: var(--radius-xl);
}

.btn-group .btn:last-child {
    border-top-right-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
    border-right: none;
}

/* Responsive button adjustments */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: var(--font-base);
    }
    
    .btn-lg {
        min-height: 52px;
        padding: var(--spacing-lg) var(--spacing-xl);
        font-size: var(--font-lg);
    }
    
    .btn-xl {
        min-height: 56px;
        padding: var(--spacing-lg) var(--spacing-xl);
        font-size: var(--font-xl);
    }
}

/* iPad optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .btn {
        min-height: 52px;
        padding: var(--spacing-lg) var(--spacing-2xl);
        font-size: var(--font-lg);
    }
    
    .btn-lg {
        min-height: 60px;
        padding: var(--spacing-xl) var(--spacing-2xl);
        font-size: var(--font-xl);
    }
    
    .btn-xl {
        min-height: 68px;
        padding: var(--spacing-xl) var(--spacing-2xl);
        font-size: var(--font-2xl);
    }
    
    .btn-icon {
        width: 52px;
        height: 52px;
    }
    
    .btn-fab {
        width: 68px;
        height: 68px;
    }
}

/* components/modals.css */
/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Modal container */
.modal {
    background-color: white;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform var(--transition-normal);
    max-height: 90vh;
    overflow: auto;
    position: relative;
    width: 100%;
    max-width: 32rem;
}

.modal.show {
    transform: scale(1);
}

/* Modal sizes */
.modal-sm {
    max-width: 20rem;
}

.modal-md {
    max-width: 32rem;
}

.modal-lg {
    max-width: 48rem;
}

.modal-xl {
    max-width: 64rem;
}

.modal-full {
    max-width: none;
    width: 95vw;
    height: 95vh;
    max-height: none;
}

/* Modal header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xl);
    border-bottom: 1px solid #E5E7EB;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.modal-title {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-3xl);
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-secondary);
    background-color: #F3F4F6;
}

/* Modal body */
.modal-body {
    padding: var(--spacing-xl);
    color: var(--text-primary);
    line-height: 1.6;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

/* Modal footer */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    border-top: 1px solid #E5E7EB;
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    flex-wrap: wrap;
}

.modal-footer .btn {
    min-width: 100px;
}

/* Modal types */
.modal-success {
    background-color: var(--bg-success);
}

.modal-success .modal-title {
    color: var(--color-success);
}

.modal-error {
    background-color: var(--bg-error);
}

.modal-error .modal-title {
    color: var(--color-error);
}

.modal-warning {
    background-color: var(--bg-warning);
}

.modal-warning .modal-title {
    color: var(--color-warning);
}

.modal-info {
    background-color: var(--bg-primary);
}

.modal-info .modal-title {
    color: var(--color-info);
}

/* Feedback modal specific styles */
.feedback-modal {
    text-align: center;
}

.feedback-modal .modal-title {
    font-size: var(--font-5xl);
    font-weight: 900;
    margin-bottom: var(--spacing-md);
}

.feedback-modal .modal-body {
    padding: var(--spacing-2xl);
}

.feedback-modal .feedback-text {
    font-size: var(--font-xl);
    margin-bottom: var(--spacing-xl);
}

/* Explanation container */
.explanation-container {
    background-color: #F9FAFB;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    margin: var(--spacing-md) 0;
    text-align: left;
    font-size: var(--font-base);
    line-height: 1.6;
}

.explanation-container.hidden {
    display: none;
}

.explanation-text {
    color: var(--text-primary);
}

.explanation-text strong {
    color: var(--color-primary);
    font-weight: 700;
}

.explanation-text em {
    color: var(--color-success);
    font-style: normal;
    font-weight: 600;
}

/* Loading spinner */
.loader {
    border: 4px solid #F3F4F6;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: var(--spacing-md) auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader.hidden {
    display: none;
}

/* Achievement modal styles */
.achievement-modal {
    text-align: center;
    background: linear-gradient(135deg, #FEF3C7 0%, #F9FAFB 100%);
}

.achievement-modal .modal-title {
    color: #D97706;
    margin-bottom: var(--spacing-lg);
}

.achievement-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    display: block;
}

.achievement-name {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.achievement-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.achievement-points {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--color-primary);
}

/* Settings modal styles */
.settings-modal .modal-body {
    padding: var(--spacing-2xl);
}

.setting-group {
    margin-bottom: var(--spacing-xl);
}

.setting-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.setting-description {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* Responsive modal adjustments */
@media (max-width: 768px) {
    .modal-backdrop {
        padding: var(--spacing-sm);
    }
    
    .modal {
        max-width: none;
        width: 100%;
        max-height: 85vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--spacing-lg);
    }
    
    .modal-title {
        font-size: var(--font-xl);
    }
    
    .feedback-modal .modal-title {
        font-size: var(--font-4xl);
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* iPad optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .modal {
        max-width: 90vw;
    }
    
    .modal-lg {
        max-width: 85vw;
    }
    
    .modal-xl {
        max-width: 90vw;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--spacing-2xl);
    }
    
    .feedback-modal .modal-title {
        font-size: var(--font-6xl);
    }
    
    .achievement-icon {
        font-size: 6rem;
    }
}

/* Animation for modal entrance */
@keyframes modalSlideIn {
    from {
        transform: translateY(-50px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

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

.modal.animate-in {
    animation: modalSlideIn var(--transition-normal) ease-out;
}

.modal.animate-out {
    animation: modalSlideOut var(--transition-normal) ease-in;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Focus trap styles */
.modal-focus-trap {
    position: absolute;
    top: -1px;
    left: -1px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* main.css */







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

html {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Nunito', sans-serif;
    line-height: 1.6;
}

/* Main game container */
#game-container {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    text-align: center;
}

/* Game title */
.game-title {
    font-size: var(--font-6xl);
    font-weight: 900;
    color: var(--color-primary);
    margin-bottom: var(--spacing-2xl);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* Welcome section */
.welcome-section {
    width: 100%;
    padding: var(--spacing-xl);
    background-color: white;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--spacing-xl);
}

.welcome-title {
    font-size: var(--font-2xl);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.welcome-text {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    font-size: var(--font-lg);
}

/* Operation buttons grid */
.operation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.operation-button {
    padding: var(--spacing-lg) var(--spacing-xl);
    font-size: var(--font-2xl);
    font-weight: 700;
    border-radius: var(--radius-xl);
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.operation-button:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
}

.operation-button:active {
    transform: scale(0.98);
}

/* Game area */
#game-area {
    width: 100%;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    padding: 0 var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.game-content {
    background-color: white;
    padding: var(--spacing-xl) var(--spacing-2xl);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
}

/* Problem display */
.problem-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.problem-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.number-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

/* Answer input */
.answer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-2xl);
}

.answer-input {
    font-size: var(--font-4xl);
    font-weight: 700;
    text-align: center;
    width: 12rem;
    padding: var(--spacing-md);
    border: 4px solid #D1D5DB;
    border-radius: var(--radius-lg);
    background-color: white;
    transition: border-color var(--transition-fast);
}

.answer-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.answer-input::placeholder {
    color: var(--text-muted);
}

/* Score display */
.score-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.score-label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.score-value {
    font-size: var(--font-xl);
    font-weight: 700;
}

/* Player stats */
.player-stats {
    background-color: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-md);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.visible {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.fade-in {
    animation: fadeIn var(--animation-normal) ease-out;
}

.fade-out {
    animation: fadeOut var(--animation-normal) ease-in;
}

/* Score change effects */
.score-change-effect {
    position: absolute;
    font-weight: 700;
    font-size: var(--font-lg);
    color: var(--color-success);
    pointer-events: none;
    z-index: 10;
    animation: scoreChangeFloat 1s ease-out forwards;
}

@keyframes scoreChangeFloat {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px);
    }
}

/* Achievement popup */
.achievement-score-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: var(--z-modal);
    animation: achievementPopup 2.5s ease-out forwards;
}

@keyframes achievementPopup {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
    }
    
    .game-title {
        font-size: var(--font-4xl);
        margin-bottom: var(--spacing-lg);
    }
    
    .welcome-section {
        padding: var(--spacing-lg);
    }
    
    .game-content {
        padding: var(--spacing-lg);
    }
    
    .problem-row {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .answer-input {
        width: 10rem;
        font-size: var(--font-3xl);
    }
    
    .operation-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .game-header {
        flex-direction: column;
        text-align: center;
    }
    
    .score-section {
        justify-content: center;
    }
}

/* iPad optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .game-title {
        font-size: var(--font-6xl);
    }
    
    .operation-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg);
    }
    
    .operation-button {
        min-height: 100px;
        font-size: var(--font-3xl);
    }
    
    .answer-input {
        width: 14rem;
        font-size: var(--font-5xl);
        padding: var(--spacing-lg);
    }
    
    .number-display {
        font-size: var(--font-6xl);
    }
    
    .operator {
        font-size: 6rem;
    }
}

/* Large desktop optimizations */
@media (min-width: 1024px) {
    .operation-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .problem-row {
        gap: var(--spacing-2xl);
    }
}

/* Print styles */
@media print {
    body {
        background-color: white;
        color: black;
    }
    
    .btn,
    .modal-backdrop,
    .score-change-effect,
    .achievement-score-popup {
        display: none !important;
    }
}

/* Utility classes */
.grayscale {
    filter: grayscale(100%);
}

.min-w-80 {
    min-width: 20rem;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .block {
        border-width: 3px;
        border-color: black;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .answer-input {
        border-width: 3px;
        border-color: black;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .block {
        transition: none;
    }
    
    .btn {
        transition: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* components/badges.css */
/* Badge System Styles */

/* Badge Popup */
.badge-popup {
    background: radial-gradient(circle, #fff 0%, #f8f9fa 100%);
    border: 3px solid #ffd700;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: badgeAppear 0.8s ease-out;
    padding: 20px;
}

.badge-image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.badge-image {
    width: 120px;
    height: 120px;
    animation: badgePulse 1s ease-in-out infinite alternate;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    border-radius: 50%;
}

/* Badge Animations */
@keyframes badgeAppear {
    0% { 
        transform: scale(0) rotate(-180deg); 
        opacity: 0; 
    }
    50% { 
        transform: scale(1.2) rotate(-10deg); 
        opacity: 0.8; 
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1; 
    }
}

@keyframes badgePulse {
    0% { 
        transform: scale(1); 
    }
    100% { 
        transform: scale(1.05); 
    }
}

/* Streak Counter */
.streak-counter {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
}

.streak-counter:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.streak-update {
    animation: streakUpdate 0.3s ease-in-out;
}

@keyframes streakUpdate {
    0% { 
        transform: scale(1); 
    }
    50% { 
        transform: scale(1.1); 
        background: linear-gradient(45deg, #66BB6A, #4CAF50);
    }
    100% { 
        transform: scale(1); 
    }
}

/* Badge Modal Enhancements */
.modal.badge-earned {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modal.badge-earned .modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .streak-counter {
        top: 60px;
        right: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .badge-image {
        width: 100px;
        height: 100px;
    }

    .badge-popup {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .streak-counter {
        top: 50px;
        right: 5px;
        padding: 4px 8px;
        font-size: 11px;
    }

    .badge-image {
        width: 80px;
        height: 80px;
    }
}

/* Progress Bar for Next Badge */
.badge-progress {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.badge-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Badge Collection Display */
.badge-collection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    padding: 20px;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    transition: transform 0.2s ease;
}

.badge-item:hover {
    transform: translateY(-2px);
}

.badge-item.earned {
    background: linear-gradient(135deg, #ffd700, #ffed4a);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.badge-item.not-earned {
    background: #f5f5f5;
    opacity: 0.6;
}

.badge-item img {
    width: 50px;
    height: 50px;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.badge-item.not-earned img {
    filter: grayscale(100%) opacity(0.5);
}

.badge-item .badge-name {
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    color: #333;
}

.badge-item .badge-count {
    font-size: 10px;
    color: #666;
}

/* Next Badge Target */
.next-badge-target {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
    text-align: center;
}

.next-badge-target h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.next-badge-target p {
    margin: 5px 0;
    font-size: 14px;
}

.target-progress {
    background: rgba(255, 255, 255, 0.2);
    height: 6px;
    border-radius: 3px;
    margin: 10px 0;
    overflow: hidden;
}

.target-progress-fill {
    height: 100%;
    background: white;
    border-radius: 3px;
    transition: width 0.3s ease;
}

