@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --background-color: #1a1b26;
    --foreground-color: #a9b1d6;
    --container-bg: #24283b;
    --border-color: #414868;
    --accent-color: #7aa2f7;
    --accent-color-dim: rgba(122, 162, 247, 0.3);
    --pending-color: #565f89;
    --correct-color: #9ece6a;
    --error-color: #f7768e;
}

.typing-area-wrapper {
    position: relative;
    width: 100%;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--background-color);
    color: var(--foreground-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s ease;
    background-image: radial-gradient(var(--accent-color-dim) 1px, transparent 0.1px);
    background-size: 50px 50px; /* Adjust size of dots */
}

.main-content {
    width: 800px;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.title {
    font-size: 2.5rem;
    color: var(--accent-color);
    font-weight: 700;
    letter-spacing: -1px;
}

.container {
    width: 100%;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.container#typing-window {
    position: relative;
    padding: 25px;
    font-size: 1.2rem;
    line-height: 2;
    color: var(--pending-color);
    /* Add these properties */
    max-height: 400px; /* Or any height you prefer */
    overflow-y: hidden;
}

.container#timer {
    padding: 10px 25px;
    font-size: 1.5rem;
    color: var(--accent-color);
    text-align: center;
}

#stats {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 20px;
}

.mini-container {
    flex: 1;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.mini-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.mini-container-title {
    font-size: 0.9rem;
    color: var(--foreground-color);
    margin-bottom: 5px;
}

.mini-container-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* --- Typing Text Styling --- */
.word {
    display: inline-block;
}

.word.pending {
    color: var(--pending-color);
}

.word.correct {
    color: var(--correct-color);
}

.letter {
    transition: color 0.2s ease;
}

.letter.correct {
    color: var(--correct-color);
}

/* --- Cursor Animation --- */
@keyframes blink {
  0%, 100% { background-color: transparent; }
  50% { background-color: var(--accent-color-dim); }
}

.current-letter {
    border-radius: 2px;
    animation: blink 1s infinite;
}

/* --- Error Animation --- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.error-shake {
    animation: shake 0.3s ease-in-out;
}

.current-letter.error {
    background-color: var(--error-color) !important;
    animation: none; /* Disable blinking during error */
}

.main-content.finished #typing-window > div {
    filter: blur(4px);
    transition: filter 0.5s ease-in-out;
}

#finish-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 27, 38, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#finish-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.checkmark {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: block;
    stroke-width: 4;
    stroke: var(--correct-color);
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px var(--correct-color);
    animation: scale .3s ease-in-out .9s both;
}

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 4;
    stroke-miterlimit: 10;
    stroke: var(--correct-color);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

@keyframes scale {
    0%, 100% { transform: none; }
    50% { transform: scale3d(1.1, 1.1, 1); }
}

/* Add styles for the restart button */
.restart-button {
    bottom: 15%;
    background-color: var(--accent-color);
    color: var(--background-color);
    border: none;
    padding: 12px 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.restart-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(122, 162, 247, 0.4);
}