/* Main Container */
.typing-tool-container {
    font-family: 'Segoe UI', Arial, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* Header & Settings */
.typing-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.settings-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.set-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.set-item select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.btn-start {
    background: #16a34a;
    color: white;
    border: none;
    padding: 6px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-start:hover { background: #15803d; }

.btn-reset {
    background: #dc2626;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-around;
    background: #fff;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.stat-box {
    text-align: center;
}
.stat-label { display: block; font-size: 12px; color: #000; font-weight:500; text-transform: uppercase; }
.stat-val { display: block; font-size: 24px; font-weight: 800; color: #333; }
#timer { color: #dc2626; }

/* Typing Areas */
.typing-area-wrapper {
    padding: 20px;
    background: #fdfdfd;
}

/* 1. Master Text Display */
.text-display-box {
    height: 150px;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 15px;
    font-size: 18px;
    line-height: 1.6;
    color: #444;
    overflow-y: auto;
    background: #fafafa;
    user-select: none; /* User can't copy text */
    margin-bottom: 15px;
    font-family: 'Courier New', Courier, monospace; /* Monospace for alignment */
    white-space: pre-wrap;
}

/* Character States */
.char-correct { color: #16a34a; background: #dcfce7; }
.char-wrong { color: #dc2626; background: #fee2e2; text-decoration: underline; }
.char-active { background: #3b82f6; color: white; } /* Blue cursor highlight */

/* 2. Input Box */
.text-input-box {
    width: 100%;
    height: 100px;
    border: 2px solid #3b82f6;
    border-radius: 6px;
    padding: 15px;
    font-size: 18px;
    font-family: 'Courier New', Courier, monospace;
    resize: none;
}
.text-input-box:focus { outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.text-input-box:disabled { background: #eee; border-color: #ccc; cursor: not-allowed; }

/* RESULT POPUP */
.result-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}
.result-box {
    background: white; width: 90%; max-width: 450px;
    border-radius: 10px; padding: 30px; text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.res-header { font-size: 22px; font-weight: bold; margin-bottom: 20px; color: #333; border-bottom: 2px solid #eee; padding-bottom: 10px; }

.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }
.res-item { background: #f8f9fa; padding: 10px; border-radius: 8px; }
.res-val { font-size: 24px; font-weight: bold; color: #333; }
.res-label { font-size: 12px; color: #666; }

.res-remark { font-size: 16px; font-weight: bold; color: #16a34a; margin-bottom: 20px; }

.btn-close-res {
    background: #333; color: white; border: none; padding: 10px 20px;
    border-radius: 5px; cursor: pointer; font-size: 16px;
}
.btn-close-res:hover { background: #000; }

@media (max-width: 600px) {
    .typing-header { flex-direction: column; align-items: stretch; }
    .settings-bar { justify-content: space-between; }
    .text-display-box { font-size: 16px; }
}