:root {
  --bg: #F4F6FF; --card: #FFFFFF; --ink: #1F2937; --ink2: #4B5563; --ink3: #9CA3AF;
  --line: #E5E7EB; --accent: #6366F1; --accent-soft: #E0E7FF; --good: #059669; --bad: #DC2626;
  --bad-soft: #FEE2E2; --gold: #F59E0B; --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.45; }
button { font-family: inherit; font-size: 18px; cursor: pointer; border: none; border-radius: 12px; padding: 10px 18px; background: var(--accent-soft); color: var(--ink); font-weight: 700; }
button.primary { background: var(--accent); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.center-msg { text-align: center; padding: 80px 20px; font-size: 24px; color: var(--ink2); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 18px; background: var(--card); border-radius: var(--radius); margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 28px; }
.topbar .hi { font-size: 22px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.saved { font-size: 15px; color: var(--ink3); min-width: 90px; }
.saved.ok { color: var(--good); }
.saved.err { color: var(--bad); }
.card { background: var(--card); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.card h2 { margin: 0 0 6px; font-size: 26px; }
.card .cap { color: var(--ink2); margin: 0 0 14px; font-size: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.steps { list-style: none; padding: 0; margin: 0 0 14px; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 6px 0 10px 48px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 4px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.steps b { display: block; font-size: 19px; }
.steps span { color: var(--ink2); font-size: 16px; }
/* sign-in */
.signin { max-width: 760px; margin: 40px auto; padding: 16px; text-align: center; }
.signin h1 { font-size: 40px; margin: 0 0 6px; }
.signin p { color: var(--ink2); font-size: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin: 24px 0; }
.tile { padding: 28px 12px; border-radius: 22px; font-size: 30px; font-weight: 800; color: var(--ink); border: 4px solid transparent; transition: transform .12s; }
.tile:hover { transform: translateY(-3px); }
.tile.sel { border-color: var(--ink); }
.tile small { display: block; font-size: 15px; font-weight: 600; color: var(--ink2); }
.pw { background: var(--card); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pw input { font-size: 24px; padding: 12px 16px; border-radius: 12px; border: 2px solid var(--line); width: min(360px, 100%); font-family: inherit; }
.err-msg { color: var(--bad); font-weight: 700; min-height: 26px; }
/* timer */
.timer { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.timer .clock { font-size: 44px; font-weight: 800; font-family: var(--mono); }
.bar { position: relative; height: 18px; border-radius: 9px; background: #EEF0F6; overflow: hidden; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); transition: width .9s linear; }
.bar .tick { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; }
.seglabels { display: flex; font-size: 13px; color: var(--ink3); }
.seglabels span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* stats */
.stats { display: flex; flex-wrap: wrap; gap: 14px 28px; margin: 6px 0 14px; }
.stat small { display: block; font-size: 14px; color: var(--ink3); }
.stat b { font-size: 28px; }
/* typing */
.tip { font-size: 18px; color: var(--ink2); margin-bottom: 8px; }
.typebox { border: 3px solid var(--accent); border-radius: 16px; padding: 22px 20px; background: #FAFBFF; }
.target { font-family: var(--mono); font-size: 36px; line-height: 56px; white-space: pre-wrap; word-break: break-word; letter-spacing: .04em; }
.target span { border-bottom: 4px solid transparent; border-radius: 4px; }
.target .ok { color: var(--good); }
.target .miss { color: var(--bad); text-decoration: underline wavy; }
.target .todo { color: var(--ink3); }
.target .cur { color: var(--ink); background: var(--accent-soft); border-bottom-color: var(--accent); }
.target .cur.flash { background: var(--bad-soft); border-bottom-color: var(--bad); }
.nextline { font-family: var(--mono); font-size: 22px; color: var(--ink3); margin-top: 10px; }
.hint { font-size: 18px; color: var(--ink2); margin-top: 14px; min-height: 26px; }
.done { text-align: center; padding: 6px 0; }
.stars { display: flex; justify-content: center; gap: 12px; }
.stars span { font-size: 64px; line-height: 72px; animation: pop .6s both; }
.done h3 { font-size: 28px; margin: 8px 0; animation: rise .5s .5s both; }
@keyframes pop { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 70% { transform: scale(1.35) rotate(8deg); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes rise { 0% { transform: translateY(10px); opacity: 0; } 100% { transform: none; opacity: 1; } }
/* keyboard */
.kb { display: flex; flex-direction: column; gap: 6px; max-width: 820px; margin: 14px auto 0; }
.kb .krow { display: flex; gap: 6px; justify-content: center; }
.key { flex: 1 1 0; min-width: 0; height: 50px; border-radius: 10px; color: #1F2937; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; transition: transform .12s, opacity .12s; position: relative; }
.key.wide { flex: 2 1 0; font-size: 14px; }
.key.space { flex: 0 1 55%; font-size: 14px; }
.key.dim { opacity: .5; }
.key.on { outline: 4px solid #1F2937; outline-offset: 2px; transform: translateY(-4px) scale(1.1); z-index: 2; opacity: 1; }
.key.on.wrong { outline-color: var(--bad); }
.key .bump { width: 14px; height: 3px; border-radius: 2px; background: #1F2937; margin-top: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; color: var(--ink2); font-size: 16px; }
.legend i { display: inline-block; width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; margin-right: 6px; }
/* ladder */
.ladder { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.lesson { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; font-weight: 400; }
.lesson.cur { border: 3px solid var(--accent); }
.lesson:disabled { opacity: .5; }
.lesson small { font-size: 14px; color: var(--ink3); }
.lesson b { font-size: 20px; }
.lesson .k { font-size: 15px; color: var(--ink2); }
.lesson .st { font-size: 24px; color: var(--gold); letter-spacing: 2px; }
.lesson .st.none { color: var(--ink3); }
/* game */
.arena { position: relative; height: 380px; border-radius: 16px; overflow: hidden; border: 3px solid var(--line); background: #FAFBFF; }
.word { position: absolute; padding: 6px 14px; border-radius: 12px; font-size: 26px; font-weight: 700; font-family: var(--mono); color: #1F2937; white-space: nowrap; }
.word.match { outline: 3px solid #1F2937; }
.word u { text-decoration: underline; }
.ground { position: absolute; left: 0; right: 0; bottom: 0; height: 10%; background: #E9ECF5; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 16px; }
.buf { font-family: var(--mono); font-size: 28px; min-height: 40px; margin-top: 10px; }
/* tables */
table { border-collapse: collapse; width: 100%; font-size: 17px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 14px; color: var(--ink3); font-weight: 600; }
td.num, th.num { text-align: right; }
.goal { background: var(--accent-soft); border-radius: 14px; padding: 14px 16px; margin: 6px 0 16px; font-size: 19px; }
.tablewrap { overflow-x: auto; }
