:root {
    --bg-color: #0d1117;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-color: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.4);
    --bg-panel: rgba(22, 27, 34, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --key-default: rgba(255, 255, 255, 0.05);
    --key-active: #8b5cf6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    line-height: 1.6;
}

.app-wrapper {
    width: 100%;
    max-width: 800px;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 1rem;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.glow-text {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.accent-text {
    color: var(--accent-color);
    text-shadow: 0 0 20px var(--accent-glow);
}

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

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Tabs */
.mode-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 1rem;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--accent-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--accent-color);
    box-shadow: 0 -2px 10px var(--accent-glow);
}

/* App Content Area */
.app-content {
    padding: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.top-controls {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
    margin-bottom: 1rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.time-settings {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s ease;
}

.time-btn:hover {
    color: var(--text-primary);
}

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

/* Custom toggle button in time settings */
.time-btn.custom-toggle {
    border-left: 1px solid var(--border-color);
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.time-btn.custom-toggle.active {
    background: linear-gradient(135deg, #7c3aed, #38bdf8);
    color: white;
}

/* Custom Time Input Row */
.custom-time-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    animation: fadeInUp 0.25s ease;
}

.custom-time-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.custom-time-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.custom-time-step {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-family: inherit;
}

.custom-time-step:hover {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-color);
}

.custom-time-step:active {
    background: rgba(139, 92, 246, 0.35);
    transform: scale(0.92);
}

.custom-time-input {
    width: 60px;
    height: 36px;
    text-align: center;
    background: transparent;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.custom-time-input::-webkit-inner-spin-button,
.custom-time-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-time-input:focus {
    background: rgba(139, 92, 246, 0.08);
}

.custom-time-unit {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}


.hidden {
    display: none !important;
}

/* Central Display */
.main-display {
    text-align: center;
    margin: 2rem 0;
}

.status-message {
    color: var(--text-secondary);
    height: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    animation: pulse 2s infinite;
}

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

.display-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 7rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
    letter-spacing: -2px;
}

.display-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* osu!mania Keys Visualizer */
.keys-visualizer {
    margin: 1rem 0 2rem 0;
    text-align: center;
    width: 100%;
}

.osu-config {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.key-count-selector {
    display: flex;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.key-count-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.key-count-btn:hover {
    color: var(--text-primary);
}

.key-count-btn.active {
    background: var(--accent-color);
    color: white;
}

.keys-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.key-blocks {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.key-block {
    width: 56px;
    height: 56px;
    background: var(--key-default);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-secondary);
    transition: all 0.05s ease;
}

.key-block.space-key {
    width: 90px;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.key-block.active {
    background: var(--key-active);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(4px);
}

/* Keybind Editor */
.keybind-editor {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    animation: fadeInUp 0.3s ease;
}

.keybind-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.keybind-slots {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.keybind-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    min-width: 60px;
}

.keybind-slot:hover {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.05);
}

.keybind-slot.editing {
    border-color: var(--accent-color);
    background: rgba(139, 92, 246, 0.12);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
    animation: pulse 1.5s infinite;
}

.keybind-slot-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
}

.keybind-slot-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.keybind-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.keybind-done-btn {
    background: var(--accent-color) !important;
    color: white !important;
    border-color: var(--accent-color) !important;
}

/* Stats Row */
.stats-row {
    display: flex;
    width: 100%;
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Action Button */
.results-action {
    margin-top: 1.5rem;
    width: 100%;
}

/* (Share button removed — future leaderboard feature) */

/* SEO Content Section */
.seo-content {
    padding: 2.5rem;
}

.seo-content h2 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.seo-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.seo-content strong {
    color: var(--text-primary);
}

.grid-card-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 2rem 0;
}

.info-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.info-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.info-card p {
    margin-bottom: 0;
    font-size: 1rem;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 600px) {
    .app-header h1 {
        font-size: 2.2rem;
    }
    .display-number {
        font-size: 5rem;
    }
    .grid-card-layout {
        grid-template-columns: 1fr;
    }
    .stats-row {
        flex-direction: column;
    }
    .cps-click-area {
        height: 180px;
    }
    .click-counter {
        font-size: 3.5rem;
    }
    .cps-timer {
        font-size: 2rem;
    }
    .site-nav {
        gap: 0.25rem;
    }
    .nav-link {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
    .osu-config {
        flex-direction: column;
        gap: 0.5rem;
    }
    .key-block {
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
    }
    .key-block.space-key {
        width: 72px;
        font-size: 0.65rem;
    }
    .keybind-slot {
        min-width: 50px;
        padding: 0.4rem 0.5rem;
    }
    .keybind-actions {
        flex-direction: column;
    }
    .time-settings {
        flex-wrap: wrap;
        justify-content: center;
    }
    .custom-time-row {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.6rem 0.75rem;
    }
    .top-controls {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: center;
    }
}

/* ===== Cross-Page Navigation ===== */
.site-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.nav-link.active {
    color: var(--accent-color);
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.12);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* ===== CPS Test Styles ===== */

/* Timer Area */
.cps-timer-area {
    text-align: center;
    margin-bottom: 1.5rem;
    width: 100%;
}

.cps-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cps-timer-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 0.25rem;
}

.cps-progress-wrap {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.cps-progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-color), #38bdf8);
    border-radius: 2px;
    transition: width 0.05s linear;
}

/* Click Target Area */
.cps-click-area {
    width: 100%;
    max-width: 420px;
    height: 220px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(56, 189, 248, 0.12));
    border: 2px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
    transition: transform 0.06s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    margin: 1rem 0 1.5rem 0;
}

.cps-click-area:hover {
    border-color: rgba(139, 92, 246, 0.35);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.12);
}

.cps-click-area.testing {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.2);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(56, 189, 248, 0.22));
}

.cps-click-area.finished {
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 40px rgba(56, 189, 248, 0.15);
    cursor: default;
}

.click-area-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
    pointer-events: none;
}

.click-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.click-area-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

/* Ripple Animation */
.click-ripple {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.35);
    transform: translate(-50%, -50%) scale(0);
    animation: ripple-expand 0.45s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-expand {
    to {
        transform: translate(-50%, -50%) scale(14);
        opacity: 0;
    }
}

/* Results Panel */
.cps-results {
    width: 100%;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    animation: fadeInUp 0.4s ease;
}

.cps-rating {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    padding: 1rem 1.5rem;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    width: 100%;
}

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