body {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -webkit-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    background-attachment: fixed;
    min-height: 100%;
    color: #e2e8f0;
    overflow-x: hidden;
    opacity: 0;
    animation: pageLoad 1.2s ease-out forwards;
}

/* Custom Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 15, 35, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #00d4ff 0%, #00b4d8 50%, #0077b6 100%);
    border-radius: 10px;
    border: 2px solid rgba(15, 15, 35, 0.8);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #33ddff 0%, #00d4ff 50%, #00b4d8 100%);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
    transform: scale(1.05);
}

::-webkit-scrollbar-thumb:active {
    background: linear-gradient(135deg, #66e6ff 0%, #33ddff 50%, #00d4ff 100%);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.7);
}

::-webkit-scrollbar-corner {
    background: rgba(15, 15, 35, 0.8);
}

/* Firefox Scrollbar Styling */
html {
    scrollbar-width: thin;
    scrollbar-color: #00d4ff rgba(15, 15, 35, 0.8);
}

/* Custom Text Selection Styling */
::selection {
    background: #00d4ff;
    color: #0f0f23;
    text-shadow: none;
}

::-moz-selection {
    background: #00d4ff;
    color: #0f0f23;
    text-shadow: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-logo {
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, #00d4ff, #00b4d8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    animation: logoGlow 2s ease-in-out infinite alternate;
}


html {
    height: 100%;
    scroll-behavior: smooth;
}

/* Page Loading Animation */
@keyframes pageLoad {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 50%;
    border-top-color: #00d4ff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Navigation */
#navbar {
    margin: 0;
    padding: 4px 20px;
    background: linear-gradient(135deg,
            rgba(0, 212, 255, 0.15) 0%,
            rgba(15, 15, 35, 0.8) 25%,
            rgba(0, 180, 216, 0.12) 50%,
            rgba(15, 15, 35, 0.85) 75%,
            rgba(0, 212, 255, 0.1) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0px;
    left: 50%;
    width: auto;
    max-width: calc(100% - 2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
    list-style: none;
}

#navbar.hidden {
    transform: translateX(-50%) translateY(-120px);
    opacity: 0;
    pointer-events: none;
}

#navbar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

#navbar:hover {
    box-shadow: 0 12px 40px rgba(0, 212, 255, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg,
            rgba(0, 212, 255, 0.2) 0%,
            rgba(15, 15, 35, 0.85) 25%,
            rgba(0, 180, 216, 0.15) 50%,
            rgba(15, 15, 35, 0.9) 75%,
            rgba(0, 212, 255, 0.15) 100%);
}

#title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    cursor: pointer;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #00d4ff, #00b4d8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#title:hover {
    background: linear-gradient(135deg, #33ddff, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transform: scale(1.08) rotate(1deg);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    color: #a0aec0;
    font-weight: 500;
    font-size: 15px;
    padding: 12px 20px;
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #00d4ff, #00b4d8);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(0, 212, 255, 0.15);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.2);
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link:hover::after {
    width: 80%;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-toggle:hover {
    color: #ffffff;
    background: rgba(0, 212, 255, 0.15);
    transform: scale(1.1) rotate(90deg);
}

/* Mobile Menu */
.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(135deg,
            rgba(15, 15, 35, 0.95) 0%,
            rgba(26, 26, 46, 0.95) 50%,
            rgba(22, 33, 62, 0.95) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    margin-top: 8px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37);
    transform-origin: top center;
}

.mobile-menu.show {
    display: block;
    animation: slideDownBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideDownBounce {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }

    60% {
        opacity: 0.8;
        transform: translateY(5px) scale(1.05);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.mobile-menu .nav-item {
    margin: 8px 0;
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInMobile 0.4s ease-out forwards;
}

.mobile-menu .nav-item:nth-child(1) {
    animation-delay: 0.1s;
}

.mobile-menu .nav-item:nth-child(2) {
    animation-delay: 0.2s;
}

.mobile-menu .nav-item:nth-child(3) {
    animation-delay: 0.3s;
}

.mobile-menu .nav-item:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes slideInMobile {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mobile-menu .nav-link {
    width: 100%;
    text-align: center;
    padding: 16px;
    border-radius: 12px;
}

/* Main Test Container */
#test-box {
    max-width: 1000px;
    margin: 80px auto 40px;
    padding: 40px;
    background: rgba(15, 15, 35, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#test-box:hover {
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: 0 30px 100px rgba(0, 212, 255, 0.15);
    transform: translateY(-8px) scale(1.02);
}

/* Text Display */
#text-display {
    font-size: 24px;
    line-height: 1.8;
    padding: 30px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    word-spacing: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    min-height: 120px;
    display: block;
    box-sizing: border-box;
    max-width: 100%;
    text-align: center;
    color: #a0aec0;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

    
#text-display:hover {
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.15);
    color: #ffffff;
    transform: scale(1.02);
    background: rgba(0, 0, 0, 0.6);
}

/* Text Input */
#text-input {
    width: 100%;
    font-size: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-sizing: border-box;
    margin-bottom: 24px;
}

#text-input:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.02);
}

#text-input::placeholder {
    color: #a0aec0;
    opacity: 0.7;
}

/* Stats Section */
#stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    background: rgba(15, 15, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: #a0aec0;
}

.stat-item:hover {
    transform: translateY(-6px) scale(1.05);
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 15px 40px rgba(0, 212, 255, 0.2);
    background: rgba(15, 15, 35, 0.8);
}

#wpm,
#accuracy,
#time {
    font-size: 28px;
    font-weight: 700;
    color: #00d4ff;
    display: block;
    margin-top: 8px;
}

/* Controls */
#controls {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: rgba(15, 15, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#controls:hover {
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(15, 15, 35, 0.8);
}

#controls label {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 16px;
}

#time-select {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

#time-select:hover {
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(0, 0, 0, 0.7);
}

#time-select:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* Restart Button */
#restart-btn {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, #00d4ff 0%, #00b4d8 100%);
    color: #0f0f23;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
}

#restart-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 45px rgba(0, 212, 255, 0.5);
    background: linear-gradient(135deg, #33ddff 0%, #00d4ff 100%);
}

#restart-btn:active {
    transform: translateY(-2px) scale(1.02);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg,
            rgba(15, 15, 35, 0.95) 0%,
            rgba(26, 26, 46, 0.95) 50%,
            rgba(22, 33, 62, 0.95) 100%);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    text-align: center;
}

#close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

#close-modal:hover {
    color: #ffffff;
    background: rgba(255, 107, 107, 0.2);
    transform: scale(1.1);
}

.modal-content h2 {
    font-size: 32px;
    font-weight: 700;
    color: #00d4ff;
    margin: 0 0 30px 0;
}

.modal-content p {
    font-size: 18px;
    margin: 16px 0;
    color: #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content span {
    font-weight: 700;
    color: #00d4ff;
    font-size: 20px;
}

/* Text styling for typing test */
.correct {
    background-color: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border-radius: 3px;
    padding: 1px 2px;
}

.incorrect {
    background-color: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border-radius: 3px;
    padding: 1px 2px;
}

.current {
    background-color: rgba(0, 212, 255, 0.3);
    color: #00d4ff;
    border-radius: 3px;
    padding: 1px 2px;
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0.3;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #navbar {
        width: calc(100% - 2px);
        padding: 4px 14px;
        top: 0px;
    }

    .nav-links {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    #title {
        font-size: 24px;
    }

    #test-box {
        margin: 50px 20px 40px;
        padding: 24px;
    }

    #text-display {
        font-size: 18px;
        padding: 20px;
        min-height: 100px;
    }

    #text-input {
        font-size: 16px;
        padding: 16px;
    }

    #stats {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px;
    }

    .stat-item {
        padding: 16px;
    }

    #wpm,
    #accuracy,
    #time {
        font-size: 24px;
    }

    #controls {
        flex-direction: column;
        gap: 8px;
    }

    #restart-btn {
        padding: 16px 24px;
        font-size: 15px;
    }

    .modal-content {
        padding: 30px 20px;
        margin: 20px;
    }

    .modal-content h2 {
        font-size: 24px;
    }

    .modal-content p {
        font-size: 16px;
        flex-direction: column;
        text-align: center;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    #navbar {
        width: calc(100% - 2px);
        padding: 4px 10px;
    }

    #title {
        font-size: 20px;
    }

    #test-box {
        margin: 40px 10px 30px;
        padding: 16px;
    }

    #text-display {
        font-size: 16px;
        padding: 16px;
        min-height: 80px;
    }

    #text-input {
        font-size: 14px;
        padding: 12px;
    }

    #wpm,
    #accuracy,
    #time {
        font-size: 20px;
    }
}

@view-transition {
    navigation: auto;
}