/*
 * TypeMaster Pro: the tool's own components, styled in the site's design language (7 Oct 2026, on the UltraCompress Pro
 * template, after TextAnalyzer Pro). Base: /libs/site-pages.css (tokens, Inter and Space Grotesk, buttons, theme toggle, focus
 * rings) and /libs/shared-nav.css (the site's header and footer). This file holds only what the tool itself needs: the
 * toolbar with the status pill and the six pill tabs, the select pills and pill groups, the live stat tiles with their bars,
 * the text display with its coloured characters and the typing box, the virtual keyboard with finger colours, the level,
 * goal and challenge rows, the lesson and game cards, the game overlay, the progress chart, the problem-keys map, the
 * achievements, the history table and pager, the switches, the range slider, the windows, the toasts and the information
 * sections. Light is the default; dark applies when <html> has no data-theme.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;
    --surface-2: #f3f4f8;
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --radius-lg: 16px;
    --pos: #10b981;
    --neg: #ef4444;
    --warn: #92400e;
    --info: #38bdf8;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
    --type-size: 20px;
    --key-bg: #ffffff;
    --key-edge: rgba(0, 0, 0, 0.14);
    --key-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --warn: #f59e0b;
    --surface-2: rgba(255, 255, 255, 0.05);
    --key-bg: #1d1d2c;
    --key-edge: rgba(255, 255, 255, 0.14);
    --key-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container { max-width: calc(var(--app-max) + 2 * var(--content-gutter)); margin-top: 16px; }
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- Tools back link above the header, as on every other tool ----- */
body { padding-top: 0; }
.back-bar { height: 48px; display: flex; align-items: center; padding: 0 var(--zdu-gutter, 24px); }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: calc(90px + var(--bar-offset, 48px)); }
@media (max-width: 768px) { .theme-toggle { top: calc(75px + var(--bar-offset, 48px)); } }
.hidden-input { display: none; }
[hidden] { display: none !important; }

/* ----- Hero ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--text-strong); }
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 9999px; font-family: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2; padding: 12px 24px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn-secondary[aria-pressed="true"] { border-color: var(--brand); color: var(--link); background: var(--tint-brand); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid rgba(185, 28, 28, 0.35); padding: 11px 23px; }
.btn-danger:hover:not(:disabled) { background: var(--danger-strong); color: #fff; border-color: transparent; transform: translateY(-2px); }
.btn-sm { font-size: 0.85rem; padding: 9px 16px; }
.btn-secondary.btn-sm, .btn-danger.btn-sm { padding: 8px 15px; }
.btn-icon.btn-sm { width: 38px; height: 38px; padding: 0; }
.btn-icon.btn-sm svg { width: 17px; height: 17px; }
.btn-stack { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-stack--top { margin-top: 14px; }
.btn-stack--column { flex-direction: column; align-items: stretch; }

/* ----- Toolbar and tabs ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 1.25rem; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 10px; padding: 6px 16px 6px 10px; border-radius: 9999px; border: 1px solid var(--tint-brand-border); background: var(--tint-brand); min-width: 260px; max-width: 100%; }
.status-icon { font-size: 1.3rem; line-height: 1; }
.status-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.status-main { font-weight: 700; font-size: 0.85rem; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-sub { font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 9999px; background: var(--surface-2); max-width: 100%; margin: 0 0 20px; }
.view-tab { padding: 8px 18px; border: 0; border-radius: 9999px; background: transparent; font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.view-tab:hover { color: var(--link); }
.view-tab.active { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.view-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
kbd { font-family: inherit; font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--chip-border); background: var(--chip); color: var(--text-strong); }

/* ----- Cards ----- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.card-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--surface-shadow); overflow: hidden; display: flex; flex-direction: column; min-width: 0; margin-bottom: 0; }
.app-shell > .card, .view > .card { margin-bottom: 20px; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-note { font-size: 0.8125rem; color: var(--text-3); }
.card-body { padding: 16px 20px 20px; flex: 1; }
.form-hint { font-size: 0.78rem; color: var(--text-3); margin: 10px 0 0; line-height: 1.5; }
.form-hint--top { margin: 0 0 12px; }
.form-group { margin-bottom: 18px; min-width: 0; }
.form-group:last-child { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-label { display: block; margin-bottom: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-strong); }
.form-input, .form-select { width: 100%; padding: 10px 14px; background: var(--field); border: 1px solid var(--field-border); border-radius: 10px; font-family: inherit; font-size: 0.9rem; color: var(--text); outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.form-input:focus, .form-select:focus, .text-box:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.form-input::placeholder, .text-box::placeholder { color: var(--placeholder); }
.text-box { width: 100%; min-height: 150px; resize: vertical; padding: 12px 14px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; font-family: var(--mono); font-size: 0.85rem; line-height: 1.5; color: var(--text); outline: none; }
.num-strong { font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.list-empty { color: var(--text-3); font-size: 0.875rem; margin: 0; padding: 10px 0; line-height: 1.5; }

/* ----- Select pills and pill groups ----- */
.control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 16px; }
.control-buttons { margin-left: auto; }
.select-pill { display: inline-flex; align-items: center; gap: 8px; padding: 0 6px 0 14px; height: 38px; border-radius: 9999px; border: 1px solid var(--surface-border); background: var(--surface); font-size: 0.8rem; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.select-pill select { border: 0; background: transparent; font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-strong); padding: 6px 6px; outline: none; cursor: pointer; max-width: 160px; }
.select-pill select:focus-visible { outline: 2px solid var(--brand); border-radius: 8px; }
.select-pill--small { height: 34px; font-size: 0.75rem; }
.select-pill--small select { font-size: 0.8rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-group { display: inline-flex; gap: 4px; padding: 4px; border-radius: 9999px; background: var(--surface-2); }
.pill-btn { padding: 7px 16px; border: 0; border-radius: 9999px; background: transparent; font-family: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease; }
.pill-btn:hover { color: var(--link); }
.pill-btn.active { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.pill-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pill-group--small .pill-btn { padding: 5px 12px; font-size: 0.76rem; }

/* ----- Stat tiles ----- */
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-tiles--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-tiles--six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat-tile { background: var(--surface-2); border: 1px solid var(--surface-border); border-radius: 12px; padding: 12px 10px; text-align: center; display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--brand); min-width: 0; }
.stat-tile--wpm { border-top-color: #8b5cf6; } .stat-tile--acc { border-top-color: var(--pos); } .stat-tile--time { border-top-color: var(--warn); } .stat-tile--streak { border-top-color: var(--neg); }
.stat-num { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.live-tiles .stat-num { font-size: 1.75rem; }
.stat-label { font-size: 0.72rem; color: var(--text-3); line-height: 1.3; }
.stat-bar { display: block; height: 5px; border-radius: 3px; background: var(--surface-border); margin-top: 8px; overflow: hidden; }
.stat-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--gradient-brand); transition: width 0.25s ease; }
.stat-tile--acc .stat-bar i { background: linear-gradient(90deg, #10b981, #06b6d4); }
.stat-tile--time .stat-bar i { background: linear-gradient(90deg, #f59e0b, #ec4899); }
.stat-tile--streak .stat-bar i { background: linear-gradient(90deg, #ef4444, #f59e0b); }
.live-tiles { margin-bottom: 16px; }
.detail-list { display: grid; grid-template-columns: 1fr; gap: 0; margin: 14px 0 0; }
.detail-list div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--surface-border); min-width: 0; }
.detail-list dt { font-size: 0.8rem; color: var(--text-2); }
.detail-list dd { margin: 0; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; font-size: 0.9rem; text-align: right; white-space: nowrap; }

/* ----- Text display and typing box ----- */
.type-display { position: relative; font-family: var(--mono); font-size: var(--type-size); line-height: 1.75; padding: 16px 18px; border: 1px solid var(--surface-border); border-radius: 12px; background: var(--field); color: var(--text-2); max-height: calc(var(--type-size) * 1.75 * 4 + 32px); overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap; margin-bottom: 12px; user-select: none; -webkit-user-select: none; }
.type-display.is-code { line-height: 1.6; }
.type-placeholder { color: var(--text-3); font-family: inherit; }
.ch { border-radius: 3px; padding: 1px 0; }
.ch.ok { color: #047857; }
.ch.bad { color: #b91c1c; background: rgba(239, 68, 68, 0.16); text-decoration: underline; text-decoration-color: #ef4444; }
.ch.bad.sp { background: rgba(239, 68, 68, 0.35); }
.ch.now { background: var(--tint-brand); box-shadow: inset 0 -3px 0 var(--brand); color: var(--text-strong); animation: caret 1s steps(2, start) infinite; }
.ch.nl::after { content: '\21B5'; color: var(--text-3); font-size: 0.8em; }
:root:not([data-theme="light"]) .ch.ok { color: #34d399; }
:root:not([data-theme="light"]) .ch.bad { color: #fca5a5; }
@keyframes caret { 50% { box-shadow: inset 0 -3px 0 transparent; } }
.type-input { width: 100%; resize: none; padding: 12px 16px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; font-family: var(--mono); font-size: 1rem; line-height: 1.5; color: var(--text); outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.type-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.type-input:disabled { opacity: 0.6; }
.live-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; }
.live-hint { margin: 0; flex: 1 1 240px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 9999px; background: var(--chip); border: 1px solid var(--chip-border); color: var(--text-2); font-size: 0.78rem; font-weight: 600; }
.chip b { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.chip--pos { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.35); }
.chip--neg { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.35); }
.test-timer-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.test-timer { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 2.6rem; font-weight: 700; line-height: 1; background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; }
.test-timer-row .form-hint { margin: 0; flex: 1 1 240px; }

/* ----- Virtual keyboard ----- */
.keyboard { display: flex; flex-direction: column; gap: 6px; max-width: 980px; margin: 0 auto; overflow-x: auto; padding-bottom: 4px; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key { --fc: var(--text-3); flex: 0 0 auto; width: 52px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--key-bg); border: 1px solid var(--key-edge); border-bottom: 2px solid var(--fc); box-shadow: var(--key-shadow); font-family: var(--mono); font-size: 0.85rem; font-weight: 600; color: var(--text-strong); position: relative; transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease; }
.key::before { content: ''; position: absolute; inset: 0; border-radius: 7px; background: var(--fc); opacity: 0.09; pointer-events: none; }
.key.wide { width: 80px; } .key.wider { width: 96px; } .key.widest { width: 112px; } .key.space { width: 300px; }
.key.home::after { content: ''; position: absolute; bottom: 7px; left: 50%; width: 14px; height: 3px; margin-left: -7px; border-radius: 2px; background: var(--fc); opacity: 0.7; }
.key.next { background: var(--fc); color: #000; box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc) 35%, transparent), 0 6px 16px color-mix(in srgb, var(--fc) 40%, transparent); transform: translateY(-2px); }
.key.next::before { opacity: 0; }
.key.down { transform: translateY(2px); box-shadow: none; background: var(--tint-brand); }
.key.down.next { background: var(--fc); }
.key .sub { position: absolute; top: 4px; left: 7px; font-size: 0.6rem; font-weight: 500; color: var(--text-3); }
.key.next .sub { color: rgba(255, 255, 255, 0.8); }
.finger-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 14px; font-size: 0.75rem; color: var(--text-2); }
.finger-legend span { display: inline-flex; align-items: center; gap: 6px; }
.finger-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ----- Level, goals and challenges ----- */
.level-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.level-num { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 1.6rem; font-weight: 700; background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.level-xp { font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.progress-track { height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--surface-border); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--gradient-brand); transition: width 0.4s ease; }
.progress-track--pos i { background: linear-gradient(90deg, #10b981, #06b6d4); }
.progress-track--warn i { background: linear-gradient(90deg, #f59e0b, #ec4899); }
.goal-row { margin-bottom: 16px; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.85rem; color: var(--text-2); margin-bottom: 6px; }
.streak-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--surface-border); font-weight: 700; color: var(--text-strong); }
.streak-flame { font-size: 1.2rem; }
.challenge-list { display: flex; flex-direction: column; gap: 10px; }
.challenge { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--surface-border); background: var(--surface-2); }
.challenge.done { border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.08); }
.challenge-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.challenge-name { font-weight: 700; font-size: 0.875rem; color: var(--text-strong); }
.challenge-xp { font-size: 0.78rem; font-weight: 700; color: var(--warn); white-space: nowrap; }
.challenge-desc { font-size: 0.78rem; color: var(--text-2); margin: 0 0 8px; }
.challenge-foot { display: flex; align-items: center; gap: 10px; }
.challenge-foot .progress-track { flex: 1; height: 7px; }
.challenge-val { font-size: 0.72rem; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ----- Lessons ----- */
.lesson-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.lesson { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 14px; border: 1px solid var(--surface-border); background: var(--surface-2); min-width: 0; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.lesson:hover { transform: translateY(-3px); box-shadow: var(--surface-hover-shadow); }
.lesson-top { display: flex; align-items: center; gap: 10px; }
.lesson-icon { font-size: 1.6rem; line-height: 1; }
.lesson-title { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text-strong); margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-tag { font-size: 0.68rem; font-weight: 700; padding: 3px 9px; border-radius: 9999px; white-space: nowrap; }
.lesson-tag--beginner { background: rgba(16, 185, 129, 0.14); color: #047857; }
.lesson-tag--intermediate { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.lesson-tag--advanced { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.lesson-tag--expert { background: rgba(99, 102, 241, 0.16); color: #4338ca; }
:root:not([data-theme="light"]) .lesson-tag--beginner { color: #34d399; }
:root:not([data-theme="light"]) .lesson-tag--intermediate { color: #fbbf24; }
:root:not([data-theme="light"]) .lesson-tag--advanced { color: #fca5a5; }
:root:not([data-theme="light"]) .lesson-tag--expert { color: #a5b4fc; }
.lesson-desc { font-size: 0.82rem; color: var(--text-2); margin: 0; }
.lesson-preview { font-family: var(--mono); font-size: 0.75rem; color: var(--text-3); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.lesson-best { font-size: 0.75rem; color: var(--text-3); }
.lesson-best b { color: var(--link); }
.lesson-custom { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--link); }

/* ----- Games ----- */
.game-desc { font-size: 0.875rem; color: var(--text-2); margin: 0 0 14px; line-height: 1.55; }
.game-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.games-hint { margin: 0 0 4px; }
.game-overlay { position: fixed; inset: 0; z-index: 1100; background: rgba(10, 10, 20, 0.7); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.game-panel { width: 100%; max-width: 960px; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 20px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4); display: flex; flex-direction: column; overflow: hidden; }
.game-hud { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--surface-border); }
.game-title { margin: 0; font-size: 1.05rem; flex: 1; min-width: 120px; }
.game-score, .game-time { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: 9999px; background: var(--surface-2); border: 1px solid var(--surface-border); font-size: 0.85rem; }
.game-stage { background: #0f1120; aspect-ratio: 16 / 9; max-height: 60vh; position: relative; }
.game-stage canvas { display: block; width: 100%; height: 100%; }
.game-input-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--surface-border); }
.game-input { flex: 1 1 200px; font-family: var(--mono); }
.game-input-row .form-hint { margin: 0; flex: 1 1 200px; }

/* ----- Progress ----- */
.canvas-wrap { position: relative; width: 100%; min-height: 240px; }
.canvas-wrap canvas { display: block; width: 100%; }
.canvas-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.freq-list { display: flex; flex-direction: column; gap: 6px; }
.freq-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 96px; align-items: center; gap: 10px; font-size: 0.82rem; }
.freq-key { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; color: var(--text-strong); white-space: nowrap; }
.freq-bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.freq-bar i { display: block; height: 100%; border-radius: 5px; background: var(--gradient-brand); transition: width 0.3s ease; }
.freq-bar--b0 i { background: linear-gradient(90deg, #ef4444, #dc2626); } .freq-bar--b1 i { background: linear-gradient(90deg, #f59e0b, #d97706); } .freq-bar--b2 i { background: linear-gradient(90deg, #eab308, #ca8a04); } .freq-bar--b3 i { background: linear-gradient(90deg, #10b981, #059669); } .freq-bar--b4 i { background: linear-gradient(90deg, #06b6d4, #0891b2); } .freq-bar--b5 i { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }
.freq-count { font-size: 0.75rem; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.note-list { display: flex; flex-direction: column; gap: 10px; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--surface-border); border-left-width: 4px; border-left-color: var(--info); background: var(--surface-2); }
.note p { margin: 0; font-size: 0.875rem; color: var(--text); line-height: 1.5; }
.note-icon { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 800; color: #fff; background: var(--info); }
.note--warning { border-left-color: var(--warn); } .note--warning .note-icon { background: var(--warn); }
.note--success { border-left-color: var(--pos); } .note--success .note-icon { background: var(--pos); }
.ach-list { display: flex; flex-direction: column; gap: 8px; }
.ach { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--surface-border); background: var(--surface-2); }
.ach.on { border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.08); }
.ach-icon { font-size: 1.4rem; line-height: 1; filter: grayscale(1); opacity: 0.55; }
.ach.on .ach-icon { filter: none; opacity: 1; }
.ach-text { flex: 1; min-width: 0; }
.ach-name { font-weight: 700; font-size: 0.85rem; color: var(--text-strong); margin: 0; }
.ach-desc { font-size: 0.75rem; color: var(--text-3); margin: 0; }
.ach-mark { font-size: 0.8rem; font-weight: 700; color: var(--pos); }
.ach:not(.on) .ach-mark { color: var(--text-3); }
.heat-keys { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.heat-row { display: flex; gap: 6px; }
.heat-key { width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; border: 2px solid var(--hk, var(--surface-border)); color: var(--hk, var(--text-3)); background: color-mix(in srgb, var(--hk, var(--surface-border)) 14%, transparent); cursor: default; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--surface-border); color: var(--text); white-space: nowrap; }
.data-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); font-weight: 600; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.data-table td.wpm { color: var(--link); font-weight: 700; }
.table-scroll { overflow-x: auto; }
.row-del { background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.row-del:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pager-info { font-size: 0.8rem; color: var(--text-3); }
.score-list { display: flex; flex-direction: column; gap: 8px; }
.score-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--surface-border); background: var(--surface-2); font-size: 0.85rem; }
.score-row.mine { border-color: var(--brand); background: var(--tint-brand); }
.score-rank { font-weight: 800; color: var(--text-3); text-align: center; }
.score-name { font-weight: 700; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-meta { font-size: 0.72rem; color: var(--text-3); display: block; }
.score-val { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; color: var(--link); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ----- Switches and the range slider ----- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.9rem; font-weight: 600; color: var(--text-strong); cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 24px; border-radius: 12px; background: var(--chip-border); position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.2s ease; margin: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.range-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.range-head .form-label { margin: 0; }
.range-value { font-size: 0.85rem; font-weight: 700; color: var(--link); font-variant-numeric: tabular-nums; }
.range { --fill: 50%; width: 100%; height: 8px; appearance: none; -webkit-appearance: none; border-radius: 4px; background: linear-gradient(90deg, #8B5CF6 0%, #EC4899 var(--fill), var(--surface-2) var(--fill), var(--surface-2) 100%); border: 1px solid var(--surface-border); outline: none; cursor: pointer; }
.range::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid #8B5CF6; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); cursor: pointer; }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #8B5CF6; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); cursor: pointer; }
.range:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.range-marks { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-3); margin-top: 6px; }

/* ----- Windows ----- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10, 10, 20, 0.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s ease; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 20px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); width: 100%; max-width: 560px; max-height: 92vh; overflow: hidden; display: flex; flex-direction: column; transform: translateY(12px); transition: transform 0.25s ease; }
.modal--narrow { max-width: 420px; }
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { margin: 0; font-size: 1.15rem; }
.modal-close { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--chip-border); background: var(--chip); color: var(--text-strong); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color 0.2s ease, color 0.2s ease; }
.modal-close:hover { border-color: var(--brand); color: var(--link); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm-message { margin: 0; color: var(--text); }
.result-lead { margin: 0 0 14px; font-weight: 700; color: var(--text-strong); font-size: 1rem; text-align: center; }
#resultModal .note-list { margin-top: 14px; }
.countdown { margin: 14px 0 0; text-align: center; font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 3rem; font-weight: 700; background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.shortcut-list { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.shortcut-list div { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.875rem; color: var(--text); }
.shortcut-list dt { white-space: nowrap; }
.shortcut-list dd { margin: 0; text-align: right; color: var(--text-2); }

/* ----- Toasts ----- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); }
.toast { background: #0a0a14; color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); border-left: 4px solid var(--brand); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); min-width: 260px; max-width: 400px; font-size: 0.875rem; font-weight: 500; overflow-wrap: anywhere; animation: slideIn 0.3s ease; transition: opacity 0.3s ease, transform 0.3s ease; }
.toast-icon { font-size: 0.95rem; font-weight: 700; line-height: 1; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.12); flex-shrink: 0; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left-color: #4ade80; } .toast.error { border-left-color: #f87171; } .toast.warning { border-left-color: #fbbf24; } .toast.info { border-left-color: #38bdf8; }
.toast.leaving { opacity: 0; transform: translateX(40px); }

/* ----- Information sections ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 16px; box-shadow: var(--surface-shadow); padding: 20px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.step-card { position: relative; padding-top: 24px; }
.step-num { position: absolute; top: -16px; left: 20px; width: 34px; height: 34px; border-radius: 50%; background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary { cursor: pointer; padding: 16px 20px; font-weight: 600; color: var(--text-strong); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ----- Tablets ----- */
@media (max-width: 1023px) {
    .card-grid, .card-grid--two { grid-template-columns: 1fr; }
    .lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-tiles--six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .info-section .info-grid { grid-template-columns: repeat(2, 1fr); }
    .info-three { grid-template-columns: 1fr; }
    .keyboard { justify-content: flex-start; }
    .key { width: 44px; height: 40px; font-size: 0.78rem; }
    .key.wide { width: 66px; } .key.wider { width: 80px; } .key.widest { width: 92px; } .key.space { width: 240px; }
}

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .app-toolbar { gap: 10px; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .status-pill { flex: 1; min-width: 0; }
    .toolbar-right .btn { flex: 1 1 auto; }
    .toolbar-right .btn-icon { flex: 0 0 38px; }
    .view-tabs { width: 100%; flex-wrap: wrap; border-radius: 18px; }
    .view-tab { flex: 1 1 30%; padding: 8px 4px; font-size: 0.76rem; text-align: center; }
    .card-grid, .card-grid--two { gap: 14px; margin-bottom: 14px; }
    .app-shell > .card, .view > .card { margin-bottom: 14px; }
    .card-header { padding-left: 16px; padding-right: 16px; }
    .card-body { padding: 14px 16px 16px; }
    .control-row { gap: 8px; }
    .select-pill { flex: 1 1 45%; min-width: 0; }
    .select-pill select { flex: 1; min-width: 0; max-width: none; }
    .control-buttons { margin-left: 0; width: 100%; }
    .control-buttons .btn { flex: 1 1 auto; }
    .pill-group { width: 100%; }
    .pill-btn { flex: 1; padding: 7px 6px; font-size: 0.76rem; text-align: center; }
    .stat-tiles--four, .stat-tiles--six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .live-tiles .stat-num { font-size: 1.4rem; }
    :root { --type-size: 17px !important; }
    #keyboardCard { display: none; }
    .lesson-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .freq-row { grid-template-columns: 72px minmax(0, 1fr) 84px; }
    .heat-key { width: 28px; height: 28px; font-size: 0.72rem; }
    .heat-row { gap: 4px; }
    .modal-overlay { padding: 8px; }
    .modal-body, .modal-header, .modal-footer { padding-left: 16px; padding-right: 16px; }
    .game-overlay { padding: 8px; }
    .game-stage { aspect-ratio: 4 / 3; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; align-items: flex-end; }
    .toast { min-width: 0; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}

@media print {
    .back-bar, body > header, .theme-toggle, .app-toolbar, .view-tabs, .site-footer, .toast-container, .modal-overlay, .game-overlay, #zdu-cookie-banner { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .info-card, .modal, .toast, .chip, .view-tab, .pill-btn, .key, .lesson, .stat-bar i, .progress-track i, .freq-bar i { transition: none; animation: none; }
    .ch.now { animation: none; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026) */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"],
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) { min-height: 44px; }
    div.card-body > p#lvNext.form-hint,
    div.card-body > p.form-hint,
    div.challenge > p.challenge-desc,
    div.goal-row > p#goalDailyHint.form-hint,
    div.goal-row > p#goalSpeedHint.form-hint { font-size: 1rem; }
    main button#shortcutsBtn { min-width: 44px; }
}
