/* ===== CSS Variables ===== */
:root {
    --primary: #6C63FF;
    --primary-light: #8B85FF;
    --primary-dark: #5046E5;
    --secondary: #FF6B6B;
    --secondary-light: #FF8E8E;
    --secondary-dark: #E84A4A;
    --accent: #FFD166;
    --accent-light: #FFE090;
    --accent-dark: #FFBA36;
    --success: #06D6A0;
    --error: #EF476F;
    --warning: #FF9F1C;
    --info: #118AB2;
    --background: #F7F9FC;
    --card-bg: #FFFFFF;
    --text-dark: #2D3748;
    --text-light: #718096;
    --border: #E2E8F0;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(108, 99, 255, 0.15);
    --shadow-lg: 0 10px 20px rgba(108, 99, 255, 0.2);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --font: 'Nunito', sans-serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ===== Base Styles ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background-color: var(--background);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding: 0 16px 24px;
    max-width: 100%;
}

/* ===== Utility Classes ===== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

/* ===== Header Styles ===== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    text-align: center;
    padding: 24px 20px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
    z-index: 1;
    position: relative;
}

.header::before {
    content: "";
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: rgba(255, 255, 255, 0.1);
    width: 120px;
    height: 120px;
    border-radius: 50%;
}

.header::after {
    content: "";
    position: absolute;
    bottom: -20px;
    left: -20px;
    background-color: rgba(255, 255, 255, 0.1);
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 5px;
    z-index: 1;
    position: relative;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    background-color: var(--primary-dark);
    color: white;
    font-size: 0.9rem;
    margin-top: 30px;
}

/* ===== Tab Navigation ===== */
.tab-container {
    max-width: 550px;
    margin: 0 auto 20px;
    display: flex;
    position: relative;
}

.tab-buttons {
    display: flex;
    width: 100%;
    border-radius: var(--radius-md);
    background-color: var(--card-bg);
    padding: 5px;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1;
}

.tab-btn {
    flex: 1;
    padding: 12px 15px;
    border: none;
    background: none;
    font-family: var(--font);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-light);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    text-align: center;
    z-index: 2;
    border-radius: var(--radius-sm);
}

.tab-btn.active {
    color: var(--primary-dark);
}

.tab-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.tab-indicator {
    position: absolute;
    height: calc(100% - 10px);
    top: 5px;
    left: 5px;
    width: calc(50% - 5px);
    background-color: white;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    z-index: 1;
}

.tab-btn:first-child.active ~ .tab-indicator {
    left: 5px;
}

.tab-btn:last-child.active ~ .tab-indicator {
    left: calc(50% + 2.5px);
}

.tab-btn .icon {
    margin-right: 6px;
    font-size: 1.2em;
    display: inline-block;
    vertical-align: middle;
}

/* ===== Card Styles ===== */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    margin: 16px auto;
    box-shadow: var(--shadow-md);
    max-width: 550px;
    transition: var(--transition);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    display: none; /* Hide by default */
}

.card.active {
    display: block; /* Show only active card */
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
    position: relative;
    display: inline-flex;
    align-items: center;
}

.card h2::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    height: 2px;
    width: 40%;
    background-color: var(--accent);
}

.card h2 .icon {
    margin-right: 8px;
    font-size: 1.2em;
}

.card-content {
    position: relative;
    z-index: 1;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, transparent 70%, rgba(108, 99, 255, 0.1) 100%);
    border-radius: 0 var(--radius-md) 0 100%;
    z-index: 0;
}

/* ===== Word Display Area ===== */
.word-display {
    position: relative;
    min-height: 180px;
    background-color: var(--background);
    border-radius: var(--radius-md);
    margin: 25px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 2px dashed var(--border);
    transition: var(--transition);
    padding: 10px;
}

/* Pulsing arrow for input cue */
.input-cue {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: var(--accent);
    animation: bounce-down 2s infinite;
    opacity: 0.8;
}

@keyframes bounce-down {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
    40% { transform: translateX(-50%) translateY(10px); }
    60% { transform: translateX(-50%) translateY(5px); }
}

.word-display.active {
    border: 3px solid var(--primary-light);
    background-color: rgba(108, 99, 255, 0.05);
    box-shadow: 0 0 15px rgba(108, 99, 255, 0.15) inset;
}

.word-display.correct {
    border: 3px solid var(--success);
    background-color: rgba(6, 214, 160, 0.1);
}

.word-display.incorrect {
    border: 3px solid var(--error);
    background-color: rgba(239, 71, 111, 0.1);
}

/* Initial hint in word display */
.display-hint {
    color: var(--text-light);
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0.7;
    text-align: center;
    padding: 0 15px;
}

/* Word Animation */
.letter-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    height: 100%;
    width: 100%;
    perspective: 800px;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: rotateY(90deg) scale(0.5);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.6s ease-out,
                filter 0.3s ease;
    margin: 0 8px 4px;
    font-size: 5rem;
    font-weight: 800;
    position: relative;
    text-shadow: 3px 3px 5px rgba(0,0,0,0.15);
    cursor: pointer;
    user-select: none;
}

.letter.visible {
    opacity: 1;
    transform: rotateY(0) scale(1);
    animation: letter-pop 0.5s forwards;
}

.letter.hint-highlight {
    animation: hint-pulse 1s infinite;
    filter: brightness(1.3);
    text-shadow: 0 0 15px currentColor;
}

@keyframes hint-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes letter-pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.letter:hover {
    filter: brightness(1.2);
    transform: translateY(-5px) scale(1.05);
}

.letter::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: currentColor;
    opacity: 0.4;
    border-radius: 3px;
}

/* ===== Word Images ===== */
.word-image-container {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    min-height: 100px;
}

.word-image {
    max-width: 100px;
    max-height: 100px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
    object-fit: cover;
}

.word-image.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.image-fallback {
    color: var(--text-light);
    font-size: 0.9rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(108, 99, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.2rem;
    background-color: var(--background);
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    color: var(--text-dark);
    transition: var(--transition);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.form-select {
    appearance: none;
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    background-color: var(--background);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236C63FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    color: var(--text-dark);
    transition: var(--transition);
    cursor: pointer;
}

/* Input highlight effect */
.form-input.highlight {
    animation: input-pulse 2s infinite;
}

@keyframes input-pulse {
    0% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(108, 99, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0); }
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.2);
}

.form-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

/* Category selector and difficulty toggles */
.category-selector {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--background);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.category-selector label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.difficulty-toggles {
    display: flex;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.difficulty-toggles span {
    margin-right: 12px;
    font-weight: 600;
    color: var(--text-dark);
}

.level-btn {
    padding: 6px 12px;
    background-color: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    margin: 3px;
}

.level-btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

.level-btn:hover:not(.active) {
    border-color: var(--primary-light);
    color: var(--primary);
}

.level-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

/* ===== Button Styles ===== */
.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 140px;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    color: white;
    background-color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    flex: 1;
    position: relative;
    overflow: hidden;
}

.btn.btn-lg {
    font-size: 1.3rem;
    padding: 16px 32px;
    margin-bottom: 10px;
}

.btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), rgba(255,255,255,0));
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.3);
}

.btn:disabled {
    background-color: var(--border);
    color: var(--text-light);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-primary {
    background-color: var(--primary);
}

.btn-secondary {
    background-color: var(--secondary);
}

.btn-accent {
    background-color: var(--accent);
    color: var(--text-dark);
}

.btn-success {
    background-color: var(--success);
}

.btn-audio {
    background-color: var(--accent);
    color: var(--text-dark);
}

.btn-icon {
    margin-right: 8px;
    font-size: 1.2em;
}

/* Animated Button */
.btn-animated {
    animation: button-pulse 2s infinite;
}

@keyframes button-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ===== Feedback Styles ===== */
.feedback {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 15px 0;
    min-height: 28px;
    transition: var(--transition);
}

.feedback.correct {
    color: var(--success);
}

.feedback.incorrect {
    color: var(--error);
}

/* ===== Progress Bar ===== */
.progress-container {
    margin: 20px 0;
    background-color: var(--background);
    border-radius: 100px;
    height: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--primary), var(--primary-light));
    transition: width 0.5s ease;
    border-radius: 100px;
}

/* ===== Stats ===== */
.stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-md);
    max-width: 90%;
    width: 500px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: modal-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    color: var(--primary);
    margin-bottom: 15px;
    border: none;
}

.modal-content p {
    margin-bottom: 15px;
    line-height: 1.5;
}

.stars-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.star {
    font-size: 2.5rem;
    margin: 0 5px;
    animation: star-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: scale(0);
}

.star:nth-child(1) { animation-delay: 0s; }
.star:nth-child(2) { animation-delay: 0.2s; }
.star:nth-child(3) { animation-delay: 0.4s; }
.star:nth-child(4) { animation-delay: 0.6s; }
.star:nth-child(5) { animation-delay: 0.8s; }

@keyframes star-pop {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Notifications ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 350px;
    min-width: 280px;
    background-color: white;
    border-radius: var(--radius-sm);
    padding: 15px;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 1000;
    font-size: 0.95rem;
}

.notification.visible {
    transform: translateX(0);
}

.notification-content {
    display: flex;
    flex-direction: column;
}

.notification::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 4px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.notification.info::before {
    background-color: var(--info);
}

.notification.warning::before {
    background-color: var(--warning);
}

.notification.error::before {
    background-color: var(--error);
}

.notification.success::before {
    background-color: var(--success);
}

.notification-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
}

.notification-action {
    margin-top: 10px;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.notification-action:hover {
    background-color: var(--primary-dark);
}

/* ===== Sparkle Effect ===== */
.sparkle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: white;
    pointer-events: none;
    z-index: 10;
    animation: sparkle 1.5s ease-in-out forwards;
}

@keyframes sparkle {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    50% { transform: scale(1) rotate(180deg); opacity: 1; }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

/* ===== Instructions ===== */
.instructions {
    position: relative;
    padding: 10px 0;
    margin-bottom: 5px;
    font-size: 1.1rem;
    color: var(--text-dark);
    text-align: center;
}

/* ===== Animations ===== */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    60% { transform: translateY(-10px); }
}

.bounce {
    animation: bounce 1s ease;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes rainbow-text {
    0% { color: #FF6B6B; }
    15% { color: #FF9E7D; }
    30% { color: #FFD166; }
    45% { color: #06D6A0; }
    60% { color: #1B9AAA; }
    75% { color: #6C63FF; }
    90% { color: #8338EC; }
    100% { color: #FF6B6B; }
}

.rainbow-text {
    animation: rainbow-text 8s linear infinite;
}

/* ===== Responsive Design ===== */
@media (max-width: 600px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .card {
        padding: 20px;
        margin: 12px auto;
        border-radius: var(--radius-sm);
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 0.95rem;
        min-width: 110px;
    }
    
    .letter {
        font-size: 3.5rem; /* Still bigger but fits mobile */
        margin: 0 4px;
    }
    
    .word-display {
        min-height: 150px;
    }
    
    .form-input {
        padding: 12px 16px;
        font-size: 1rem;
    }
    
    .feedback {
        font-size: 1rem;
    }

    .tab-btn {
        font-size: 0.9rem;
        padding: 10px;
    }

    .tab-btn .icon {
        margin-right: 4px;
    }
    
    .difficulty-toggles {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .difficulty-toggles span {
        margin-bottom: 8px;
    }
    
    .modal-content {
        padding: 20px;
        width: 90%;
    }
    
    .star {
        font-size: 2rem;
    }
    
    .notification {
        max-width: 90%;
        right: 5%;
        left: 5%;
    }
}

@media (max-width: 400px) {
    .letter {
        font-size: 2.8rem;
        margin: 0 3px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* ===== Print styles ===== */
@media print {
    .card, .header, .footer {
        box-shadow: none;
    }
    
    .btn {
        display: none;
    }
    
    body {
        background-color: white;
    }
}
/* --- Add this CSS --- */
.pexels-attribution {
    font-size: 0.75rem; /* Smaller text */
    color: var(--text-light);
    text-align: center;
    margin-top: 8px;
    padding: 0 10px; /* Add some horizontal padding */
    opacity: 0; /* Start hidden for fade-in */
    transition: opacity 0.6s ease-out;
    line-height: 1.4; /* Improve readability */
}

.pexels-attribution a {
    color: var(--primary); /* Use theme color for links */
    text-decoration: none;
}

.pexels-attribution a:hover {
    text-decoration: underline;
}

.pexels-attribution.fade-in {
    opacity: 1; /* Fade in */
}

/* Adjust container padding if needed */
#practice-image-container.has-image,
#custom-image-container.has-image {
    padding-bottom: 10px; /* Add slightly more padding at the bottom */
}
/* ===== Focus styles for accessibility ===== */
:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}