* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #fdf7f0 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><circle cx="6" cy="6" r="3" fill="%23ffd9c0" opacity="0.5"/><circle cx="30" cy="20" r="4" fill="%23b9e8c6" opacity="0.5"/><circle cx="14" cy="32" r="3" fill="%23ffd9c0" opacity="0.5"/><circle cx="34" cy="34" r="2" fill="%23b9e8c6" opacity="0.5"/></svg>');
    color: #2d2a26;
    line-height: 1.6;
    padding: 20px 14px 60px;
    margin: 0;
}

.container {
    max-width: 760px;
    margin: 0 auto;
}

/* ---------- header ---------- */
.typing-head {
    background: linear-gradient(160deg, #0c2f1f, #1b5e20, #2e8b3c, #66bb6a);
    border-radius: 20px;
    padding: 26px 20px;
    text-align: center;
    color: #fff;
    box-shadow: 0 8px 22px rgba(0,0,0,0.25);
    margin-bottom: 18px;
}

.typing-head h1 {
    font-size: 32px;
    letter-spacing: 1px;
    text-shadow: 0 3px 8px rgba(0,0,0,0.35);
}

.typing-head p {
    font-size: 16px;
    color: #f3ffe6;
    margin-top: 6px;
}

/* ---------- selectors ---------- */
.select-block {
    background: #fffdfa;
    border: 2px solid #ffe0c0;
    border-radius: 18px;
    padding: 14px 16px;
    margin: 14px 0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.07);
}

.select-label {
    display: block;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #2e8b3c;
    margin-bottom: 8px;
    text-align: center;
}

.select-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.mode-btn {
    background: #eef7ee;
    color: #1b5e20;
    border: 2px solid #b9e8c6;
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.12s, background 0.12s;
}

.mode-btn:hover { transform: scale(1.06); }

.mode-btn.active {
    background: linear-gradient(135deg, #2e8b3c, #66bb6a);
    color: #fff;
    border-color: #2e8b3c;
}

.diff-btn.active {
    background: linear-gradient(135deg, #ff6a88, #e8438f);
    border-color: #e8438f;
}

/* ---------- stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.stat {
    background: linear-gradient(180deg, #ffffff, #fff4ec);
    border: 2px solid #ffe0c0;
    border-radius: 14px;
    padding: 10px 6px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.stat-label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ad1457;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #1b5e20;
}

.stat-unit { font-size: 13px; color: #8a6d3b; }

/* ---------- typing area ---------- */
.text-display {
    background: #fffdfa;
    border: 2px solid #ffe0c0;
    border-radius: 16px;
    padding: 20px;
    font-size: 21px;
    line-height: 1.8;
    letter-spacing: 0.4px;
    min-height: 120px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.08);
    text-align: left;
    word-wrap: break-word;
    color: #8a8175;
}

.text-display span.correct { color: #1b5e20; }

.text-display span.incorrect {
    color: #d81b60;
    background: #ffe3ec;
    border-radius: 3px;
}

.text-display span.current {
    background: #ffe0c0;
    border-radius: 3px;
    box-shadow: inset 0 -3px 0 #ff6a88;
}

.input-area {
    width: 100%;
    margin-top: 12px;
    padding: 14px 16px;
    font-size: 19px;
    font-family: inherit;
    border: 2px solid #ffe0c0;
    border-radius: 14px;
    resize: none;
    height: 96px;
    background: #fffdfa;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.05);
    color: #2d2a26;
}

.input-area:focus {
    outline: none;
    border-color: #66bb6a;
    box-shadow: 0 0 0 3px rgba(102,187,106,0.25);
}

.input-area:disabled { background: #f4efe8; }

/* ---------- buttons ---------- */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
}

.btn {
    background: linear-gradient(135deg, #ff6a00, #ee0979);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 30px;
    font-size: 17px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.22);
    transition: transform 0.12s;
}

.btn:hover { transform: scale(1.05); }

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background: linear-gradient(135deg, #2e8b3c, #66bb6a);
}

.btn.warn {
    background: linear-gradient(135deg, #e53935, #ff7043);
}

.btn.info {
    background: linear-gradient(135deg, #1565c0, #42a5f5);
}

/* ---------- learn / teach ---------- */
.learn-section {
    margin-top: 18px;
    text-align: center;
}

.learn-content {
    display: none;
    margin-top: 14px;
    text-align: left;
}

.learn-content.active { display: block; }

.lesson-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.lesson-tab {
    background: #fff0f3;
    border: 2px solid #ffb8cc;
    border-radius: 999px;
    padding: 7px 15px;
    font-size: 14px;
    font-weight: bold;
    color: #ad1457;
    cursor: pointer;
}

.lesson-tab.active {
    background: linear-gradient(135deg, #ad1457, #ff6a88);
    color: #fff;
    border-color: #ad1457;
}

.lesson-body {
    background: #fffdfa;
    border: 2px solid #ffe0c0;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.07);
}

.lesson-body h3 {
    color: #e8438f;
    font-size: 19px;
    margin-bottom: 6px;
}

.lesson-body p.desc {
    font-size: 15px;
    color: #555;
    margin-bottom: 12px;
}

.finger-key {
    display: inline-block;
    background: #1b5e20;
    color: #fff;
    border-radius: 6px;
    padding: 1px 7px;
    font-weight: bold;
    margin: 0 1px;
}

.drill-target {
    background: #fffdfa;
    border: 2px dashed #b9e8c6;
    border-radius: 12px;
    padding: 14px;
    font-size: 20px;
    letter-spacing: 1px;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.drill-target span.correct { color: #1b5e20; }

.drill-target span.incorrect {
    color: #d81b60;
    text-decoration: underline;
}

.drill-target span.pending { color: #b3aa9d; }

.drill-progress {
    font-size: 13px;
    font-weight: bold;
    color: #2e8b3c;
    text-align: right;
    margin-bottom: 6px;
}

.drill-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 18px;
    font-family: inherit;
    border: 2px solid #ffe0c0;
    border-radius: 12px;
    background: #fffdfa;
}

.drill-input:focus {
    outline: none;
    border-color: #66bb6a;
}

/* ---------- result ---------- */
.result {
    margin-top: 16px;
    text-align: center;
    font-size: 19px;
    font-weight: bold;
    color: #ad1457;
    min-height: 28px;
}

.result-card {
    display: inline-block;
    background: linear-gradient(160deg, #ffd1e8, #fff3e0);
    border: 2px solid #ffb74d;
    border-radius: 16px;
    padding: 16px 22px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.10);
    animation: pop 0.35s ease;
}

@keyframes pop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.result-card .big { font-size: 24px; display: block; margin-bottom: 4px; }
.result-card .small { font-size: 15px; color: #6d5330; font-weight: normal; }

#confettiCanvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
}

@media (max-width: 600px) {
    .typing-head h1 { font-size: 25px; }
    .text-display { font-size: 18px; }
    .stat-value { font-size: 22px; }
}
