/* ==========================================
   FIXED TOGGLES — Stats, Favorites, Game
   ========================================== */
.stats-toggle,
.favorites-toggle,
.game-toggle {
    position: fixed;
    top: 0.75rem;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.08));
}

.stats-toggle {
    left: 0.75rem;
}

.favorites-toggle {
    left: 4rem;
}

.game-toggle {
    left: 7.25rem;
}

.stats-toggle:active,
.favorites-toggle:active,
.game-toggle:active {
    transform: scale(0.9);
}

.stats-toggle svg,
.favorites-toggle svg,
.game-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.favorites-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
}

/* ==========================================
   STATS BAR
   ========================================== */
.stats-bar {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    justify-content: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.7rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 1px;
}

/* ==========================================
   CATEGORIES NAV
   ========================================== */
.categories-nav {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0 0.75rem;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.categories-nav::-webkit-scrollbar {
    display: none;
}

.category-chip {
    padding: 0.45rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.category-chip:active {
    transform: scale(0.95);
}

.category-chip.active {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
}

/* ==========================================
   SEARCH
   ========================================== */
.search-container {
    position: relative;
    width: 100%;
    margin-bottom: 0.5rem;
}

.search-input {
    width: 100%;
    padding: 0.65rem 0.9rem 0.65rem 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    /* min 16px prevents iOS zoom */
    font-size: max(16px, 0.95rem);
    outline: none;
}

.search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ==========================================
   CARD ACTION BUTTONS (row of small circles)
   ========================================== */
.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    justify-content: center;
}

.action-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.08));
    transition: transform 0.12s;
}

.action-btn:active {
    transform: scale(0.88);
}

.action-btn svg {
    width: 17px;
    height: 17px;
    color: var(--text-primary);
}

/* ==========================================
   MODALS — bottom sheet
   ========================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 1rem 1rem calc(1.2rem + env(safe-area-inset-bottom));
    width: 100%;
    max-height: 85dvh;
    overflow-y: auto;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    animation: slideInUp 0.28s ease;
    position: relative;
}

/* drag pill */
.modal-content::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 0.85rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
}

.modal-header h2 {
    font-size: 1.15rem;
    color: var(--text-primary);
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
}

.modal-close:active {
    background: var(--border-color);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.stat-card {
    background: var(--bg-primary, #f0f2ff);
    padding: 0.85rem;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-card.full-width {
    grid-column: 1 / -1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.stat-name {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* favorites list */
.favorite-item {
    background: var(--bg-primary, #f0f2ff);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.favorite-text {
    flex: 1;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.45;
}

.remove-favorite {
    background: rgba(245, 87, 108, 0.12);
    border: none;
    color: #f5576c;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.empty-favorites {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ==========================================
   TOAST
   ========================================== */
.toast {
    position: fixed;
    bottom: calc(1.2rem + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.65rem 1.1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md, 0 4px 16px rgba(0, 0, 0, 0.12));
    color: var(--text-primary);
    font-size: 0.88rem;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    max-width: 88vw;
    text-align: center;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================
   EXPORT TEMPLATE (off-screen)
   ========================================== */
.export-template {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1080px;
    height: 1080px;
    overflow: hidden;
}

.export-container {
    width: 1080px;
    height: 1080px;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    position: relative;
}

.export-logo-text {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.export-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 80px;
}

.export-quote-icon {
    color: rgba(255, 255, 255, 0.15);
    margin-bottom: 40px;
}

.export-proverb {
    font-family: 'Playfair Display', serif;
    font-size: 64px;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
    margin-bottom: 50px;
    max-width: 900px;
    color: #fff;
}

.export-meaning-box {
    background: rgba(255, 255, 255, 0.05);
    border-left: 8px solid #6366f1;
    border-radius: 20px;
    padding: 40px;
    max-width: 850px;
}

.export-meaning {
    font-size: 26px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.82);
    text-align: center;
}

.export-footer {
    position: absolute;
    bottom: 50px;
    font-size: 16px;
    letter-spacing: 8px;
    color: rgba(255, 255, 255, 0.18);
    text-transform: uppercase;
    font-weight: 600;
}

/* ==========================================
   PWA INSTALL BADGE
   ========================================== */
.install-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    margin-top: 0.6rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 100px;
    color: #6366f1;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.install-badge svg {
    width: 16px;
    height: 16px;
}

.install-badge.hidden {
    display: none;
}

/* ==========================================
   QUIZ MODAL
   ========================================== */
.quiz-content {
    /* inherits .modal-content */
}

.quiz-score-display {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    color: #6366f1;
    margin-bottom: 0.85rem;
}

.quiz-instruction {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.quiz-proverb {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.15rem, 5vw, 1.6rem);
    text-align: center;
    margin-bottom: 1.1rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.quiz-option-btn {
    padding: 0.8rem 0.4rem;
    font-size: 0.92rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary, #f0f2ff);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.quiz-option-btn:active {
    transform: scale(0.95);
}

.quiz-option-btn.correct {
    background: #10b981;
    color: #fff;
    border-color: #10b981;
}

.quiz-option-btn.wrong {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* ==========================================
   ACHIEVEMENTS / BADGES
   ========================================== */
.achievements-section {
    margin-top: 1.2rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color);
}

.achievements-title {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.65rem;
}

.badges-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    gap: 0.5rem;
}

.badge-card {
    background: var(--bg-primary, #f0f2ff);
    border: 1px solid var(--border-color);
    padding: 0.65rem 0.3rem;
    border-radius: var(--radius-md);
    text-align: center;
    opacity: 0.35;
    filter: grayscale(1);
    transition: opacity 0.25s, filter 0.25s;
}

.badge-card.unlocked {
    opacity: 1;
    filter: none;
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.badge-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
    display: block;
}

.badge-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

/* ==========================================
   FOOTER COUNT
   ========================================== */
.footer-count {
    font-size: 0.78rem;
    margin-top: 0.25rem;
    opacity: 0.7;
}

.footer-count span {
    font-weight: 600;
    color: var(--primary-gradient-start, #667eea);
}

/* ==========================================
   DESKTOP UPGRADES
   ========================================== */
@media (min-width: 768px) {

    .stats-toggle,
    .favorites-toggle,
    .game-toggle {
        top: 1.5rem;
        width: 50px;
        height: 50px;
    }

    .stats-toggle {
        left: 1.5rem;
    }

    .favorites-toggle {
        left: 5.5rem;
    }

    .game-toggle {
        left: 9.5rem;
    }

    .stats-toggle svg,
    .favorites-toggle svg,
    .game-toggle svg {
        width: 24px;
        height: 24px;
    }

    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius-xl);
        max-width: 560px;
        width: 92%;
        max-height: 82vh;
        padding: 2rem;
        animation: fadeIn 0.22s ease;
    }

    .modal-content::before {
        display: none;
    }

    .modal-body {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.75rem;
    }

    .category-chip {
        padding: 0.6rem 1.2rem;
        font-size: 0.88rem;
    }

    .category-chip:hover {
        background: rgba(99, 102, 241, 0.08);
        color: var(--text-primary);
    }

    .category-chip.active:hover {
        color: #fff;
    }

    .action-btn {
        width: 46px;
        height: 46px;
    }

    .action-btn:hover {
        transform: scale(1.08) translateY(-2px);
    }

    .stat-item:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-sm);
    }

    .quiz-proverb {
        font-size: 1.8rem;
    }
}