/* TullyType Styles - Combined from TullyAPI and TullyDBMS */

/* ===== CSS Variables ===== */
:root {
    /* Colors - TullyAPI Green + TullyDBMS Gradients */
    --accent-color: #10b981;
    --accent-hover: #059669;
    --accent-secondary: #06b6d4;

    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;

    /* Success/Error */
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Finger Colors for Keyboard */
    --left-pinky: #ef4444;
    --left-ring: #f59e0b;
    --left-middle: #10b981;
    --left-index: #06b6d4;
    --right-index: #3b82f6;
    --right-middle: #8b5cf6;
    --right-ring: #ec4899;
    --right-pinky: #f43f5e;
}

[data-theme="dark"] {
    --bg-primary: #0a0f1c;
    --bg-secondary: #141b2d;
    --bg-tertiary: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

.modal-overlay .modal-content {
    width: 100%;
    max-width: 800px;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}

/* ===== Splash Screen (from TullyDBMS) ===== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeOut 0.5s 1s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.splash-content {
    text-align: center;
}

.splash-logo {
    margin-bottom: 2rem;
}

.logo-svg {
    width: 120px;
    height: 120px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.splash-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.splash-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.splash-progress {
    width: 300px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.splash-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    animation: loading 1s ease-in-out;
}

@keyframes loading {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* ===== Header (from TullyAPI) ===== */
.header {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo svg {
    display: block;
}

.header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.header p {
    font-size: 0.9375rem;
    opacity: 0.9;
    margin: 0;
}

.blog-link {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    display: inline-block;
    margin-top: 0.25rem;
    transition: color 0.2s;
}

.blog-link:hover {
    color: white;
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.subscription-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.875rem;
}

.sub-icon {
    font-size: 1rem;
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Main Content ===== */
.main-content {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* ===== Mode Selector ===== */
.mode-selector {
    margin-bottom: 3rem;
}

.mode-selector h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.mode-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.mode-card.active {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.mode-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.mode-card p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* ===== Document Selector ===== */
.document-selector {
    margin-bottom: 2rem;
}

.document-selector h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.document-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.doc-btn {
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.doc-btn:hover {
    border-color: var(--accent-color);
}

.doc-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.pro-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pro-badge-inline {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.samples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.sample-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sample-card:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-md);
}

.sample-card-content {
    flex: 1;
}

.sample-card h4 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.sample-quick-start {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.sample-quick-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.sample-quick-start:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.sample-preview {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sample-length {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 600;
}

/* Upload/Paste Zones */
.upload-zone, .paste-zone {
    margin-top: 1.5rem;
}

.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-dropzone:hover {
    border-color: var(--accent-color);
    background: var(--bg-secondary);
}

.upload-dropzone svg {
    width: 48px;
    height: 48px;
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.upload-dropzone input[type="file"] {
    display: none;
}

.subtext {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

#paste-textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1rem;
}

/* ===== Typing Area ===== */
.typing-container {
    margin-top: 2rem;
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* ===== Table of Contents Sidebar ===== */
.typing-content-wrapper {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.toc-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    position: sticky;
    top: 1rem;
}

.toc-sidebar.hidden {
    display: none;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.toc-header h3 {
    font-size: 1.125rem;
    margin: 0;
    color: var(--text-primary);
}

.toc-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.toc-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

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

.toc-item {
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-align: left;
}

.toc-item:hover {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
    transform: translateX(4px);
}

.toc-item.active {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.15));
    font-weight: 600;
}

.toc-item-number {
    color: var(--accent-color);
    font-weight: 600;
    margin-right: 0.5rem;
}

#toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.text-display {
    flex: 1;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    font-size: 1.5rem;
    line-height: 2;
    font-family: 'Courier New', monospace;
    min-height: 200px;
    max-height: min(600px, 70vh);
    overflow-y: auto;
    scroll-padding-top: 1rem;
    scroll-padding-bottom: 1rem;
}

.text-display .char {
    position: relative;
}

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

.text-display .char.incorrect {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

.text-display .char.current {
    background: var(--accent-color);
    color: white;
}

.text-display.spectator-view .char.spectator-progress {
    color: var(--text-secondary);
}

.text-display.spectator-view .char.current {
    background: var(--accent-color);
    color: white;
}

@media (max-width: 1024px) {
    .typing-container {
        margin-top: 1rem;
    }

    .typing-content-wrapper {
        flex-direction: column;
    }

    .toc-sidebar {
        width: 100%;
        max-height: 240px;
        position: relative;
        top: 0;
    }

    .stats-bar {
        position: sticky;
        top: 0;
        z-index: 5;
        background: var(--bg-primary);
    }

    .text-display {
        max-height: calc(100vh - 320px);
        scroll-padding-top: 4.5rem;
        scroll-padding-bottom: 6rem;
    }

    .input-area {
        position: sticky;
        bottom: 0;
        background: var(--bg-primary);
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        z-index: 5;
    }
}

.input-area {
    margin-bottom: 2rem;
}

.typing-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: none;
}

.typing-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* ===== Results Panel ===== */
.results-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
}

.results-panel h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Key Analysis */
.key-analysis {
    margin-top: 2rem;
}

.key-analysis h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.problem-keys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.problem-key {
    background: var(--error-color);
    color: white;
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
}

/* Typing Heatmap */
.typing-heatmap {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.typing-heatmap h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.heatmap-keyboard {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.heatmap-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.heatmap-key {
    min-width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: help;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.heatmap-key:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.heatmap-legend {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-gradient {
    height: 1.5rem;
    background: linear-gradient(to right,
        rgba(34, 197, 94, 0.15) 0%,
        rgba(220, 100, 100, 0.3) 50%,
        rgba(255, 20, 20, 0.8) 100%
    );
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Finger Guide */
.finger-guide {
    margin-top: 2rem;
}

.finger-guide h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.keyboard-layout {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.key {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
}

.key.home-key {
    border-width: 3px;
}

.key[data-finger="left-pinky"] { border-color: var(--left-pinky); }
.key[data-finger="left-ring"] { border-color: var(--left-ring); }
.key[data-finger="left-middle"] { border-color: var(--left-middle); }
.key[data-finger="left-index"] { border-color: var(--left-index); }
.key[data-finger="right-index"] { border-color: var(--right-index); }
.key[data-finger="right-middle"] { border-color: var(--right-middle); }
.key[data-finger="right-ring"] { border-color: var(--right-ring); }
.key[data-finger="right-pinky"] { border-color: var(--right-pinky); }

.finger-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.finger-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.finger-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.finger-color.left-pinky { background: var(--left-pinky); }
.finger-color.left-ring { background: var(--left-ring); }
.finger-color.left-middle { background: var(--left-middle); }
.finger-color.left-index { background: var(--left-index); }
.finger-color.right-index { background: var(--right-index); }
.finger-color.right-middle { background: var(--right-middle); }
.finger-color.right-ring { background: var(--right-ring); }
.finger-color.right-pinky { background: var(--right-pinky); }

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* ===== Multiplayer/Lobby ===== */
.multiplayer-container {
    max-width: 900px;
    margin: 0 auto;
}

.lobby-selector h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.connection-status {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.connection-status.hidden {
    display: none;
}

.connection-status.info {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.08);
}

.connection-status.warn {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.12);
}

.connection-status.error {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.12);
}

.connection-status.success {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.12);
}

.connection-status .status-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.lobby-divider {
    color: var(--text-secondary);
    font-weight: 600;
}

.join-lobby-section {
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 500px;
}

.lobby-network-settings {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    max-width: 600px;
    width: 100%;
}

.lobby-network-settings h3 {
    margin-bottom: 1rem;
}

.relay-config {
    margin-top: 1rem;
    display: none;
}

.relay-config label {
    display: block;
    margin-bottom: 0.75rem;
}

.relay-config label span {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.relay-help {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.lobby-code-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 600;
}

.lobby-view {
    margin-top: 2rem;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.lobby-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lobby-role {
    padding: 0.5rem 1rem;
    background: var(--accent-color);
    color: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
}

#lobby-code-display {
    font-family: monospace;
    font-size: 1.5rem;
    color: var(--accent-color);
    letter-spacing: 0.1em;
}

.players-section {
    margin-bottom: 2rem;
}

.lobby-doc-hint {
    margin: 0.5rem 0 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.lobby-upload-card {
    border: 2px dashed var(--border-color);
    background: var(--bg-secondary);
}

.lobby-upload-card .sample-quick-start {
    margin-top: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.lobby-upload-card.is-locked {
    opacity: 0.75;
}

.lobby-upload-card.is-locked .sample-quick-start {
    cursor: not-allowed;
}

.lobby-upload-card .sample-quick-start:disabled {
    opacity: 0.75;
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.lobby-leaderboard {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.lobby-leaderboard h3 {
    margin-bottom: 1rem;
}

.host-config-summary {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.host-config-summary h3 {
    margin-bottom: 1rem;
}

.host-config-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.host-config-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.host-config-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.host-config-note {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.leaderboard-list {
    display: grid;
    gap: 0.75rem;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.leaderboard-row.leader {
    border-color: var(--accent-color);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.15);
    transform: translateY(-2px);
}

.leaderboard-rank {
    width: 2rem;
    font-weight: 700;
    color: var(--accent-color);
}

.leaderboard-name {
    flex: 1;
    font-weight: 600;
}

.leaderboard-name small {
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 0.35rem;
}

.leaderboard-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: right;
}

.leaderboard-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

.leaderboard-empty {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
}

.player-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name {
    font-weight: 600;
}

.player-status {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.player-status.ready {
    background: var(--success-color);
    color: white;
}

.player-status.waiting {
    background: var(--warning-color);
    color: white;
}

.ready-section {
    text-align: center;
    margin: 2rem 0;
}

.ready-status {
    color: var(--text-secondary);
    margin-top: 1rem;
}

/* Race Progress */
.race-progress {
    margin-top: 2rem;
}

.progress-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.player-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player-progress-name {
    min-width: 150px;
    font-weight: 600;
}

.player-progress-bar {
    flex: 1;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.player-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    transition: width 0.3s;
}

.player-progress-percent {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
}

/* ===== Free Type ===== */
.free-type-container {
    max-width: 900px;
    margin: 0 auto;
}

.free-type-container h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.free-type-container > p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.free-type-area {
    margin-top: 2rem;
}

.free-type-input {
    width: 100%;
    min-height: 400px;
    padding: 1.5rem;
    font-size: 1.125rem;
    line-height: 1.8;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.free-type-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

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

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-xl {
    padding: 1.25rem 3rem;
    font-size: 1.25rem;
}

/* ===== Footer (from TullyAPI) ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 3rem 2rem 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--text-secondary);
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.footer-section p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== Modals (from TullyDBMS) ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal .modal-content {
    width: 100%;
    max-width: 800px;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 0;
}

/* Removed conflicting .modal-content rule - now using .modal-overlay .modal-content */

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

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#stats-modal .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 2;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

#stats-modal .modal-header > div {
    flex-wrap: wrap;
    justify-content: flex-end;
}

#stats-modal .modal-close {
    font-size: 2.25rem;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    flex: 0 0 auto;
}

.modal-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.settings-section label {
    display: block;
    margin-bottom: 0.5rem;
}

.settings-section label span {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.select-input {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== Cookie Banner (from TullyAPI) ===== */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 2px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.cookie-banner-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.cookie-banner-text h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.cookie-banner-text p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.cookie-banner-buttons {
    display: flex;
    gap: 1rem;
}

.cookie-accept, .cookie-decline {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cookie-accept {
    background: var(--accent-color);
    color: white;
}

.cookie-accept:hover {
    background: var(--accent-hover);
}

.cookie-decline {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.cookie-decline:hover {
    border-color: var(--accent-color);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .header-left {
        flex-direction: column;
        gap: 1rem;
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .header-actions button {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }

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

    .mode-card {
        padding: 1.5rem;
    }

    .stats-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .stat-item {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        padding: 0.75rem;
        background: var(--bg-secondary);
        border-radius: 6px;
    }

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

    .keyboard-row {
        gap: 0.125rem;
    }

    .key {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }

    .lobby-header {
        flex-direction: column;
    }

    .cookie-banner-content {
        flex-direction: column;
        text-align: center;
    }

    .modal-content {
        width: 95%;
        max-width: none;
    }

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

    /* TOC sidebar responsive */
    .typing-content-wrapper {
        flex-direction: column;
    }

    .toc-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        max-height: 300px;
        margin-bottom: 1rem;
    }

    .toc-sidebar.hidden {
        display: none;
    }

    #toc-toggle {
        width: 100%;
        justify-content: center;
    }

    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

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

    /* Hide finger guide on mobile */
    .finger-guide {
        display: none;
    }

    /* Adjust typing input for mobile */
    .typing-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Text display responsive */
    .text-display {
        font-size: 1rem;
        padding: 1rem;
    }

    /* Stats bar responsive */
    .stats-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .stat-item {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 80px;
    }

    /* Chunk navigation buttons on mobile */
    #chunk-progress button {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }

    /* Heatmap keyboard on mobile */
    .heatmap-key {
        min-width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }

    .heatmap-row {
        gap: 0.25rem;
    }

    .typing-heatmap {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .mode-card h3 {
        font-size: 1.25rem;
    }

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

    .result-card {
        padding: 1rem;
    }

    .stats-overview {
        grid-template-columns: 1fr;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
    }

    .keyboard-row {
        gap: 0.0625rem;
    }

    .key {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    /* Further reduce heatmap on very small screens */
    .heatmap-key {
        min-width: 1.5rem;
        height: 1.5rem;
        font-size: 0.65rem;
    }

    /* Stack stat items vertically on very small screens */
    .stat-item {
        flex: 1 1 100%;
    }

    /* Smaller text display on small phones */
    .text-display {
        font-size: 0.9rem;
        padding: 0.75rem;
    }

    /* Adjust chunk progress text size */
    #chunk-progress-text {
        font-size: 0.75rem;
    }
}

/* ===== Achievement Notifications ===== */
.achievement-notification {
    position: fixed;
    top: 100px;
    right: -400px;
    width: 350px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: right 0.3s ease-out;
    text-align: center;
}

.achievement-notification.show {
    right: 20px;
}

/* ===== Stats Modal ===== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.achievement-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s;
}

.achievement-card.unlocked {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.achievement-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.achievement-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.achievement-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.race-history {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.race-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.race-history-item:last-child {
    border-bottom: none;
}

.race-history-item div:first-child {
    color: var(--text-secondary);
}

.race-history-item div:last-child {
    color: var(--accent-color);
    font-weight: 600;
}

/* ===== Loading States ===== */
.loading-spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

/* ===== Keyboard Shortcuts Styles ===== */
.shortcuts-section {
    margin-bottom: 2rem;
}

.shortcuts-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

kbd {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--text-tertiary);
    border-radius: 4px;
    box-shadow: 0 2px 0 var(--text-tertiary);
    white-space: nowrap;
}

.shortcut-item span {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== Smooth Transitions ===== */
.sample-card {
    transition: all 0.2s ease;
}

.sample-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.mode-card {
    transition: all 0.3s ease;
}

.mode-card:hover:not(.active) {
    transform: scale(1.02);
    border-color: var(--accent-color);
}

.achievement-card.unlocked:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* ===== Progress Animations ===== */
.char.correct {
    animation: correctChar 0.1s ease;
}

.char.incorrect {
    animation: incorrectChar 0.2s ease;
}

@keyframes correctChar {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes incorrectChar {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-2px);
    }
    75% {
        transform: translateX(2px);
    }
}

/* ===== Success Effects ===== */
.celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    animation: celebrate 1s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
}

@keyframes celebrate {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1) translateY(-100px);
    }
}

/* ===== Typing Lessons Styles ===== */
.lessons-container {
    max-width: 900px;
    margin: 0 auto;
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.lesson-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.lesson-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.lesson-card:hover::before {
    transform: scaleX(1);
}

.lesson-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.2);
}

.lesson-card:active {
    transform: translateY(-2px);
}

.lesson-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.lesson-card:hover .lesson-icon {
    transform: scale(1.1) rotate(5deg);
}

.lesson-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.lesson-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .lessons-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lesson-card {
        padding: 1.5rem;
    }

    .lesson-icon {
        font-size: 2.5rem;
    }
}

/* ===== Lobby Leaderboard Styles ===== */
.lobby-leaderboard {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.lobby-leaderboard h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.leaderboard-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.leaderboard-item.rank-1 {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: 700;
    min-width: 3rem;
    text-align: center;
}

.leaderboard-player {
    flex: 1;
}

.leaderboard-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.leaderboard-stats {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.leaderboard-progress {
    width: 100px;
}

.progress-bar-mini {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    transition: width 0.3s ease;
}

/* ===== Section Picker Styles ===== */
.section-btn {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.section-btn:hover {
    border-color: var(--accent-color);
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

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

/* ===== Multiplayer Race Results Styles ===== */
.race-final-rankings {
    margin-bottom: 1.5rem;
}

.final-rank-item {
    animation: slideInUp 0.5s ease-out backwards;
}

.final-rank-item:nth-child(1) { animation-delay: 0.1s; }
.final-rank-item:nth-child(2) { animation-delay: 0.2s; }
.final-rank-item:nth-child(3) { animation-delay: 0.3s; }
.final-rank-item:nth-child(4) { animation-delay: 0.4s; }

.rank-gold {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 193, 7, 0.15)) !important;
    border-color: #FFD700 !important;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.rank-silver {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(169, 169, 169, 0.15)) !important;
    border-color: #C0C0C0 !important;
}

.rank-bronze {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(184, 115, 51, 0.15)) !important;
    border-color: #CD7F32 !important;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Race Countdown Overlay Styles ===== */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

.countdown-content {
    text-align: center;
}

.countdown-text {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.countdown-number {
    font-size: 10rem;
    font-weight: 900;
    color: var(--accent-color);
    line-height: 1;
    animation: countdownPulse 1s ease-in-out;
}

.countdown-subtext {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Live WPM Chart Styles ===== */
.live-wpm-chart {
    animation: slideInUp 0.5s ease-out;
}

.live-wpm-chart canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

#wpm-chart-legend {
    animation: fadeIn 0.5s ease-out 0.3s backwards;
}

/* ===== Responsive Styles ===== */
@media (max-width: 768px) {
    .leaderboard-item {
        flex-wrap: wrap;
    }

    .leaderboard-progress {
        width: 100%;
        margin-top: 0.5rem;
    }

    .section-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }

    .live-wpm-chart canvas {
        height: 150px;
    }

    #wpm-chart-legend {
        font-size: 0.75rem;
    }
}
/* Turn Switch Animations */
.turn-pulse {
    animation: turnPulse 0.6s ease-out;
}

@keyframes turnPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Shake animation for errors */
.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Fade in animation for notifications */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Confetti Effect */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    z-index: 10000;
    top: -10px;
    animation: confettiFall linear forwards;
    pointer-events: none;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Fireworks Effect */
.firework {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
}

.spark {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, #fff, #10b981);
    border-radius: 50%;
    animation: sparkExpand 1s ease-out forwards;
    transform-origin: center;
    --angle: 0deg;
}

@keyframes sparkExpand {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(
            calc(cos(var(--angle)) * 100px),
            calc(sin(var(--angle)) * 100px)
        ) scale(0);
        opacity: 0;
    }
}

/* Winner Glow Effect */
.winner-glow {
    animation: winnerGlow 2s ease-in-out infinite;
}

@keyframes winnerGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(16, 185, 129, 0.8), 0 0 60px rgba(6, 182, 212, 0.5);
    }
}

/* Pause Overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.pause-overlay.hidden {
    display: none;
}

.pause-content {
    text-align: center;
    animation: scaleIn 0.4s ease-out;
}

.pause-icon {
    font-size: 8rem;
    margin-bottom: 1rem;
    animation: pausePulse 2s ease-in-out infinite;
}

@keyframes pausePulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

.pause-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.pause-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Typing Insights Panel */
.insight-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: transform 0.2s, border-color 0.2s;
}

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

.insight-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.insight-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

.insight-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.insight-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.insight-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}


/* Difficulty Mode Selector */
.difficulty-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 3px solid var(--border-color);
    transition: all 0.3s;
}

.difficulty-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.difficulty-card.active {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, var(--bg-secondary), rgba(16, 185, 129, 0.05));
}

#difficulty-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#difficulty-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}


/* Streak Calendar */
.streak-stat-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: transform 0.2s, border-color 0.2s;
}

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

.streak-stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.streak-stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

.streak-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.calendar-cell:hover {
    transform: scale(1.2);
    transition: transform 0.2s;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.calendar-legend-square {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
}


/* Daily Goal Tracker */
#daily-goal-badge {
    display: flex;
    align-items: center;
    justify-content: center;
}

.goal-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.goal-option.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1)) !important;
}


/* Typing Speed Progression Graph */
.progression-stat-card {
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--border-color);
}

.progression-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.range-btn.active {
    background: var(--accent-color) !important;
    color: white !important;
}


/* Typing Challenges */
.challenge-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 3px solid var(--border-color);
    transition: all 0.3s;
}

.challenge-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.challenge-card.completed {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(6, 182, 212, 0.05));
    opacity: 0.8;
}

.challenge-stat-box {
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--border-color);
}

.challenge-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.challenge-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}


/* Keyboard Heatmap */
.heatmap-key:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-color) !important;
}

.heatmap-key:active {
    transform: translateY(-2px);
}


/* Warmup Exercises */
.warmup-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 3px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.warmup-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.warmup-card:active {
    transform: translateY(-2px);
}


/* Focus/Zen Mode */
body.focus-mode {
    background: #000;
}

body.focus-mode .typing-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

body.focus-mode .text-display {
    font-size: 1.5rem;
    line-height: 2.5rem;
    text-align: center;
}

body.focus-mode .typing-input {
    font-size: 1.25rem;
    text-align: center;
    padding: 1.5rem;
}

.focus-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.5s ease-out;
}

/* Toggle Switch for Focus Settings */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: 0.4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}


/* Code Practice */
.code-lang-card {
    padding: 2rem 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 3px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.code-lang-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.code-snippet-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.code-snippet-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.code-snippet-card pre {
    transition: background 0.2s;
}

.code-snippet-card:hover pre {
    background: var(--bg-tertiary) !important;
}
