:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --error: #ef4444;
}

body.dark-mode {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* Header */
header {
    background-color: var(--card-bg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 12px 4%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.logo {
    font-size: 24px;
    font-weight: 900;
    color: var(--primary);
    text-decoration: none;
}

.logo span {
    color: var(--success);
}

.stats {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--bg);
    border: 2px solid var(--border);
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
}

.rank-box { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.streak-box { background: #ffedd5; border-color: #fed7aa; color: #c2410c; }
.score-box { background: #e0e7ff; border-color: #c7d2fe; color: #3730a3; }
.progress-box { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }

.icon-btn {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 5px 10px;
    font-size: 18px;
    cursor: pointer;
    transition: 0.2s;
}

.icon-btn:hover {
    transform: scale(1.08);
}

/* Tepa reklama banneri */
.ad-banner-top {
    display: block;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    color: #ffffff;
    text-decoration: none;
    margin: 12px auto 6px;
    width: 95%;
    max-width: 1280px;
    padding: 12px 18px;
    text-align: center;
    border-radius: 14px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    transition: transform 0.2s;
}

.ad-banner-top:hover {
    transform: translateY(-2px);
}

/* Kitoblar menyusi */
.books-bar {
    display: flex;
    gap: 10px;
    width: 95%;
    max-width: 1280px;
    margin: 8px auto;
    overflow-x: auto;
    padding-bottom: 4px;
}

.book-btn {
    padding: 8px 16px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
}

.book-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
}

/* Asosiy konteyner */
.main-container {
    display: grid;
    grid-template-columns: 275px 1fr 245px;
    gap: 18px;
    width: 95%;
    max-width: 1280px;
    margin: 8px auto 40px;
    flex: 1;
    align-items: start;
}

/* 📚 30 TA UNIT SKROLSIZ TO'LIQ KO'RINADIGAN PANEL */
.sidebar-units {
    background: var(--card-bg);
    padding: 14px;
    border-radius: 18px;
    border: 2px solid var(--border);
    box-shadow: 0 4px 14px rgba(0,0,0,0.03);
}

.sidebar-units h3 {
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 900;
    text-align: center;
}

.unit-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.unit-btn {
    padding: 8px 4px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    font-size: 12.5px;
    transition: 0.18s;
    text-align: center;
}

.unit-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.unit-btn.completed {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

.unit-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

/* O'yin maydoni */
.game-area {
    background: var(--card-bg);
    padding: 22px;
    border-radius: 18px;
    border: 2px solid var(--border);
    box-shadow: 0 6px 18px rgba(0,0,0,0.04);
}

.mode-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.mode-tab {
    padding: 10px 8px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}

.mode-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.round-badge {
    background: #e0e7ff;
    color: #3730a3;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 13px;
}

.progress-bar-wrap {
    width: 100%;
    height: 10px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 18px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e, #10b981);
    transition: width 0.3s ease;
}

/* 🏷️ SO'Z TURKUMI (n., v., adj., adv.) NISHONCHASI */
.pos-badge {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 900;
    font-style: italic;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(79, 70, 229, 0.12);
    color: #4338ca;
    border: 1px solid rgba(79, 70, 229, 0.25);
}

body.dark-mode .pos-badge {
    background: rgba(129, 140, 248, 0.2);
    color: #c7d2fe;
    border-color: rgba(129, 140, 248, 0.35);
}

/* 📖 FLASHCARD (O'RGANISH) REJIMI */
.flashcard-box {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    text-align: center;
    max-width: 560px;
    margin: 0 auto;
}

.flashcard-icon {
    font-size: 56px;
    margin-bottom: 6px;
}

.flashcard-word-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.flashcard-word-row h3 {
    font-size: 34px;
    font-weight: 900;
    color: var(--primary);
}

.speak-btn-large {
    background: #e0e7ff;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    font-size: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.speak-btn-large:hover {
    transform: scale(1.1);
}

.flashcard-tr {
    font-size: 17px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 16px;
}

.flashcard-meaning,
.flashcard-syn,
.flashcard-example {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 12px;
    text-align: left;
}

.fc-label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.flashcard-meaning p {
    font-size: 19px;
    font-weight: 800;
    color: #15803d;
}

body.dark-mode .flashcard-meaning p {
    color: #4ade80;
}

.flashcard-syn p {
    font-size: 16px;
    font-weight: 800;
    color: #4f46e5;
}

body.dark-mode .flashcard-syn p {
    color: #818cf8;
}

.fc-ex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flashcard-example p {
    font-size: 15px;
    font-style: italic;
    font-weight: 700;
    margin-top: 4px;
}

.flashcard-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 18px;
}

.fc-nav-btn, .fc-play-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
}

.fc-nav-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
}

.fc-play-btn {
    background: #dcfce7;
    color: #15803d;
    border-color: #86efac;
}

/* 🧩 JUFTINI TOP KARTOCHKALARI */
.cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.column-title {
    text-align: center;
    font-size: 13px;
    font-weight: 900;
    color: var(--muted);
    margin-bottom: 10px;
    letter-spacing: 0.8px;
}

.word-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    border-radius: 14px;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border: 2px solid transparent;
    border-bottom-width: 5px;
    min-height: 70px;
}

/* 5 xil 3D rangli tema */
.card-theme-0 { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }
.card-theme-1 { background: #f5f3ff; border-color: #c4b5fd; color: #4c1d95; }
.card-theme-2 { background: #fdf2f8; border-color: #f9a8d4; color: #831843; }
.card-theme-3 { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.card-theme-4 { background: #fffbeb; border-color: #fcd34d; color: #78350f; }

body.dark-mode .card-theme-0,
body.dark-mode .card-theme-1,
body.dark-mode .card-theme-2,
body.dark-mode .card-theme-3,
body.dark-mode .card-theme-4 {
    background: #263349;
    border-color: #475569;
    color: #f8fafc;
}

.card-main-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.card-word-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 900;
}

.card-emoji {
    font-size: 22px;
}

.card-sub-meta {
    font-size: 12px;
    font-weight: 700;
    opacity: 0.85;
}

.card-syn-tag {
    color: #4f46e5;
    font-weight: 800;
}

body.dark-mode .card-syn-tag {
    color: #a5b4fc;
}

.card-uz-text {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.35;
}

.card:hover {
    transform: translateY(-2px);
}

.card.selected {
    border-color: #2563eb !important;
    background: #dbeafe !important;
    color: #1e40af !important;
    transform: scale(1.02);
}

.card.correct {
    border-color: #16a34a !important;
    background: #bbf7d0 !important;
    color: #14532d !important;
    pointer-events: none;
}

.card.vanish {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

.card.wrong {
    border-color: #dc2626 !important;
    background: #fecaca !important;
    color: #7f1d1d !important;
    animation: shake 0.4s;
}

.speak-btn {
    background: rgba(255,255,255,0.75);
    border: none;
    font-size: 17px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Uchib chiquvchi ball */
.floating-point {
    position: fixed;
    font-weight: 900;
    font-size: 20px;
    color: #16a34a;
    pointer-events: none;
    z-index: 9999;
    animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-45px) scale(1.25); }
}

/* Bosqich tugagandagi GIF oyna */
.cleared-box {
    text-align: center;
    padding: 25px 15px;
}

.stars-row {
    font-size: 36px;
    margin-bottom: 10px;
}

.win-gif {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 16px;
    margin: 8px auto 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.cleared-sub {
    color: var(--muted);
    font-weight: 700;
    margin: 6px 0 16px;
}

.next-round-btn {
    width: 100%;
    max-width: 360px;
    padding: 14px;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* 📝 QUIZ REJIMI */
.quiz-box {
    text-align: center;
}

.quiz-question-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.quiz-icon {
    font-size: 46px;
    margin-bottom: 4px;
}

.quiz-main-word {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 30px;
    font-weight: 900;
    color: var(--primary);
}

.quiz-meta {
    margin-top: 6px;
    font-size: 15px;
    color: var(--muted);
    font-weight: 700;
}

.quiz-subtitle {
    margin-bottom: 12px;
    font-weight: 800;
    color: var(--muted);
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Yon reklama bloklari */
.sidebar-ads {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ad-box-side {
    background: #fffbeb;
    border: 2px dashed #f59e0b;
    border-radius: 16px;
    padding: 18px;
    text-align: center;
    text-decoration: none;
    color: #92400e;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 220px;
    transition: 0.2s;
}

.ad-box-side.green-ad {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
}

.ad-tag {
    font-size: 11px;
    font-weight: 900;
    background: rgba(0,0,0,0.08);
    padding: 3px 8px;
    border-radius: 8px;
}

.ad-cta {
    margin-top: 6px;
    font-weight: 900;
    font-size: 13px;
    text-decoration: underline;
}

/* 📱 Mobil moslashuv */
@media (max-width: 980px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    .unit-grid {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
    }
    .unit-btn {
        min-width: 78px;
    }
    .mode-tabs {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .cards-container, .quiz-options {
        grid-template-columns: 1fr;
    }
}