@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');
@import url('brand.css');

/* ============================================================
   MONKEY-TYPE.IN — PREMIUM LIGHT REDESIGN 2026
   Design: Modern Airy Light Theme, No Sidebar, No Dark Mode
   ============================================================ */

:root {
    /* Core Palette — Deep Indigo Dark Premium */
    --primary:       #4F46E5;      /* Rich Indigo */
    --primary-light: #6D64F0;
    --primary-dark:  #3730A3;
    --accent:        #0891B2;      /* Vivid Cyan */
    --accent-light:  #67E8F9;
    --gold:          #F59E0B;      /* Amber Gold */

    /* Backgrounds */
    --bg:            #F8F9FF;      /* Cool White tinted */
    --bg-card:       #FFFFFF;
    --bg-soft:       #EEF0FB;      /* Soft Indigo Tint */
    --bg-subtle:     #F0F0FF;      /* Very Light Indigo */
    --surface:       #FFFFFF;

    /* Text */
    --text:          #0F0E2B;      /* Deep Navy */
    --text-body:     #2D2B4A;
    --text-muted:    #6B6A8A;
    --text-light:    #A8A7C0;

    /* UI States */
    --correct:       #10B981;
    --error:         #EF4444;
    --error-extra:   #991B1B;
    --warn:          #F59E0B;

    /* Borders */
    --border:        #E0E0F0;
    --border-focus:  var(--primary);

    /* Effects */
    --shadow-sm:     0 1px 3px rgba(79,70,229,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 12px rgba(79,70,229,0.10), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:     0 10px 30px rgba(79,70,229,0.12), 0 4px 8px rgba(0,0,0,0.05);
    --shadow-xl:     0 20px 60px rgba(15,14,43,0.15), 0 8px 20px rgba(0,0,0,0.08);
    --shadow-coral:  0 8px 25px rgba(79,70,229,0.30);   /* renamed but kept var name for compat */
    --shadow-teal:   0 8px 25px rgba(8,145,178,0.22);

    /* Typography */
    --font-ui:       'Inter', sans-serif;
    --font-mono:     'JetBrains Mono', monospace;

    /* Radius */
    --r-sm:   6px;
    --r-md:   12px;
    --r-lg:   20px;
    --r-xl:   32px;
    --r-full: 9999px;

    /* Transitions */
    --t-fast:   0.15s ease;
    --t-base:   0.25s ease;
    --t-slow:   0.4s ease;

    /* Gradient */
    --grad-primary: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    --grad-accent:  linear-gradient(135deg, #0891B2 0%, #0E4F6F 100%);
    --grad-warm:    linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #0891B2 100%);
    --grad-hero:    linear-gradient(160deg, #F8F9FF 0%, #EEF0FB 40%, #E8F0FF 100%);

    /* Legacy compat */
    --bg-color:       var(--bg);
    --bg-color-alt:   var(--bg-soft);
    --card-bg:        var(--bg-card);
    --main-color:     var(--primary);
    --main-dark:      var(--primary-dark);
    --main-gradient:  var(--grad-primary);
    --main-glow:      rgba(79,70,229,0.28);
    --secondary-color:var(--gold);
    --sub-color:      var(--text-body);
    --sub-alt-color:  var(--bg-soft);
    --text-color:     var(--text);
    --header-text-color:#FFFFFF;
    --correct-color:  var(--correct);
    --error-color:    var(--error);
    --error-extra-color:var(--error-extra);
    --border-color:   var(--border);
    --roundness:      var(--r-md);
    --font-family-ui: var(--font-ui);
    --font-family-mono:var(--font-mono);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-soft); }
::-webkit-scrollbar-thumb { background: var(--accent-light); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ============================================================
   TOP UTILITY BAR
   ============================================================ */
.top-bar {
    background: var(--text);
    color: rgba(255,255,255,0.75);
    padding: 0.35rem 2.5rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.top-bar a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: color var(--t-fast);
}

.top-bar a:hover { color: var(--gold); }

.top-bar-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.top-bar-links a::before {
    content: '';
}

/* Top bar separator */
#nav-auth-container {
    font-weight: 600;
}
#nav-auth-container a {
    color: var(--gold) !important;
    text-decoration: none;
}

/* ============================================================
   MAIN HEADER / NAVIGATION
   ============================================================ */
.main-header-section {
    background: #fff;
    position: sticky;
    top: 1.8rem; /* height of top-bar */
    z-index: 999;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--t-base), top var(--t-base);
    width: 100%;
}

.main-header-section.scrolled {
    box-shadow: var(--shadow-md);
}

.curved-header-bg {
    background: #fff;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    border-bottom-left-radius: 0;
    transition: all var(--t-base);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.header-logo span {
    background: var(--grad-warm);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Logo icon container */
.header-logo > div {
    background: var(--grad-primary) !important;
    border-radius: var(--r-md) !important;
    padding: 6px !important;
    height: 40px !important;
    width: 40px !important;
    box-shadow: var(--shadow-coral);
}

.header-logo > div svg {
    fill: #fff !important;
}

.header-search {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: 0.45rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 260px;
    transition: all var(--t-base);
}

.header-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255,107,53,0.12);
    background: #fff;
}

.header-search input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 0.875rem;
    background: transparent;
    color: var(--text);
    font-family: var(--font-ui);
}

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

/* Search button */
.header-search button {
    background: var(--primary) !important;
    border: none !important;
    border-radius: var(--r-full) !important;
    width: 26px !important;
    height: 26px !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all var(--t-fast) !important;
    flex-shrink: 0;
}

.header-search button:hover { background: var(--primary-dark) !important; transform: scale(1.05); }

/* ── Main Navigation ─────────────────────────────────────── */
.main-nav {
    background: transparent;
    backdrop-filter: none;
    padding: 0 2.5rem;
    display: flex;
    gap: 0.25rem;
    align-items: center;
    height: 48px;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

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

.nav-link-item {
    color: var(--text-body);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: var(--r-full);
    border: none;
    transition: all var(--t-fast);
    white-space: nowrap;
    position: relative;
}

.nav-link-item:hover {
    color: var(--primary);
    background: var(--bg-subtle);
}

.nav-link-item.active {
    color: var(--primary);
    background: var(--bg-subtle);
    font-weight: 600;
}

/* Hamburger */
.hamburger-btn {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    display: none;
    border-radius: var(--r-md);
}

.hamburger-btn:hover { background: var(--bg-soft); }

/* Hide old elements */
.navbar { display: none !important; }
.app-sidebar { display: none !important; }
.sidebar-toggle { display: none !important; }

/* ============================================================
   APP LAYOUT — FULL WIDTH (NO SIDEBAR)
   ============================================================ */
.app-layout {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    flex: 1;
    overflow-x: hidden;
}

.app-container {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Legacy header hidden */
header { display: none; }

/* ============================================================
   HERO AREA (Main Header above toolbar)
   ============================================================ */
.main-header {
    background: var(--grad-hero);
    border-radius: var(--r-xl);
    padding: 3rem 3.5rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}

.main-header::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -80px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(79,70,229,0.12) 0%, transparent 70%);
    pointer-events: none;
}

.main-header::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: 30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(8,145,178,0.10) 0%, transparent 70%);
    pointer-events: none;
}

.main-header h1 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text);
    margin-bottom: 0.75rem;
    background: none;
    -webkit-text-fill-color: initial;
}

.main-header h1 span {
    background: var(--grad-warm);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.main-header p {
    color: var(--text-body);
    font-size: 1.05rem;
    max-width: 600px;
    font-weight: 400;
}

/* Override inline styles on main-header section */
section.main-header {
    text-align: left !important;
    background: var(--grad-hero) !important;
    backdrop-filter: none !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}

section.main-header h1 {
    font-size: clamp(1.5rem, 2.5vw, 2.2rem) !important;
    background: none !important;
    -webkit-text-fill-color: var(--text) !important;
    text-transform: none !important;
    letter-spacing: -0.02em !important;
    color: var(--text) !important;
}

section.main-header p {
    color: var(--text-body) !important;
    font-size: 0.975rem !important;
}

/* ============================================================
   TOOLBAR — MODE SELECTION
   ============================================================ */
.toolbar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0;
    border-top: none;
    position: relative;
}

.toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 2rem;
    right: 2rem;
    height: 3px;
    background: var(--grad-primary);
    border-radius: 0 0 var(--r-full) var(--r-full);
}

.mode-group,
.sub-mode-group,
.lang-group,
.type-group,
.diff-group {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
}

/* ── Buttons in Toolbar ──────────────────────────────────── */
.icon-btn,
.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ui);
    cursor: pointer;
    transition: all var(--t-fast);
    padding: 0.35rem 0.75rem;
    border-radius: var(--r-full);
    font-weight: 500;
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.icon-btn:hover,
.mode-btn:hover {
    color: var(--text);
    background: var(--bg-soft);
}

.icon-btn { font-size: 1.2rem; padding: 0.5rem; }

.mode-btn,
.sub-option {
    font-size: 0.82rem;
    padding: 0.35rem 0.8rem;
    border-radius: var(--r-full);
}

.mode-btn.active,
.sub-option.active {
    color: var(--primary);
    background: var(--bg-subtle);
    border: 1px solid rgba(255,107,53,0.3);
    font-weight: 700;
    box-shadow: none;
}

/* Language select */
select {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    padding: 0.4rem 2.2rem 0.4rem 0.85rem;
    border-radius: var(--r-full);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.85em;
    transition: all var(--t-fast);
}

select:hover, select:focus {
    border-color: var(--primary);
    background-color: var(--bg-subtle);
}

/* ============================================================
   TYPING CONTAINER
   ============================================================ */
.typing-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 2.5rem;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    box-shadow: var(--shadow-md);
    margin: 1.25rem 0;
    transition: box-shadow var(--t-base), border-color var(--t-base);
    border-top: none;
    border-left: none;
    overflow: hidden;
}

.typing-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--grad-primary);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.typing-container:focus-within {
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-light);
}

/* Live stats overlay */
.stats-overlay {
    position: absolute;
    top: 1.25rem;
    left: 2rem;
    display: flex;
    gap: 2rem;
    font-size: 1.1rem;
    font-family: var(--font-mono);
    color: var(--primary);
    opacity: 0;
    transition: opacity var(--t-base);
    font-weight: 600;
    z-index: 2;
}

.stats-overlay.visible { opacity: 1; }

/* Words display */
.words-wrapper {
    font-family: var(--font-mono);
    font-size: 1.55rem;
    line-height: 1.65;
    color: var(--text-light);
    word-break: break-word;
    height: 160px;
    overflow: hidden;
    position: relative;
    user-select: none;
    cursor: text;
}

.word {
    display: inline-block;
    margin-right: 0.6em;
}

.letter {
    position: relative;
    transition: color 0.08s;
}

.letter.correct {
    color: var(--correct);
    text-shadow: none;
}

.letter.incorrect {
    color: var(--error);
    text-decoration: underline;
    text-decoration-style: wavy;
}

.letter.extra { color: var(--error-extra); }

/* Typing cursor */
.word.active .letter.active::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 8%;
    height: 84%;
    width: 2.5px;
    background: var(--primary);
    border-radius: var(--r-full);
    animation: blink 1s infinite;
    box-shadow: 0 0 6px rgba(79,70,229,0.5);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.hidden-input {
    position: absolute;
    opacity: 0;
    z-index: -1;
}

/* Restart button */
.restart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
    gap: 0.4rem;
    opacity: 0;
    transition: opacity var(--t-base);
}

.typing-container:hover .restart-container,
.restart-container:focus-within { opacity: 1; }

#restart-btn {
    font-size: 1.4rem;
    padding: 0.75rem;
    background: var(--bg-soft);
    border: 1.5px solid var(--border);
    border-radius: var(--r-full);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--t-base);
}

#restart-btn:hover {
    color: var(--primary);
    transform: rotate(180deg) scale(1.1);
    border-color: var(--primary);
    background: var(--bg-subtle);
    box-shadow: var(--shadow-coral);
}

.key-hint {
    font-size: 0.72rem;
    color: var(--text-light);
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
}

/* ============================================================
   CAPS LOCK WARNING
   ============================================================ */
.caps-lock-warning {
    background: var(--error);
    color: #fff;
    padding: 0.65rem 1.5rem;
    border-radius: var(--r-md);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(230,57,70,0.3);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PARAGRAPH SELECTION
   ============================================================ */
.paragraph-selection h3 {
    text-align: center;
    margin-bottom: 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-body);
}

.paragraph-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
}

.para-btn {
    padding: 0.45rem 1rem;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-body);
    border-radius: var(--r-full);
    cursor: pointer;
    transition: all var(--t-fast);
    font-weight: 500;
    font-size: 0.82rem;
    font-family: var(--font-ui);
}

.para-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-subtle);
}

.para-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-coral);
}

.custom-text-btn {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.custom-text-btn:hover {
    background: var(--accent);
    opacity: 0.85;
    color: #fff;
}

/* ============================================================
   HERO TEST SECTIONS (Practice / Exam modes)
   ============================================================ */
.hero-tests,
.leaderboard-section,
.articles-section,
.faq-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0;
    transition: box-shadow var(--t-base);
    border-top: none;
    position: relative;
    overflow: hidden;
}

/* Decorative corner accent */
.hero-tests::before,
.articles-section::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at top right, rgba(79,70,229,0.06) 0%, transparent 70%);
    pointer-events: none;
}

.hero-tests:hover,
.articles-section:hover {
    box-shadow: var(--shadow-md);
}

.hero-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text);
    text-align: center;
    letter-spacing: -0.02em;
}

.hero-subtext {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 2rem auto;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ── Timed Test / Exam Buttons ───────────────────────────── */
.btn-3d-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-3d {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.75rem;
    text-decoration: none;
    color: var(--primary) !important;
    background: var(--bg-subtle);
    border: 1.5px solid rgba(79,70,229,0.3);
    border-radius: var(--r-full);
    font-weight: 700;
    font-size: 0.9rem;
    transition: all var(--t-base);
    overflow: hidden;
}

.btn-3d::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--grad-primary);
    opacity: 0;
    transition: opacity var(--t-base);
    border-radius: inherit;
}

.btn-3d span { position: relative; z-index: 1; }

.btn-3d:hover {
    color: #fff !important;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-coral);
}

.btn-3d:hover::before { opacity: 1; }
.btn-3d:active { transform: translateY(0); }

/* Exam-mode button variant */
.exam-mode-btn {
    color: var(--accent) !important;
    background: rgba(8,145,178,0.06);
    border-color: rgba(8,145,178,0.3);
}

.exam-mode-btn::before {
    background: var(--grad-accent);
}

.exam-mode-btn:hover {
    color: #fff !important;
    border-color: transparent;
    box-shadow: var(--shadow-teal);
}

/* ============================================================
   INFO / CONTENT SECTIONS
   ============================================================ */
.info-section {
    background: var(--bg-soft) !important;
    border-radius: var(--r-lg) !important;
    padding: 2.5rem !important;
    border: 1px solid var(--border) !important;
    margin-top: 0 !important;
}

.info-section h2 {
    color: var(--text) !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
}

.info-section h3 {
    color: var(--text) !important;
    font-weight: 700 !important;
}

.info-section p, .info-section li {
    color: var(--text-body) !important;
    line-height: 1.75 !important;
}

/* Info card grid items */
.lang-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.4rem;
    transition: all var(--t-base);
}

.lang-card:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow-teal);
    transform: translateY(-2px);
}

.lang-card a {
    color: var(--primary) !important;
    text-decoration: none !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    transition: color var(--t-fast);
}

.lang-card a:hover { color: var(--primary-dark) !important; }

/* ============================================================
   ARTICLE CARDS (Blog / Tools)
   ============================================================ */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.75rem 1.5rem;
    text-align: center;
    text-decoration: none;
    transition: all var(--t-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    position: relative;
    overflow: hidden;
}

.article-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--grad-primary);
    opacity: 0;
    transition: opacity var(--t-base);
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(79,70,229,0.2);
}

.article-card:hover::after { opacity: 1; }

.icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: var(--r-md);
    background: var(--bg-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-base);
}

.article-card:hover .icon-wrapper {
    background: var(--primary);
    color: #fff;
    transform: scale(1.08) rotate(-4deg);
    box-shadow: var(--shadow-coral);
}

.article-card h3 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.article-card p {
    color: var(--text-muted);
    font-size: 0.83rem;
    line-height: 1.5;
}

/* Speed test cards — indigo/cyan gradient variant */
.article-card.speed-test-card {
    background: linear-gradient(145deg, #f8f9ff 0%, rgba(103,100,240,0.07) 100%);
    border-color: rgba(79,70,229,0.18);
}

.article-card.speed-test-card .icon-wrapper {
    background: rgba(79,70,229,0.08);
    color: var(--primary);
}

.article-card.speed-test-card:hover {
    border-color: rgba(79,70,229,0.35);
    box-shadow: var(--shadow-coral);
}

.article-card.speed-test-card:hover .icon-wrapper {
    background: var(--primary);
    color: #fff;
    transform: scale(1.08) rotate(-4deg);
}

.article-card.speed-test-card::before {
    display: none;
}

.article-card.speed-test-card h3 { color: var(--text); }
.article-card.speed-test-card p { color: var(--text-muted); }

/* ============================================================
   FAQ SECTION
   ============================================================ */
.faq-section h2 {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.faq-container { display: flex; flex-direction: column; gap: 0.75rem; }

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: box-shadow var(--t-base);
}

.faq-item:hover { box-shadow: var(--shadow-sm); }

.faq-item summary {
    padding: 1.15rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
    background: var(--bg-card);
    list-style: none;
    transition: background var(--t-fast);
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item[open] summary { background: var(--bg-subtle); color: var(--primary); }

.faq-item summary::after {
    content: '+';
    font-size: 1.4rem;
    color: var(--primary);
    transition: transform var(--t-base);
    font-weight: 300;
    line-height: 1;
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
    color: var(--error);
}

.faq-content {
    padding: 1.15rem 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-body);
    background: var(--bg-card);
    font-size: 0.92rem;
    line-height: 1.75;
    animation: slideDown 0.25s ease;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(26,26,46,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--t-slow), visibility var(--t-slow);
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    padding: 1rem;
    border-radius: var(--r-xl);
    max-width: 780px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(24px) scale(0.97);
    transition: transform var(--t-slow);
    border-top: 4px solid var(--primary);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0) scale(1);
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ── Stats Grid in Modal ────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.stat-big {
    background: var(--bg-soft);
    padding: 0.5rem;
    border-radius: var(--r-md);
    text-align: center;
    border: 1px solid var(--border);
}

.stat-big .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-big .value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.04em;
    line-height: 1;
}

.stat-small {
    background: var(--bg-soft);
    padding: 0.5rem;
    border-radius: var(--r-md);
    text-align: center;
    border: 1px solid var(--border);
}

.stat-small .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.stat-small .value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.chart-container {
    background: var(--bg-soft);
    padding: 1rem;
    border-radius: var(--r-md);
    height: 170px;
    width: 100%;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.primary-btn,
.secondary-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--r-full);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--t-base);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.primary-btn {
    background: var(--grad-primary);
    color: #fff;
    box-shadow: var(--shadow-coral);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(79,70,229,0.35);
}

.primary-btn:active { transform: translateY(0); }

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}

.secondary-btn:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--bg-soft);
}

/* ── Share Buttons ──────────────────────────────────────── */
.share-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.share-buttons .icon-btn {
    font-size: 1.4rem;
    padding: 0.6rem;
    background: var(--bg-soft);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    transition: all var(--t-fast);
}

.share-buttons .icon-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--primary);
    transform: scale(1.1);
}

/* ── Modal Custom Time Input ──────────────────────────── */
#custom-time-input,
#custom-text-input {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--bg-soft);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    border-radius: var(--r-md);
    outline: none;
    transition: all var(--t-base);
    margin: 0 0 1.5rem 0;
}

#custom-text-input {
    height: 200px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.87rem;
}

#custom-time-input:focus,
#custom-text-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* ============================================================
   FOOTER — Premium Multi-Column
   ============================================================ */
.site-footer {
    background: #0F0E2B;
    color: rgba(255,255,255,0.75);
    width: 100%;
    padding: 0;
    margin-top: auto;
}

.footer-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 3.5rem 2rem 2rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2.5rem;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.footer-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--grad-primary);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.footer-logo-icon svg { fill: #fff; }

.footer-brand p {
    font-size: 0.875rem;
    line-height: 1.65;
    color: rgba(255,255,255,0.55);
    max-width: 260px;
}

.footer-social {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.footer-social a {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast);
    color: rgba(255,255,255,0.7);
    text-decoration: none;
}

.footer-social a:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

.footer-col h4 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    margin-bottom: 1rem;
}

.footer-col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.footer-col ul li a {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--t-fast);
}

.footer-col ul li a:hover {
    color: #fff;
    padding-left: 4px;
}

.footer-col ul li a svg {
    opacity: 0;
    transition: opacity var(--t-fast);
    flex-shrink: 0;
}

.footer-col ul li a:hover svg { opacity: 1; }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.08);
}

.footer-bottom-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-bottom p {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
}

.footer-bottom-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-bottom-links a {
    color: rgba(255,255,255,0.4);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: color var(--t-fast);
}

.footer-bottom-links a:hover { color: rgba(255,255,255,0.85); }

/* Legacy footer compat */
footer {
    margin-top: auto;
    padding: 3rem 2rem;
    background: #0F0E2B;
    color: rgba(255,255,255,0.7);
    text-align: center;
    width: 100%;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color var(--t-fast);
}

.footer-links a:hover { color: var(--gold); }

@media (max-width: 900px) {
    .footer-main {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
    .footer-main {
        grid-template-columns: 1fr;
        padding: 2rem 1.25rem 1.5rem;
    }
    .footer-brand { grid-column: auto; }
    .footer-bottom-inner { flex-direction: column; text-align: center; }
    .footer-bottom-links { justify-content: center; }
}

/* ============================================================
   MOBILE WARNING
   ============================================================ */
#mobile-warning {
    background: var(--bg-soft) !important;
    border-radius: var(--r-lg) !important;
    border: 1px solid var(--border) !important;
    padding: 3rem !important;
}

/* ============================================================
   CONTENT SECTION (About, Terms, etc)
   ============================================================ */
.content-section {
    max-width: 820px;
    margin: 2rem auto;
    padding: 2rem 1.5rem;
    color: var(--text);
    line-height: 1.75;
}

.content-section h2 {
    color: var(--primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.content-section p { margin-bottom: 1rem; color: var(--text-body); }
.content-section ul { list-style-position: inside; margin-bottom: 1rem; }
.content-section li { margin-bottom: 0.5rem; color: var(--text-body); }

/* ============================================================
   AD WRAPPER
   ============================================================ */
.ad-wrapper {
    margin: 2rem auto;
    padding: 1rem;
    text-align: center;
    background: var(--bg-soft);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    max-width: 100%;
}

.ad-wrapper::before {
    content: "Sponsored";
    position: absolute;
    top: 6px;
    right: 12px;
    font-size: 0.65rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ============================================================
   LEADERBOARD
   ============================================================ */
.leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.leaderboard-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    background: var(--bg-soft);
}

.leaderboard-table tr {
    background: var(--bg-card);
    transition: all var(--t-fast);
    border: 1px solid var(--border);
}

.leaderboard-table tr:hover {
    background: var(--bg-subtle);
    transform: scale(1.005);
}

.leaderboard-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.rank-cell {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.1rem;
    text-align: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--grad-primary);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
}

/* ============================================================
   MAIN — FLEX COLUMN WITH GAPS
   ============================================================ */
main {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (min-width: 769px) {
    .hamburger-btn { display: none !important; }
    .sidebar-toggle { display: none !important; }
}

@media (max-width: 768px) {
    .top-bar { padding: 0.3rem 1.25rem; }
    .curved-header-bg { padding: 0 1.25rem; height: 60px; }
    .main-nav {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 0 0 var(--r-lg) var(--r-lg);
        padding: 1rem;
        box-shadow: var(--shadow-lg);
        z-index: 500;
        height: auto !important;
    }
    .main-nav.active { display: flex; }
    .hamburger-btn { display: flex !important; }
    .main-header-section { top: 1.5rem; }
    .nav-link-item { border-bottom: none; padding: 0.65rem 1rem; width: 100%; border-radius: var(--r-md); }
    .header-search { display: none; }
    .app-container { padding: 1.5rem 1rem; }
    .toolbar { padding: 0.85rem 1rem; gap: 0.5rem; }
    .divider { display: none; }
    .mode-group, .sub-mode-group, .lang-group, .type-group, .diff-group { justify-content: center; flex-wrap: wrap; }
    .typing-container { padding: 1.5rem; }
    .stats-overlay { position: static; margin-bottom: 1rem; justify-content: center; }
    .words-wrapper { font-size: 1.3rem; }
    .hero-tests, .articles-section, .faq-section, .info-section { padding: 1.75rem 1.25rem !important; }
    .hero-title { font-size: 1.4rem; }
    .btn-3d-container { gap: 0.75rem; }
    .articles-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-content { padding: 1.75rem; border-radius: var(--r-lg); }
    .top-bar-links { gap: 1rem; }
    .footer-links { gap: 1.25rem; }
    .leaderboard-table th, .leaderboard-table td { padding: 0.65rem 0.75rem; }
    section.main-header { padding: 2rem 1.5rem !important; }
    .chart-container { height: 220px; }
}

/* ============================================================
   MICRO-ANIMATIONS & POLISH
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hero-tests,
.info-section,
.articles-section,
.faq-section {
    animation: fadeInUp 0.5s ease both;
}

/* Smooth transition for toolbar buttons */
.mode-btn, .sub-option, .para-btn, .btn-3d, .nav-link-item {
    will-change: transform;
}

/* Focus rings for accessibility */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Highlight first nav link as active */
.nav-link-item:first-child { color: var(--primary); font-weight: 600; }

/* ============================================================
   HERO ICONS ROW — centered, wrapping
   ============================================================ */
.hero-icons-row {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.hero-icon-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    background: rgba(79,70,229,0.06);
    border: 1px solid rgba(79,70,229,0.15);
    border-radius: var(--r-full);
    color: var(--primary-dark);
    font-size: 0.815rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--t-fast);
    white-space: nowrap;
}

.hero-icon-pill svg {
    flex-shrink: 0;
    color: var(--primary);
}

.hero-icon-pill:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-coral);
}

/* ============================================================
   BLOG SECTION — header + 4-card grid, centred & responsive
   ============================================================ */
.blog-section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.blog-section-header h2 {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.blog-section-header p {
    color: var(--text-body);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

/* 4-column grid, wraps to 2 then 1 col */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    justify-items: center;
}

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

@media (max-width: 600px) {
    .blog-grid { grid-template-columns: 1fr; }
    .blog-section-header h2 { font-size: 1.3rem; }
}

/* Article card inside blog-grid */
.blog-grid .article-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 1.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    text-decoration: none;
    color: var(--text);
    transition: all var(--t-base);
    width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.blog-grid .article-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--grad-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--t-base);
}

.blog-grid .article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(79,70,229,0.25);
}

.blog-grid .article-card:hover::after { transform: scaleX(1); }

.blog-grid .article-card .icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 0.25rem;
}

.blog-grid .article-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin: 0;
}

.blog-grid .article-card p {
    font-size: 0.82rem;
    color: var(--text-body);
    line-height: 1.5;
    margin: 0;
    flex: 1;
}

/* Article tag badge */
.article-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(79,70,229,0.08);
    color: var(--primary-dark);
    border: 1px solid rgba(79,70,229,0.18);
    border-radius: var(--r-full);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-top: auto;
}


/* ============================================================
   INNER PAGE — section.main-header center alignment
   Applies to inner pages where section.main-header is the
   page title banner (not the homepage hero)
   ============================================================ */
.app-container > main > section.main-header:not(#typing-section) {
    text-align: center !important;
}

.app-container > main > section.main-header:not(#typing-section) h1 {
    text-align: center !important;
    font-size: clamp(1.5rem, 3vw, 2.2rem) !important;
    margin-left: auto;
    margin-right: auto;
}

.app-container > main > section.main-header:not(#typing-section) p {
    text-align: center !important;
    max-width: 600px;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Homepage hero: left-align within the grid column */
#typing-section .hero-content {
    text-align: left !important;
}

#typing-section .hero-content h1 {
    font-size: clamp(1.75rem, 3.5vw, 2.8rem) !important;
    -webkit-text-fill-color: var(--text) !important;
}

#typing-section .hero-content h1 span {
    -webkit-text-fill-color: transparent !important;
}

/* ============================================================
   RESPONSIVE OVERRIDES — MOBILE & TABLET
   ============================================================ */

/* Tablet & Mobile (< 1024px) */
@media (max-width: 1024px) {
    .top-bar {
        padding: 0.35rem 1.5rem;
    }
    
    .curved-header-bg {
        padding: 0 1.5rem;
    }
    
    .main-nav {
        padding: 0 1.5rem;
    }

    .app-container {
        padding: 2rem 1.5rem;
    }
}

/* Mobile Screens (< 768px) */
@media (max-width: 768px) {
    .top-bar-links {
        display: none; /* Hide top-bar links on mobile */
    }
    
    .top-bar {
        justify-content: center;
        text-align: center;
        padding: 0.35rem 1rem;
    }
    
    #nav-auth-container {
        min-width: unset !important;
        text-align: center;
        flex: 1;
    }

    #nav-auth-container span {
        display: none; /* Hide the separator pip | */
    }

    .curved-header-bg {
        height: 64px;
    }

    .header-logo {
        font-size: 1.1rem;
    }

    .header-logo > div {
        height: 34px !important;
        width: 34px !important;
        padding: 5px !important;
    }

    .header-search {
        display: none; /* Hide search in main header on mobile */
    }

    .hamburger-btn {
        display: flex; /* Show hamburger on mobile */
    }

    .main-nav {
        display: none; /* Hide desktop nav on mobile */
    }

    .app-container {
        padding: 1.5rem 1rem;
    }

    /* Toolbar wrapping */
    .toolbar {
        padding: 1rem;
        gap: 0.75rem;
        justify-content: center;
    }

    .toolbar .divider {
        display: none; /* Hide dividers on mobile for cleaner wrap */
    }

    .mode-group, .sub-mode-group, .lang-group, .type-group, .diff-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }
    
    .mode-btn, .sub-option {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Typing container adjustments */
    .typing-container {
        padding: 1.5rem;
        min-height: 220px;
    }

    .words-wrapper {
        font-size: 1.25rem;
        height: 140px;
    }

    .stats-overlay {
        left: 1.5rem;
        top: 1rem;
        font-size: 0.9rem;
        gap: 1rem;
    }

    /* Footer stacking */
    .footer-main {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 2.5rem;
    }

    .footer-brand {
        align-items: center;
        display: flex;
        flex-direction: column;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-col h4::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .footer-bottom-inner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Very Small Mobile (< 480px) */
@media (max-width: 480px) {
    .header-logo span {
        display: inline-block; /* Ensure title is visible on small screens */
        font-size: 0.9rem;
    }
    
    .toolbar {
        justify-content: center;
    }
    
    .hero-cta-row {
        flex-direction: column !important;
        width: 100%;
        gap: 0.75rem !important;
    }
    
    .hero-cta-primary, .hero-cta-secondary {
        width: 100% !important;
        justify-content: center;
        margin: 0 !important;
    }
}

/* ============================================================
   MOBILE MENU DRAWER
   ============================================================ */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    z-index: 2000;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
}

.mobile-menu-drawer.active {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15,14,43,0.5);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.mobile-menu-close {
    background: var(--bg-soft);
    border: none;
    color: var(--text);
    padding: 0.5rem;
    border-radius: var(--r-md);
    cursor: pointer;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-nav-link {
    color: var(--text-body);
    text-decoration: none;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: var(--r-md);
    transition: all var(--t-fast);
}

.mobile-nav-link:hover, .mobile-nav-link.active {
    background: var(--bg-soft);
    color: var(--primary);
}

.mobile-menu-footer {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}