* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 900px;
    padding: 0;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.hero-section {
    background: white;
    padding: 40px 30px 30px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

h1 {
    color: #667eea;
    font-size: 3em;
    margin: 0 0 10px 0;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    color: #666;
    font-size: 1.2em;
    margin: 0;
    font-weight: 400;
}

.intro-section {
    background: linear-gradient(to bottom, white, #f8f9ff);
    padding: 25px 30px;
    border-left: 4px solid #667eea;
    border-right: 4px solid #667eea;
}

.intro-text {
    color: #555;
    line-height: 1.6;
    margin: 0;
    font-size: 0.95em;
    text-align: left;
}

.intro-text a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.intro-text a:hover {
    color: #764ba2;
    text-decoration: underline;
}

#lesson-selector {
    background: white;
    padding: 30px;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.selector-title {
    color: #333;
    font-size: 1.5em;
    margin: 0 0 20px 0;
    font-weight: 600;
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.lesson-grid button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.lesson-grid button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.lesson-grid button:active {
    transform: translateY(0);
}

#flashcard-container {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.card-counter {
    color: #666;
    font-size: 0.95em;
    font-weight: 600;
    margin: 0;
}

#card-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    perspective: 1000px;
}

#card {
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1 / 1;
    margin-bottom: 15px;
}

.flip-hint {
    color: #999;
    font-size: 0.9em;
    margin: 0 0 20px 0;
    font-style: italic;
}

#navigation {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 450px;
    gap: 15px;
}

.nav-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.nav-button:active {
    transform: translateY(0);
}

#flashcard-container.hidden {
    display: none;
}

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

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

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8f9ff 0%, #e9ecff 100%);
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 3px solid #667eea;
}

.back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #fff5f8 0%, #ffe9f0 100%);
    border-color: #764ba2;
}

.flashcard img {
    max-width: 75%;
    max-height: 65%;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.english-word {
    margin-top: 15px;
    font-size: 22px;
    color: #444;
    font-weight: 600;
}

.arabic-word {
    font-family: 'Amiri', serif;
    font-size: 52px;
    color: #764ba2;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#congratulations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100;
}

#congratulations-box {
    background: linear-gradient(135deg, white 0%, #f8f9ff 100%);
    padding: 50px 70px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 3px solid #667eea;
    animation: slideIn 0.5s ease-out;
}

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

#congratulations h2 {
    background: linear-gradient(135deg, #42b72a 0%, #2d8a1f 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 42px;
    margin: 0 0 15px 0;
}

#congratulations p {
    font-size: 18px;
    margin-bottom: 30px;
    color: #555;
}

#revise-other {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

#revise-other:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#revise-other:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

/* Styles for Singular to Plural cards */
.flashcard.singular-plural .front .english-word {
    font-family: 'Amiri', serif;
    font-size: 52px;
    color: #444;
    font-weight: 700;
}

.flashcard.singular-plural .front img {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    h1 {
        font-size: 2.2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .hero-section {
        padding: 30px 20px 20px;
    }
    
    .intro-section {
        padding: 20px;
    }
    
    #lesson-selector {
        padding: 20px;
    }
    
    .lesson-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .lesson-grid button {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    #flashcard-container {
        padding: 20px;
    }
    
    .arabic-word {
        font-size: 42px;
    }
    
    .english-word {
        font-size: 18px;
    }
    
    #congratulations-box {
        padding: 35px 40px;
        margin: 0 20px;
    }
    
    #congratulations h2 {
        font-size: 32px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .lesson-grid {
        grid-template-columns: 1fr;
    }
    
    #navigation {
        flex-direction: column;
    }
    
    .nav-button {
        width: 100%;
    }
}
