/* =============================================
   ENGLISH WORLD - GRADE 2
   Professional Redesign
   ============================================= */

/* === DESIGN TOKENS === */
:root {
    --primary: #6c63ff;
    --primary-dark: #4c46d9;
    --primary-light: #a89cff;
    --primary-glow: rgba(108, 99, 255, 0.25);

    --secondary: #ff6b9d;
    --accent: #ffd166;
    --success: #06d6a0;
    --info: #118ab2;

    --bg: #0f1117;
    --bg-card: #1a1d2e;
    --bg-card-2: #22263a;
    --border: rgba(255,255,255,0.08);

    --text: #f0f2ff;
    --text-muted: #8b90b8;
    --text-dim: #4a4f72;

    --radius-sm: 12px;
    --radius: 20px;
    --radius-lg: 28px;
    --radius-xl: 40px;

    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px rgba(108, 99, 255, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(108,99,255,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255,107,157,0.05) 0%, transparent 50%);
}

#app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

.hidden { display: none !important; }

/* =============================================
   TOP NAVIGATION
   ============================================= */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.brand-name {
    font-size: 1.3rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.brand-name strong {
    color: var(--text);
    font-weight: 900;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 800;
    font-size: 0.9rem;
}

.home-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    transition: var(--transition);
}

.home-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.home-btn i {
    font-size: 0.9rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.85rem;
    color: white;
    box-shadow: 0 0 0 3px rgba(108,99,255,0.3);
}

/* =============================================
   HERO SECTION
   ============================================= */
.hero-section {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50px; left: -50px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    pointer-events: none;
}

.hero-greeting {
    font-size: 0.9rem;
    color: var(--primary-light);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1.15;
    margin-bottom: 8px;
}

.hero-name {
    background: linear-gradient(90deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.hero-stats {
    display: flex;
    gap: 14px;
    margin-top: 24px;
}

.stat-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    text-align: center;
    min-width: 80px;
}

.stat-num {
    display: block;
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.emoji-container {
    font-size: 2.2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
    min-height: 40px;
}

.hero-illustration {
    width: 280px;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 5s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.hero-emoji {
    font-size: 8rem;
    filter: drop-shadow(0 15px 40px rgba(108,99,255,0.4));
}

.hero-illustration img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 15px 40px rgba(108,99,255,0.4));
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(2deg); }
}

/* =============================================
   PROGRESS SECTION
   ============================================= */
.progress-section {
    margin-bottom: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 24px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.progress-pct {
    color: var(--primary-light);
}

.overall-progress-bar {
    height: 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
}

.overall-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 10px;
    transition: width 1s ease;
    position: relative;
}

.overall-progress-fill::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    border-radius: 10px;
}

/* =============================================
   BOOK TABS SWITCHER
   ============================================= */
.book-tabs-section {
    margin-bottom: 24px;
}

.book-tabs {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

.book-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
}

.book-tab.active {
    background: var(--bg-card-2);
    color: var(--primary-light);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.book-tab:hover:not(.active) {
    background: rgba(255,255,255,0.03);
    color: var(--text);
}

.tab-icon {
    font-size: 1.2rem;
}

/* =============================================
   UNIT SECTIONS
   ============================================= */
.unit-block {
    margin-bottom: 44px;
}

.unit-header-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.unit-num-badge {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.unit-title-text h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}

.unit-title-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* =============================================
   LESSON CARDS
   ============================================= */
.lesson-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lesson-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: left;
}

.lesson-card:hover {
    transform: translateY(-6px);
    border-color: rgba(108,99,255,0.35);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), var(--shadow-glow);
}

.lesson-card:hover::before {
    transform: scaleX(1);
}

.lesson-card:active {
    transform: translateY(-2px) scale(0.98);
}

.lesson-icon-box {
    width: 48px;
    height: 48px;
    background: rgba(108,99,255,0.12);
    border: 1px solid rgba(108,99,255,0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: var(--transition);
}

.lesson-card:hover .lesson-icon-box {
    background: rgba(108,99,255,0.2);
    transform: scale(1.1);
}

.lesson-card h3 {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.3;
}

.lesson-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.lesson-type-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    text-transform: capitalize;
}

.lesson-arrow {
    width: 28px;
    height: 28px;
    background: rgba(108,99,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--primary-light);
    transition: var(--transition);
}

.lesson-card:hover .lesson-arrow {
    background: var(--primary);
    color: white;
    transform: translateX(3px);
}

/* =============================================
   LESSON VIEWER
   ============================================= */
#lesson-viewer {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viewer-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

.viewer-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.back-btn {
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.back-btn:hover {
    background: rgba(108,99,255,0.15);
    border-color: var(--primary);
    color: var(--primary-light);
}

.viewer-title-block {
    flex: 1;
    min-width: 0;
}

.viewer-unit-label {
    font-size: 0.75rem;
    color: var(--primary-light);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.viewer-title-block h2 {
    font-size: 1.1rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-progress-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 140px;
}

.step-counter {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 700;
}

.progress-bar-container {
    width: 140px;
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Viewer Content */
.viewer-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    scroll-behavior: smooth;
    /* Extra top padding to avoid header cutoff */
    padding-top: 50px;
}

.viewer-content::-webkit-scrollbar { width: 4px; }
.viewer-content::-webkit-scrollbar-track { background: transparent; }
.viewer-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Viewer Footer */
.viewer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.step-dots {
    display: flex;
    gap: 6px;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: var(--transition);
}

.step-dot.active {
    background: var(--primary);
    width: 20px;
    border-radius: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 800;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.nav-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--primary-glow);
}

.nav-btn.secondary {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.nav-btn.secondary:hover:not(:disabled) {
    background: var(--bg-card-2);
    color: var(--text);
}

/* =============================================
   LESSON CONTENT TYPES
   ============================================= */

/* Dialogue */
.dialogue-container {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.dialogue-bubble {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    animation: bubbleIn 0.4s ease-out forwards;
    opacity: 0;
}

.dialogue-bubble.self {
    flex-direction: row-reverse;
}

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

.char-img {
    font-size: 2rem;
    width: 52px;
    height: 52px;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bubble-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: 20px 20px 20px 4px;
    cursor: pointer;
    transition: var(--transition);
    max-width: 75%;
}

.self .bubble-content {
    background: rgba(108,99,255,0.15);
    border-color: rgba(108,99,255,0.3);
    border-radius: 20px 20px 4px 20px;
}

.bubble-content:hover {
    border-color: var(--primary);
    transform: scale(1.02);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.bubble-content p {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}

.translation {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 5px;
    display: block;
    font-weight: 600;
}

/* Vocab Grid */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 680px;
}

.vocab-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 22px 16px;
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.vocab-card:hover {
    border-color: var(--primary);
    background: rgba(108,99,255,0.08);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), var(--shadow-glow);
}

.qa-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qa-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.qa-main-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.q-translation {
    font-size: 1rem;
    color: var(--text-dim);
    direction: rtl;
    margin-bottom: 5px;
}

.answer-section {
    margin-top: 15px;
    width: 100%;
}

.show-answer-btn {
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
}

.show-answer-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--shadow-glow);
}

.a-text.hidden {
    display: none;
}

.a-text {
    margin-top: 15px;
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 800;
    animation: fadeInScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.qa-image {
    font-size: 3.5rem;
    margin-bottom: 10px;
}

.vocab-card:active {
    transform: scale(0.96);
}

.vocab-card .emoji {
    font-size: 2.6rem;
    display: block;
    line-height: 1;
}

.vocab-card span {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.3;
}

.owner-tag {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--secondary);
    color: white;
    font-size: 0.68rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 800;
}

/* Intro / Description */
.intro-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    max-width: 560px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.intro-card::before {
    content: '';
    position: absolute;
    top: -30px; left: -30px;
    width: 150px; height: 150px;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    pointer-events: none;
}

.intro-card h2 {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary-light);
    line-height: 1.4;
    margin-bottom: 15px;
}

.intro-translation {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 600;
    opacity: 0.9;
    direction: rtl;
    line-height: 1.5;
}

/* Phrases / Practice */
.qa-container {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.qa-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    cursor: pointer;
    transition: var(--transition);
    animation: bubbleIn 0.4s ease-out forwards;
}

.qa-card:hover {
    border-color: var(--primary);
    background: rgba(108,99,255,0.07);
    transform: translateX(4px);
}

.qa-card .q-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.qa-card .qa-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

.qa-card .a-text {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary-light);
}

/* =============================================
   FINISH SCREEN (when lesson completes)
   ============================================= */
.finish-screen {
    text-align: center;
    animation: bubbleIn 0.5s ease;
}

.finish-screen .finish-emoji {
    font-size: 5rem;
    margin-bottom: 20px;
}

.finish-screen h2 {
    font-size: 2rem;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 10px;
}

.finish-screen p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* =============================================
   WRITING PRACTICE & WHITEBOARD
   ============================================= */
.writing-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    animation: bubbleIn 0.5s ease;
}

.whiteboard-box {
    background: white;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.whiteboard-box:hover {
    border-color: var(--primary);
}

.canvas-wrapper {
    position: relative;
    background: repeating-linear-gradient(
        #fff,
        #fff 39px,
        #e0e0e0 39px,
        #e0e0e0 40px
    );
    border-radius: 8px;
    cursor: crosshair;
    overflow: hidden;
    touch-action: none; /* Prevents scrolling while drawing */
}

/* ---- MATCHING GAME ---- */
.matching-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    width: 100%;
}

.matching-grid {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    width: 100%;
    max-width: 700px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    padding: 40px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative; /* Base for absolute canvas */
    min-height: 400px;
}

.match-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 20px;
    z-index: 1; /* Below canvas for clicks if needed, but we want canvas to catch drawing */
    width: 160px;
}

.match-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 15px;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--border);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    color: white;
    user-select: none;
}

.match-item.img {
    font-size: 3rem;
}

.match-overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 5; /* On top of everything to catch drawing events */
    touch-action: none;
}

.clear-btn {
    padding: 12px 30px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px var(--accent-glow);
    transition: all 0.3s ease;
}

.clear-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

/* ---- COMPLETED MODAL ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.completed-modal {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: 30px;
    padding: 40px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 25px;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.completed-modal h2 {
    margin: 0;
    text-align: center;
    font-size: 1.8rem;
    color: var(--primary);
}

.completed-list-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.completed-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.completed-list li {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 20px;
    border-radius: 15px;
    border: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space between text and trash icon */
    gap: 12px;
    transition: transform 0.2s;
}

.lesson-info {
    flex-grow: 1;
    text-align: left;
}

.delete-lesson-btn {
    background: rgba(255, 71, 71, 0.1);
    border: 1px solid rgba(255, 71, 71, 0.3);
    color: #ff4747;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.delete-lesson-btn:hover {
    background: #ff4747;
    color: white;
    transform: scale(1.1);
}

.completed-list li:hover {
    transform: translateX(5px);
    border-color: var(--primary);
}

.close-modal-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 15px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--shadow-glow);
}

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

.canvas-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    font-weight: 800;
    color: rgba(0,0,0,0.05);
    pointer-events: none;
    font-family: 'Nunito', sans-serif;
    user-select: none;
}

.canvas-tools {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.clear-btn {
    background: #ff4757;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
}

.clear-btn:hover {
    background: #ff6b81;
    transform: scale(1.05);
}

.tool-label {
    font-weight: 800;
    color: #333;
    font-size: 0.9rem;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .hero-section {
        flex-direction: column;
        padding: 28px 24px;
        text-align: center;
    }

    .hero-illustration { display: none; }

    .hero-stats { justify-content: center; }

    .vocab-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .top-nav { flex-wrap: wrap; gap: 12px; }

    .lesson-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .viewer-header {
        flex-wrap: wrap;
    }
    
    .viewer-progress-block {
        min-width: unset;
        width: 100%;
        align-items: flex-start;
    }
    
    .progress-bar-container {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .lesson-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-title { font-size: 1.7rem; }
    
    .nav-btn { padding: 10px 18px; font-size: 0.9rem; }
}
