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

body {
    font-family: 'Inter', 'Helvetica Neue', sans-serif;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background-color: #050505;
    position: relative;
}

/* Background Elements */
.gradient-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.7;
}

.sphere-1 {
    width: 40vw;
    height: 40vw;
    background: linear-gradient(40deg, rgba(255, 0, 128, 0.8), rgba(255, 102, 0, 0.4));
    top: -10%;
    left: -10%;
    animation: float-1 15s ease-in-out infinite alternate;
}

.sphere-2 {
    width: 45vw;
    height: 45vw;
    background: linear-gradient(240deg, rgba(72, 0, 255, 0.8), rgba(0, 183, 255, 0.4));
    bottom: -20%;
    right: -10%;
    animation: float-2 18s ease-in-out infinite alternate;
}

.sphere-3 {
    width: 30vw;
    height: 30vw;
    background: linear-gradient(120deg, rgba(133, 89, 255, 0.5), rgba(98, 216, 249, 0.3));
    top: 60%;
    left: 20%;
    animation: float-3 20s ease-in-out infinite alternate;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 40px 40px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    z-index: 0;
    pointer-events: none;
}

.glow {
    position: fixed;
    width: 40vw;
    height: 40vh;
    background: radial-gradient(circle, rgba(72, 0, 255, 0.15), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    animation: pulse 8s infinite alternate;
    filter: blur(30px);
    pointer-events: none;
}

.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

/* Footer Styles */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.credits {
    color: #888;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.credits span {
    color: #4CAF50;
    font-weight: 500;
}

.copyright {
    font-size: 12px;
    opacity: 0.7;
}

.social-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

.social-link {
    color: #888;
    font-size: 18px;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.social-link:hover {
    color: #4CAF50;
    transform: translateY(-3px);
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
}

/* Typing animation styles */
h2 {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cursor {
    animation: blink 1s infinite;
}

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

/* WPM Test Styles - Minimal styles for incorrect keystroke feedback */
#wpm-text span.incorrect {
    color: #ff5252;
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}

.typing {
    border-right: 3px solid #000000;
    animation: blink-caret 0.75s step-end infinite;
}

@keyframes float-1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

@keyframes float-2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-10%, -5%) scale(1.15); }
}

@keyframes float-3 {
    0% { transform: translate(0, 0) scale(1); opacity: 0.3; }
    100% { transform: translate(-5%, 10%) scale(1.05); opacity: 0.6; }
}

@keyframes pulse {
    0% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); }
}

.container {
    text-align: center;
    position: fixed;
    z-index: 10;
    background: rgba(5, 5, 5, 0.85);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 1200px;
    margin: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex: 1;
    margin-bottom: 100px; /* Space for footer */
}

h1 {
    font-size: 64px;
    margin-bottom: 5px;
}

h2 {
    font-size: 40px;
    font-weight: normal;
    color: #ccc;
    margin-top: 0;
    margin-bottom: 64px;
}

h3 {
    font-size: 20px;
    font-weight: normal;
    color: #ccc;
    margin-top: 0;
    margin-bottom: 50px;
}

#keyboard-container {
    position: relative; /* This is the positioning context */
    margin-bottom: 50px;
    width: 1000px;
}

#heatmap-container {
    position: absolute;
    top: -363px; /* Adjust this value to move the heatmap up/down */
    left: 70px;
    width: 100%;
    height: 100%;
    z-index: 10; /* A high z-index to ensure it's on top */
    pointer-events: none; /* Allows clicks to pass through */
}

.heatmap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Sidebar Toggles */
#sidebar .sidebar-toggle {
    display: flex;
    align-items: center;
    margin: 12px 0;
    color: #e0e0e0;
    font-size: 14px;
}

#sidebar .sidebar-toggle:not(:first-child) {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar .switch {
    position: absolute;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-right: 30px;
    margin-left: 125px;
}

/* Sample Buttons */
.sample-buttons {
    margin-bottom: 20px;
    transition: opacity 0.3s ease, height 0.3s ease;
    overflow: hidden;
}

/* Start Screen */
/* WPM Test Styles */
#wpm-test {
    text-align: center;
    margin: 0;
    padding: 0;
}

#wpm-text {
    position: relative;
    display: inline-block;
    text-align: left;
}

#wpm-text span {
    position: relative;
    transition: color 0.1s ease;
}

#wpm-text span.correct {
    color: #0066ff;
}

#wpm-text span.current {
    position: relative;
}

#wpm-text span.current::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 100%;
    height: 2px;
    background: #0066ff;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.start-screen {
    text-align: center;
    margin: 0;
    padding: 0;
    transition: all 0.3s ease;
}

.big-text {
    font-size: 32px;
    color: #fff;
    margin-bottom: 25px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.start-button {
    background: linear-gradient(45deg, #0066ff, #00ccff);
    color: white;
    border: none;
    padding: 10px 40px;
    font-size: 18px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 102, 255, 0.3);
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 1px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        display: block;
        padding-top: 20px;
    }

    .container {
        position: relative;
        width: 90%;
        padding: 1rem;
        margin: 0 auto 120px auto; /* Margin for footer */
        flex: none;
    }

    h1 {
        font-size: 36px;
    }

    h2 {
        font-size: 24px;
        margin-bottom: 32px;
    }

    #keyboard-container {
        width: 100%;
        max-width: 500px; /* Limit keyboard size on mobile */
        margin: 0 auto 20px auto;
    }

    #keyboard-img {
        width: 100%;
        height: auto;
    }

    #heatmap-container {
        top: -180px; /* Adjust for smaller keyboard */
        left: 35px; /* Adjust for smaller keyboard */
    }

    #sidebar {
        position: fixed;
        bottom: 60px; /* Above the main footer */
        left: 0;
        right: 0;
        width: 100%;
        display: flex;
        justify-content: space-around;
        background: rgba(10, 10, 10, 0.9);
        padding: 10px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 99;
    }

    #sidebar .sidebar-toggle {
        margin: 0;
        padding: 0;
        border: none;
        flex-direction: column;
        gap: 5px;
    }

    #sidebar .switch {
        position: static;
        margin: 0;
    }

    .footer {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        text-align: center;
    }

    #stats-container {
        position: static;
        width: 100%;
        margin-top: 20px;
        padding: 1rem;
        background: none;
        border: none;
        box-shadow: none;
    }

    #wpm-start, #wpm-test {
        min-height: auto;
    }

    .big-text {
        font-size: 24px;
    }
}

.start-button:hover {
    transform: translateY(-2px); 
    box-shadow: 0 6px 20px rgba(0, 102, 255, 0.4);
}

.start-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 102, 255, 0.3);
}

.sample-buttons button {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 10px 15px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s, border-color 0.3s;
}

.sample-buttons button:hover {
    background-color: #444;
    border-color: #777;
}

#text-input {
    width: 95%;
    max-width: 980px;
    height: 100px;
    margin-top: 20px;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    font-size: 14px;
    resize: vertical;
    background-color: #222;
    color: #fff;
}

#text-input::placeholder {
    color: #888;
}

#keyboard-img {
    width: 100%;
    display: block;
    position: relative; /* Add positioning context */
    z-index: 1;         /* Ensure it's below the heatmap */
}

#sidebar {
    position: fixed;
    left: 20px;
    top: 20px; /* Fixed distance from top */
    background: rgba(5, 5, 5, 0.85);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: calc(50vh - 30px); /* Half of viewport height minus padding */
    overflow-y: auto; /* Enable scrolling if content is too long */
    scrollbar-width: thin; /* For Firefox */
    scrollbar-color: #555 #333; /* For Firefox */
    cursor: move; /* Fallback */
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
}

#sidebar:active {
    cursor: grabbing;
}

#sidebar .sidebar-toggle:first-child {
    cursor: move; /* Fallback */
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
}

#sidebar .sidebar-toggle:first-child:active {
    cursor: grabbing;
}

/* Stats Container Styles */
#stats-container {
    position: fixed;
    left: 20px;
    top: calc(50vh + 10px); /* Position below the sidebar */
    background: rgba(5, 5, 5, 0.85);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    width: 250px;
    color: #e0e0e0;
    max-height: calc(50vh - 40px);
    overflow-y: auto;
    cursor: move; /* Fallback */
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
}

#stats-container:active {
    cursor: grabbing;
}

#stats-container h3 {
    margin: 0 0 15px 0;
    color: #4CAF50;
    font-size: 1.1em;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
    cursor: move; /* Fallback */
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
}

#stats-container h3:active {
    cursor: grabbing;
}

#stats-container h3 {
    margin: 0 0 15px 0;
    color: #4CAF50;
    font-size: 1.1em;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.stat-label {
    color: #aaa;
    margin-right: 10px;
}

.stat-value {
    color: #fff;
    font-weight: 500;
}

/* Custom scrollbar for Webkit browsers */
#stats-container::-webkit-scrollbar {
    width: 6px;
}

#stats-container::-webkit-scrollbar-track {
    background: #333;
    border-radius: 3px;
}

#stats-container::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 3px;
}

/* Custom scrollbar for Webkit browsers */
#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track {
    background: #333;
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 3px;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    margin: 15px 0;
    color: #ffffff;
    font-size: 14px;
    justify-content: flex-start;
    gap: 10px;
}

.heatmap-size-select {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #555;
    background-color: #333;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
}

.heatmap-size-select:focus {
    outline: none;
    border-color: #4c93af;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-left: 10px;
    order: 2; /* This will move the switch to the right */
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
    border-radius: 24px;
}

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

input:checked + .slider {
    background-color: #4c93af;
}

input:focus + .slider {
    box-shadow: 0 0 1px #4c93af;
}

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

/* Text Input Styles */
#text-input {
    display: block;
    width: 80%;
    max-width: 800px;
    margin: 20px auto;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #444;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    min-height: 120px;
    outline: none;
    transition: all 0.3s ease;
}

#text-input:focus {
    border-color: #4c93af;
    box-shadow: 0 0 10px rgba(76, 147, 175, 0.5);
}

/* Mobile Styles */
@media screen and (max-width: 768px) {
    body {
        padding: 0;
        background: #000;
    }
    
    .container {
        position: relative;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 10px;
        border-radius: 0;
        background: transparent;
        display: flex;
        flex-direction: column;
    }
    
    /* Hide sidebar on mobile */
    #sidebar, #stats-container {
        display: none !important;
    }
    
    /* Mobile toggle buttons container */
    .mobile-toggles {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin: 15px auto;
        width: 90%;
        max-width: 300px;
    }
    
    /* Style for mobile toggle items */
    .mobile-toggle-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px;
        background: rgba(5, 5, 5, 0.7);
        border-radius: 6px;
        color: #e0e0e0;
    }
    
    /* Mobile-specific heatmap container */
    #keyboard-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        position: relative;
        overflow: hidden;
    }
    
    #heatmap-container {
        top: -215px !important;
        left: 42px !important;
        width: 200% !important;
        height: 200% !important;
        transform: scale(0.58);
        transform-origin: top left;
    }
    
    #keyboard-img {
        width: 100%;
        height: auto;
        display: block;
    }
    
    h1 {
        font-size: 1.5rem;
        margin: 0.5rem 0;
    }
    
    h2 {
        font-size: 1rem;
        margin: 0.25rem 0 1rem;
    }
    
    #keyboard-container {
        margin: 0 auto;
        max-width: 100%;
        padding: 0 5px;
    }
    
    #keyboard-img {
        max-width: 100%;
        height: auto;
    }
    
    #heatmap-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    #text-input {
        width: 95%;
        margin: 10px auto;
        padding: 10px;
        min-height: 80px;
        font-size: 14px;
    }
    

}

/* Reset Button Styles */
.reset-button {
    width: 100%;
    padding: 8px 12px;
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.reset-button:hover {
    background: #444;
    border-color: #666;
}

.reset-button:active {
    background: #2a2a2a;
    transform: translateY(1px);
}

.reset-button i {
    font-size: 12px;
}