/* Student app. */
html, body { height: 100%; }
body { overflow: hidden; }
#app { height: 100%; }

/* ---------- splash ---------- */
#splash { position: fixed; inset: 0; z-index: 100; width: 100%; height: 100%; background: var(--paper); touch-action: none; transition: opacity .3s; }
#splash.clear { background: transparent; }
#splash.out { opacity: 0; pointer-events: none; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 1; overflow-y: auto; overflow-x: hidden;
  background: var(--paper); overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.wrap { max-width: 720px; margin: 0 auto; padding: calc(22px + env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom)); }
.screen.full { z-index: 30; left: 0 !important; }
.center-msg { min-height: 60vh; display: grid; place-items: center; text-align: center; gap: 16px; align-content: center; }

.page-h { display: grid; gap: 6px; margin: 6px 0 22px; }
.page-h h1 { font-family: var(--f-display); font-weight: 600; font-size: clamp(42px, 11vw, 58px); line-height: .98; letter-spacing: -.015em; }
.page-h p { color: var(--graphite); }
.topbar { display: flex; align-items: center; gap: 4px; margin: -8px 0 10px -10px; }

.section { margin-top: 30px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-h h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }

/* ---------- login ---------- */
.login { height: 100%; overflow-y: auto; display: grid; place-items: center; padding: calc(32px + env(safe-area-inset-top)) 20px 32px; }
.login-box { width: min(100%, 380px); display: grid; gap: 16px; }
.login-word { font-family: var(--f-display); font-weight: 600; font-size: clamp(68px, 21vw, 104px); line-height: .86; letter-spacing: -.025em; margin-bottom: 4px; }
.login-word span { color: var(--accent); }
.login-sub { color: var(--graphite); margin-bottom: 14px; }
.login-note { font-size: 13.5px; color: var(--muted); text-align: center; }

/* ---------- navigation: bottom bar on phones, rail on desktop ---------- */
.nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(18px); backdrop-filter: saturate(1.5) blur(18px);
  border-top: 1px solid var(--line);
  transition: transform .45s var(--ease);
}
.nav-brand, .nav-user { display: none; }
.nav-items { position: relative; display: flex; flex: 1; max-width: 520px; margin: 0 auto; }
.nav-btn {
  position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; border-radius: 14px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  text-decoration: none; transition: color .3s;
}
.link { color: var(--accent); text-decoration: none; font-weight: 700; font-size: 14px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.nav-btn .ic { transition: transform .35s var(--ease-out); }
.nav-btn[aria-current="page"] { color: var(--accent); }
.nav-btn[aria-current="page"] .ic { transform: translateY(-1px) scale(1.06); }
.nav-pill {
  position: absolute; z-index: 0; left: 0; top: 0; width: 0; height: 0; border-radius: 14px; background: var(--accent-soft);
  transition: transform .5s var(--ease), width .5s var(--ease), height .5s var(--ease);
}
.nav-pill.instant { transition: none; }
body.is-full .nav { transform: translateY(110%); }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 248px; flex-direction: column; align-items: stretch;
    padding: 30px 16px 22px; border-top: 0; border-right: 1px solid var(--line); background: var(--paper);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  body.is-full .nav { transform: translateX(-110%); }
  .nav-brand { display: block; font-family: var(--f-display); font-weight: 600; font-size: 38px; line-height: 1; letter-spacing: -.02em; padding: 0 14px 30px; }
  .nav-brand span { color: var(--accent); }
  .nav-items { flex-direction: column; flex: none; gap: 4px; max-width: none; margin: 0; }
  .nav-btn { flex: none; flex-direction: row; gap: 12px; padding: 12px 14px; font-size: 15px; }
  .nav-btn[aria-current="page"] .ic { transform: none; }
  .nav-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 10px; border-radius: 14px; text-align: left; }
  .nav-user:hover { background: var(--paper-2); }
  .nav-user b { display: block; font-size: 14px; line-height: 1.2; }
  .nav-user small { color: var(--muted); font-size: 12.5px; }
  .screen { left: 248px; }
  .wrap { padding: 52px 40px 72px; }
  .toasts { bottom: 28px; }
}

/* ---------- home ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--card); margin-bottom: 14px; }
.stat { padding: 14px 14px 12px; display: grid; gap: 2px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { font-size: 25px; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 5px; line-height: 1.15; }
.stat b .ic { color: var(--accent); }
.stat.hot b .ic { color: #E8590C; }
.stat span { font-size: 12.5px; color: var(--graphite); font-weight: 600; line-height: 1.3; }

.hero {
  position: relative; overflow: hidden; isolation: isolate; border-radius: 24px; width: 100%; text-align: left;
  background: var(--accent); color: var(--on-accent); padding: 22px 20px 20px; display: grid; gap: 14px; margin-bottom: 10px;
}
.hero .meta { color: inherit; opacity: .85; }
.hero h2 { font-family: var(--f-display); font-size: clamp(34px, 9vw, 42px); font-weight: 600; line-height: .98; letter-spacing: -.01em; max-width: 13ch; }
.hero .btn { background: var(--on-accent); color: var(--accent); justify-self: start; }
.hero.calm { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.hero.calm .btn { background: var(--ink); color: var(--paper); }

.row-card {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; text-align: left;
  border-radius: var(--r); background: var(--card); border: 1px solid var(--line); transition: border-color .2s;
}
.row-card:hover { border-color: var(--line-2); }
.row-card .grow { flex: 1; min-width: 0; }
.row-card b { display: block; font-weight: 800; }
.row-card small { color: var(--graphite); font-size: 14px; }
.row-card > .ic:last-child { color: var(--muted); }
.badge { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--wrong-soft); color: var(--wrong); flex: none; }
.badge.blue { background: var(--accent-soft); color: var(--accent); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; padding: 16px 14px 12px; }
.week-col { display: grid; gap: 6px; justify-items: center; }
.week-val { font-size: 11.5px; font-weight: 700; color: var(--graphite); min-height: 1.2em; }
.week-bar { width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px; background: var(--line-2); min-height: 4px; transition: height .6s var(--ease-out); }
.week-col.today .week-bar { background: var(--accent); }
.week-col.today .week-day { color: var(--accent); }
.week-day { font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- lessons ---------- */
.units { display: grid; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; }
.unit {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; width: 100%;
  padding: 18px 16px 18px 18px; background: transparent; text-align: left; transition: background-color .2s;
}
.unit + .unit { border-top: 1px solid var(--line); }
.unit:hover { background: var(--paper-2); }
.unit:focus-visible { outline-offset: -3px; }
.unit.lesson { grid-template-columns: auto 1fr auto; }
.unit-t { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.unit-s { display: block; font-size: 14px; color: var(--graphite); margin-top: 2px; }
.unit .ic { color: var(--muted); }
.meter { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 12px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.unit-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 6px; }

.unit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 26px; }
.words { display: grid; border-top: 1px solid var(--line); }
.word-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.word-row .grow { flex: 1; min-width: 0; }
.word-row b { display: block; font-weight: 800; font-size: 16.5px; }
.word-row small { display: block; color: var(--graphite); font-size: 14px; }
.dots { display: flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); }
.dots i.on { background: var(--accent); }
.empty { padding: 36px 20px; text-align: center; color: var(--graphite); border: 1.5px dashed var(--line-2); border-radius: var(--r); }

/* ---------- games ---------- */
.game-card { border-radius: 24px; border: 1px solid var(--line); background: var(--card); overflow: hidden; }
.game-art { position: relative; height: 176px; background: var(--paper-2); display: grid; place-items: center; overflow: hidden; }
.game-art .em { font-size: 64px; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; }
.game-art .tag { position: absolute; font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.game-body { padding: 20px; display: grid; gap: 14px; }
.game-body h2 { font-family: var(--f-display); font-size: 36px; font-weight: 600; line-height: 1; }
.join-row { display: flex; gap: 8px; }
.join-row .input { flex: 1; font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .3em; font-size: 20px; text-align: center; min-width: 0; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.game { display: flex; flex-direction: column; }
.g-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 6px; max-width: 980px; margin: 0 auto; width: 100%; min-height: 56px; }
.g-top .grow { flex: 1; min-width: 0; }
.g-main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 22px; }
.g-code-box { text-align: center; display: grid; gap: 6px; padding: 18px 0 8px; }
.g-code { font-family: var(--f-mono); font-size: clamp(48px, 15vw, 76px); font-weight: 500; letter-spacing: .2em; line-height: 1; padding-left: .2em; }
.g-code-actions { display: flex; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.player { display: inline-flex; align-items: center; gap: 8px; padding: 5px 13px 5px 5px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: 14.5px; animation: riseIn .35s var(--ease-out); }
.player .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.player .ic { color: #D69E00; }
.player.off { opacity: .45; }
.player em { font-style: normal; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.g-info { font-size: 14px; color: var(--graphite); }
.wait { display: flex; align-items: center; gap: 12px; justify-content: center; color: var(--graphite); font-weight: 600; padding: 14px; }

.g-play { position: fixed; inset: 0; top: var(--vvt, 0); bottom: auto; height: var(--vvh, 100%); display: flex; flex-direction: column; }
.scorebar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; justify-content: flex-end; }
.scorebar::-webkit-scrollbar { display: none; }
.score { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px 3px 3px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 800; font-size: 13.5px; white-space: nowrap; transition: border-color .2s; }
.score .avatar { width: 24px; height: 24px; font-size: 10px; }
.score.me { border-color: var(--accent); }
.score.bump { animation: bump .6s var(--ease-out); }
@keyframes bump { 30% { transform: scale(1.15); } }
.g-count { font-size: 13.5px; font-weight: 700; color: var(--graphite); white-space: nowrap; }
.g-stage { flex: 1; min-height: 0; display: grid; place-items: center; align-content: center; gap: 14px; position: relative; padding: 8px 16px; }
.g-card { position: relative; width: min(66vw, 40vh, 300px); aspect-ratio: 1; display: grid; place-items: center; }
.g-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.g-ring circle { fill: none; stroke-width: 2.2; }
.g-ring .track { stroke: var(--line); }
.g-ring .left { stroke: var(--accent); stroke-linecap: round; }
.g-ring.late .left { stroke: var(--wrong); }
.g-pic { width: 86%; height: 86%; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; font-size: min(34vw, 21vh, 150px); line-height: 1; }
.g-pic img { width: 100%; height: 100%; object-fit: cover; }
.g-reveal { min-height: 96px; text-align: center; display: grid; gap: 2px; align-content: start; }
.g-reveal .w { font-family: var(--f-display); font-size: clamp(36px, 10vw, 52px); font-weight: 600; line-height: 1.05; animation: riseIn .35s var(--ease-out); }
.g-reveal .ru { color: var(--graphite); }
.g-reveal .who { font-weight: 800; color: var(--accent); margin-top: 4px; }
.g-reveal .who.none { color: var(--muted); }
.g-reveal .q { color: var(--muted); font-weight: 600; padding-top: 8px; }
.g-answer { display: flex; gap: 8px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; width: 100%; }
.g-answer .input { flex: 1; min-height: 58px; font-size: 19px; min-width: 0; }
.g-answer .input.bad { border-color: var(--wrong); box-shadow: 0 0 0 4px var(--wrong-soft); animation: shake .35s; }
.g-answer .btn { min-height: 58px; padding: 0 20px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-display); font-size: min(42vw, 240px); font-weight: 600; line-height: 1; pointer-events: none; }
.countdown span { animation: tick 1s var(--ease-out) both; }
@keyframes tick { 0% { opacity: 0; transform: scale(1.6); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.85); } }
.banner { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--paper); font-size: 13.5px; font-weight: 700; padding: 8px 14px; border-radius: 999px; display: flex; gap: 8px; align-items: center; }

.board { display: grid; gap: 8px; width: 100%; }
.board-row { display: grid; grid-template-columns: 26px auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); animation: riseIn .45s var(--ease-out) backwards; }
.board-row.first { border-color: var(--accent); background: var(--accent-soft); }
.board-row .pos { font-weight: 800; color: var(--muted); font-size: 15px; }
.board-row b { font-size: 16px; }
.board-row .pts { font-size: 20px; font-weight: 800; }
.board-row .track { grid-column: 3 / 4; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.board-row .track i { display: block; height: 100%; background: var(--accent); }
.over-h { text-align: center; display: grid; gap: 6px; padding-top: 10px; }
.over-h h1 { font-family: var(--f-display); font-size: clamp(44px, 12vw, 64px); font-weight: 600; line-height: .98; }

/* ---------- profile ---------- */
.me-card { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.me-card .avatar { width: 68px; height: 68px; font-size: 24px; }
.me-card h1 { font-family: var(--f-display); font-size: 40px; font-weight: 600; line-height: 1; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.grid4 .stat:nth-child(3) { border-left: 0; }
.grid4 .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
@media (min-width: 600px) {
  .grid4 { grid-template-columns: repeat(4, 1fr); }
  .grid4 .stat:nth-child(3) { border-left: 1px solid var(--line); }
  .grid4 .stat:nth-child(n+3) { border-top: 0; }
}
.set-list { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; flex-wrap: wrap; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row b { font-weight: 700; }
.set-row small { display: block; color: var(--graphite); font-size: 13.5px; }
.pw-form { display: grid; gap: 12px; padding: 16px; }

/* ---------- lessons (full tasks) ---------- */
.lesson .l-mark {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; align-self: start; margin-top: -4px;
  font-size: 13.5px; font-weight: 800; color: var(--graphite); border: 1.5px solid var(--line-2);
}
.lesson.next .l-mark { border-color: var(--accent); color: var(--accent); }
.lesson.done .l-mark { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lesson .unit-meta { margin-top: 10px; justify-content: flex-start; gap: 4px 14px; flex-wrap: wrap; }
.lesson .unit-meta > span { white-space: nowrap; }
.l-res { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.mini-stars { display: inline-flex; gap: 1px; color: var(--line-2); }
.mini-stars .on { color: var(--accent); }
.mini-stars .on .ic { fill: currentColor; }
.l-best { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--accent-soft); margin: -6px 0 18px; color: var(--graphite); font-size: 14.5px; }
.l-best b { color: var(--ink); font-size: 18px; font-weight: 800; }
.k-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.k-list li { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.k-list b { font-weight: 800; }
.k-list small { grid-column: 1; color: var(--graphite); font-size: 14px; }
.k-list .n { grid-column: 2; grid-row: 1; color: var(--graphite); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.unit .l-mark .ic, .unit .mini-stars .ic { color: inherit; }

/* docked main button on phones: appears above the tab bar when the original scrolls away */
.dock {
  position: sticky; z-index: 5; bottom: calc(80px + env(safe-area-inset-bottom)); margin-top: 18px;
  opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .2s, transform .25s var(--ease-out);
}
.dock.show { opacity: 1; transform: none; pointer-events: auto; }
.dock .btn { width: 100%; box-shadow: 0 10px 28px -10px rgba(43, 63, 245, .55); }
@media (min-width: 900px) { .dock { display: none; } }
