:root {
    --bg-primary: #050810;
    --bg-secondary: #080d1a;
    --bg-card: #0c1220;
    --bg-card-hover: #101829;
    --border: rgba(34, 211, 238, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.05);
    --text-primary: #e8edf7;
    --text-secondary: #8899b4;
    --text-muted: #4a5a72;
    --accent: #22d3ee;
    --accent-dim: rgba(34, 211, 238, 0.15);
    --accent-glow: rgba(34, 211, 238, 0.06);
    --success: #34d399;
    --error: #f87171;
    --cursor-color: #38bdf8;
    --char-pending: #3a4a60;
    --char-correct: #34d399;
    --char-wrong: #f87171;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Manrope', sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(34, 211, 238, 0.2);
    border-radius: 4px;
}

/* ── Selection ── */
::selection {
    background: rgba(34, 211, 238, 0.2);
    color: var(--text-primary);
}

/* ── Background mesh ── */
.bg-mesh {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(34, 211, 238, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(56, 189, 248, 0.03) 0%, transparent 60%),
        radial-gradient(ellipse 100% 80% at 50% 50%, rgba(8, 13, 26, 0) 0%, var(--bg-primary) 100%);
}

/* ── Nav ── */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(5, 8, 16, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 32px;
    list-style: none;
}

.nav-links a {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: 0.3px;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text-primary);
}

.nav-cta {
    background: var(--accent-dim);
    border: 1px solid rgba(34, 211, 238, 0.2);
    color: var(--accent) !important;
    padding: 7px 18px;
    border-radius: 8px;
    transition: all 0.2s !important;
}

.nav-cta:hover {
    background: rgba(34, 211, 238, 0.22) !important;
    color: var(--accent) !important;
}

/* ── Hero ── */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 24px 60px;
    position: relative;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    border: 1px solid rgba(34, 211, 238, 0.18);
    border-radius: 100px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 32px;
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.hero h1 {
    font-size: clamp(40px, 6vw, 72px);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -2px;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.hero h1 em {
    font-style: normal;
    color: var(--accent);
}

.hero p {
    font-size: clamp(15px, 2vw, 18px);
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 44px;
    line-height: 1.7;
    font-weight: 400;
}

.hero-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary {
    background: var(--accent);
    color: #050810;
    font-size: 14px;
    font-weight: 700;
    padding: 14px 32px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    letter-spacing: 0.2px;
}

.btn-primary:hover {
    background: #38e8ff;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(34, 211, 238, 0.2);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    padding: 14px 28px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.hero-stats {
    display: flex;
    gap: 48px;
    justify-content: center;
    margin-top: 64px;
    flex-wrap: wrap;
}

.hero-stat {
    text-align: center;
}

.hero-stat .val {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.hero-stat .lbl {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.4px;
    margin-top: 2px;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: var(--border-subtle);
    align-self: center;
}

/* ── Section titles ── */
.section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

.section-title {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 16px;
}

.section-sub {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.65;
    max-width: 520px;
}

/* ── Typing Arena ── */
#typing-arena {
    padding: 100px 24px;
    position: relative;
}

.arena-container {
    max-width: 900px;
    margin: 0 auto;
}

.arena-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.difficulty-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 4px;
    border-radius: 10px;
}

.diff-tab {
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
    letter-spacing: 0.2px;
}

.diff-tab:hover {
    color: var(--text-secondary);
}

.diff-tab.active {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.timer-controls {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 4px;
    border-radius: 10px;
}

.timer-btn {
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}

.timer-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

/* ── Typing Card ── */
.typing-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.typing-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.15), transparent);
}

.typing-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border-subtle);
}

.timer-display {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Manrope', sans-serif;
    letter-spacing: -1px;
    min-width: 60px;
}

.timer-display.warning {
    color: #fbbf24;
}

.timer-display.critical {
    color: #f87171;
}

.progress-bar-wrap {
    flex: 1;
    margin: 0 24px;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sound-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-muted);
}

.sound-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
}

.sound-btn.active {
    color: var(--accent);
    border-color: rgba(34, 211, 238, 0.25);
}

.reset-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-muted);
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
    transform: rotate(180deg);
}

/* ── Text Display ── */
.text-display-wrap {
    padding: 40px 40px 32px;
    min-height: 200px;
    position: relative;
    cursor: text;
}

.text-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(20px, 3.2vw, 32px);
    line-height: 1.85;
    letter-spacing: 0.02em;
    word-break: break-word;
    user-select: none;
    position: relative;
}

.char {
    color: var(--char-pending);
    position: relative;
    transition: color 0.08s;
}

.char.correct {
    color: var(--char-correct);
}

.char.wrong {
    color: var(--char-wrong);
    background: rgba(248, 113, 113, 0.1);
    border-radius: 2px;
}

.char.cursor::after {
    content: '';
    position: absolute;
    left: -1px;
    top: 5%;
    height: 90%;
    width: 2px;
    background: var(--cursor-color);
    border-radius: 2px;
    animation: blink 1s ease-in-out infinite;
}

.char.space.cursor::after {
    left: 0;
}

@keyframes blink {

    0%,
    45% {
        opacity: 1;
    }

    55%,
    100% {
        opacity: 0;
    }
}

.typing-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    top: 0;
    left: 0;
}

.click-to-start {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: rgba(5, 8, 16, 0.6);
    backdrop-filter: blur(2px);
    border-radius: 0 0 20px 20px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.click-to-start.hidden {
    opacity: 0;
    pointer-events: none;
}

.click-to-start-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.click-to-start-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.typing-bottom {
    padding: 16px 28px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.typing-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.char-counter {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ── Result Screen ── */
.result-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(5, 8, 16, 0.92);
    backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.result-overlay.visible {
    display: flex;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid rgba(34, 211, 238, 0.12);
    border-radius: 24px;
    padding: 48px;
    max-width: 680px;
    width: 100%;
    position: relative;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.35), transparent);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.result-header {
    text-align: center;
    margin-bottom: 40px;
}

.result-rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 20px;
    border: 1px solid;
}

.result-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.result-msg {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.result-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

@media (max-width: 560px) {
    .result-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-card {
        padding: 32px 24px;
    }

    .text-display {
        font-size: 18px;
    }

    .text-display-wrap {
        padding: 24px 20px;
    }

    .typing-top-bar {
        padding: 14px 18px;
    }

    .diff-tab,
    .timer-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .hero-stats {
        gap: 24px;
    }

    .stat-divider {
        display: none;
    }
}

.metric-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 20px 16px;
    text-align: center;
}

.metric-val {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.metric-lbl {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.metric-val.accent {
    color: var(--accent);
}

.metric-val.success {
    color: var(--success);
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.result-actions .btn-primary {
    flex: 1;
    justify-content: center;
}

.result-actions .btn-secondary {
    flex: 1;
    justify-content: center;
}

/* ── Features ── */
#features {
    padding: 100px 24px;
}

.features-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.features-head {
    text-align: center;
    margin-bottom: 60px;
}

.features-head .section-sub {
    margin: 0 auto;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 900px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .features-grid {
        grid-template-columns: 1fr;
    }

    .nav-links {
        display: none;
    }
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 28px;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.feature-card:hover {
    border-color: rgba(34, 211, 238, 0.15);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.feature-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-dim);
    border: 1px solid rgba(34, 211, 238, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    color: var(--accent);
}

.feature-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.2px;
}

.feature-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ── Why section ── */
#why {
    padding: 100px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.why-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    align-items: center;
}

@media (max-width: 768px) {
    .why-inner {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

.why-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 32px;
}

.why-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.why-check {
    width: 22px;
    height: 22px;
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--success);
}

.why-item-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.why-item-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

.why-visual {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 32px;
    position: relative;
    overflow: hidden;
}

.why-visual::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.2), transparent);
}

.wpm-demo {
    text-align: center;
    padding: 24px 0 16px;
}

.wpm-big {
    font-size: 80px;
    font-weight: 800;
    letter-spacing: -4px;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent), #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.wpm-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

.wpm-bar-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 28px;
}

.wpm-bar-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpm-bar-name {
    font-size: 12px;
    color: var(--text-muted);
    width: 72px;
    flex-shrink: 0;
    font-weight: 500;
}

.wpm-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
}

.wpm-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
}

.wpm-bar-val {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    width: 36px;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

/* ── Footer ── */
footer {
    padding: 48px 24px;
    border-top: 1px solid var(--border-subtle);
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-logo {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.footer-logo span {
    color: var(--accent);
}

.footer-copy {
    font-size: 13px;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 24px;
    list-style: none;
}

.footer-links a {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-secondary);
}

/* ── Fade-in animation ── */
.fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}