/* ===================================
   TypeFury - Futuristic Typing Test
   Premium Cyber/Neon Theme + Sidebar
   =================================== */

/* --- CSS Variables --- */
:root {
    --bg-deep: #06060f;
    --bg-primary: #0a0a1a;
    --bg-secondary: #0f0f24;
    --bg-card: #12122a;
    --bg-card-hover: #181840;
    --bg-input: #0d0d20;
    --bg-sidebar: #08081a;
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555570;
    --text-word: #4a4a6a;
    --text-active: #ffffff;
    --cyan: #00f0ff;
    --cyan-dim: rgba(0, 240, 255, 0.12);
    --cyan-glow: rgba(0, 240, 255, 0.4);
    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.15);
    --purple-glow: rgba(168, 85, 247, 0.3);
    --orange: #ff6b2b;
    --orange-dim: rgba(255, 107, 43, 0.15);
    --orange-glow: rgba(255, 107, 43, 0.4);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.2);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.2);
    --yellow: #facc15;
    --gold: #ffd700;
    --border: rgba(255, 255, 255, 0.06);
    --border-cyan: rgba(0, 240, 255, 0.15);
    --sidebar-width: 220px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --font-mono: 'JetBrains Mono', monospace;
    --font-display: 'Oswald', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s ease;
}

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-secondary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--cyan);
    color: var(--bg-deep);
}

a {
    text-decoration: none;
    color: inherit;
}

/* Background Grid */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(0, 240, 255, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 240, 255, 0.012) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ==============================
   SIDEBAR
   ============================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--text-primary);
    letter-spacing: 2px;
}

.logo-bolt {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 6px var(--cyan-glow));
}

.logo-text strong {
    color: var(--cyan);
    text-shadow: 0 0 20px var(--cyan-glow);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.sidebar-link:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-link.active {
    color: var(--cyan);
    background: var(--cyan-dim);
}

.sidebar-link.active svg {
    stroke: var(--cyan);
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 14px;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}

.sound-theme-picker {
    margin-bottom: 10px;
}

.sound-theme-label {
    display: block;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
}

.sound-theme-btns {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.sound-theme-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.sound-theme-btn:hover {
    border-color: var(--border-cyan);
    background: var(--bg-card-hover);
    transform: scale(1.08);
}

.sound-theme-btn.active {
    border-color: var(--cyan);
    background: var(--cyan-dim);
    box-shadow: 0 0 10px var(--cyan-dim);
}

.sidebar-sound {
    width: 100%;
    justify-content: center;
}

/* ==============================
   MOBILE BAR
   ============================== */
.mobile-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(6, 6, 15, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 90;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-btn {
    width: 36px;
    height: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.mobile-menu-btn span {
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

/* ==============================
   MAIN WRAPPER
   ============================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* ==============================
   SETTINGS BAR
   ============================== */
.settings-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    margin: 16px 24px 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.settings-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 6px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.mode-btn:hover {
    color: var(--text-secondary);
}

.mode-btn.active {
    background: var(--cyan-dim);
    color: var(--cyan);
}

.dur-btn,
.diff-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
}

.dur-btn:hover,
.diff-btn:hover {
    color: var(--text-secondary);
}

.dur-btn.active,
.diff-btn.active {
    background: var(--bg-card);
    color: var(--cyan);
}

/* ==============================
   AD SLOTS
   ============================== */
.ad-slot {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.ad-top {
    padding-top: 12px;
}

.ad-bottom {
    padding-bottom: 12px;
}

.ad-placeholder {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px dashed rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.6rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-family: var(--font-mono);
    opacity: 0.5;
}

/* ==============================
   TEST AREA
   ============================== */
.test-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 24px 32px;
    position: relative;
    z-index: 1;
    min-height: calc(100vh - 220px);
}

/* --- Circular Timer --- */
.timer-wrapper {
    position: relative;
    width: 130px;
    height: 130px;
    margin-bottom: 20px;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-track {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 4;
}

.timer-progress {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
    filter: drop-shadow(0 0 8px var(--cyan-glow));
}

.timer-progress.warning {
    stroke: var(--yellow);
    filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.4));
}

.timer-progress.critical {
    stroke: var(--red);
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.5));
    animation: timer-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.timer-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-value {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -1px;
}

.timer-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 4px;
}

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 28px;
    padding: 10px 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 56px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.stat-divider {
    width: 1px;
    height: 30px;
    background: var(--border);
}

.streak-item .stat-value {
    color: var(--orange);
    text-shadow: 0 0 10px var(--orange-glow);
}

/* --- Combo Display --- */
.combo-display {
    height: 36px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.combo-text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--orange);
    text-shadow: 0 0 20px var(--orange-glow);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-text.visible {
    opacity: 1;
    transform: scale(1);
}

.combo-text.mega {
    font-size: 1.8rem;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

/* --- Words Display --- */
.words-container {
    position: relative;
    max-width: 720px;
    width: 100%;
    height: 115px;
    overflow: hidden;
    margin-bottom: 20px;
}

.words-blur-top,
.words-blur-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: 20px;
    z-index: 2;
    pointer-events: none;
}

.words-blur-top {
    top: 0;
    background: linear-gradient(to bottom, var(--bg-deep), transparent);
}

.words-blur-bottom {
    bottom: 0;
    background: linear-gradient(to top, var(--bg-deep), transparent);
}

.words-display {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    line-height: 2.2;
    color: var(--text-word);
    text-align: center;
    padding: 6px 16px;
    user-select: none;
    transition: transform 0.3s ease;
}

.words-display .word {
    display: inline-block;
    margin: 0 5px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s ease;
    position: relative;
}

.words-display .word.active {
    color: var(--text-primary);
    background: var(--cyan-dim);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.08);
}

.words-display .word.correct {
    color: var(--green);
}

.words-display .word.incorrect {
    color: var(--red);
    text-decoration: underline;
    text-decoration-color: rgba(239, 68, 68, 0.4);
    text-underline-offset: 4px;
}

.words-display .word .char {
    transition: color var(--transition-fast);
}

.words-display .word .char.correct {
    color: var(--green);
}

.words-display .word .char.incorrect {
    color: var(--red);
    background: var(--red-dim);
    border-radius: 2px;
}

.words-display .word .char.cursor {
    border-left: 2px solid var(--cyan);
    animation: cursor-blink 1s step-end infinite;
    margin-left: -1px;
}

@keyframes cursor-blink {

    0%,
    100% {
        border-color: var(--cyan);
    }

    50% {
        border-color: transparent;
    }
}

/* --- Input --- */
.input-wrapper {
    position: relative;
    max-width: 480px;
    width: 100%;
    margin-bottom: 14px;
}

.type-input {
    width: 100%;
    padding: 14px 24px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.05rem;
    outline: none;
    transition: var(--transition);
    text-align: center;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

.type-input::placeholder {
    color: var(--text-muted);
    font-size: 0.82rem;
    letter-spacing: 0;
}

.type-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 4px var(--cyan-dim), 0 0 30px rgba(0, 240, 255, 0.06);
}

.type-input.error {
    border-color: var(--red);
    box-shadow: 0 0 0 4px var(--red-dim);
    animation: shake 0.3s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-4px);
    }

    40%,
    80% {
        transform: translateX(4px);
    }
}

.input-glow {
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-md);
    background: linear-gradient(45deg, var(--cyan-glow), var(--purple-glow), var(--cyan-glow));
    background-size: 200% 200%;
    animation: glow-rotate 3s ease-in-out infinite;
    opacity: 0;
    z-index: 0;
    filter: blur(8px);
    transition: opacity 0.3s ease;
}

.type-input:focus~.input-glow {
    opacity: 0.35;
}

@keyframes glow-rotate {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* --- Start Prompt --- */
.start-prompt {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    font-family: var(--font-mono);
}

.prompt-key {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* --- Particle Canvas --- */
.particle-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

/* ==============================
   RESULTS OVERLAY
   ============================== */
.results-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 15, 0.92);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    padding: 24px;
}

.results-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.results-card {
    max-width: 540px;
    width: 100%;
    padding: 44px 36px;
    background: var(--bg-card);
    border: 1px solid var(--border-cyan);
    border-radius: var(--radius-xl);
    text-align: center;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 60px rgba(0, 240, 255, 0.04);
}

.results-overlay.visible .results-card {
    transform: translateY(0) scale(1);
}

.results-grade-wrapper {
    margin-bottom: 14px;
}

.results-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    font-family: var(--font-display);
    font-size: 2.3rem;
    font-weight: 700;
    color: var(--cyan);
    background: var(--cyan-dim);
    border: 2px solid var(--cyan);
    text-shadow: 0 0 20px var(--cyan-glow);
    box-shadow: 0 0 30px var(--cyan-dim);
    animation: grade-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

@keyframes grade-pop {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.results-grade.grade-s {
    color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.1);
}

.results-grade.grade-a {
    color: var(--green);
    background: var(--green-dim);
    border-color: var(--green);
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.results-grade.grade-b {
    color: var(--cyan);
}

.results-grade.grade-c {
    color: var(--yellow);
    background: rgba(250, 204, 21, 0.1);
    border-color: var(--yellow);
}

.results-grade.grade-d {
    color: var(--orange);
    background: var(--orange-dim);
    border-color: var(--orange);
}

.results-grade.grade-f {
    color: var(--red);
    background: var(--red-dim);
    border-color: var(--red);
}

.results-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 28px;
    font-weight: 600;
    letter-spacing: 1px;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.result-stat.primary .result-value {
    font-size: 2.4rem;
    color: var(--cyan);
    text-shadow: 0 0 20px var(--cyan-glow);
}

.result-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.results-graph-wrapper {
    margin-bottom: 20px;
    padding: 14px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.results-graph {
    width: 100%;
    height: 110px;
}

.personal-best {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    animation: pb-shine 1s ease 0.5s both;
}

@keyframes pb-shine {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pb-icon {
    font-size: 1.1rem;
}

.pb-text {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--gold);
    letter-spacing: 2px;
    font-weight: 600;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--cyan);
    color: var(--bg-deep);
}

.btn-primary:hover {
    background: #33f5ff;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--cyan-dim);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* --- Icon Button --- */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.icon-btn:hover {
    color: var(--cyan);
    border-color: var(--border-cyan);
}

/* --- Footer --- */
.footer {
    padding: 20px 0;
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 1;
}

.footer-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-brand {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.footer-brand strong {
    color: var(--cyan);
}

.footer-copy {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- Screen Shake --- */
body.screen-shake {
    animation: screen-shake-anim 0.2s ease;
}

@keyframes screen-shake-anim {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .mobile-bar {
        display: flex;
    }

    .main-wrapper {
        margin-left: 0;
        padding-top: 56px;
    }

    .settings-bar {
        margin: 12px 16px 0;
        padding: 10px 12px;
        gap: 4px;
    }

    .settings-divider {
        width: 1px;
        height: 20px;
        margin: 0 4px;
    }

    .dur-btn,
    .diff-btn {
        padding: 5px 8px;
        font-size: 0.65rem;
    }

    .mode-btn {
        padding: 5px 10px;
        font-size: 0.72rem;
    }
}

@media (max-width: 640px) {
    .timer-wrapper {
        width: 100px;
        height: 100px;
    }

    .timer-value {
        font-size: 2rem;
    }

    .stats-bar {
        gap: 14px;
        padding: 8px 18px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .words-display {
        font-size: 1.05rem;
    }

    .words-container {
        height: 95px;
    }

    .type-input {
        font-size: 0.95rem;
        padding: 12px 18px;
    }

    .results-card {
        padding: 28px 20px;
    }

    .results-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-stat.primary .result-value {
        font-size: 1.8rem;
    }

    .footer-container {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }

    .ad-placeholder {
        height: 60px;
    }

    .results-actions {
        flex-direction: column;
    }

    .settings-bar {
        flex-direction: column;
        gap: 8px;
    }

    .settings-divider {
        width: 100%;
        height: 1px;
        margin: 0;
    }
}

/* ===================================================
   NEW SECTIONS — Shared Styles
   =================================================== */
.app-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 0;
}

.app-section:not(.active) {
    display: none;
}

.section-header {
    text-align: center;
    margin-bottom: 28px;
}

.section-header h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-primary);
    margin: 0 0 6px;
    text-shadow: 0 0 15px var(--cyan-glow);
}

.section-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 18px;
    transition: border-color var(--transition);
}

.section-card:hover {
    border-color: var(--border-cyan);
}

.section-card h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 1.1rem;
    margin: 0 0 12px;
}

/* Shared word display */
.words-container {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    height: 120px;
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
}

.words-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.words-display .word {
    color: var(--text-word);
}

.words-display .word.active {
    color: var(--text-primary);
}

.words-display .word.correct {
    color: var(--green);
    opacity: 0.5;
}

.words-display .word.incorrect {
    color: var(--red);
    opacity: 0.5;
}

.words-display .char.correct {
    color: var(--green);
}

.words-display .char.incorrect {
    color: var(--red);
    text-decoration: underline;
    text-decoration-color: var(--red);
}

.words-display .char.cursor {
    border-left: 2px solid var(--cyan);
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0
    }
}

/* Shared type input */
.type-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.type-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 12px var(--cyan-dim);
}

/* Live stats bar */
.live-stats-bar {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 16px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.live-stats-bar span strong {
    color: var(--cyan);
    font-size: 1rem;
}

/* Button styles */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
}

.btn-primary:hover {
    background: rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 15px var(--cyan-dim);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ===================================================
   TYPING PRACTICE
   =================================================== */
.practice-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.practice-controls .dur-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 16px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition);
}

.practice-controls .dur-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.practice-controls .dur-btn.active {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
}

.practice-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

/* Practice summary */
.practice-summary {
    text-align: center;
    padding: 40px 20px;
}

.practice-summary .stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 500px;
    margin: 24px auto;
}

.practice-summary .stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.practice-summary .stat-item .stat-value {
    font-size: 1.8rem;
    font-family: var(--font-display);
    color: var(--cyan);
}

.practice-summary .stat-item .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.practice-summary h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 1.4rem;
}

/* ===================================================
   TYPING LESSONS
   =================================================== */
.lesson-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 10px;
    transition: all var(--transition);
}

.lesson-card.lesson-unlocked {
    cursor: pointer;
}

.lesson-card.lesson-unlocked:hover {
    border-color: var(--cyan);
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.lesson-card.lesson-completed {
    cursor: pointer;
    border-color: rgba(34, 197, 94, 0.2);
}

.lesson-card.lesson-completed:hover {
    border-color: var(--green);
    background: var(--bg-card-hover);
}

.lesson-card.lesson-locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.lesson-card-num {
    font-size: 1.5rem;
    min-width: 40px;
    text-align: center;
}

.lesson-card-info h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: var(--font-body);
}

.lesson-card-info p {
    margin: 0 0 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.lesson-keys {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.lesson-keys code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--cyan);
    font-family: var(--font-mono);
}

.lesson-card-status {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--green);
}

/* Keyboard visual */
.keyboard-visual {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
}

.kb-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: all var(--transition);
}

.kb-key.kb-highlight {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 8px var(--cyan-dim);
}

.kb-key.kb-space {
    min-width: 200px;
}

/* Lesson active stats */
.lesson-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.lesson-stats strong {
    color: var(--cyan);
    font-size: 1rem;
    margin-right: 4px;
}

.lesson-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

/* Lesson complete */
.lesson-complete {
    text-align: center;
    padding: 40px 20px;
}

.lesson-complete h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--text-primary);
}

.lesson-complete .results-grade {
    font-size: 2rem;
    margin: 16px 0;
}

.lesson-result-stats {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin: 20px 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lesson-result-stats strong {
    color: var(--cyan);
    display: block;
    font-size: 1.3rem;
}

.lesson-unlock-msg {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 16px 0 24px;
}

/* ===================================================
   TYPING GAMES
   =================================================== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 28px 24px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.game-card:hover {
    border-color: var(--cyan);
    background: var(--bg-card-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 240, 255, 0.08);
}

.game-card .game-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.game-card h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    margin: 0 0 8px;
}

.game-card p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 0;
    line-height: 1.5;
}

/* Word Rain */
.wr-container {
    text-align: center;
}

.wr-hud {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.wr-hud strong {
    color: var(--cyan);
}

#wrCanvas {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-deep);
    margin-bottom: 12px;
}

.wr-input-row {
    display: flex;
    gap: 10px;
}

.wr-input-row input {
    flex: 1;
}

/* Code Breaker */
.cb-container {
    text-align: center;
}

.cb-hud {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cb-hud strong {
    color: var(--cyan);
}

.cb-sentence {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 8px;
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.8;
    min-height: 60px;
}

.cb-char-feedback {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1.8;
    min-height: 60px;
    text-align: left;
}

.cb-char {
    color: var(--text-word);
}

.cb-char.correct {
    color: var(--green);
}

.cb-char.incorrect {
    color: var(--red);
    text-decoration: underline;
}

/* Game Over */
.game-over {
    text-align: center;
    padding: 30px 20px;
}

.game-over h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--text-primary);
    margin: 0 0 24px;
}

.game-over-stats {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin-bottom: 24px;
}

.game-over-stat {
    text-align: center;
}

.game-over-stat .go-value {
    font-size: 2rem;
    font-family: var(--font-display);
    color: var(--cyan);
}

.game-over-stat .go-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.game-over .personal-best {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    margin-bottom: 20px;
}

.game-over-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ===================================================
   DAILY CHALLENGE
   =================================================== */
.challenge-date {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--cyan);
    text-align: center;
    margin-bottom: 20px;
}

.challenge-info {
    text-align: center;
    padding: 30px;
}

.challenge-info p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 12px 0;
}

.challenge-done {
    text-align: center;
    padding: 20px;
}

.challenge-done h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0 0 16px;
}

.challenge-result-stats {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin: 16px 0;
}

.challenge-result-stat {
    text-align: center;
}

.challenge-result-stat .cr-value {
    font-size: 1.6rem;
    font-family: var(--font-display);
    color: var(--cyan);
}

.challenge-result-stat .cr-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.challenge-active .challenge-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.challenge-active .challenge-stats strong {
    color: var(--cyan);
}

/* Challenge history table */
.challenge-history {
    margin-top: 24px;
}

.challenge-history h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0 0 12px;
}

.challenge-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.challenge-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 0.65rem;
}

.challenge-table td {
    padding: 8px 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.grade-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.grade-badge.grade-s {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
}

.grade-badge.grade-a {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.grade-badge.grade-b {
    background: rgba(0, 240, 255, 0.15);
    color: #00f0ff;
}

.grade-badge.grade-c {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.grade-badge.grade-d {
    background: rgba(255, 107, 43, 0.15);
    color: #ff6b2b;
}

.grade-badge.grade-f {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ===================================================
   MY STATS
   =================================================== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 16px;
    text-align: center;
    transition: border-color var(--transition);
}

.stats-card:hover {
    border-color: var(--border-cyan);
}

.stats-card .stats-value {
    font-size: 2rem;
    font-family: var(--font-display);
    color: var(--cyan);
}

.stats-card .stats-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-transform: uppercase;
    margin-top: 4px;
}

.stats-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.stats-chart-container h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0 0 12px;
}

#statsChart {
    width: 100%;
    border-radius: var(--radius-sm);
}

.stats-pb h3,
.stats-history h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0 0 12px;
}

.stats-pb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 24px;
}

.stats-pb-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
}

.stats-pb-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stats-pb-value {
    font-size: 0.85rem;
    color: var(--cyan);
    font-family: var(--font-mono);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.stats-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 0.65rem;
}

.stats-table td {
    padding: 8px 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.stats-danger {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(239, 68, 68, 0.15);
    text-align: center;
}

.stats-danger .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition);
}

.stats-danger .btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--red);
}

/* ===================================================
   RESPONSIVE — New Sections
   =================================================== */
@media (max-width: 768px) {
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }

    .practice-summary .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .game-grid {
        grid-template-columns: 1fr;
    }

    .kb-key {
        min-width: 28px;
        height: 28px;
        font-size: 0.55rem;
    }

    .kb-key.kb-space {
        min-width: 140px;
    }

    .challenge-result-stats {
        flex-direction: column;
        gap: 12px;
    }

    .game-over-stats {
        flex-direction: column;
        gap: 12px;
    }

    .lesson-result-stats {
        flex-direction: column;
        gap: 12px;
    }
}