.snarky-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 180ms ease;
}

.snarky-modal-overlay.show {
    opacity: 1;
}

.snarky-modal {
    background: #0e1722;
    border: 1px solid rgba(6, 182, 212, 0.35);
    border-radius: 14px;
    padding: 18px 20px;
    max-width: 460px;
    width: calc(100% - 32px);
    color: #e6eef6;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
    transform: translateY(12px);
    transition: transform 180ms ease;
}

.snarky-modal-overlay.show .snarky-modal {
    transform: translateY(0);
}

.snarky-modal h3 {
    margin: 0 0 8px 0;
    font-size: 1.05rem;
    color: #06b6d4;
}

.snarky-modal p {
    margin: 0 0 14px 0;
    line-height: 1.4;
    color: #cbd5f5;
}

.snarky-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.snarky-modal-actions button {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
}

.snarky-modal-actions .snarky-modal-ok {
    background: #06b6d4;
    color: #0b1220;
}
/**
 * SnarkyType Main Stylesheet
 * v1.2.0
 * 
 * SECTIONS:
 * 1. General UI & Layout - Body, typography, general elements
 * 2. Topbar - Navigation and header styling
 * 3. Buttons & Controls - All button styles and interactive elements
 * 4. Typing Test Container - Main typing area layout and dimensions
 * 5. Text Styling & Display - Character spans, word display, caret
 * 6. Modal Dialogs - Login, signup, account modals
 * 7. Forms & Inputs - Form elements and validation states
 * 8. Graph/Canvas - Results visualization
 * 9. Footer - Site-wide footer styling
 * 10. Responsive Design - Mobile and tablet optimizations
 * 11. Utility Classes - Helpers and miscellaneous
 * 
 * Color Scheme:
 * - Dark bg: #0b1220 or #1a1a1a
 * - Primary: #06b6d4 (cyan)
 * - Text: #e0e0e0 or #e6eef6
 * - Muted: #888 or #9fb3c9
 * 
 * Make changes to individual sections below as needed.
 */

/* ===== 1. GENERAL UI & LAYOUT ===== */
/* General UI Enhancements (from previous) */
* {
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}


body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;

    .mobile-hints {
        display: none;
    }

    box-sizing: border-box;
}

/* ===== 2. TOPBAR ===== */
#topbar {
    width: 100%;
    max-width: 80%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    font-size: 1.5em;
    font-weight: bold;
    color: #00bcd4;
    /* background-color: gold; */
}

/* ===== Streak Badge (small + minimal) ===== */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: #e6eef6;
    line-height: 1;
    transition: opacity 220ms ease, transform 220ms ease;
}

.streak-badge.is-faded {
    opacity: 0.08;
}

.streak-fire {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.streak-fire img {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    /* Make the fire read as a "white flame" while keeping it tiny */
    filter: grayscale(1) brightness(2.1) contrast(1.2);
}

/* ===== Streak Celebration (prominent but short) ===== */
.streak-badge.streak-celebrate {
    animation: streakCelebrate 950ms ease-out 1;
    transform-origin: center;
}

.streak-badge.streak-celebrate .streak-fire img {
    animation: streakFirePop 950ms ease-out 1;
}

@keyframes streakCelebrate {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.0);
        border-color: rgba(255,255,255,0.08);
    }
    22% {
        transform: scale(1.14);
        box-shadow: 0 0 0 10px rgba(6, 182, 212, 0.16);
        border-color: rgba(6, 182, 212, 0.55);
    }
    55% {
        transform: scale(1.06);
        box-shadow: 0 0 0 18px rgba(6, 182, 212, 0.08);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.0);
        border-color: rgba(255,255,255,0.08);
    }
}

@keyframes streakFirePop {
    0% { transform: scale(1); }
    22% { transform: scale(1.55); }
    55% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .streak-badge.streak-celebrate,
    .streak-badge.streak-celebrate .streak-fire img {
        animation: none !important;
    }
}

/* Fixed overlay used for streak celebrations so it's visible even when the topbar is off-screen */
.streak-celebration-overlay {
    position: fixed;
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    z-index: 50050;
    pointer-events: none;
    opacity: 0;
    transition: opacity 180ms ease;
}

.streak-celebration-overlay.is-visible {
    opacity: 1;
}

#topbar a {
    color: #00bcd4;
    text-decoration: none;
}

/* Ensure buttons inside the topbar use the .btn styling (override anchor color) */
#topbar .btn { color: #fff; background-color: #007bff; }
#topbar .btn:hover { background-color: #06b6d4; color: #0b1220; }

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

#usernameDisplay {
    font-size: 0.9em;
    color: #a0a0a0;
}

a {
    color: #06b6d4;
}

/* ===== 3. BUTTONS & CONTROLS ===== */
.btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.12s ease;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

.btn:hover {
    background-color: #06b6d4;
    color: #0b1220;
    transform: translateY(-2px);
}

#dashboardBtn:hover,
#accountBtn:hover {
    background-color: #06b6d4;
    color: #0b1220;
}

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

/* Small button variant for compact navs */
.btn-sm {
    padding: 6px 10px;
    font-size: 0.85em;
    border-radius: 6px;
    box-shadow: 0 3px 8px rgba(0,123,255,0.18);
    transition-duration: 0.3s;
}

/* Ensure leaderboard and other topbar controls fade in testing mode similarly */
/* Note: brand-title and stats are kept visible for context */
body.testing-mode #leaderboardBtn,
body.testing-mode #dashboardBtn,
body.testing-mode #loginBtn,
body.testing-mode #signupBtn,
body.testing-mode #snarkycoinDisplay,
body.testing-mode #usernameDisplay,
body.testing-mode .alpha-badge,
body.testing-mode #topbar,
body.testing-mode #modeSelector,
body.testing-mode .nav-btn {
    opacity: 0.08;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* When mouse activity is detected during a test, temporarily show ALL UI elements */
body.testing-mode.mouse-active #leaderboardBtn,
body.testing-mode.mouse-active #dashboardBtn,
body.testing-mode.mouse-active #loginBtn,
body.testing-mode.mouse-active #signupBtn,
body.testing-mode.mouse-active #snarkycoinDisplay,
body.testing-mode.mouse-active #usernameDisplay,
body.testing-mode.mouse-active #indexStreak,
body.testing-mode.mouse-active .alpha-badge,
body.testing-mode.mouse-active #topbar,
body.testing-mode.mouse-active #modeSelector,
body.testing-mode.mouse-active .nav-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
}

/* Restart animation for subtle reset feedback */
.restart-anim {
    transition: transform 220ms cubic-bezier(.2,.9,.3,1), opacity 220ms ease;
    transform-origin: center center;
}
.restart-anim.play {
    transform: scale(0.985);
    opacity: 0.98;
}

/* ===== 4. TYPING TEST CONTAINER ===== */
/* Typing test container: exactly 3 visible lines (no more) */
#canvasContainer {
    position: relative;
    width: 100%;
    max-width: 80%;
    /* Calculate height for 3 lines using line-height (46px) plus vertical padding (28px top + 28px bottom) */
    height: calc(46px * 3 + 56px);
    /* 3 lines visible exactly */
    background-color: #2a2a2a;
    border-radius: 12px;
    padding: 28px;
    margin: 30px 0;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    line-height: 46px;
    /* fixed line-height used by caret/snapping */
    font-size: 22px;
    /* larger test font */
    box-sizing: border-box;
}

#typingContent {
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 20px;
    line-height: 46px;
    /* explicit line-height used for snapping */
    font-size: 22px;
    /* larger for readability */
    transition: transform 0.08s ease-out;
    will-change: transform;
}

/* Typing text only */
#container,
#typing-text,
.word,
.char {
    font-family: "Courier New", Courier, monospace;
    font-weight: bold;
    padding: 1px;
}

.word {
    display: inline-block;
    /* margin-right: 5px; */
}

.char {
    display: inline-block;
    transition: background-color 0.1s ease;
    border-bottom: 1px solid transparent;
    user-select: none;
    /* Prevent text selection */
}

.char.correct {
    color: #4CAF50;
}

.char.incorrect {
    color: #f44336;
    background-color: rgba(244, 67, 54, 0.2);
    border-bottom: 1px solid #f44336;
}

/* Add to your existing style.css */

#caret {
    position: absolute;
    background-color: #00bcd4;
    /* Your caret color */
    width: 2px;
    /* Or your desired caret width */
    /* Smooth transitions for both horizontal and vertical movement */
    transition: left 0.08s ease-out, top 0.08s ease-out;
    /* Smooth animation for both axes */
    will-change: left, top;
    /* Optimize for animation */
    pointer-events: none;
    /* Ensure it doesn't block clicks */
    left: 0;
    top: 0;
}

@keyframes caretPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

#caret.idle {
    animation: caretPulse 1.2s ease-in-out infinite;
}

.char.correct {
    transform: translateY(0);
}

.char.justTyped {
    transform: translateY(-1px);
    transition: transform 80ms ease-out;
}


/* Initial character highlight before typing */
.initial-highlight {
    display: inline-block;
    transform-origin: left center;
    transform: scale(1.06);
    color: #ffffff;
    font-weight: 700;
    transition: transform 260ms cubic-bezier(.2, .9, .3, 1), color 220ms ease, opacity 220ms ease;
}

.char {
    transition: color 140ms ease, transform 200ms ease;
}

@keyframes blink {

    from,
    to {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

#stats {
    font-size: 1.4em;
    color: #ddd;
    margin-top: 15px;
    display: flex;
    gap: 25px;
    font-weight: bold;
}

#stats #wpm,
#stats #accuracy,
#stats #timer {
    color: #00bcd4;
}


/* Mode Selector - ANIMATIONS & UI IMPROVEMENTS */
#modeSelector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 30px;
}

#mode-select {
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #00bcd4;
    background-color: #333;
    color: #e0e0e0;
    font-size: 1em;
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20256%20256%22%3E%3Cpath%20fill%3D%22%23e0e0e0%22%20d%3D%22M208.5%2080.5l-80%2080c-3.1%203.1-8.2%203.1-11.3%200l-80-80c-3.1-3.1-3.1-8.2%200-11.3s8.2-3.1%2011.3%200l74.3%2074.3%2074.3-74.3c3.1-3.1%208.2-3.1%2011.3%200s3.1%208.2%200%2011.3z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1em;
    transition: all 0.2s ease-in-out;
    /* Smooth transitions */
}

#mode-select:hover {
    background-color: #444;
}

#mode-select:focus {
    outline: none;
    border-color: #00aacc;
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.5);
}

#mode-options-navbar {
    display: flex;
    gap: 10px;
    background-color: #2a2a2a;
    padding: 8px;
    border-radius: 10px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    /* Add transition for display property (requires JS help) */
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

#mode-options-navbar.show {
    opacity: 1;
    transform: translateY(0);
}


.mode-option-btn {
    background-color: #444;
    color: #e0e0e0;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    outline: none;
    position: relative;
    /* For custom input styling */
}

.mode-option-btn:hover {
    background-color: #555;
    transform: translateY(-1px);
}

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

.mode-option-btn.active {
    background-color: #00bcd4 !important;
    color: #1a1a1a !important;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 188, 212, 0.4);
}

.mode-option-btn input.mode-option-custom {
    background: transparent;
    border: none;
    color: #e0e0e0;
    width: 60px;
    text-align: center;
    font-size: 0.95em;
    padding: 0;
    margin: 0;
    outline: none;
    border-bottom: 1px solid #777;
    transition: border-bottom-color 0.2s ease;
}

.mode-option-btn input.mode-option-custom:focus {
    border-bottom-color: #00bcd4;
}

/* Results Screen */
#resultsScreen {
    background-color: #2a2a2a;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-top: 40px;
    width: 100%;
    max-width: 700px;
    display: none;
    /* Add animation for results screen */
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

#resultsScreen.show {
    opacity: 1;
    transform: translateY(0);
}

#resultsScreen h2 {
    color: #00bcd4;
    margin-bottom: 20px;
    font-size: 2em;
}

#resultsSummary {
    font-size: 1.3em;
    line-height: 1.6;
    color: #e0e0e0;
    margin-bottom: 25px;
}

#resultsCanvas {
    width: 100%;
    height: 250px;
    /* Increased height for better graph visibility */
    display: block;
    margin: 0 auto 25px auto;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #1f1f1f;
}

/* Graph Tooltip */
#graphTooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    pointer-events: none;
    /* Important: don't block mouse events on canvas */
    white-space: nowrap;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
    transform: translate(-50%, -100%) translateY(-10px);
}

#graphTooltip.show {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(-5px);
    /* Move slightly down on show */
}


/* Modal Styling (from previous) */
.modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: #2a2a2a;
    margin: auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.modal-content h2 {
    color: #00bcd4;
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.8em;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content input[type="email"],
.modal-content input[type="password"] {
    padding: 12px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #3a3a3a;
    color: #e0e0e0;
    font-size: 1em;
}

.modal-content input[type="email"]::placeholder,
.modal-content input[type="password"]::placeholder {
    color: #888;
}

.modal-content .btn {
    width: 100%;
    margin-top: 10px;
}

.close {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover,
.close:focus {
    color: #e0e0e0;
    text-decoration: none;
    cursor: pointer;
}

/* Animations for modals */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Focus Modal Styling (from previous) */
#focusModal {
    transition: opacity 0.3s ease-out, display 0.3s ease-out;
    background: rgba(0, 0, 0, 0.6);
}

#focusModal>div {
    background: rgba(30, 30, 30, 0.98);
    color: #fff;
    padding: 50px 70px;
    border-radius: 18px;
    font-size: 2.2rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    opacity: 0.98;
    text-align: center;
    border: 2px solid #00bcd4;
}

#focusModal>div div:last-child {
    font-size: 1.2rem;
    opacity: 0.8;
    margin-top: 15px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-title {
    font-size: 2em;
    font-weight: bold;
    color: #06b6d4;
    cursor: pointer;
    user-select: none;
    letter-spacing: 1px;
    transition: color 0.3s ease;
}

.brand-title:hover {
    color: #ffffff;
}

.alpha-badge code {
    background: #222;
    color: #ffb300;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.9em;
    margin-left: 4px;
}

/* Refresh Animation for Test Content */
@keyframes refreshFadeIn {
    from {
        opacity: 0.3;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#typingContent.refresh-animate {
    animation: refreshFadeIn 0.5s ease-out;
}

@keyframes statsGlow {
    from {
        opacity: 0.5;
        box-shadow: 0 0 0 rgba(0, 188, 212, 0);
    }

    to {
        opacity: 1;
        box-shadow: 0 0 12px rgba(0, 188, 212, 0.4);
    }
}

#stats.refresh-animate {
    animation: statsGlow 0.5s ease-out;
}

/* Portrait-specific shrink using vh to make UI scale smaller on short mobile screens */
@media (max-width: 480px) and (orientation: portrait) {

    /* Scale base font-size by viewport height so UI elements scale proportionally */
    html,
    body {
        /* 2.2vh gives reasonably small but readable text on many phones */
        font-size: calc(2.2vh + 8px);
    }

    /* Make the typing area take more vertical space but scale text with vh */
    #canvasContainer {
        padding: 3vh 3vw !important;
    }

    #typingContent {
        font-size: calc(2.8vh + 6px) !important;
        line-height: 1.25 !important;
    }

    /* Reduce sizes of header and nav to avoid cramping */
    header,
    .topnav,
    nav {
        font-size: calc(1.8vh + 6px) !important;
        padding: 1vh 2vw !important;
    }

    /* Make buttons slightly smaller and touch-friendly */
    button,
    .mode-option-btn {
        padding: 1.2vh 2vw !important;
        font-size: calc(1.8vh + 6px) !important;
    }

    /* Ensure results overlay fits on short screens */
    #resultsScreen {
        padding: 2vh 3vw !important;
    }
}

/* Focused testing mode: hide distractions and emphasize test area */
/* Note: brand-title and stats remain visible for typing context */
body.testing-mode #modeSelector,
body.testing-mode #dashboardBtn,
body.testing-mode #loginBtn,
body.testing-mode #signupBtn,
body.testing-mode #snarkycoinDisplay,
body.testing-mode #usernameDisplay,
body.testing-mode .alpha-badge,
body.testing-mode .nav-btn {
    opacity: 0.08;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Mouse-active overrides to show everything */
body.testing-mode.mouse-active #modeSelector,
body.testing-mode.mouse-active #dashboardBtn,
body.testing-mode.mouse-active #loginBtn,
body.testing-mode.mouse-active #signupBtn,
body.testing-mode.mouse-active #snarkycoinDisplay,
body.testing-mode.mouse-active #usernameDisplay,
body.testing-mode.mouse-active .alpha-badge,
body.testing-mode.mouse-active .nav-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
}

body.testing-mode #canvasContainer {
    /* Keep layout stable: do not change padding, font-size, or width to avoid resizing.
       Only apply a visual emphasis that doesn't affect layout. */
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
}

/* Nav hide/show transitions */
#topbar {
    transition: opacity 0.18s ease, transform 0.18s ease;
}

/* SnarkyCoin icon sizing */
.sc-icon {
    width: 1em;
    height: 1em;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
    display: inline-block;
}

/* ===== LIGHT MODE ===== */
/* Light mode variables and comprehensive theming */
body.light-mode {
    --bg: #f5f5f5;
    --bg-alt: #ffffff;
    --panel: #ffffff;
    --panel-alt: #f9f9f9;
    --muted: #333333;
    --muted-light: #666666;
    --border: #d0d7de;
    --border-light: #e8ecf1;
    --accent: #0891b2;
    --accent-hover: #0e7490;
    --shadow: rgba(0, 0, 0, 0.08);
    color: var(--muted);
    background: var(--bg);
}

body.light-mode * {
    --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Light mode navbar/topbar styling */
body.light-mode #topbar,
body.light-mode .topnav,
body.light-mode .register-header,
body.light-mode .about-topbar {
    background: var(--panel);
    border-bottom-color: var(--border);
    color: var(--muted);
}

body.light-mode .brand-title,
body.light-mode .topnav-brand {
    color: var(--accent) !important;
}

body.light-mode .brand-title:hover,
body.light-mode .topnav-brand:hover {
    color: var(--accent-hover) !important;
}

body.light-mode .topnav-links a,
body.light-mode a {
    color: var(--accent);
}

body.light-mode .topnav-links a:hover,
body.light-mode a:hover {
    color: var(--accent-hover);
}

/* Light mode buttons */
body.light-mode .btn,
body.light-mode .btn-topnav,
body.light-mode button {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

body.light-mode .btn:hover,
body.light-mode .btn-topnav:hover,
body.light-mode button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

body.light-mode .btn-sm {
    background: var(--accent);
    color: white;
}

body.light-mode .btn-sm:hover {
    background: var(--accent-hover);
}

/* Light mode cards and panels */
body.light-mode .card,
body.light-mode .panel,
body.light-mode #canvasContainer,
body.light-mode #stats,
body.light-mode .settings-header,
body.light-mode .settings-section,
body.light-mode .modal-content,
body.light-mode #resultsScreen {
    background: var(--panel);
    color: var(--muted);
    border-color: var(--border);
    box-shadow: 0 1px 4px var(--shadow);
}

body.light-mode .card {
    border: 1px solid var(--border-light);
}

body.light-mode .card:hover {
    box-shadow: 0 4px 8px var(--shadow);
    border-color: var(--accent);
}

body.light-mode .stat-box {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.05) 0%, rgba(8, 145, 178, 0.02) 100%);
    border-color: var(--border-light);
}

body.light-mode .stat-box:hover {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.1) 0%, rgba(8, 145, 178, 0.05) 100%);
}

body.light-mode .recent-test-item {
    background: linear-gradient(90deg, rgba(8, 145, 178, 0.05) 0%, rgba(8, 145, 178, 0) 100%);
    border-left-color: var(--accent);
}

body.light-mode .friend-item {
    background: rgba(8, 145, 178, 0.08);
}

body.light-mode .friend-item:hover {
    background: rgba(8, 145, 178, 0.15);
}

/* Light mode inputs and forms */
body.light-mode input,
body.light-mode textarea,
body.light-mode select {
    background: var(--bg-alt);
    color: var(--muted);
    border-color: var(--border);
}

body.light-mode input:focus,
body.light-mode textarea:focus,
body.light-mode select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

body.light-mode .input-friend {
    border-color: var(--border);
    box-shadow: none;
}

body.light-mode .input-friend:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(8, 145, 178, 0.3);
}

/* Light mode typography */
body.light-mode .primary {
    color: var(--accent);
}

body.light-mode .muted {
    color: var(--muted-light);
}

body.light-mode #typingContent {
    color: var(--muted);
}

body.light-mode .alpha-badge {
    background: var(--bg-alt);
    color: var(--muted);
    border-color: var(--border);
}

body.light-mode .title {
    color: var(--accent);
}

body.light-mode .lb-item {
    border-bottom-color: var(--border-light);
}

body.light-mode .char.correct {
    color: #22c55e;
}

body.light-mode .char.incorrect {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.15);
    border-bottom-color: #ef4444;
}

body.light-mode #caret {
    background-color: var(--accent);
}

body.light-mode .mode-option-btn {
    background: var(--bg-alt);
    color: var(--muted);
    border: 1px solid var(--border);
}

body.light-mode .mode-option-btn:hover {
    background: var(--border-light);
}

body.light-mode .mode-option-btn.active {
    background: var(--accent) !important;
    color: white !important;
}

body.light-mode #mode-select {
    background: var(--bg-alt);
    color: var(--muted);
    border-color: var(--border);
}

/* Light mode modals */
body.light-mode .modal {
    background-color: rgba(0, 0, 0, 0.15);
}

body.light-mode .close {
    color: var(--muted);
}

body.light-mode .close:hover {
    color: var(--accent);
}

/* ===== LIGHT MODE TOGGLE BUTTON ===== */
.light-mode-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.light-mode-toggle:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: rgba(6, 182, 212, 0.5);
}

.light-mode-toggle input {
    display: none;
}

.light-mode-toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: #444;
    border-radius: 10px;
    transition: background 0.3s ease;
}

.light-mode-toggle-slider::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: left 0.3s ease;
}

.light-mode-toggle input:checked + .light-mode-toggle-slider {
    background: #06b6d4;
}

.light-mode-toggle input:checked + .light-mode-toggle-slider::after {
    left: 18px;
}

body.light-mode .light-mode-toggle {
    background: rgba(8, 145, 178, 0.15);
    border-color: rgba(8, 145, 178, 0.5);
}

body.light-mode .light-mode-toggle-slider {
    background: #0891b2;
}

body.light-mode .light-mode-toggle-slider::after {
    background: #f5f5f5;
}

/* Single roast element styling (neutral color, no orange) */
.snarky-text {
    font-style: italic;
    color: #06b6d4;
    /* prominent brand color */
    margin-top: 12px;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.2;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

/* Small celebratory coin float animation */
.coin-fly {
    display: inline-block;
    font-weight: 800;
    color: #06b6d4;
    font-size: 1rem;
    transform: translateY(0);
    opacity: 1;
    animation: coinFloat 1s ease forwards;
}

@keyframes coinFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    60% {
        transform: translateY(-18px) scale(1.05);
        opacity: 0.9;
    }

    100% {
        transform: translateY(-36px) scale(1);
        opacity: 0;
    }
}

/* Site footer (global) */
.site-footer {
    /* position: fixed; */
    left: 0;
    right: 0;
    bottom: 8px;
    text-align: center;
    font-size: 0.85rem;
    color: #94a3b8;
    pointer-events: auto;
    z-index: 1000;
    transition: opacity 220ms ease, transform 220ms ease;
}

.site-footer a {
    color: #94a3b8;
    text-decoration: none;
    margin: 0 8px;
}

.site-footer a:hover {
    color: #06b6d4;
}

/* When testing, reduce footer prominence */
.testing-mode .site-footer {
    opacity: 0.12;
    transform: translateY(4px);
}

/* Small footer specialized style for homepage */
.site-footer.homepage {
    font-size: 0.78rem;
    bottom: 6px;
}

/* ============================================
   MOBILE RESPONSIVE DESIGN
   ============================================ */

/* Tablets & Small Devices (768px and below) */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    #topbar {
        max-width: 100%;
        padding: 12px 0;
        margin-bottom: 15px;
        font-size: 1.2em;
        flex-wrap: wrap;
    }

    .topbar-right {
        gap: 8px;
        flex-wrap: wrap;
        width: 100%;
        margin-top: 10px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.9em;
        color: #fff;
    }

    #canvasContainer {
        max-width: 100%;
        height: calc(46px * 3 + 48px);
        padding: 20px;
        margin: 20px 0;
        font-size: 18px;
        border-radius: 10px;
    }

    #typingContent {
        font-size: 18px;
    }

    #stats {
        font-size: 1em;
        padding: 10px 15px;
        margin: 15px 0;
    }

    #modeSelector {
        max-width: 100%;
        margin: 15px 0;
    }

    #mode-select {
        width: 100%;
        padding: 10px;
        margin-bottom: 12px;
    }

    .mode-options-navbar {
        flex-wrap: wrap !important;
        gap: 8px !important;
        margin-bottom: 15px !important;
    }

    .mode-option-btn {
        padding: 8px 12px !important;
        font-size: 0.9em !important;
        flex: 1 1 calc(50% - 4px);
        min-width: 70px;
    }

    .mode-option-custom {
        width: 50px !important;
    }

    #resultsScreen {
        max-width: 100%;
        padding: 20px;
        margin: 15px 0;
    }

    #resultsScreen h2 {
        font-size: 1.5em;
    }

    #resultsSummary {
        font-size: 1em !important;
    }

    #resultsCanvas {
        height: 300px;
        max-width: 100%;
    }

    .modal-content {
        width: 95%;
        margin: 20% auto;
        padding: 20px;
    }

    /* Form inputs on mobile */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    select {
        font-size: 16px !important;
        padding: 12px !important;
    }

    /* Prevent zoom on input focus on iOS */
    input:focus,
    select:focus,
    textarea:focus {
        font-size: 16px !important;
    }

    .brand-title {
        font-size: 1.5em;
    }

    #onboardingModal {
        padding: 20px !important;
    }

    #onboardingModal>div {
        padding: 30px 20px !important;
        max-width: 95% !important;
    }

    #startTutorialBtn {
        padding: 12px 25px !important;
    }
}

/* Mobile Phones (480px and below) */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    #topbar {
        flex-direction: column;
        gap: 12px;
    }

    .topbar-right {
        width: 100%;
        gap: 6px;
        justify-content: center;
    }

    .brand {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .brand-title {
        font-size: 1.3em;
        letter-spacing: 0.5px;
    }

    .alpha-badge code {
        font-size: 0.8em;
        padding: 1px 6px;
        margin-left: 2px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.85em;
        white-space: nowrap;
    }

    #canvasContainer {
        max-width: 100%;
        height: calc(46px * 2.5 + 40px);
        padding: 16px;
        margin: 15px 0;
        font-size: 16px;
        line-height: 42px;
    }

    #typingContent {
        font-size: 16px;
        line-height: 42px;
    }

    #caret {
        border-right: 2px solid #06b6d4;
    }

    #stats {
        font-size: 0.9em;
        padding: 8px 12px;
        margin: 12px 0;
    }

    #wpm,
    #accuracy {
        font-size: 1.1em;
    }

    #mode-select {
        font-size: 14px;
        padding: 10px;
    }

    .mode-option-btn {
        padding: 7px 10px !important;
        font-size: 0.8em !important;
        flex: 1 1 calc(50% - 4px);
    }

    .mode-option-btn:nth-child(n+3) {
        flex: 1 1 calc(50% - 4px);
    }

    .mode-option-custom input {
        width: 45px !important;
        font-size: 0.8em;
    }

    #resultsScreen {
        padding: 16px;
        margin: 12px 0;
    }

    #resultsScreen h2 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }

    #resultsSummary {
        font-size: 0.9em !important;
    }

    #resultsCanvas {
        height: 250px;
        margin: 15px 0 !important;
    }

    .modal-content {
        width: 95%;
        margin: 25% auto;
        padding: 18px;
    }

    .modal-content h2 {
        font-size: 1.3em;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
        padding: 12px !important;
        border-radius: 6px;
    }

    /* Ensure proper spacing for form */
    #loginForm,
    #signupForm {
        gap: 12px !important;
    }

    #onboardingModal {
        padding: 10px !important;
    }

    #onboardingModal>div {
        padding: 20px 15px !important;
        max-width: 98% !important;
    }

    #onboardingModal h1 {
        font-size: 1.3em;
    }

    #onboardingModal p {
        font-size: 0.95em;
    }

    #startTutorialBtn {
        padding: 10px 20px !important;
        font-size: 0.95em !important;
    }

    /* Make container touch-friendly */
    #canvasContainer {
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    /* Improve focus visual feedback on mobile */
    #canvasContainer:active {
        box-shadow: 0 8px 20px rgba(6, 182, 212, 0.4);
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    #canvasContainer {
        height: calc(46px * 2 + 40px);
        padding: 15px;
        margin: 10px 0;
    }

    #stats {
        margin: 8px 0;
    }

    .mode-options-navbar {
        margin-bottom: 10px !important;
    }
}

/* Very small phones (under 360px width) */
@media (max-width: 360px) {
    #topbar {
        gap: 8px;
    }

    .brand-title {
        font-size: 1.2em;
    }

    .btn {
        padding: 6px 10px;
        font-size: 0.8em;
    }

    #canvasContainer {
        font-size: 14px;
        line-height: 40px;
        height: calc(40px * 2.5 + 32px);
    }

    #typingContent {
        font-size: 14px;
        line-height: 40px;
    }

    .mode-option-btn {
        padding: 6px 8px !important;
        font-size: 0.75em !important;
    }
}

/* ===== 11. TOOLTIP ===== */
.tooltip {
    position: relative;
    /* cursor: help; */
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateX(-50%) translateY(5px);
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip:hover::after,
.tooltip:focus::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tooltip:hover::before,
.tooltip:focus::before {
    opacity: 1;
}