:root {
  --bg: #0f1115; --card: #181b22; --line: #2a2f3a; --text: #f2f4f8; --muted: #9aa3b2;
  --accent: #ff6b2c; --accent-2: #ffb02c; --ok: #3ddc84; --err: #ff5c5c;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 24px; } h3 { font-size: 18px; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.err { color: var(--err); min-height: 1em; margin: 4px 0; }
.screen { display: flex; flex-direction: column; gap: 14px; }

.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: #1a0d05; cursor: pointer; min-height: 48px;
}
.btn.big { font-size: 18px; padding: 16px; min-height: 56px; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }
.btn:focus-visible, .link:focus-visible, .pick:focus-visible, .tab:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent-2); outline-offset: 2px;
}
.link { background: none; border: 0; color: var(--muted); font: inherit; padding: 8px; cursor: pointer; min-height: 44px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
input[type=password], input:not([type]), input[inputmode] {
  font: inherit; font-size: 18px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; min-height: 48px; width: 100%;
}
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
label.opt { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 16px; margin: 0;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; min-height: 48px; }
label.opt input { width: 20px; height: 20px; accent-color: var(--accent); }

.brand { text-align: center; padding: 24px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.brand h1 { font-size: 32px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border-radius: 12px; padding: 4px; border: 1px solid var(--line); }
.tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 10px; border-radius: 9px; min-height: 44px; cursor: pointer; }
.tab[aria-selected=true] { background: var(--line); color: var(--text); }

.top { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.top p { margin: 0; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tot { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; }
.num { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.row-head { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

.ch { display: flex; flex-direction: column; gap: 10px; }
.ch + .ch { margin-top: 10px; }
.ch.hl { border-color: var(--accent); }
.ch-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ch-top b { font-size: 17px; }
.badge { font-size: 13px; padding: 3px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.live { background: rgba(61,220,132,.15); color: var(--ok); }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.board li.me { outline: 1px solid var(--line); }
.board .place { font-weight: 700; color: var(--muted); text-align: center; }
.board .reps { font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { grid-column: 2 / 4; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 20px; }
ul.plain { list-style: none; padding: 0; margin: 10px 0 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
summary { cursor: pointer; min-height: 32px; }

.pick { display: flex; gap: 14px; align-items: center; text-align: left; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r); padding: 18px; font: inherit; cursor: pointer; }
.pick .emoji { font-size: 34px; }
.tips ul { margin: 8px 0 0; padding-left: 20px; }

/* Тренировка — на весь экран */
.train { position: fixed; inset: 0; background: #000; gap: 0; z-index: 5; }
.cam { position: relative; flex: 1; overflow: hidden; }
.cam video, .cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam.mirror video, .cam.mirror canvas { transform: scaleX(-1); }
.hud { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 16px; pointer-events: none; }
.ex-name { background: rgba(0,0,0,.55); padding: 4px 12px; border-radius: 99px; font-size: 14px; }
.count { font-size: 120px; font-weight: 900; line-height: 1; text-shadow: 0 4px 24px rgba(0,0,0,.7); font-variant-numeric: tabular-nums; margin-top: 8px; }
.count.pop { animation: pop .25s ease-out; color: var(--accent-2); }
@keyframes pop { from { transform: scale(1.25); } to { transform: scale(1); } }
.hint { margin-top: auto; background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 12px; text-align: center; max-width: 100%; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 160px; font-weight: 900; background: rgba(0,0,0,.45); }
.train-bar { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.train-bar .stop { flex: 1; }

.done { text-align: center; padding: 40px 0 10px; }
.done p { margin: 6px 0; }
.count.big { font-size: 110px; color: var(--accent); text-shadow: none; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px); }
@media (prefers-reduced-motion: reduce) { .count.pop { animation: none; } }
form .btn, .screen > .btn { width: 100%; }
#toast { width: max-content; text-align: center; }
