:root {
    --bg-color: #1e1e1e;
    --text-color: #ffffff;
    --primary-color: #4a9eff;
    --secondary-color: #2d2d2d;
    --error-color: #ff4a4a;
    --success-color: #4aff4a;
    --neutral-color: #666666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 16px;
}

.container {
    width: 95%;
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: clamp(1rem, 2vw, 2rem);
}

.stats-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: clamp(2rem, 4vw, 4rem);
    font-size: clamp(1.2rem, 1.5vw, 1.5rem);
}

.timer, .speed {
    background-color: var(--secondary-color);
    padding: clamp(0.75rem, 1.5vw, 1.5rem) clamp(1rem, 2vw, 2rem);
    border-radius: 8px;
    min-width: 120px;
    text-align: center;
}

.typing-container {
    background-color: var(--secondary-color);
    padding: clamp(1.5rem, 3vw, 3rem);
    border-radius: 12px;
    margin: 0 auto;
    position: relative;
    max-width: 100%;
    height: clamp(400px, 60vh, 600px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.3) transparent;
}

.typing-container::-webkit-scrollbar {
    width: 8px;
}

.typing-container::-webkit-scrollbar-track {
    background: transparent;
}

.typing-container::-webkit-scrollbar-thumb {
    background-color: rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    border: 2px solid transparent;
}

.text-display {
    text-align: left;
    padding: 0 clamp(1rem, 2vw, 2rem);
    font-size: clamp(24px, 2vw, 32px);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    transition: font-size 0.3s ease;
}

.text-display span {
    transition: all 0.2s ease;
}

.text-display span.untyped {
    color: #94a3b8;
}

.text-display span.current {
    color: #ffffff;
    border-left: 2px solid #3b82f6;
    margin-left: -2px;
    animation: blink 1s infinite;
}

.text-display span.correct {
    color: #22c55e;
}

.text-display span.incorrect {
    color: #ef4444;
    text-decoration: underline;
    text-decoration-color: #ef4444;
}

@keyframes blink {
    0%, 100% { border-left-color: transparent; }
    50% { border-left-color: #3b82f6; }
}

.results-screen {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: clamp(1rem, 2vw, 2rem);
}

.results-content {
    width: 95%;
    max-width: 1200px;
    text-align: center;
    padding: clamp(1.5rem, 2vw, 2rem);
}

.results-content h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: clamp(2rem, 3vw, 3rem);
    color: var(--primary-color);
}

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

.stat-box {
    background-color: var(--secondary-color);
    padding: clamp(1.5rem, 2vw, 2rem);
    border-radius: 12px;
    transition: transform 0.2s;
}

.stat-box:hover {
    transform: translateY(-5px);
}

.stat-box h3 {
    color: var(--primary-color);
    margin-bottom: clamp(0.75rem, 1vw, 1rem);
    font-size: clamp(1.2rem, 1.5vw, 1.5rem);
}

.stat-box span {
    font-size: clamp(2rem, 3vw, 3rem);
    font-weight: bold;
}

.chart-container {
    background-color: var(--secondary-color);
    padding: clamp(1rem, 2vw, 2rem);
    border-radius: 12px;
    margin: clamp(2rem, 3vw, 3rem) 0;
    height: clamp(250px, 40vh, 300px);
}

.restart-btn {
    padding: clamp(0.75rem, 1.5vw, 1.5rem) clamp(1rem, 2vw, 2rem);
    font-size: clamp(1rem, 1.5vw, 1.5rem);
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    position: fixed;
    bottom: clamp(1rem, 2vw, 2rem);
    right: clamp(1rem, 2vw, 2rem);
}

.shortcut-hint {
    font-size: clamp(0.75rem, 1vw, 1rem);
    opacity: 0.7;
    margin-left: clamp(0.25rem, 0.5vw, 0.5rem);
    padding: clamp(0.1rem, 0.2vw, 0.2rem) clamp(0.5rem, 0.5vw, 0.5rem);
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.restart-btn:hover {
    transform: scale(1.05);
    background-color: #5ba8ff;
}

/* Loading skeleton animation */
.skeleton {
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.1) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: shimmer 0.8s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* Media Queries for different laptop screens */

/* Small laptops and below (13"-14" laptops) */
@media screen and (max-width: 1366px) {
    .container {
        width: 98%;
        padding: 1rem;
    }

    .typing-container {
        padding: 1.5rem;
        height: clamp(350px, 55vh, 450px);
    }

    .text-display {
        font-size: clamp(20px, 1.8vw, 28px);
    }

    .stats-container {
        margin-bottom: 2rem;
    }

    .timer, .speed {
        padding: 0.75rem 1rem;
        min-width: 100px;
    }

    .results-content {
        padding: 1.5rem;
    }

    .stats-grid {
        gap: 1rem;
    }

    .chart-container {
        height: clamp(200px, 35vh, 250px);
    }
}

/* Medium laptops (15" laptops) */
@media screen and (min-width: 1367px) and (max-width: 1600px) {
    .container {
        width: 96%;
    }

    .typing-container {
        height: clamp(400px, 58vh, 500px);
    }

    .text-display {
        font-size: clamp(22px, 1.9vw, 30px);
    }
}

/* Large laptops and desktop monitors (17" and above) */
@media screen and (min-width: 1601px) {
    .container {
        width: 90%;
        max-width: 1800px;
    }

    .typing-container {
        height: clamp(450px, 65vh, 600px);
    }

    .text-display {
        font-size: clamp(24px, 2vw, 32px);
        padding: 0 3rem;
    }

    .stats-container {
        margin-bottom: 3rem;
    }

    .timer, .speed {
        padding: 1.25rem 2.5rem;
        min-width: 180px;
    }

    .results-content {
        max-width: 1400px;
    }

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

/* High-DPI (Retina) displays */
@media screen and (min-resolution: 192dpi) {
    .text-display {
        font-smoothing: antialiased;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0F172A;
        --text-color: #ffffff;
        --secondary-color: #1E293B;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }

    .stat-box:hover {
        transform: none;
    }
}

/* Portrait orientation warning */
@media screen and (orientation: portrait) {
    body::before {
        content: "Please use landscape orientation for better experience";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--primary-color);
        color: var(--text-color);
        text-align: center;
        padding: 0.5rem;
        z-index: 1000;
        font-size: 0.875rem;
    }
}
