/* ===== Home Variables ===== */
:root {
    --key-unit: 52px; --key-gap: 4px; --key-h: 48px; --key-r: 7px;
    --header-from: #e8e6e0; --header-to: #6bcb77;
    --idle-color: #3a3848;
    --glow-color: rgba(107,203,119,.03);
    --palm-bg: #15151f; --palm-border: #252536;
}
:root.light {
    --idle-color: #b0a89e;
    --glow-color: rgba(107,180,119,.06);
    --palm-bg: #eeece6; --palm-border: #d4d0c6;
}

/* ===== Container ===== */
.container { flex: 1 1 0; max-width: 1040px; min-width: 0; }

/* ===== Header ===== */
header { text-align: center; margin-bottom: 28px; animation: fadeUp .6s ease; }
header h1 {
    font-family: 'Syne', sans-serif; font-weight: 800; font-size: 38px;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--header-from) 30%, #6bcb77);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 8px;
}
header p { color: var(--text-muted); font-size: 13px; letter-spacing: .08em; }

/* ===== Mode Bar ===== */
.mode-bar {
    display: flex; justify-content: center; gap: 8px;
    margin-bottom: 20px; flex-wrap: wrap;
    animation: fadeUp .6s ease .08s backwards;
}
.mode-btn {
    padding: 9px 18px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-muted); font-family: 'DM Mono', monospace;
    font-size: 12px; cursor: pointer; transition: all .2s; letter-spacing: .03em;
}
.mode-btn:hover { background: var(--surface-3); color: var(--text); border-color: #3a3a50; }
.mode-btn.active { background: var(--surface-3); border-color: #6bcb77; color: #6bcb77; box-shadow: 0 0 20px rgba(107,203,119,.1); }

/* ===== Progress ===== */
.progress-bar {
    width: 100%; height: 3px; background: var(--surface-2);
    border-radius: 2px; margin-bottom: 14px; overflow: hidden;
    animation: fadeUp .6s ease .1s backwards;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, #6bcb77, #4d96ff); border-radius: 2px; transition: width .3s; width: 0; }

/* ===== Text Panel ===== */
.text-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 26px 30px; margin-bottom: 18px;
    min-height: 110px; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
    animation: fadeUp .6s ease .12s backwards;
    transition: background .4s, border-color .4s;
}
.text-panel::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 50% 0%, var(--glow-color), transparent 70%);
    pointer-events: none;
}
.text-display {
    font-size: 26px; line-height: 1.7; letter-spacing: .06em;
    word-break: break-all; text-align: center;
    max-height: 160px; overflow-y: auto;
}
.text-display::-webkit-scrollbar { width: 4px; }
.text-display::-webkit-scrollbar-track { background: transparent; }
.text-display::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.char {
    display: inline-block; padding: 1px 2px; border-radius: 3px;
    border-bottom: 2px solid transparent;
    transition: all .12s; text-shadow: var(--t-shadow);
}
.char.correct  { color: rgba(107,203,119,.35); }
.char.error    { color: rgba(255,107,107,.55); text-decoration: line-through; }
.char.current  { color: var(--text); animation: pulse 1.2s ease-in-out infinite; }
.char.upcoming { color: var(--text-muted); }
.idle-msg { color: var(--idle-color); font-size: 16px; letter-spacing: .06em; }

/* ===== Stats ===== */
.stats-bar {
    display: flex; justify-content: center; gap: 36px; margin-bottom: 22px;
    animation: fadeUp .6s ease .16s backwards;
}
.stat { text-align: center; }
.stat-value { font-size: 22px; font-weight: 500; font-family: 'Syne', sans-serif; color: var(--text); }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .12em; margin-top: 1px; }

/* ===== Hands ===== */
.hands-wrap {
    display: flex; justify-content: center; align-items: flex-end;
    gap: 12px; margin-bottom: 16px;
    animation: fadeUp .6s ease .2s backwards;
}
.hand { display: flex; flex-direction: column; align-items: center; }
.fingers { display: flex; gap: 5px; margin-bottom: -2px; position: relative; z-index: 1; }
.finger { display: flex; flex-direction: column; align-items: center; transition: transform .18s cubic-bezier(.34,1.56,.64,1); }
.finger-tip {
    width: 38px; height: 58px; border-radius: 19px 19px 10px 10px;
    border: 2px solid var(--fc);
    background: linear-gradient(180deg, rgba(var(--fcr),.2) 0%, rgba(var(--fcr),.04) 100%);
    transition: all .18s; position: relative;
}
.finger-tip::before {
    content: ''; position: absolute; top: 7px; left: 50%;
    transform: translateX(-50%); width: 16px; height: 3px;
    border-radius: 2px; background: rgba(var(--fcr),.3);
}
.finger.active { transform: translateY(-14px); }
.finger.active .finger-tip {
    background: linear-gradient(180deg, rgba(var(--fcr),.7) 0%, rgba(var(--fcr),.25) 100%);
    box-shadow: 0 6px 22px rgba(var(--fcr),.45); border-color: var(--fc);
}
.finger.active .finger-tip::before { background: rgba(var(--fcr),.6); }
.finger-name { font-size: 10px; margin-top: 5px; color: rgba(var(--fcr),.6); letter-spacing: .04em; transition: color .18s; }
.finger.active .finger-name { color: var(--fc); }
.finger-home { font-size: 10px; font-weight: 500; margin-top: 1px; color: rgba(var(--fcr),.45); transition: color .18s; }
.finger.active .finger-home { color: var(--fc); }
.palm {
    width: 175px; height: 38px; background: var(--palm-bg);
    border: 1px solid var(--palm-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--text-dim); letter-spacing: .1em;
    transition: background .4s, border-color .4s;
}
.left-hand .palm { border-radius: 0 0 0 28px; border-top: none; border-right: none; }
.right-hand .palm { border-radius: 0 0 28px 0; border-top: none; border-left: none; }
.thumb-area { display: flex; flex-direction: column; align-items: center; margin-bottom: -2px; position: relative; z-index: 1; }

/* ===== Keyboard ===== */
.keyboard {
    display: flex; flex-direction: column; align-items: center;
    gap: var(--key-gap); padding: 14px 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px;
    animation: fadeUp .6s ease .24s backwards;
    transition: background .4s, border-color .4s;
}
.kb-row { display: flex; gap: var(--key-gap); }
.key {
    height: var(--key-h); border-radius: var(--key-r);
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    cursor: default;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .12s;
    position: relative; user-select: none; flex-shrink: 0;
    text-shadow: var(--t-shadow);
}
.key.home-dot::after {
    content: ''; position: absolute; bottom: 6px; left: 50%;
    transform: translateX(-50%); width: 12px; height: 3px;
    border-radius: 2px; background: var(--text-dim);
}
.key.highlight { transform: translateY(-3px); z-index: 2; }
.key.flash-correct { animation: flashC .3s ease; }
.key.flash-error   { animation: flashE .3s ease; }
:root.light .key { border-color: #d4d0c6; background: #f8f6f1; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
:root.light .key.home-dot::after { background: #b8b0a2; }

/* ===== Legend ===== */
.legend {
    display: flex; justify-content: center; gap: 14px;
    margin-top: 18px; flex-wrap: wrap;
    animation: fadeUp .6s ease .28s backwards;
}
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ===== Animations ===== */
@keyframes flashC {
    0%   { box-shadow: 0 0 0 0 rgba(107,203,119,.7); }
    50%  { box-shadow: 0 0 18px 3px rgba(107,203,119,.3); }
    100% { box-shadow: none; }
}
@keyframes flashE {
    0%   { box-shadow: 0 0 0 0 rgba(255,107,107,.7); background: rgba(255,107,107,.18); }
    100% { box-shadow: none; background: var(--surface-2); }
}

/* ===== Responsive ===== */
@media (max-width: 1040px) {
    :root { --key-unit: 44px; --key-h: 40px; }
    .text-display { font-size: 22px; } .palm { width: 150px; }
}
@media (max-width: 880px) {
    :root { --key-unit: 36px; --key-h: 34px; }
    .text-display { font-size: 18px; }
    .finger-tip { width: 30px; height: 46px; border-radius: 15px 15px 8px 8px; }
    .finger-tip::before { width: 12px; height: 2px; top: 5px; }
    .palm { width: 125px; height: 32px; } .stats-bar { gap: 20px; }
}
@media (max-width: 520px) {
    header h1 { font-size: 28px; } header p { font-size: 11px; }
    :root { --key-unit: 28px; --key-h: 28px; }
    .finger-tip { width: 24px; height: 36px; border-radius: 12px 12px 6px 6px; }
    .finger-tip::before { width: 10px; height: 2px; top: 4px; }
    .finger-name { font-size: 8px; } .finger-home { font-size: 8px; }
    .palm { width: 100px; height: 28px; font-size: 9px; }
    .hands-wrap { gap: 6px; } .fingers { gap: 3px; }
    .text-display { font-size: 16px; }
    .stat-value { font-size: 18px; } .stat-label { font-size: 9px; }
    .stats-bar { gap: 14px; }
}
