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

:root {
    --bg: #121212;
    --card: #181818;
    --accent: #1DB954;
    --accent-hover: #1ed760;
    --text: #FFFFFF;
    --text-secondary: #B3B3B3;
    --text-muted: #535353;
    --border: #404040;
    --surface: #282828;
    --surface-dark: #212121;
    --error: #C0392B;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.header-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.header-nav a:hover {
    color: var(--text);
}

/* 3-Column Layout */
.layout-3col {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: 160px 1fr 300px;
    gap: 24px;
}

.sidebar {
    position: sticky;
    top: 84px;
    align-self: start;
}

.main-content {
    min-width: 0;
}

/* Ad Slots */
.ad-slot {
    background: var(--surface-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}

.ad-inline-mobile {
    display: none;
    margin: 24px 0;
}

/* Title */
.main-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Timer Selection */
.timer-selection {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.timer-btn {
    padding: 8px 20px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.timer-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text);
}

.timer-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    font-weight: 600;
}

/* Live Stats */
.live-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-box {
    background: var(--surface);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Typing Area */
.typing-area {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    min-height: 200px;
    cursor: text;
    position: relative;
    transition: border-color 0.2s;
    outline: none;
}

.typing-area:focus,
.typing-area.active {
    border-color: var(--accent);
}

.text-display {
    font-size: 1.25rem;
    line-height: 2;
    font-family: 'Inter', monospace;
    letter-spacing: 0.01em;
    user-select: none;
}

.text-display .char {
    position: relative;
    transition: color 0.05s;
}

.text-display .char.correct {
    color: var(--accent);
}

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

.text-display .char.current {
    border-bottom: 2px solid var(--accent);
    animation: blink 1s step-end infinite;
}

.text-display .char.pending {
    color: var(--text-muted);
}

@keyframes blink {
    50% { border-bottom-color: transparent; }
}

.typing-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.hidden-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Results Screen */
.results-screen {
    background: var(--card);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 32px;
    margin-top: 20px;
    text-align: center;
}

.results-screen h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--accent);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.result-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.result-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 28px;
    border-radius: 999px;
    border: none;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
}

.hidden {
    display: none !important;
}

/* History */
.history-section {
    margin-top: 40px;
}

.history-section h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.history-chart {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    overflow: hidden;
}

.history-chart canvas {
    width: 100% !important;
    height: 200px !important;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: var(--surface);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.history-item .hi-wpm {
    color: var(--accent);
    font-weight: 600;
    font-size: 1rem;
}

.history-item .hi-accuracy {
    color: var(--text-secondary);
}

.history-item .hi-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.no-history {
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
    font-size: 0.875rem;
}

/* Content Section */
.content-section {
    background: var(--surface-dark);
    padding: 60px 24px;
    margin-top: 40px;
}

.content-inner {
    max-width: 900px;
    margin: 0 auto;
}

.content-inner h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    margin-top: 40px;
}

.content-inner h2:first-child {
    margin-top: 0;
}

.content-inner p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

/* Tips Grid */
.tips-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.tip-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
}

.tip-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--accent);
}

.tip-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* FAQ */
.faq-section {
    margin-top: 16px;
}

.faq-item {
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.faq-item summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    content: '-';
}

.faq-item p {
    padding: 0 20px 16px;
    font-size: 0.875rem;
}

/* Cross Links */
.cross-links {
    padding: 60px 24px;
}

.cross-links h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    text-align: center;
}

.cross-links-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
}

.cross-link-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.cross-link-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.cross-link-icon {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--surface);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cross-link-title {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
}

.cross-link-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Footer */
.footer {
    background: var(--surface-dark);
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    text-align: center;
}

.footer-inner {
    max-width: 900px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 16px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
}

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

.footer-copy {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .layout-3col {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .ad-inline-mobile {
        display: block;
    }
}

@media (max-width: 768px) {
    .main-content h1 {
        font-size: 1.5rem;
    }

    .text-display {
        font-size: 1.05rem;
    }

    .typing-area {
        padding: 16px;
    }

    .timer-selection {
        flex-wrap: wrap;
    }

    .live-stats {
        flex-wrap: wrap;
    }

    .stat-box {
        min-width: 80px;
        flex: 1;
    }

    .tips-grid {
        grid-template-columns: 1fr;
    }

    .cross-links-grid {
        grid-template-columns: 1fr;
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .layout-3col {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .result-value {
        font-size: 1.5rem;
    }

    .results-grid {
        grid-template-columns: 1fr 1fr;
    }
}
