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

body {
    font-family: 'Comic Neue', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    animation: slideInDown 0.6s ease-out;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

header p {
    font-size: 1.3rem;
    color: #666;
}

/* Vocabulary selector */
.vocab-selector {
    margin-bottom: 30px;
}

.selector-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.9);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.selector-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4a5568;
}

.vocab-select {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-width: 250px;
}

.vocab-select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.3);
}

.file-upload-container {
    position: relative;
}

.file-upload-label {
    display: inline-block;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.file-upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Navigation */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.mode-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: 3px solid #764ba2;
    background: rgba(255, 255, 255, 0.9);
    color: #764ba2;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.mode-btn.active {
    background: #764ba2;
    color: white;
    transform: translateY(-2px);
}

.mode-btn:focus {
    outline: 2px solid #4a5568;
    outline-offset: 2px;
}

/* Question section */
.question-section {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.question-section h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.question-section p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 0;
}

/* Sections */
.section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.6s ease-out;
}

.section.hidden {
    display: none;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.toggle-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.toggle-label {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 20px;
    transition: all 0.3s ease;
    background: rgba(118, 75, 162, 0.1);
}

.toggle-label:hover {
    background: rgba(118, 75, 162, 0.2);
    transform: translateY(-1px);
}

.toggle-label:focus-within {
    outline: 2px solid #4a5568;
    outline-offset: 2px;
    background: rgba(118, 75, 162, 0.2);
}

.toggle-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #764ba2;
    border-radius: 50%;
    margin-right: 10px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-label input[type="radio"]:checked + .radio-custom {
    background: #764ba2;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.5);
}

.toggle-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Score container */
.score-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.score-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

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

.score-value.correct {
    color: #48bb78;
}

.score-value.incorrect {
    color: #f56565;
}

/* Flashcard */
.flashcard-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    perspective: 1000px;
}

.flashcard {
    width: 100%;
    max-width: 500px;
    height: 300px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.card-back {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    transform: rotateY(180deg);
}

/* Ensure screen readers respect the visual flip state */
.flashcard:not(.flipped) .card-back {
    visibility: hidden;
}

.flashcard.flipped .card-front {
    visibility: hidden;
}

.card-text {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    hyphens: auto;
}

.card-meaning {
    margin-top: 20px;
    font-size: 1.2rem;
    text-align: center;
    opacity: 0.9;
}

/* Input container */
.input-container {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: stretch;
}

#user-answer {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.2rem;
    border: 3px solid #e2e8f0;
    border-radius: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

#user-answer:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.3);
    transform: translateY(-1px);
}

#user-answer:disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
    border-color: #e2e8f0;
}

/* Buttons */
.btn {
    padding: 16px 32px;
    font-size: 1.3rem;
    font-weight: 600;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.btn:focus {
    outline: 2px solid #4a5568;
    outline-offset: 2px;
}

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

.btn:disabled:hover {
    transform: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-accent {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
}

/* Feedback */
.feedback-container {
    margin-bottom: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback {
    padding: 15px 25px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    animation: fadeInScale 0.5s ease-out;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.feedback.hidden {
    display: none;
}

.feedback.correct {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.feedback.incorrect {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
}

.feedback.partial {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Study mode */
.study-header {
    margin-bottom: 30px;
}

.study-header h2 {
    font-size: 2.5rem;
    color: #4a5568;
    margin-bottom: 20px;
    text-align: center;
}

.study-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    min-width: 250px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.3);
}

.study-table-container {
    overflow-x: auto;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.study-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.1rem;
    background: white;
}

.study-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: left;
    font-weight: 700;
    font-size: 1.2rem;
}

.study-table th:first-child {
    border-top-left-radius: 15px;
}

.study-table th:last-child {
    border-top-right-radius: 15px;
}

.study-table td {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.study-table tr:hover td {
    background: rgba(118, 75, 162, 0.05);
}

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

.study-table tr:last-child td:first-child {
    border-bottom-left-radius: 15px;
}

.study-table tr:last-child td:last-child {
    border-bottom-right-radius: 15px;
}

/* Progress bar */
.progress-bar-container {
    margin-top: 30px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

/* Celebration */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.celebration.hidden {
    display: none;
}

.celebration-content {
    background: white;
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: celebrationBounce 0.8s ease-out;
    position: relative;
    overflow: hidden;
}

.celebration-content h2 {
    font-size: 3rem;
    color: #4a5568;
    margin-bottom: 20px;
}

.celebration-content p {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 30px;
}

.emoji-rain {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    height: 20px;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.8), transparent);
    animation: shimmer 2s infinite;
}

/* Screen reader only */
.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 slideInDown {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

@keyframes fadeInScale {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes celebrationBounce {
    0% {
        transform: scale(0.3) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: 200px 0;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2.2rem;
    }

    header p {
        font-size: 1.1rem;
    }

    .selector-container {
        flex-direction: column;
        text-align: center;
    }

    .vocab-select {
        min-width: auto;
        width: 100%;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .toggle-container {
        justify-content: center;
    }

    .score-container {
        justify-content: center;
    }

    .card-text {
        font-size: 2rem;
    }

    .input-container {
        flex-direction: column;
    }

    .navigation {
        flex-direction: column;
    }

    .mode-selector {
        flex-direction: column;
        align-items: center;
    }

    .search-input {
        min-width: auto;
        width: 100%;
    }

    .study-controls {
        flex-direction: column;
    }

    .celebration-content {
        margin: 20px;
        padding: 30px 20px;
    }

    .celebration-content h2 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .section {
        padding: 20px;
    }

    .card-text {
        font-size: 1.5rem;
    }

    .flashcard {
        height: 250px;
    }

    .study-table th,
    .study-table td {
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card-front,
    .card-back {
        border: 2px solid currentColor;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .flashcard {
        transition: none;
    }
}

/* Focus indicators */
@media (prefers-reduced-motion: no-preference) {
    :focus {
        animation: focusRing 0.3s ease-out;
    }
}

@keyframes focusRing {
    0% {
        box-shadow: 0 0 0 0 rgba(118, 75, 162, 0.7);
    }
    100% {
        box-shadow: 0 0 0 4px rgba(118, 75, 162, 0);
    }
}