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

:root {
    --primary-color: #00796b;
    --second-color: #ffffff;
    --black-color: #000000;
    --error-color: #d32f2f;
    --success-color: #4CAF50;
    --light-bg: #f4f4f9;
    --section-bg: #ffffff;
    --border-color: #e0e0e0;
    --glass-effect: rgba(255, 255, 255, 0.5);
    --text-dark: #333;
    --link-color: #03a9f4;
}

body {
    background-color: var(--light-bg);
    color: var(--text-dark);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
    background-color: var(--glass-effect);
    backdrop-filter: blur(5px);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: var(--section-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.file-reset-group {
    display: flex;
    gap: 0;
    align-items: center;
}

.word-count-display,
.timer-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
}

.word-count-display span {
    font-weight: bold;
    color: #57a3f3;
}

.reset-top {
    font-size: 2em;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.reset-top:hover {
    transform: scale(1.1);
}

.file-input-wrapper label {
    display: flex;
    cursor: pointer;
    font-size: 2em;
    transition: transform 0.2s;
}

.file-input-wrapper label:hover {
    transform: scale(1.1);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.timer-custom-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 2px 5px;
    background-color: var(--section-bg);
    position: relative;
}

.timer-unit-input {
    font-size: 1.1em;
    font-weight: bold;
    width: 60px;
    border: none;
    text-align: center;
    color: #58a8f7;
    background-color: transparent;
    outline: none;
    z-index: 2;
}

.mins-left-arrows {
    direction: rtl;
    text-align: right;
}

#infinityOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--section-bg);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    color: #58a8f7;
    font-weight: bold;
    z-index: 3;
    pointer-events: none;
}

.show-infinity #infinityOverlay {
    display: flex;
}

.timer-separator {
    font-weight: bold;
    color: var(--primary-color);
    margin: 0 2px;
}

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button {  
   opacity: 1;
}

.reference-container {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--section-bg);
    max-height: 200px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.reference-text {
    font-size: 1.1em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.reference-text span {
    position: relative;
}

.reference-text .next-char-ref {
    background-color: #ffeb3b;
    border-radius: 2px;
    text-decoration: underline;
}

.reference-text .correct-char-ref { color: var(--success-color); }
.reference-text .incorrect-char-ref { color: var(--error-color); }

.typing-input {
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px;
    height: 120px;
    max-height: 120px;
    overflow-y: auto;
    background-color: var(--section-bg);
    font-size: 1.2em;
    line-height: 1.6;
    outline: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    cursor: text;
}

.typing-input:empty:before {
    content: attr(data-placeholder);
    color: #aaa;
}

.typing-input span.error-char-input {
    color: var(--error-color);
    background-color: #ffcdd2;
    text-decoration: underline;
}

.typing-input span.extra-char-input {
    color: #a01010;
    background-color: #ef9a9a;
}

.typing-input span.buffer-char {
    color: transparent !important;
    display: inline;
}

.stats-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    background-color: var(--section-bg);
}

.stats-container h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.stats-grid {
    margin-bottom: 15px;
}

.stats-container p {
    margin-bottom: 5px;
    font-size: 1.1em;
}

.stats-container span {
    font-weight: bold;
    color: var(--primary-color);
}

#downloadButton {
    display: none;
    padding: 12px 25px;
    cursor: pointer;
    border: 3px solid var(--success-color);
    background-color: var(--success-color);
    color: white;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.2em;
    transition: all 0.3s;
    margin-top: 15px;
    width: 100%;
}

#downloadButton:hover {
    background-color: white;
    color: var(--success-color);
    transform: translateY(-2px);
}

.status-running { color: #ff9800; }
.status-finished { color: var(--error-color); font-weight: bold; }
.status-success { color: var(--success-color); font-weight: bold; }