:root {
    /* Classic quiz palette (blue accent) */
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --error-color: #c0392b;
    --locked-color: #95a5a6;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.app-container {
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
    padding: 24px 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(0,0,0,0.08);
}

h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.hidden {
    display: none !important;
}

.center-message {
    text-align: center;
    margin-top: 50px;
    color: #7f8c8d;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    padding: 10px 15px;
    border-radius: 8px;
    transition: transform 0.1s, opacity 0.2s;
}

button:active {
    transform: scale(0.98);
}

button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.stats-header {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 18px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.page-title {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.back-btn {
    padding: 10px 12px;
    border-radius: 10px;
}

/* Home / Level Grid */
.level-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.level-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.level-card:hover:not(.locked) {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.level-card.locked {
    background-color: #e0e0e0;
    cursor: not-allowed;
    opacity: 0.7;
}

.level-title {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.level-meta {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.level-status {
    text-align: right;
    font-weight: bold;
}

.best-score {
    display: block;
    font-size: 0.9rem;
    color: var(--success-color);
}

/* Quiz UI */
.quiz-header {
    margin-bottom: 20px;
}

.progress-bar-bg {
    background: #e0e0e0;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-bar-fill {
    background: var(--accent-color);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.lives-count {
    text-align: right;
    font-size: 0.9rem;
    color: #7f8c8d;
}

.question-box {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.question-label {
    font-size: 0.9rem;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-type {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
    margin: 5px 0 15px;
}

.question-word {
    font-size: 2rem;
    color: var(--primary-color);
    font-weight: bold;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 420px) {
    .options-grid {
        grid-template-columns: 1fr;
    }

    .question-word {
        font-size: 1.7rem;
    }

    .category-thumbnail {
        height: 160px;
    }
}

.option-btn {
    background: white;
    border: 2px solid #e0e0e0;
    padding: 20px;
    font-size: 1.5rem;
    font-family: 'Amiri', serif;
    color: var(--text-color);
    border-radius: 12px;
    min-height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.option-btn:hover {
    border-color: var(--accent-color);
    background: #f8fbff;
}

.option-btn.correct {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.option-btn.wrong {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

/* Feedback Overlay */
.feedback-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 20px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    text-align: center;
    animation: slideUp 0.3s ease;
    z-index: 100;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.feedback-text {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.arabic-lg {
    display: block;
    font-size: 2rem;
    font-family: 'Amiri', serif;
    color: var(--primary-color);
    margin: 10px 0;
}

#next-btn {
    background: var(--accent-color);
    color: white;
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

/* Results */
.result-container {
    text-align: center;
    padding: 40px 20px;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 8px solid var(--accent-color);
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#score-percent {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 30px;
}

.primary-btn {
    background: var(--accent-color);
    color: white;
    padding: 15px;
    font-size: 1.1rem;
    box-shadow: 0 6px 0 rgba(0,0,0,0.10);
}

.primary-btn:hover {
    opacity: 0.95;
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.10);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.secondary-btn:hover {
    opacity: 0.9;
}

/* Category grid (Home) */
.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

@media (min-width: 720px) {
    .category-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* === THUMBNAIL (YouTube Style) CATEGORY CARD === */
.category-card-container {
    width: 100%;
    margin: 0;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.category-card-container:hover {
    transform: scale(1.02);
}

.category-thumbnail {
    width: 100%;
    height: 180px; 
    /* Home page: keep thumbnails neutral (no accent color) */
    background: linear-gradient(135deg, #111111 0%, #4a4a4a 100%);
    border-radius: 12px;
    position: relative;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.9);
    color: white;
}

.category-thumbnail.locked {
    background: var(--locked-color);
    filter: grayscale(1);
    cursor: not-allowed;
}

.category-thumbnail h2 {
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin: 0;
    padding: 20px;
    z-index: 2;
    color: white;
    letter-spacing: 2px;
    /* Remove emojis if any passed in text */
}

/* Overlay effect */
.category-thumbnail::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.1);
    z-index: 1;
}

.category-meta-info {
    padding-top: 10px;
    display: flex;
    justify-content: center;
    color: #7f8c8d;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

/* Remove default emojis classes */
.status-icon { display: none; } 

/* LEVEL VIEW - FULL SCREEN OVERLAY or Just New Page Look */
/* Let's reuse .app-container but clearer grid */
.level-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding: 10px;
}

.mini-level-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
}

.mini-level-title {
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--primary-color);
}

.mini-level-score {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.mini-level-score.mastered {
    color: var(--success-color);
    font-weight: 700;
}

.mini-level-card:hover:not(.locked) {
    transform: translateY(-3px);
    border-color: var(--accent-color);
}

.mini-level-card.locked {
    background: #f9f9f9;
    color: #aaa;
    opacity: 0.85;
    cursor: not-allowed;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-badge {
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #d8e3ec;
    color: var(--primary-color);
    background: #fff;
}

.auth-card {
    max-width: 520px;
    margin: 20px auto 0;
}

.auth-card h2 {
    color: var(--primary-color);
    margin-bottom: 6px;
}

.auth-subtitle {
    color: #7f8c8d;
    margin-bottom: 16px;
}

.auth-message {
    margin-bottom: 12px;
    color: var(--primary-color);
    font-weight: 600;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form input,
.auth-form select {
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 0.95rem;
}

.auth-form button {
    margin-top: 8px;
}

.auth-divider {
    text-align: center;
    margin: 14px 0;
    color: #95a5a6;
    font-size: 0.9rem;
}

.auth-error {
    margin-top: 12px;
    color: var(--error-color);
    font-weight: 600;
}

