:root {
    --tst-bg: #F9F7F4;
    --tst-surface: #fff;
    --tst-border: #E4E0D8;
    --tst-border-dark: #C8C3B8;
    --tst-text-primary: #1A1814;
    --tst-text-secondary: #6B6560;
    --tst-text-muted: #A09A93;
    --tst-accent: #2C6E5A;
    --tst-accent-light: #E6F4EE;
    --tst-accent2: #C05B3A;
    --tst-accent2-light: #FAECE7;
    --tst-success: #1A7548;
    --tst-success-bg: #E8F5EE;
    --tst-error: #C03A2B;
}
.tst-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
.tst-wrapper { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--tst-bg); color: var(--tst-text-primary); max-width: 820px; margin: 0 auto; padding: 20px 0; }
.tst-stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.tst-stat { background: var(--tst-surface); border: 1px solid var(--tst-border); border-radius: 12px; padding: 14px 18px; box-shadow: 0 2px 5px rgba(0,0,0,.04); transition: box-shadow 0.2s; }
.tst-stat-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--tst-text-muted); margin-bottom: 4px; }
.tst-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 500; color: var(--tst-text-primary); line-height: 1; }
.tst-stat-value small { font-size: 12px; font-weight: 400; color: var(--tst-text-muted); margin-left: 2px; font-family: 'DM Sans', sans-serif; }
.tst-stat-wpm .tst-stat-value { color: var(--tst-accent); }
.tst-stat-errors .tst-stat-value { color: var(--tst-accent2); }
.tst-timer-wrapper { margin-bottom: 14px; }
.tst-timer-track { height: 4px; background: var(--tst-border); border-radius: 99px; overflow: hidden; }
.tst-timer-fill { height: 100%; background: var(--tst-accent); border-radius: 99px; width: 100%; transition: width 1s linear, background .4s; }
.tst-timer-fill.tst-warn { background: #D4840A; }
.tst-timer-fill.tst-critical { background: var(--tst-accent2); }
.tst-card { background: var(--tst-surface); border: 1px solid var(--tst-border); border-radius: 20px; box-shadow: 0 8px 30px rgba(0,0,0,.12); position: relative; overflow: visible; transition: box-shadow 0.3s ease; }
.tst-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--tst-border); background: #FAFAF8; flex-wrap: wrap; gap: 12px; border-radius: 20px 20px 0 0; }
.tst-difficulty-tabs { display: flex; gap: 3px; background: var(--tst-bg); border: 1px solid var(--tst-border); border-radius: 8px; padding: 3px; }
.tst-diff-btn { padding: 5px 14px; border: none; background: transparent; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; color: var(--tst-text-secondary); cursor: pointer; transition: all .2s; }
.tst-diff-btn.tst-active { background: var(--tst-surface); color: var(--tst-accent); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.tst-toolbar-right { display: flex; align-items: center; gap: 10px; }
.tst-duration-select { font-family: 'DM Sans', sans-serif; font-size: 13px; border: 1px solid var(--tst-border); border-radius: 8px; padding: 5px 10px; background: var(--tst-surface); color: var(--tst-text-primary); cursor: pointer; outline: none; transition: border 0.2s; min-width: 85px; }
.tst-duration-select:hover { border-color: var(--tst-accent); }
.tst-icon-btn { height: 34px; padding: 0 14px; border: 1px solid var(--tst-border-dark); border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; background: white; color: var(--tst-text-secondary); cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all .2s; }
.tst-icon-btn:hover { background: var(--tst-bg); color: var(--tst-text-primary); border-color: var(--tst-accent); box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.tst-zone { padding: 32px 32px 28px; cursor: text; outline: none; position: relative; min-height: 280px; max-height: none; overflow-y: visible; }
.tst-zone-blur::after { content: 'Click here and start typing'; position: absolute; inset: 0; background: rgba(255,255,255,.94); display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--tst-text-secondary); font-weight: 500; cursor: pointer; border-radius: 16px; backdrop-filter: blur(2px); }
.tst-passage { font-family: 'Libre Baskerville', serif; font-size: 20px; line-height: 1.9; letter-spacing: .01em; color: var(--tst-text-muted); user-select: none; word-wrap: break-word; white-space: normal; }
.tst-ch { position: relative; display: inline; white-space: normal; }
.tst-ch.tst-ok { color: var(--tst-success); }
.tst-ch.tst-bad { color: var(--tst-error); text-decoration: underline; text-decoration-color: var(--tst-error); text-underline-offset: 3px; }
.tst-ch.tst-current { color: var(--tst-text-primary); }
.tst-ch.tst-current::before { content: ''; position: absolute; left: -1px; top: 5px; bottom: 5px; width: 2px; background: var(--tst-accent); border-radius: 2px; animation: tst-blink .85s step-end infinite; }
@keyframes tst-blink { 50% { opacity: 0; } }
.tst-bottom-bar { padding: 0 32px 24px; display: flex; align-items: center; gap: 12px; }
.tst-type-display { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--tst-text-muted); background: var(--tst-bg); border: 1px solid var(--tst-border); border-radius: 8px; padding: 9px 14px; min-height: 38px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: border 0.2s; }
.tst-type-display.tst-error-border { border-color: var(--tst-error); color: var(--tst-error); }
.tst-restart-btn { height: 42px; padding: 0 22px; background: var(--tst-accent); color: #fff; border: none; border-radius: 10px; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all .2s; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,.1); }
.tst-restart-btn:hover { background: #235B4A; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,.12); }
.tst-restart-btn:active { transform: translateY(1px); }

/* Overlay - completely visible and scrollable */
.tst-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: rgba(249, 247, 244, 0.98);
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    border-radius: 20px;
    padding: 30px 20px 40px;
    overflow-y: auto;
    text-align: center;
    box-sizing: border-box;
    backdrop-filter: blur(4px);
}
.tst-overlay.tst-show {
    display: flex;
}
.tst-overlay-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--tst-text-muted);
}
.tst-overlay-wpm {
    font-family: 'JetBrains Mono', monospace;
    font-size: 64px;
    font-weight: 500;
    color: var(--tst-accent);
    line-height: 1;
}
.tst-overlay-sub {
    font-size: 12px;
    color: var(--tst-text-muted);
    text-align: center;
    margin-top: 2px;
    font-weight: 500;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.tst-overlay-stats {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    margin: 10px 0;
}
.tst-overlay-stat {
    text-align: center;
    min-width: 90px;
}
.tst-overlay-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 26px;
    font-weight: 500;
    color: var(--tst-text-primary);
}
.tst-overlay-label-small {
    font-size: 11px;
    color: var(--tst-text-muted);
    letter-spacing: .07em;
    text-transform: uppercase;
    margin-top: 3px;
}
.tst-overlay-sep {
    width: 1px;
    height: 44px;
    background: var(--tst-border);
}
@media (max-width: 550px) {
    .tst-overlay-stats { gap: 12px; }
    .tst-overlay-sep { display: none; }
    .tst-overlay-wpm { font-size: 52px; }
    .tst-overlay-value { font-size: 20px; }
}
.tst-badge {
    padding: 6px 20px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 600;
    margin: 5px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.tst-badge.tst-excellent { background: var(--tst-success-bg); color: var(--tst-success); }
.tst-badge.tst-good { background: var(--tst-accent-light); color: var(--tst-accent); }
.tst-badge.tst-average { background: #FEF3E2; color: #9A6200; }
.tst-badge.tst-beginner { background: var(--tst-accent2-light); color: var(--tst-accent2); }
.tst-try-btn {
    height: 56px;
    padding: 0 36px;
    background: var(--tst-accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,.1);
}
.tst-try-btn:hover {
    background: #235B4A;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,.15);
}
.tst-try-btn:active {
    transform: translateY(1px);
}

.tst-hint {
    max-width: 820px;
    margin-top: 14px;
    text-align: center;
    font-size: 12px;
    color: var(--tst-text-muted);
}
.tst-hint kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: #fff;
    border: 1px solid var(--tst-border-dark);
    border-radius: 5px;
    padding: 2px 7px;
    color: var(--tst-text-secondary);
    box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
@media (max-width: 600px) {
    .tst-stats-bar { grid-template-columns: repeat(2, 1fr); }
    .tst-zone, .tst-bottom-bar { padding-left: 18px; padding-right: 18px; }
    .tst-passage { font-size: 17px; }
    .tst-overlay { padding: 20px 15px; gap: 15px; }
    .tst-try-btn { height: 50px; padding: 0 28px; font-size: 15px; }
}