/* --- Main Container & Typography --- */
body {
    background: #e0eafc; 
}
.tp-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 30px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    transition: all 0.3s ease;
    position: relative;
}

/* --- Header & Metrics --- */
.tp-header {
    margin-bottom: 25px;
}
.tp-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.tp-metric {
    text-align: center;
    background: linear-gradient(145deg, #f9f9f9, #e6e6e6);
    padding: 20px 10px;
    border-radius: 15px;
    box-shadow: 5px 5px 10px #d1d1d1, -5px -5px 10px #ffffff;
    transition: all 0.2s ease-in-out;
}
.tp-metric:hover {
    transform: scale(1.05);
}
.tp-metric-label {
    font-size: 1em;
    color: #5a5a5a;
    margin-bottom: 8px;
    font-weight: 500;
}
.tp-metric-value {
    font-size: 2.5em;
    font-weight: 700;
    color: #3f51b5;
}

/* --- Branding Text Style --- */
.tp-branding {
    text-align: center;
    font-size: 0.9em;
    color: #aaa;
    margin-top: 15px;
    font-weight: 500;
}

/* --- Words Display Area --- */
.tp-words {
    font-size: 1.8em;
    line-height: 1.9;
    background-color: #ffffff;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    border: 1px solid #ddd;
    height: 150px; 
    overflow: auto; 
    color: #444;
    position: relative; 
    box-shadow: inset 0px 2px 8px rgba(0,0,0,0.05);
}
.tp-word.current {
    background-color: #cce7ff;
    color: #0056b3;
    border-radius: 5px;
    padding: 3px 1px;
    font-weight: 500;
}
.tp-letter.correct {
    color: #2e7d32;
    font-weight: 500;
}
.tp-letter.incorrect {
    color: #c62828;
    background-color: #ffcdd2;
    border-radius: 3px;
    text-decoration: none;
}

/* --- Input & Controls --- */
.tp-input-area {
    display: flex;
    gap: 15px;
}
#tp-input {
    flex-grow: 1;
    padding: 18px;
    font-size: 1.3em;
    border: 2px solid transparent;
    border-radius: 12px;
    background-color: #f1f3f4;
    transition: all 0.2s;
}
#tp-input:focus {
    outline: none;
    border-color: #81d4fa;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(129, 212, 250, 0.4);
}
#tp-input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* --- Buttons --- */
.tp-button {
    padding: 0 35px;
    font-size: 1.2em;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background: linear-gradient(45deg, #673ab7, #512da8);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 4px 15px rgba(103, 58, 183, 0.35);
}
.tp-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(103, 58, 183, 0.4);
}

/* --- Paste Area --- */
.tp-paste-area {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed #ccc;
}

/* --- NEW: Hide Typing Area when Results are Active --- */
.tp-container.results-active .tp-words,
.tp-container.results-active .tp-input-area,
.tp-container.results-active .tp-paste-area {
    display: none;
}

/* --- Results Screen (Now in normal document flow) --- */
.tp-results-screen {
    display: none; /* Hidden by default, JS will show it */
}

.tp-results-box {
    text-align: center;
    padding: 40px 50px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 15px;
    color: #fff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    margin-top: 25px; /* Space from the header */
}

.tp-results-box h3 {
    margin: 0 0 25px 0;
    font-size: 2.8em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.tp-results-main-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 15px;
}

.tp-results-stat-label {
    font-size: 1.1em;
    opacity: 0.8;
}

.tp-results-stat-value {
    font-size: 2.8em;
    font-weight: 700;
}

.tp-results-box p { /* For CPM */
    font-size: 1.2em;
    margin-bottom: 20px;
    opacity: 0.9;
}

.tp-results-char-stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.tp-results-char-stat .tp-results-stat-label {
    font-size: 1em;
}

.tp-results-char-stat .tp-results-stat-value {
    font-size: 1.8em;
}

.tp-results-stat-value.green {
    color: #c8e6c9;
}

.tp-results-stat-value.red {
    color: #ffcdd2;
}

#tp-restart-results-btn {
    margin-top: 30px;
    font-size: 1.2em;
    padding: 12px 40px;
    background: #fff;
    color: #673ab7;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

#tp-restart-results-btn:hover {
    background: #f1f3f4;
    transform: translateY(-2px);
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .tp-container {
        margin: 10px;
        padding: 20px;
    }
    .tp-metrics {
        grid-template-columns: 1fr;
    }
    .tp-words {
        font-size: 1.4em;
        height: 120px;
        padding: 15px;
    }
    .tp-input-area {
        flex-direction: column;
        gap: 12px;
    }
    .tp-button {
        width: 100%;
        padding: 15px 0;
    }
    .tp-results-box {
        padding: 30px 20px;
        width: 100%;
        box-sizing: border-box;
    }
    .tp-results-box h3 {
        font-size: 2em;
    }
    .tp-results-main-stats {
        flex-direction: column;
        gap: 15px;
    }
    .tp-results-stat-value {
        font-size: 2.2em;
    }
    .tp-results-char-stats {
        gap: 15px;
    }
}
