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

:root {
    --bg-color: #1a1a1a;
    --text-color: #fff;
    --header-bg: #2a2a2a;
    --typing-area-bg: #2a2a2a;
    --char-color: #666;
    --correct-color: #4caf50;
    --incorrect-color: #f44336;
    --cursor-color: #fff;
    --button-bg: #333;
    --button-hover-bg: #444;
    --transition-speed: 0.3s;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 0;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    opacity: 0;
    animation: fadeInPage 0.6s ease-out forwards;
    height: 100vh;
    overflow: hidden;
}

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

.container {
    max-width: 900px;
    width: 100%;
    height: 100vh;
    margin: 0 auto;
    padding: 1rem;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container.hide {
    opacity: 0;
    transform: translateY(-20px);
}

.header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--header-bg);
    border-radius: 8px;
    transition: background-color var(--transition-speed) ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.stats {
    display: flex;
    gap: 25px;
    justify-content: center;
    flex-wrap: wrap;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.stats.visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.stat {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    padding: 8px 12px;
    border-radius: 8px;
    background: linear-gradient(145deg, 
        var(--header-bg),
        var(--bg-color)
    );
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.stats.visible .stat {
    flex-direction: column;
    align-items: center;
    text-align: center;
    transform: translateY(0);
}

.stat .label {
    margin-right: 4px;
    font-size: 0.9rem;
    color: var(--char-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.stats.visible .stat .label {
    margin-right: 0;
    margin-bottom: 6px;
}

.stat span:not(.label) {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stats.visible .stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    background: linear-gradient(145deg, 
        var(--header-bg),
        var(--bg-color) 70%
    );
}

#timeSelect {
    justify-self: start;
}

#themeSelect {
    justify-self: end;
}

select, button {
    padding: 8px 16px;
    font-size: 1rem;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

select:hover, button:hover {
    background-color: var(--button-hover-bg);
    transform: translateY(-2px);
}

.typing-area {
    flex: 1;
    padding: 20px;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    margin-bottom: 10px;
    width: 100%;
    max-height: 200px;
}


#text-display {
    font-size: 1.2rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: normal;
    word-wrap: break-word;
    transition: transform 0.2s ease;
    max-width: 100%;
    padding-right: 10px;
    overflow: hidden;
}

.char {
    position: relative;
    color: var(--char-color);
    opacity: 0.6;
    transition: all 0.2s ease;
    display: inline-block;
}

.char.active {
    opacity: 0.9;
    transform: scale(1.02);
}

.char.correct {
    color: var(--text-color);
    opacity: 1;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.2);
}

.char.incorrect {
    color: var(--incorrect-color);
    opacity: 1;
    text-shadow: 0 0 2px rgba(244, 67, 54, 0.2);
}

.char.active::after {
    content: '';
    position: absolute;
    left: -1px;
    top: 15%;
    width: 2px;
    height: 70%;
    background-color: var(--cursor-color);
    box-shadow: 0 0 4px var(--cursor-color);
    opacity: 1;
    animation: simpleBlink 1s ease-in-out infinite;
    transition: left 0.2s ease;
}

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

.typing-area::after {
    content: none;
}

.title {
    text-align: center;
    margin-bottom: 2rem;
    opacity: 0;
    animation: titleFadeIn 3s ease-out forwards;
    position: relative;
}

.title h1 {
    font-size: 2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    display: inline-block;
    color: var(--text-color);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: gentlePulse 4s ease-in-out infinite;
    transition: opacity 0.2s ease;
}

.title h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--cursor-color),
        transparent
    );
    opacity: 0.3;
    animation: lineFlow 3s ease-in-out infinite;
}

/* Remove the before element */
.title h1::before {
    content: none;
}

/* Hover effect - simple scale */
.title h1:hover {
    transform: scale(1.05);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Gentle pulse animation */
@keyframes gentlePulse {
    0%, 100% {
        opacity: 0.9;
    }
    50% {
        opacity: 1;
    }
}

/* Line animation */
@keyframes lineFlow {
    0%, 100% {
        opacity: 0.2;
        transform: scaleX(0.8);
    }
    50% {
        opacity: 0.4;
        transform: scaleX(1);
    }
}

@keyframes titleFadeIn {
    0% { 
        opacity: 0; 
        transform: translateY(-20px); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    display: none;
    overflow: hidden;
}

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

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 800px;
    max-height: 95vh;
    overflow-y: auto;
    margin: 0;
    padding: 1.5rem;
    background: linear-gradient(145deg, 
        var(--header-bg),
        var(--bg-color)
    );
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal.show .modal-content {
    opacity: 1;
}

.graph-section {
    height: 250px;
    margin-bottom: 0;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: 8px;
}

.stats-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.8rem;
    margin-bottom: 0;
}

.stat-card {
    flex: 1;
    min-width: 0;
    padding: 1rem 0.8rem;
    background: linear-gradient(145deg, var(--bg-color), var(--header-bg));
    border-radius: 8px;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.5s ease forwards;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 0.2rem;
    color: var(--text-color);
}

.stat-label {
    color: var(--char-color);
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

#playAgainBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 auto;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#playAgainBtn:hover {
    background-color: var(--button-hover-bg);
    transform: translateY(-2px);
}

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

/* Animation delays for stat cards */
.stats-container .stat-card:nth-child(1) { animation-delay: 0.4s; }
.stats-container .stat-card:nth-child(2) { animation-delay: 0.5s; }
.stats-container .stat-card:nth-child(3) { animation-delay: 0.6s; }
.stats-container .stat-card:nth-child(4) { animation-delay: 0.7s; }
.stats-container .stat-card:nth-child(5) { animation-delay: 0.8s; }

/* Add new styles for restart button container */
.restart-container {
    display: flex;
    justify-content: center;
    margin-top: 20px; 
}

#restart {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    width: 35px;
    height: 35px;
    background-color: transparent;
    color: var(--char-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#restart:focus {
    outline: none;
    background-color: transparent;
}

#restart .material-icons {
    font-size: 20px;
}

/* Animation for both hover and focus */
#restart:hover .material-icons,
#restart:focus .material-icons {
    animation: rotateAndColor 0.5s ease forwards;
}

@keyframes rotateAndColor {
    0% {
        transform: rotate(0deg);
        color: var(--char-color);
    }
    100% {
        transform: rotate(360deg);
        color: var(--text-color);
    }
}

*:focus {
    outline: none;
}

#restart:focus {
    outline: none;
    background-color: var(--button-hover-bg);
}

.char.active {
    transform: scale(1.05);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Update the select styles */
select {
    padding: 8px 12px;
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
    max-width: 130px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Specific styles for timeSelect and themeSelect */
#timeSelect, #themeSelect {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 25px;
}

/* Hover state */
select:hover {
    background-color: var(--header-bg);
}

/* Focus state */
select:focus {
    outline: none;
    background-color: var(--bg-color);
}

/* Style for the options */
select option {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 8px;
}

/* Add responsive breakpoints */
@media (min-width: 768px) {
    .header {
        grid-template-columns: auto auto auto;
    }

    .title h1 {
        font-size: 3rem;
        letter-spacing: 4px;
    }

    #text-display {
        font-size: 1.5rem;
        line-height: 1.8;
    }

    .stat {
        font-size: 0.9rem;
        min-width: 80px;
    }

    .container {
        padding: 2rem;
    }
}

/* Add styles for larger screens */
@media (min-width: 1024px) {
    .container {
        padding: 2rem;
    }

    .typing-area {
        padding: 25px;
        min-height: 250px;
    }

    #text-display {
        font-size: 1.3rem;
        line-height: 1.8;
    }

    .title h1 {
        font-size: 3.5rem;
    }
}

/* Update media queries for better responsiveness */
@media (max-width: 1024px) {
    #text-display {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .header {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 12px;
    }

    .stats {
        order: -1; /* Move stats to top on mobile */
    }

    #timeSelect, #themeSelect {
        width: 100%;
        max-width: none;
        justify-self: center;
    }

    .title h1 {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    .container {
        padding: 0.5rem;
    }

    .typing-area {
        padding: 15px;
        min-height: 150px;
    }

    #text-display {
        font-size: 1.1rem;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 0.3rem;
    }

    .title h1 {
        font-size: 1.8rem;
    }

    .typing-area {
        padding: 10px;
        min-height: 120px;
    }

    #text-display {
        font-size: 1rem;
        line-height: 1.4;
    }
}

/* Add styles for virtual keyboard support */
.virtual-keyboard {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-color);
    padding: 10px;
    box-shadow: none;
}

.container.keyboard-visible {
    padding-bottom: 60px;
}

/* Update icon styles */
#restart .material-icons {
    font-size: 20px;
}

/* Add responsive icon sizes */
@media (max-width: 768px) {
    #restart {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    #restart .material-icons {
        font-size: 18px;
    }

    #playAgainBtn .material-icons {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    #restart {
        width: 28px;
        height: 28px;
        padding: 4px;
    }

    #restart .material-icons {
        font-size: 16px;
    }

    #playAgainBtn {
        padding: 0.6rem 1.2rem;
    }

    #playAgainBtn .material-icons {
        font-size: 16px;
    }
}

/* Update modal title styles to match main title */
.modal-title {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.modal-title h1 {
    font-size: 2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    display: inline-block;
    color: var(--text-color);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    transition: all 0.5s ease;
    animation: gentlePulse 4s ease-in-out infinite;
}

.modal-title h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--cursor-color),
        transparent
    );
    opacity: 0.3;
    animation: lineFlow 3s ease-in-out infinite;
}
l
/* Hover effect for modal title */
.modal-title h1:hover {
    transform: scale(1.05);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Update responsive styles for modal title */
@media (max-width: 768px) {
    .modal-title h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .modal-title h1 {
        font-size: 1.8rem;
    }
}

/* Add responsive adjustments */
@media (max-width: 768px) {
    #text-display {
        font-size: 1.1rem; /* Slightly smaller font on medium screens */
    }
}

@media (max-width: 480px) {
    #text-display {
        font-size: 1rem; /* Even smaller font on mobile */
    }
    .typing-area {
        padding: 15px; /* Less padding on mobile */
    }
}

.title h1.title-change {
    transform: translateY(-20px);
    opacity: 0;
}

@keyframes titleSwap {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    50% {
        transform: translateY(-20px);
        opacity: 0;
    }
    51% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Remove these styles as they're no longer needed */
.caps-lock-indicator,
.caps-lock-indicator.visible,
.caps-lock-indicator .material-icons,
.caps-lock-indicator .caps-text,
.hidden {
    display: none;
}
  