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

html {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    touch-action: pan-y;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; touch-action: manipulation; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.hidden { display: none !important; }

/* ===== INLINE SVG ICONS (no icon font, no emoji) ===== */
.ic {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.14em;
    flex: 0 0 auto;
}
.ic-lg { width: 2.2em; height: 2.2em; stroke-width: 1.6; }

/* ===== HEADER ===== */
.header {
    background: #fff;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 70px;
}

.logo {
    font-size: 1.65rem;
    font-weight: 800;
    color: #6c5ce7;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    letter-spacing: -0.02em;
}
.logo .ic { width: 1.15em; height: 1.15em; stroke-width: 1.7; }

.nav { display: flex; gap: 26px; }

.nav-link {
    font-weight: 500;
    font-size: 0.95rem;
    color: #666;
    transition: color 0.25s;
    padding: 5px 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.nav-link:hover, .nav-link.active { color: #6c5ce7; border-bottom-color: #6c5ce7; }

.header-right { display: flex; align-items: center; gap: 15px; }

.score-badge {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
    padding: 8px 15px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

/* ===== HERO ===== */
.hero {
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #74b9ff 100%);
    color: #fff;
    padding: 56px 0 50px;
    text-align: center;
}
.hero h1 {
    font-size: 2.7rem;
    font-weight: 800;
    margin-bottom: 14px;
    line-height: 1.15;
    letter-spacing: -0.02em;
}
.hero p {
    font-size: 1.08rem;
    max-width: 680px;
    margin: 0 auto 30px;
    opacity: 0.95;
}
.hero-stats { display: flex; justify-content: center; gap: 42px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-number { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.9; }

/* ===== FILTER SECTION ===== */
.filter-section { padding: 26px 0 6px; }
.filter-bar { display: flex; flex-direction: column; gap: 16px; }

.search-box { position: relative; max-width: 460px; width: 100%; margin: 0 auto; color: #9aa0ae; }
.search-box .ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 1.05rem; height: 1.05rem; }
.search-box input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 2px solid #e4e6ec;
    border-radius: 30px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color 0.25s;
}
.search-box input:focus { border-color: #6c5ce7; }

.category-filters { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.filter-btn {
    padding: 7px 16px;
    border: 2px solid #e4e6ec;
    background: #fff;
    border-radius: 20px;
    font-size: 0.84rem;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.22s;
}
.filter-btn:hover { border-color: #6c5ce7; color: #6c5ce7; }
.filter-btn.active { background: #6c5ce7; border-color: #6c5ce7; color: #fff; }

/* ===== QUIZ GRID ===== */
.main-content { padding: 26px 0 40px; }
.blog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.blog-card {
    position: relative;
    background: #fff;
    padding: 30px 22px 26px;
    border-radius: 18px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.06);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 12px;
    min-height: 190px;
    transition: transform 0.25s, box-shadow 0.25s;
    outline: none;
}
.blog-card:hover, .blog-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(108,92,231,0.18);
}
.blog-card .card-icon { color: #6c5ce7; font-size: 2.2rem; line-height: 1; display: block; }
.blog-card .card-title { font-size: 1.05rem; font-weight: 600; color: #2d3436; line-height: 1.35; }
.blog-card .card-cat {
    margin-top: auto;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    color: #8a8f9c;
}
.blog-card .completed-mark { position: absolute; top: 13px; right: 15px; color: #00b894; font-size: 1rem; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 44px 20px; color: #8a8f9c; }
.empty-state .ic-lg { margin-bottom: 10px; }

/* ===== ABOUT / EDITORIAL ===== */
.about-section { padding: 10px 0 50px; }
.about-inner {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.06);
    padding: 36px 34px 30px;
    max-width: 860px;
    margin: 0 auto;
}
.about-inner h2 { font-size: 1.55rem; font-weight: 800; color: #2d3436; margin-bottom: 12px; letter-spacing: -0.01em; }
.about-inner h3 { font-size: 1.15rem; font-weight: 700; color: #6c5ce7; margin: 26px 0 8px; }
.about-inner p { color: #4b5058; margin-bottom: 14px; font-size: 0.97rem; }

/* ===== QUIZ VIEW ===== */
.quiz-view { padding: 26px 0 50px; }
.quiz-view .container { display: flex; justify-content: center; }

.quiz-blog {
    max-width: 800px;
    width: 100%;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.13);
}

.quiz-hero-image {
    min-height: 210px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 13px;
    color: #fff;
    text-align: center;
    padding: 32px 24px;
}
.quiz-hero-image .quiz-icon { font-size: 3rem; line-height: 1; display: block; }
.quiz-hero-image h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.quiz-hero-image .quiz-meta-info {
    display: flex; gap: 18px; font-size: 0.85rem; opacity: 0.95; flex-wrap: wrap; justify-content: center;
}

.quiz-content { padding: 28px 30px 30px; border-bottom: 1px solid #f0f0f0; }
.quiz-content .blog-text { color: #4b5058; margin-bottom: 22px; font-size: 0.98rem; }

.start-quiz-btn, .next-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff; border: none; border-radius: 30px;
    padding: 13px 30px; font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.start-quiz-btn:hover, .next-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(108,92,231,0.32); }

.quiz-body { padding: 28px 30px 32px; }

.question-counter { font-size: 0.85rem; color: #777; margin-bottom: 10px; }
.progress-bar { height: 7px; background: #ecedf2; border-radius: 6px; overflow: hidden; margin-bottom: 22px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #6c5ce7, #a29bfe); border-radius: 6px; transition: width 0.35s; }

.question-text { font-size: 1.3rem; font-weight: 700; color: #2d3436; margin-bottom: 20px; line-height: 1.35; }

.options-list { display: flex; flex-direction: column; gap: 11px; }
.option-btn {
    display: flex; align-items: center; gap: 13px; text-align: left;
    width: 100%; padding: 14px 16px;
    background: #fff; border: 2px solid #e4e6ec; border-radius: 13px;
    font-size: 0.97rem; color: #2d3436; cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.option-btn:hover:not(.disabled) { border-color: #6c5ce7; background: #f7f5ff; transform: translateX(3px); }
.option-btn .option-label {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 50%; background: #ecedf2; color: #6c5ce7; font-weight: 700; font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
}
.option-btn:hover:not(.disabled) .option-label { background: #6c5ce7; color: #fff; }
.option-btn.correct { border-color: #00b894; background: #e8fbf5; }
.option-btn.correct .option-label { background: #00b894; color: #fff; }
.option-btn.wrong { border-color: #e17055; background: #fdeee9; }
.option-btn.wrong .option-label { background: #e17055; color: #fff; }
.option-btn.disabled { cursor: default; pointer-events: none; }

.explanation-box { margin-top: 18px; padding: 15px 17px; border-radius: 13px; font-size: 0.93rem; line-height: 1.55; }
.explanation-box strong { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.explanation-box.correct-explanation { background: #e8fbf5; border-left: 4px solid #00b894; color: #1d5f50; }
.explanation-box.wrong-explanation { background: #fdeee9; border-left: 4px solid #e17055; color: #7b3520; }

#next-container { margin-top: 20px; text-align: center; }

/* ===== QUIZ RESULTS ===== */
.quiz-results { padding: 34px 30px 34px; text-align: center; }
.results-icon { font-size: 3rem; color: #6c5ce7; line-height: 1; margin-bottom: 8px; }
.results-title { font-size: 1.35rem; font-weight: 800; color: #2d3436; margin-bottom: 6px; line-height: 1.3; }
.results-level { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.results-score { font-size: 3rem; font-weight: 800; color: #6c5ce7; line-height: 1.1; }
.results-detail { color: #777; font-size: 0.92rem; margin-bottom: 22px; }

.results-breakdown { display: flex; justify-content: center; gap: 30px; margin-bottom: 8px; flex-wrap: wrap; }
.breakdown-item { display: flex; flex-direction: column; }
.breakdown-number { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.breakdown-number.correct-num { color: #00b894; }
.breakdown-number.wrong-num { color: #e17055; }
.breakdown-number.points-num { color: #6c5ce7; }
.breakdown-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: #8a8f9c; }

.results-actions { display: flex; justify-content: center; gap: 11px; flex-wrap: wrap; margin-top: 6px; }
.results-actions button {
    display: inline-flex; align-items: center; gap: 8px;
    border: none; border-radius: 26px; padding: 11px 22px;
    font-size: 0.92rem; font-weight: 600; color: #fff; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.results-actions button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.16); }
.btn-retry { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.btn-levels { background: linear-gradient(135deg, #00b894, #55efc4); }
.btn-home { background: #2d3436; }

/* ===== CATEGORIES VIEW ===== */
.categories-view, .leaderboard-view { padding: 34px 0 54px; }
.section-title { font-size: 1.75rem; font-weight: 800; color: #2d3436; text-align: center; margin-bottom: 8px; }
.section-sub { text-align: center; color: #777; font-size: 0.95rem; margin-bottom: 26px; }

.categories-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.category-card {
    background: #fff; padding: 26px 16px; border-radius: 16px; text-align: center;
    box-shadow: 0 4px 18px rgba(0,0,0,0.06); cursor: pointer;
    transition: transform 0.22s, box-shadow 0.22s; outline: none;
}
.category-card:hover, .category-card:focus-visible { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(108,92,231,0.18); }
.category-icon { font-size: 2rem; color: #6c5ce7; line-height: 1; margin-bottom: 10px; }
.category-name { font-weight: 700; color: #2d3436; font-size: 1rem; }
.category-count { font-size: 0.8rem; color: #8a8f9c; }

/* ===== SCOREBOARD VIEW ===== */
.leaderboard { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 11px; }
.leaderboard-item {
    display: flex; align-items: center; gap: 15px;
    background: #fff; padding: 15px 18px; border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06); cursor: pointer;
    transition: transform 0.2s; outline: none;
}
.leaderboard-item:hover, .leaderboard-item:focus-visible { transform: translateX(4px); }
.lb-rank {
    width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #ecedf2; color: #666; font-weight: 800; font-size: 0.95rem;
}
.lb-rank.gold { background: linear-gradient(135deg, #f7971e, #ffd200); color: #fff; }
.lb-rank.silver { background: linear-gradient(135deg, #bdc3c7, #e6e9ec); color: #fff; }
.lb-rank.bronze { background: linear-gradient(135deg, #b06f2e, #d9a066); color: #fff; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; color: #2d3436; font-size: 0.95rem; display: flex; align-items: center; gap: 7px; }
.lb-category { font-size: 0.78rem; color: #8a8f9c; }
.lb-score { font-weight: 800; color: #6c5ce7; font-size: 1.2rem; }
.lb-empty { text-align: center; color: #8a8f9c; padding: 44px 20px; }
.lb-empty .ic-lg { margin-bottom: 10px; color: #c9ccd4; }

/* ===== LEVEL SELECTOR ===== */
.level-selector { text-align: center; }
.level-selector h3 { font-size: 1.3rem; font-weight: 800; color: #2d3436; margin-bottom: 6px; }
.level-selector > p { font-size: 0.9rem; color: #888; margin-bottom: 22px; }
.level-cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.level-card {
    flex: 1 1 180px; min-width: 170px; max-width: 230px;
    background: #fff; border: 2px solid #e4e6ec; border-radius: 16px;
    padding: 20px 14px 18px; cursor: pointer; text-align: center;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; outline: none;
}
.level-card:hover, .level-card:focus-visible { transform: translateY(-4px); box-shadow: 0 10px 26px rgba(0,0,0,0.1); }
.level-card.easy:hover, .level-card.easy:focus-visible { border-color: #00b894; }
.level-card.medium:hover, .level-card.medium:focus-visible { border-color: #f39c12; }
.level-card.hard:hover, .level-card.hard:focus-visible { border-color: #e17055; }
.level-card .level-icon { font-size: 1.9rem; line-height: 1; display: block; margin-bottom: 8px; }
.level-card.easy .level-icon { color: #00b894; }
.level-card.medium .level-icon { color: #f39c12; }
.level-card.hard .level-icon { color: #e17055; }
.level-card .level-name { font-weight: 800; color: #2d3436; font-size: 1.05rem; }
.level-card .level-blurb { font-size: 0.8rem; color: #8a8f9c; margin-bottom: 6px; }
.level-card .level-points { font-size: 0.78rem; color: #666; margin-bottom: 9px; }
.level-card .level-status { font-size: 0.76rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.level-card .level-status.completed { color: #00b894; }
.level-card .level-status.not-attempted { color: #b2b6c0; }

/* ===== FOOTER ===== */
.footer {
    background: #2d3436;
    color: #b2bec3;
    text-align: center;
    padding: 24px 20px 30px;
    font-size: 0.85rem;
    margin-top: auto;
}
.footer a { color: #dfe6e9; }
.footer a:hover { text-decoration: underline; }

/* ===== AD SLOTS ===== */
.ad-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    width: auto;
    max-width: 100%;
    margin: 22px auto;
    overflow: visible;
}

.ad-slot iframe { border: 0; display: block; max-width: 100%; }
.ad-slot--result { margin: 20px auto 24px; }
.ad-top-wrap { margin: 18px auto 4px; }

/* The fixed side rails are gone. They held a 160x600 and a 160x300
   skyscraper, a format retired across every site. */
@media (min-width: 1200px) { .container { max-width: min(1200px, calc(100vw - 400px)); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .categories-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .blog-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .header .container { flex-wrap: wrap; height: auto; padding: 11px 18px; gap: 9px; }
    .nav { order: 3; width: 100%; justify-content: center; gap: 20px; }
    .logo { font-size: 1.4rem; }
    .hero { padding: 40px 0 36px; }
    .hero h1 { font-size: 1.9rem; }
    .hero p { font-size: 0.97rem; }
    .hero-stats { gap: 26px; }
    .stat-number { font-size: 1.5rem; }
    .about-inner { padding: 26px 20px 22px; border-radius: 16px; }
    .about-inner h2 { font-size: 1.3rem; }
    .quiz-content, .quiz-body, .quiz-results { padding-left: 20px; padding-right: 20px; }
    .quiz-hero-image { min-height: 175px; padding: 26px 18px; }
    .quiz-hero-image h1 { font-size: 1.32rem; }
    .quiz-hero-image .quiz-icon { font-size: 2.5rem; }
    .question-text { font-size: 1.12rem; }
    .categories-grid { grid-template-columns: repeat(2, 1fr); }
    .results-breakdown { gap: 20px; }
    .results-score { font-size: 2.5rem; }
    .section-title { font-size: 1.45rem; }
}

@media (max-width: 560px) {
    /* tighter gutters so a 300px-wide ad unit is never clipped */
    .container { padding: 0 13px; }
    .about-inner { padding: 24px 15px 20px; }
    .quiz-content, .quiz-body, .quiz-results { padding-left: 15px; padding-right: 15px; }
    .blog-grid { grid-template-columns: 1fr; }
    .blog-card { min-height: 0; padding: 22px 18px 20px; flex-direction: row; text-align: left; align-items: center; gap: 15px; }
    .blog-card .card-icon { font-size: 1.9rem; }
    .blog-card .card-title { font-size: 1rem; flex: 1; }
    .blog-card .card-cat { display: none; }
    .blog-card .completed-mark { top: 9px; right: 11px; }
    .hero h1 { font-size: 1.65rem; }
    .hero-stats { gap: 18px; }
    .stat-number { font-size: 1.35rem; }
    .stat-label { font-size: 0.68rem; }
    .option-btn { padding: 12px 13px; font-size: 0.92rem; gap: 10px; }
    .results-actions button { width: 100%; justify-content: center; }
    .quiz-hero-image .quiz-meta-info { gap: 12px; font-size: 0.78rem; }
}

@media (max-height: 460px) and (orientation: landscape) {
    .hero { padding: 26px 0 24px; }
    .hero h1 { font-size: 1.5rem; }
    .quiz-hero-image { min-height: 0; padding: 20px 16px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.blog-card, .category-card, .quiz-blog, .about-inner { animation: fadeUp 0.4s ease both; }
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
