/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    color: #4CAF50;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0;
}

.score-display {
    display: flex;
    gap: 20px;
    font-size: 1.2rem;
    font-weight: bold;
}

.score-display span {
    background: #4CAF50;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

.progress-header-btn {
    background: #2196F3;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(33, 150, 243, 0.3);
    transition: all 0.3s ease;
}

.progress-header-btn:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    max-width: 800px;
    animation: fadeIn 0.5s ease-in-out;
}

.screen.active {
    display: block;
}

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

/* Setup Screen */
.setup-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.setup-container h2 {
    color: #4CAF50;
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.setup-section {
    margin-bottom: 30px;
}

.setup-section h3 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

/* Button Styles */
.operation-buttons, .difficulty-buttons, .question-count-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.operation-btn, .difficulty-btn, .count-btn {
    background: linear-gradient(135deg, #FF9A56 0%, #FFAD56 100%);
    border: none;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 154, 86, 0.3);
    min-width: 120px;
    color: white;
    font-family: inherit;
    font-weight: bold;
}

.operation-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
}

.operation-symbol {
    font-size: 2rem;
    margin-bottom: 8px;
}

.operation-name {
    font-size: 1rem;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.difficulty-number {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.difficulty-label {
    font-size: 0.9rem;
}

.count-btn {
    font-size: 1.5rem;
}

.operation-btn:hover, .difficulty-btn:hover, .count-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 154, 86, 0.4);
}

.operation-btn.selected, .difficulty-btn.selected, .count-btn.selected {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.operation-btn.selected:hover, .difficulty-btn.selected:hover, .count-btn.selected:hover {
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

/* Timer Option */
.timer-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    margin: 20px 0;
}

.timer-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Number Focus Options */
.focus-mode-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.focus-mode-btn {
    background: linear-gradient(135deg, #9C27B0 0%, #8E24AA 100%);
    border: none;
    border-radius: 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.3);
    min-width: 160px;
    color: white;
    font-family: inherit;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.focus-mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.4);
}

.focus-mode-btn.selected {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.focus-mode-btn.selected:hover {
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.focus-mode-icon {
    font-size: 1.5rem;
}

.focus-mode-name {
    font-size: 1rem;
}

/* Specific Numbers Section */
.specific-numbers-section {
    background: #F5F5F5;
    border-radius: 15px;
    padding: 20px;
    margin-top: 15px;
    animation: slideDown 0.3s ease-out;
}

.specific-numbers-section.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 20px;
    }
    to {
        opacity: 1;
        max-height: 500px;
        padding: 20px;
    }
}

.focus-instruction {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #666;
    font-weight: bold;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.number-btn {
    background: linear-gradient(135deg, #607D8B 0%, #546E7A 100%);
    border: none;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(96, 125, 139, 0.3);
    color: white;
    font-family: inherit;
    font-weight: bold;
    font-size: 1.2rem;
    min-height: 50px;
}

.number-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(96, 125, 139, 0.4);
}

.number-btn.selected {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 3px 12px rgba(76, 175, 80, 0.4);
}

.number-btn.selected:hover {
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.5);
}

.helper-btn {
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-weight: bold;
    margin: 0 5px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.helper-btn:hover {
    background: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* Start Button */
.start-button {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF5252 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 20px 40px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
    font-family: inherit;
    margin-top: 20px;
}

.start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

/* Quiz Screen */
.quiz-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.quiz-header {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #E0E0E0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 15px;
}

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

.quiz-info {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
}

.timer {
    color: #FF5722;
}

.timer.warning {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Flashcard */
.flashcard {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    padding: 40px;
    margin: 30px 0;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);
}

.problem {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.answer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.multiple-choice-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.choice-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid white;
    border-radius: 15px;
    padding: 20px 15px;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: #333;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.choice-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: #FFD54F;
}

.choice-btn.selected {
    background: #FFD54F;
    border-color: #FFC107;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
}

.choice-btn.correct {
    background: #4CAF50;
    border-color: #45a049;
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.choice-btn.incorrect {
    background: #F44336;
    border-color: #d32f2f;
    color: white;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

.choice-btn:disabled {
    cursor: not-allowed;
}

.choice-btn:disabled:hover {
    transform: none;
}

/* Quiz Controls */
.quiz-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.skip-btn, .quit-btn {
    background: #757575;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.skip-btn:hover, .quit-btn:hover {
    background: #616161;
    transform: translateY(-2px);
}

/* Feedback */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    text-align: center;
    animation: bounceIn 0.5s ease-out;
}

.feedback.hidden {
    display: none;
}

.feedback-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.feedback-text {
    font-size: 2rem;
    font-weight: bold;
}

.feedback-icon {
    font-size: 3rem;
}

.feedback.correct .feedback-text {
    color: #4CAF50;
}

.feedback.incorrect .feedback-text {
    color: #F44336;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
    70% {
        transform: translate(-50%, -50%) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Results Screen */
.results-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.results-container h2 {
    color: #4CAF50;
    font-size: 2.5rem;
    margin-bottom: 30px;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 1rem;
    color: #666;
    font-weight: bold;
}

.achievement {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin: 30px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.3);
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-text {
    font-size: 1.5rem;
    font-weight: bold;
}

.results-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.review-btn, .play-again-btn, .progress-btn, .back-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.review-btn {
    background: #FF9800;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.play-again-btn {
    background: #4CAF50;
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.progress-btn, .back-btn {
    background: #2196F3;
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
}

.review-btn:hover, .play-again-btn:hover, .progress-btn:hover, .back-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* Review Screen */
.review-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.review-container h2 {
    color: #FF9800;
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-align: center;
}

.review-content {
    overflow-x: auto;
    margin-bottom: 30px;
}

.review-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.review-table th {
    background: #4CAF50;
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: bold;
    font-size: 1.1rem;
}

.review-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.review-table tr:last-child td {
    border-bottom: none;
}

.correct-row {
    background: rgba(76, 175, 80, 0.05);
}

.incorrect-row {
    background: rgba(244, 67, 54, 0.05);
}

.correct-row:hover {
    background: rgba(76, 175, 80, 0.1);
}

.incorrect-row:hover {
    background: rgba(244, 67, 54, 0.1);
}

.question-cell {
    font-weight: bold;
    font-size: 1.1rem;
    color: #333;
}

.user-answer-cell {
    font-size: 1rem;
    color: #555;
}

.no-answer {
    color: #999;
    font-style: italic;
}

.correct-answer-cell {
    font-weight: bold;
    color: #4CAF50;
    font-size: 1.1rem;
}

.result-cell {
    text-align: center;
}

.result-correct {
    color: #4CAF50;
    font-weight: bold;
}

.result-incorrect {
    color: #F44336;
    font-weight: bold;
}

.review-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Progress Screen */
.progress-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.progress-container h2 {
    color: #4CAF50;
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-align: center;
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.progress-card {
    background: #F5F5F5;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.progress-card h3 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
}

.sessions-list {
    max-height: 300px;
    overflow-y: auto;
}

.session-item {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.session-date {
    font-weight: bold;
    color: #666;
}

.session-score {
    background: #4CAF50;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: bold;
}

.overall-stats {
    background: white;
    border-radius: 10px;
    padding: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #E0E0E0;
    font-size: 1.1rem;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:last-child {
    font-weight: bold;
    color: #4CAF50;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .score-display {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .progress-header-btn {
        font-size: 1rem;
        padding: 6px 12px;
    }
    
    .setup-container, .quiz-container, .results-container, .review-container, .progress-container {
        padding: 20px;
        margin: 10px;
    }
    
    .operation-buttons, .difficulty-buttons, .focus-mode-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .operation-btn, .difficulty-btn, .focus-mode-btn {
        min-width: 200px;
    }
    
    .number-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .number-btn {
        padding: 12px;
        font-size: 1rem;
        min-height: 45px;
    }
    
    .problem {
        font-size: 2.5rem;
    }
    
    .multiple-choice-options {
        grid-template-columns: 1fr;
        max-width: 300px;
    }

    .choice-btn {
        font-size: 1.2rem;
        padding: 15px 10px;
        min-height: 60px;
    }
    
    .results-stats {
        flex-direction: column;
        gap: 20px;
    }
    
    .results-actions, .review-actions {
        flex-direction: column;
    }

    .review-table {
        font-size: 0.9rem;
    }

    .review-table th,
    .review-table td {
        padding: 8px 6px;
    }

    .review-container h2 {
        font-size: 2rem;
    }
    
    .progress-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }
    
    .setup-container, .quiz-container, .results-container, .review-container, .progress-container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .score-display {
        font-size: 1rem;
        gap: 10px;
    }
    
    .problem {
        font-size: 2rem;
    }
}