* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
}

.game-container {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    min-width: 350px;
    max-width: 500px;
    width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.score {
    font-size: 1.5rem;
    font-weight: 600;
}

#score {
    color: #ffd93d;
}

.streak {
    font-size: 1.25rem;
    font-weight: 500;
}

.mode-select {
    text-align: center;
}

.mode-select h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.mode-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn[data-mode="addition"] {
    background: #2ecc71;
    color: white;
}

.mode-btn[data-mode="subtraction"] {
    background: #3498db;
    color: white;
}

.mode-btn[data-mode="multiplication"] {
    background: #e74c3c;
    color: white;
}

.mode-btn[data-mode="mixed"] {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.mode-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.game-area {
    text-align: center;
}

.problem {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 16px;
}

#operator {
    margin: 0 0.5rem;
    color: #ffd93d;
}

.feedback {
    font-size: 1.5rem;
    font-weight: 600;
    min-height: 2.5rem;
    margin-bottom: 1rem;
}

.feedback.correct {
    color: #2ecc71;
}

.feedback.wrong {
    color: #e74c3c;
}

.answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.answer-btn {
    padding: 1.25rem;
    font-size: 1.75rem;
    font-weight: 700;
    border: none;
    border-radius: 16px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.15s;
}

.answer-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.answer-btn:active {
    transform: scale(0.98);
}

.answer-btn.correct {
    background: #2ecc71;
    color: white;
    animation: pulse 0.5s;
}

.answer-btn.wrong {
    background: #e74c3c;
    color: white;
    animation: shake 0.5s;
}

.back-to-menu {
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.back-to-menu:hover {
    background: rgba(255, 255, 255, 0.3);
}

.back-link {
    margin-top: 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    color: #fff;
}

/* Ten-Frame Styles */
.ten-frame-container {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.ten-frame-explanation {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.ten-frames {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ten-frame {
    border: 4px solid #333;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.tf-row {
    display: flex;
}

.tf-cell {
    width: 50px;
    height: 50px;
    border: 2px solid #666;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    position: relative;
}

.tf-cell .dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    position: absolute;
    transition: all 0.3s ease;
}

/* First operand color (blue) */
.tf-cell .dot.first {
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 3px 8px rgba(52, 152, 219, 0.4);
}

/* Second operand color (orange) */
.tf-cell .dot.second {
    background: linear-gradient(135deg, #e67e22, #d35400);
    box-shadow: 0 3px 8px rgba(230, 126, 34, 0.4);
}

/* Result/answer color (green) */
.tf-cell .dot.result {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    box-shadow: 0 3px 8px rgba(46, 204, 113, 0.4);
}

/* Removed/crossed out (for subtraction) */
.tf-cell .dot.removed {
    opacity: 0.25;
    transform: scale(0.7);
}

.tf-cell .dot.removed::after {
    content: '×';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: bold;
    color: #c0392b;
}

/* Group indicator for multiplication */
.tf-cell .dot.group-1 { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.tf-cell .dot.group-2 { background: linear-gradient(135deg, #1abc9c, #16a085); }
.tf-cell .dot.group-3 { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.tf-cell .dot.group-4 { background: linear-gradient(135deg, #f39c12, #d68910); }
.tf-cell .dot.group-5 { background: linear-gradient(135deg, #3498db, #2980b9); }

/* Animation for dots appearing */
@keyframes dotAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tf-cell .dot.animate {
    animation: dotAppear 0.3s ease-out forwards;
}

/* Animation for dots being removed */
@keyframes dotRemove {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.7);
        opacity: 0.25;
    }
}

.tf-cell .dot.animate-remove {
    animation: dotRemove 0.4s ease-out forwards;
}

.next-btn {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.next-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

@keyframes celebrate {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    75% { transform: scale(1.2) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

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