* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 700px;
    width: 100%;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* File Manager Section */
.file-manager {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 2px solid #e0e0e0;
}

.file-upload-section {
    margin-bottom: 20px;
}

.upload-label {
    display: block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05em;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 10px;
}

.upload-label:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.file-input {
    display: none;
}

.file-help {
    font-size: 0.85em;
    color: #999;
    text-align: center;
    margin: 10px 0;
}

.word-list-section {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.word-list-section label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.word-list-section select {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 0.95em;
    cursor: pointer;
    flex: 1;
    min-width: 200px;
    background: white;
    font-family: inherit;
}

.word-list-section select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.word-list-section .btn.small {
    padding: 8px 15px;
    font-size: 0.85em;
}

.current-list-info {
    font-size: 0.9em;
    color: #666;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
}

.current-list-info.active {
    color: #10b981;
    font-weight: 600;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border-left: 4px solid #667eea;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
}

.stat-label {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-value {
    display: block;
    color: #667eea;
    font-size: 2em;
    font-weight: bold;
}

.stat-value.correct {
    color: #10b981;
}

.stat-value.incorrect {
    color: #ef4444;
}

.stat-value.incorrect.clickable {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.stat-value.incorrect.clickable:hover {
    color: #dc2626;
}

.stat-value.percent {
    color: #f59e0b;
}

.analytics-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin: -10px 0 30px;
}

.analytics-card {
    background: #f8f9ff;
    border: 1px solid #e0e7ff;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.analytics-label,
.analytics-note {
    display: block;
    color: #666;
    font-size: 0.8em;
    font-weight: 600;
}

.analytics-value {
    display: block;
    color: #4f46e5;
    font-size: 1.45em;
    font-weight: bold;
    margin: 5px 0;
}

/* Main Content */
.main-content {
    margin-bottom: 30px;
}

.word-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 20px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.word-instruction {
    color: white;
    font-size: 1.3em;
    margin: 10px 0;
}

.translation {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2em;
    margin-top: 10px;
    font-style: italic;
    min-height: 30px;
}

/* Answer Section */
.answer-section {
    margin-bottom: 20px;
}

#answerInput {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

#answerInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#answerInput:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Feedback */
.feedback {
    min-height: 40px;
    margin-top: 15px;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    border-radius: 10px;
    padding: 10px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.feedback.correct {
    background-color: #d1fae5;
    color: #065f46;
    border: 2px solid #10b981;
}

.feedback.incorrect {
    background-color: #fee2e2;
    color: #7f1d1d;
    border: 2px solid #ef4444;
}

.feedback-word {
    display: block;
    font-size: 1.3em;
    margin: 10px 0 5px 0;
    font-weight: bold;
}

.feedback-translation {
    display: block;
    font-size: 0.95em;
    margin-top: 5px;
}

/* Buttons Section */
.buttons-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #5568d3;
}

.btn-secondary {
    background-color: #f59e0b;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #d97706;
}

.btn-warning {
    background-color: #8b5cf6;
    color: white;
}

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

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
}

.btn-info {
    background-color: #3b82f6;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background-color: #2563eb;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

/* Footer */
.footer {
    text-align: center;
    color: #999;
    font-size: 0.85em;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Error Modal */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.error-modal-content {
    background: white;
    border-radius: 15px;
    padding: 25px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.error-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ef4444;
}

.error-modal-header h2 {
    color: #ef4444;
    font-size: 1.5em;
    margin: 0;
}

.close-error-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.close-error-btn:hover {
    color: #333;
}

.error-list {
    margin-bottom: 20px;
}

.error-item {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.error-item-word {
    font-weight: 600;
    color: #991b1b;
}

.error-item-translation {
    color: #7f1d1d;
    font-size: 0.9em;
}

.error-item-answer {
    color: #991b1b;
    font-size: 0.85em;
    margin-top: 6px;
}

.error-words-column {
    flex: 1;
}

.error-item-count {
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9em;
    font-weight: bold;
    margin-left: 10px;
}

.error-summary {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
}

.error-summary-number {
    font-size: 2em;
    font-weight: bold;
    color: #ef4444;
}

.error-summary-text {
    color: #991b1b;
    font-size: 0.95em;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .header h1 {
        font-size: 2em;
    }

    .file-manager {
        padding: 15px;
        margin-bottom: 20px;
    }

    .upload-label {
        padding: 15px;
        font-size: 0.95em;
    }

    .word-list-section {
        flex-direction: column;
        align-items: stretch;
    }

    .word-list-section label {
        margin-bottom: 5px;
    }

    .word-list-section select {
        min-width: 100%;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat {
        padding: 15px;
    }

    .stat-value {
        font-size: 1.6em;
    }

    .word-display {
        padding: 30px 15px;
        min-height: 120px;
    }

    .word-instruction {
        font-size: 1.1em;
    }

    .translation {
        font-size: 1em;
    }

    .buttons-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.85em;
    }

    #answerInput {
        padding: 12px;
        font-size: 1em;
    }

    .subtitle {
        font-size: 0.95em;
    }

    .footer {
        font-size: 0.75em;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
        border-radius: 15px;
    }

    .header h1 {
        font-size: 1.6em;
        margin-bottom: 8px;
    }

    .file-manager {
        padding: 12px;
        margin-bottom: 15px;
    }

    .upload-label {
        padding: 12px;
        font-size: 0.85em;
    }

    .file-help {
        font-size: 0.75em;
    }

    .word-list-section {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .word-list-section label {
        font-size: 0.9em;
    }

    .word-list-section select {
        min-width: 100%;
        padding: 8px 10px;
        font-size: 0.9em;
    }

    .current-list-info {
        font-size: 0.8em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 20px;
    }

    .stat {
        padding: 10px;
        border-radius: 8px;
    }

    .stat-label {
        font-size: 0.8em;
        margin-bottom: 5px;
    }

    .stat-value {
        font-size: 1.4em;
    }

    .word-display {
        padding: 25px 12px;
        min-height: 100px;
        margin-bottom: 15px;
    }

    .word-instruction {
        font-size: 1em;
    }

    .translation {
        font-size: 0.95em;
    }

    .buttons-section {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .btn {
        padding: 10px;
        font-size: 0.8em;
        width: 100%;
    }

    #answerInput {
        padding: 10px;
        font-size: 0.95em;
    }

    .feedback {
        font-size: 1em;
        padding: 8px;
    }

    .feedback-word {
        font-size: 1.1em;
    }

    .feedback-translation {
        font-size: 0.9em;
    }
}
