Finální vzhled Aréna napříč aplikací (#20)
CI / test (push) Successful in 21s
CI / docker (push) Successful in 4s

Vybraná varianta Aréna z prototypu (#9, `docs/prototyp-ui/`) dotažená do celé aplikace.

**Žákovská část**
- Jeden stylesheet `static/css/app.css` s tokeny a přibalené písmo Baloo 2. Žádné písmo, styl ani skript se nenačítá z cizí domény.
- Herní obrazovka zabírá přesně výšku vizuálního viewportu. Během otázky ani zpětné vazby se nescrolluje, a to ani s otevřenou klávesnicí v režimu Psaní.
- Prstenec s aktuální hodnotou otázky místo časové lišty.
- Zpětná vazba se zobrazí v okně mezi horní lištou a ovládáním, takže je během ní vidět změna série a skóre. Na další otázku se přejde tlačítkem „Další“, klávesou Enter nebo ťuknutím na okno.
- Možnosti A–D mají kromě barvy i tvar. Verdikt je napsaný textem. Tlačítka mají velikost aspoň 48 px a jsou ve spodní části obrazovky.
- Katalog na telefonu: karty přes celou šířku s fotkou vlevo.
- Respektuje se `prefers-reduced-motion` a fokus z klávesnice je vidět.

**Administrace**
- Světlý vzhled bez herních efektů. Šablony jsou bez inline stylů, hlídá to test.
- Fotky jde na detail sady přetáhnout kamkoli. Přetažené na stránku jdou do hromadného nahrání, přetažené na kartu položky k té položce. Nic se nenahraje bez potvrzení.

**Další**
- Compose: adresa publikovaného portu jde nastavit přes `POZNAVACKY_BIND` (výchozí `127.0.0.1`).

OpenSpec: `finalni-ui-arena`. Přidává novou specifikaci `ui-layout` a upravuje požadavek herní smyčky v `quiz-gameplay`. Změna je synchronizovaná a archivovaná. Změna časové křivky bodů pro Psaní (#18) do tohoto PR nepatří.

**Ověření**
- `pytest` (336 testů) a `ruff check .`.
- Ruční test na telefonu s Androidem (Chrome): kolo A–D, kolo Psaní s klávesnicí bez scrollování, ukončení kola, katalog, detail sady, shrnutí. Všechno se chová a vypadá správně. Na iPhonu (Safari) neověřeno, iPhone nebyl k dispozici a v ČR je pro cílovou skupinu téměř nerelevantní.
- V Chromu na lokálním serveru s testovacími daty: hromadné nahrání (náhled, zrušení, potvrzení), doplnění synonym a latiny u jedné položky i u celé sady, náhled doplnění bez JavaScriptu, přetažení fotek na stránku i na kartu položky. Přetažení bylo podvržené událostmi v prohlížeči.
- Omezení pohybu v GNOME: série i okno zpětné vazby se ukážou bez animace.

**Kontrast tokenů (WCAG AA, požadavek 4,5 : 1)**, spočítáno stejnou funkcí jako `test_token_contrast_meets_wcag_aa`. Nejnižší hodnota je 4,78 (`--on-opt-a` na `--opt-a`).

| Oblast | Text | Pozadí | Kontrast |
|---|---|---|---|
| žák | `--fg` | `--bg` | 16.27 |
| žák | `--fg` | `--surface` | 13.34 |
| žák | `--fg` | `--surface-2` | 11.41 |
| žák | `--muted` | `--bg` | 8.88 |
| žák | `--muted` | `--surface` | 7.28 |
| žák | `--muted` | `--surface-2` | 6.23 |
| žák | `--link` | `--bg` | 11.27 |
| žák | `--link` | `--surface` | 9.24 |
| žák | `--accent-fg` | `--accent` | 11.27 |
| žák | `--flash-fg` | `--flash-bg` | 13.34 |
| žák | `--on-ok` | `--ok` | 4.97 |
| žák | `--on-part` | `--part` | 7.97 |
| žák | `--on-bad` | `--bad` | 5.48 |
| žák | `--on-opt-a` | `--opt-a` | 4.78 |
| žák | `--on-opt-b` | `--opt-b` | 5.21 |
| žák | `--on-opt-c` | `--opt-c` | 7.97 |
| žák | `--on-opt-d` | `--opt-d` | 4.89 |
| admin | `--fg` | `--bg` | 15.08 |
| admin | `--fg` | `--surface` | 16.27 |
| admin | `--fg` | `--surface-2` | 14.06 |
| admin | `--muted` | `--bg` | 7.18 |
| admin | `--muted` | `--surface` | 7.75 |
| admin | `--muted` | `--surface-2` | 6.70 |
| admin | `--link` | `--bg` | 6.41 |
| admin | `--link` | `--surface` | 6.92 |
| admin | `--accent-fg` | `--accent` | 5.21 |
| admin | `--flash-fg` | `--flash-bg` | 16.27 |
| admin | `--bad` | `--surface` | 5.48 |
| hra (pole odpovědi) | `#1a1e3a` | `#ffffff` | 16.27 |
| hra (pole odpovědi) | `#5a6088` | `#ffffff` | 6.06 |

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013nPfHYKGzfZageFkhvGPTx
Reviewed-on: #20
Co-authored-by: David Spáčil <spacildavi@gmail.com>
This commit was merged in pull request #20.
This commit is contained in:
david-spacil authored and David Spáčil committed 2026-11-29 16:33:41 +01:00
1 parent a1c95d7777
commit 24e946c44d
59 files changed
+4341 -690

No files matched your search

+697
View File
@@ -0,0 +1,697 @@
<!doctype html>
<html lang="cs" data-v="karta">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
<title>Poznávačky – prototyp vzhledu</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Baloo+2:wght@500;700;800&family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,800&family=Manrope:wght@500;700;800&display=swap">
<style>
/* Jeden DOM, tři vzhledy přes [data-v]. Hra = pevná výška vizuálního
viewportu (--vvh), nic se během otázky nescrolluje. */
:root {
--f-head: "Bricolage Grotesque", system-ui, sans-serif;
--f-body: "Atkinson Hyperlegible", system-ui, sans-serif;
--bg: #f3f5ef; --surface: #ffffff; --fg: #1c2a1f; --muted: #5b695d;
--line: #dbe2d6; --accent: #2f7a4d; --accent-fg: #ffffff;
--ok: #2e7d32; --part: #a86400; --bad: #c62828;
--ok-bg: #e6f3e7; --part-bg: #fff3dc; --bad-bg: #fde8e8;
--radius: 14px; --sab: env(safe-area-inset-bottom, 0px);
--sat: env(safe-area-inset-top, 0px);
color-scheme: light;
}
[data-v="celoplosna"] {
--f-head: "Manrope", system-ui, sans-serif;
--f-body: "Atkinson Hyperlegible", system-ui, sans-serif;
--bg: #0e1311; --surface: rgba(16, 22, 19, 0.82); --fg: #f1f3ee;
--muted: #a7b1a9; --line: rgba(255, 255, 255, 0.16);
--accent: #ece6d6; --accent-fg: #15140f;
--ok: #4fcf86; --part: #f2b84b; --bad: #ff6b5e;
--ok-bg: rgba(79, 207, 134, 0.18); --part-bg: rgba(242, 184, 75, 0.18);
--bad-bg: rgba(255, 107, 94, 0.18); --radius: 10px;
color-scheme: dark;
}
[data-v="arena"] {
--f-head: "Baloo 2", system-ui, sans-serif;
--f-body: "Baloo 2", system-ui, sans-serif;
--bg: #1a1e3a; --surface: #262c55; --fg: #ffffff; --muted: #b8bde6;
--line: #3a4178; --accent: #ffd23f; --accent-fg: #1a1e3a;
--ok: #2fbf71; --part: #f5a524; --bad: #e5484d;
--ok-bg: #2fbf71; --part-bg: #f5a524; --bad-bg: #e5484d;
--a: #e5484d; --b: #3e63dd; --c: #f5a524; --d: #12a594;
--radius: 18px; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
font-family: var(--f-body); font-size: 17px; line-height: 1.45;
-webkit-text-size-adjust: 100%; }
html.in-game, html.in-game body { overflow: hidden; height: 100%;
overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation: none !important; transition: none !important; }
}
/* ---------- přepínač variant (chrome prototypu) ---------- */
.proto-bar { position: sticky; top: 0; z-index: 20;
padding: calc(var(--sat) + 8px) max(16px, env(safe-area-inset-right, 0px)) 8px
max(16px, env(safe-area-inset-left, 0px));
background: #111; color: #eee; font: 600 13px/1.2 system-ui, sans-serif;
display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.proto-bar span { opacity: .7; letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
.proto-bar a { color: #eee; text-decoration: none; padding: 6px 10px;
border: 1px solid #444; border-radius: 999px; }
.proto-bar a[aria-current="true"] { background: #eee; color: #111; border-color: #eee; }
/* ---------- katalog ---------- */
.page { padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(32px + var(--sab))
max(16px, env(safe-area-inset-left, 0px)); max-width: 46rem; margin: 0 auto; }
.cat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.cat-head h1 { font-family: var(--f-head); font-size: 1.9rem; line-height: 1.1;
margin: 0; letter-spacing: -0.01em; }
.cat-head .who { color: var(--muted); font-size: .95rem; }
.grade { margin: 28px 0 10px; font-family: var(--f-head); font-size: .8rem;
text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sets { display: grid; gap: 12px; }
.set-card { display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: center;
width: 100%; text-align: left; padding: 10px; border: 1px solid var(--line);
border-radius: var(--radius); background: var(--surface); min-height: 104px; }
.set-card img { width: 84px; height: 84px; object-fit: cover; border-radius: calc(var(--radius) - 6px); }
.set-info { min-width: 0; display: grid; gap: 4px; }
.set-name { font-family: var(--f-head); font-weight: 700; font-size: 1.12rem; line-height: 1.2; }
.set-meta { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.mastery { display: flex; gap: 8px; align-items: center; font-size: .85rem;
font-variant-numeric: tabular-nums; font-weight: 700; }
.mastery .bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.mastery .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.credits { margin-top: 36px; font-size: .78rem; color: var(--muted); }
.credits summary { cursor: pointer; }
.credits li { margin: 4px 0; }
.credits a { color: inherit; }
[data-v="celoplosna"] .sets { grid-template-columns: 1fr 1fr; gap: 10px; }
[data-v="celoplosna"] .set-card { position: relative; display: block; padding: 0;
aspect-ratio: 3 / 4; overflow: hidden; border: 0; min-height: 0; }
[data-v="celoplosna"] .set-card img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; }
[data-v="celoplosna"] .set-info { position: absolute; inset: auto 0 0 0; padding: 40px 12px 12px;
background: linear-gradient(transparent, rgba(0,0,0,.85)); }
[data-v="celoplosna"] .set-name { font-size: 1rem; }
[data-v="celoplosna"] .cat-head h1 { font-weight: 800; }
[data-v="arena"] .sets { gap: 14px; }
[data-v="arena"] .set-card { border: 0; padding: 12px; box-shadow: 0 5px 0 rgba(0,0,0,.35); }
[data-v="arena"] .sets > :nth-child(4n+1) .set-card { background: var(--b); }
[data-v="arena"] .sets > :nth-child(4n+2) .set-card { background: var(--d); }
[data-v="arena"] .sets > :nth-child(4n+3) .set-card { background: var(--a); }
[data-v="arena"] .set-meta, [data-v="arena"] .cat-head .who { color: rgba(255,255,255,.85); }
[data-v="arena"] .mastery .bar { background: rgba(0,0,0,.3); }
[data-v="arena"] .cat-head h1 { font-weight: 800; font-size: 2.2rem; }
@media (min-width: 640px) {
[data-v="celoplosna"] .sets { grid-template-columns: repeat(3, 1fr); }
[data-v="karta"] .sets, [data-v="arena"] .sets { grid-template-columns: 1fr 1fr; }
}
/* ---------- výběr režimu (spodní panel) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30;
display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 34rem; background: var(--bg); color: var(--fg);
border-radius: 22px 22px 0 0;
padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(16px + var(--sab))
max(16px, env(safe-area-inset-left, 0px));
display: grid; gap: 14px; animation: up .22s ease-out; }
[data-v="celoplosna"] .sheet { background: #161d1a; }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet h2 { margin: 0; font-family: var(--f-head); font-size: 1.4rem; line-height: 1.15; }
.sheet .lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg button { min-height: 56px; border: 2px solid var(--line); border-radius: 12px;
background: var(--surface); font-weight: 700; padding: 6px; line-height: 1.15; }
.seg button small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.seg button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.primary { min-height: 58px; border: 0; border-radius: 14px; background: var(--accent);
color: var(--accent-fg); font-family: var(--f-head); font-weight: 800; font-size: 1.15rem; }
[data-v="arena"] .primary { box-shadow: 0 5px 0 #b38f13; }
/* ---------- hra ---------- */
.game { position: fixed; left: 0; right: 0; top: var(--vvt, 0px);
height: var(--vvh, 100dvh); display: grid;
grid-template-rows: auto auto minmax(0, 1fr) auto; background: var(--bg);
padding: calc(var(--sat) + 6px) max(12px, env(safe-area-inset-right, 0px)) 0
max(12px, env(safe-area-inset-left, 0px)); overflow: hidden; }
html.kb .game { padding-top: 6px; }
.hud { display: flex; align-items: center; gap: 10px; min-height: 44px; font-variant-numeric: tabular-nums; }
.quit { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent;
font-size: 1.6rem; line-height: 1; color: var(--muted); flex: none; }
.prog { flex: 1; display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.prog .bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--fg); opacity: .55; transition: width .3s; }
.score { font-family: var(--f-head); font-weight: 800; font-size: 1.2rem; position: relative;
min-width: 4.2ch; text-align: right; }
.score small { font-size: .7rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.ring { display: none; }
.combo { font-family: var(--f-head); font-weight: 800; font-size: .95rem; padding: 3px 9px;
border-radius: 99px; background: var(--accent); color: var(--accent-fg); }
.combo.pop { animation: pop .4s ease-out; }
@keyframes pop { 40% { transform: scale(1.35); } }
.timer { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; font-size: .85rem;
color: var(--muted); font-variant-numeric: tabular-nums; }
.timer .track { flex: 1; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.timer .track i { display: block; height: 100%; background: var(--accent); transform-origin: left; }
.timer b { color: var(--fg); min-width: 5ch; text-align: right; }
.photo { position: relative; min-height: 0; display: grid; place-items: center;
border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.photo-bg { position: absolute; inset: -20px; background-size: cover; background-position: center;
filter: blur(18px) brightness(.55); display: none; }
.photo img { position: relative; max-width: 100%; max-height: 100%; width: auto; height: auto;
object-fit: contain; display: block; }
.controls { padding: 10px 0 calc(10px + var(--sab)); }
html.kb .controls { padding-bottom: 8px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { min-height: 64px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px;
background: var(--surface); font-weight: 700; font-size: 1rem; line-height: 1.2; text-align: left;
display: flex; gap: 10px; align-items: center; }
.opt .key { flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
font-size: .8rem; background: var(--line); }
.opt.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-bad { border-color: var(--bad); background: var(--bad-bg); }
.opts.answered .opt:not(.is-ok):not(.is-bad) { opacity: .45; }
.wform { display: flex; gap: 8px; }
.wform input { flex: 1; min-width: 0; min-height: 56px; padding: 0 14px; font-size: 1.1rem;
border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.wform input:focus { border-color: var(--accent); outline: none; }
.wform button { min-width: 56px; min-height: 56px; border: 0; border-radius: 12px; background: var(--accent);
color: var(--accent-fg); font-weight: 800; font-size: 1.3rem; }
/* zpětná vazba – výchozí (Karta): spodní panel přes ovládání */
.fb { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(12px + var(--sab))
max(16px, env(safe-area-inset-left, 0px));
background: var(--surface); border-top: 4px solid var(--muted);
border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.18);
display: grid; gap: 6px; animation: up .2s ease-out; }
html.kb .fb { padding-bottom: 10px; }
.fb.v-spravne { border-top-color: var(--ok); }
.fb.v-castecne { border-top-color: var(--part); }
.fb.v-spatne { border-top-color: var(--bad); }
.fb-verdict { font-family: var(--f-head); font-weight: 800; font-size: 1.25rem; display: flex;
justify-content: space-between; gap: 10px; align-items: baseline; }
.fb.v-spravne .fb-verdict { color: var(--ok); }
.fb.v-castecne .fb-verdict { color: var(--part); }
.fb.v-spatne .fb-verdict { color: var(--bad); }
.fb-pts { font-variant-numeric: tabular-nums; }
.fb-name { font-size: 1.15rem; font-weight: 700; }
.fb-name i { font-weight: 400; color: var(--muted); }
.fb-meta { font-size: .9rem; color: var(--muted); }
.fb .primary { margin-top: 6px; }
.fb .hint { display: none; }
/* --- Celoplošná --- */
[data-v="celoplosna"] .game { grid-template-rows: minmax(0, 1fr) auto; padding: 0; }
[data-v="celoplosna"] .photo { grid-row: 1 / -1; grid-column: 1; border: 0; border-radius: 0; background: #000; }
[data-v="celoplosna"] .photo-bg { display: block; }
[data-v="celoplosna"] .hud { position: absolute; z-index: 3; left: 0; right: 0;
top: 0; padding: calc(var(--sat) + 4px) max(8px, env(safe-area-inset-right, 0px)) 18px
max(8px, env(safe-area-inset-left, 0px)); background: linear-gradient(rgba(0,0,0,.65), transparent); }
[data-v="celoplosna"] .timer { position: absolute; z-index: 4; left: 0; right: 0; top: 0; margin: 0; }
[data-v="celoplosna"] .timer .track { height: 4px; border-radius: 0; background: rgba(255,255,255,.12); }
[data-v="celoplosna"] .timer b { display: none; }
[data-v="celoplosna"] .controls { grid-row: 2; grid-column: 1; z-index: 3;
padding: 36px max(12px, env(safe-area-inset-right, 0px)) calc(12px + var(--sab))
max(12px, env(safe-area-inset-left, 0px));
background: linear-gradient(transparent, rgba(0,0,0,.8) 40%); }
[data-v="celoplosna"] .opts { grid-template-columns: 1fr; gap: 6px; }
[data-v="celoplosna"] .opt { min-height: 52px; background: rgba(18,24,21,.72); backdrop-filter: blur(8px);
border-color: rgba(255,255,255,.18); }
[data-v="celoplosna"] .opt .key { background: rgba(255,255,255,.14); }
[data-v="celoplosna"] .wform input { background: rgba(18,24,21,.8); border-color: rgba(255,255,255,.25); }
[data-v="celoplosna"] .prog, [data-v="celoplosna"] .quit { color: #ddd; }
[data-v="celoplosna"] .prog .bar { background: rgba(255,255,255,.2); }
[data-v="celoplosna"] .prog .bar i { background: #fff; opacity: .9; }
[data-v="celoplosna"] .game::after { content: ""; position: absolute; inset: 0; z-index: 6;
pointer-events: none; box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .25s; }
[data-v="celoplosna"] .game.g-spravne::after { box-shadow: inset 0 0 0 6px var(--ok), inset 0 0 60px var(--ok); }
[data-v="celoplosna"] .game.g-castecne::after { box-shadow: inset 0 0 0 6px var(--part), inset 0 0 60px var(--part); }
[data-v="celoplosna"] .game.g-spatne::after { box-shadow: inset 0 0 0 6px var(--bad), inset 0 0 60px var(--bad); }
[data-v="celoplosna"] .fb { background: rgba(10,14,12,.86); backdrop-filter: blur(10px);
border-top: 0; border-radius: 0; box-shadow: none; }
[data-v="celoplosna"] .fb .primary { min-height: 54px; }
/* --- Aréna --- */
[data-v="arena"] .game { grid-template-rows: auto minmax(0, 1fr) auto; }
[data-v="arena"] .timer { display: none; }
[data-v="arena"] .ring { display: block; position: absolute; right: -6px; top: 50%;
width: 58px; height: 58px; transform: translateY(-50%) rotate(-90deg); }
[data-v="arena"] .score { width: 58px; height: 58px; display: grid; place-items: center;
text-align: center; font-size: .95rem; line-height: 1; margin-right: 6px; }
[data-v="arena"] .score span { position: relative; z-index: 1; }
[data-v="arena"] .score small { display: none; }
[data-v="arena"] .ring circle { fill: none; stroke-width: 6; }
[data-v="arena"] .ring .r-bg { stroke: var(--line); }
[data-v="arena"] .ring .r-fg { stroke: var(--accent); stroke-linecap: round; }
[data-v="arena"] .hud { min-height: 64px; }
[data-v="arena"] .photo { margin-top: 4px; border: 4px solid #fff; background: #fff; }
[data-v="arena"] .opt { min-height: 74px; border: 0; color: #fff; font-size: 1.05rem;
box-shadow: 0 5px 0 rgba(0,0,0,.35); justify-content: flex-start; }
[data-v="arena"] .opt:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
[data-v="arena"] .opt:nth-child(1) { background: var(--a); }
[data-v="arena"] .opt:nth-child(2) { background: var(--b); }
[data-v="arena"] .opt:nth-child(3) { background: var(--c); color: #1a1e3a; }
[data-v="arena"] .opt:nth-child(4) { background: var(--d); }
[data-v="arena"] .opt .key { background: rgba(255,255,255,.25); }
[data-v="arena"] .opt .key svg { width: 14px; height: 14px; fill: currentColor; }
[data-v="arena"] .opt.is-ok { outline: 4px solid #fff; outline-offset: -4px; }
[data-v="arena"] .wform input { border: 0; background: #fff; color: #1a1e3a; font-weight: 700; }
[data-v="arena"] .wform button { box-shadow: 0 4px 0 #b38f13; }
[data-v="arena"] .combo { background: var(--a); color: #fff; font-size: 1.05rem; }
[data-v="arena"] .fb { inset: 0; top: 0; border: 0; border-radius: 0; box-shadow: none;
align-content: center; justify-items: center; text-align: center; gap: 10px;
padding: calc(var(--sat) + 24px) 24px calc(24px + var(--sab)); animation: flash .25s ease-out; color: #fff; }
@keyframes flash { from { transform: scale(1.06); opacity: 0; } }
[data-v="arena"] .fb.v-spravne { background: var(--ok); }
[data-v="arena"] .fb.v-castecne { background: var(--part); color: #1a1e3a; }
[data-v="arena"] .fb.v-spatne { background: var(--bad); }
[data-v="arena"] .fb .fb-verdict { color: inherit !important; flex-direction: column; align-items: center;
font-size: 2.6rem; line-height: 1; gap: 8px; }
[data-v="arena"] .fb-pts { font-size: 1.6rem; }
[data-v="arena"] .fb-name { font-size: 1.5rem; }
[data-v="arena"] .fb-name i, [data-v="arena"] .fb-meta { color: inherit; opacity: .85; }
[data-v="arena"] .fb .primary { display: none; }
[data-v="arena"] .fb .hint { display: block; margin-top: 18px; opacity: .8; font-size: .95rem; }
/* ---------- shrnutí ---------- */
.sum-hero { display: grid; gap: 4px; margin: 8px 0 18px; }
.sum-hero .big { font-family: var(--f-head); font-weight: 800; font-size: 3rem; line-height: 1;
font-variant-numeric: tabular-nums; }
.sum-hero .of { color: var(--muted); }
.badge { display: inline-block; padding: 4px 10px; border-radius: 99px; background: var(--accent);
color: var(--accent-fg); font-weight: 700; font-size: .9rem; width: max-content; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.stat { padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat b { display: block; font-family: var(--f-head); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }
.sum h2 { font-family: var(--f-head); font-size: 1.15rem; margin: 22px 0 8px; }
.mist { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center;
padding: 8px 0; border-bottom: 1px solid var(--line); }
.mist img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; }
.mist .you { font-size: .85rem; color: var(--muted); }
.mist .v { font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.mist .v-castecne { background: var(--part-bg); color: var(--part); }
.mist .v-spatne { background: var(--bad-bg); color: var(--bad); }
[data-v="arena"] .mist .v { color: #fff; }
.actions { display: grid; gap: 10px; margin-top: 22px; }
.secondary { min-height: 52px; border: 2px solid var(--line); border-radius: 14px; background: transparent;
font-weight: 700; }
.note { font-size: .8rem; color: var(--muted); }
</style>
</head>
<body>
<nav class="proto-bar" id="proto-bar" aria-label="Varianta prototypu">
<span>Varianta</span>
<a href="#karta" data-v="karta">1 Karta</a>
<a href="#celoplosna" data-v="celoplosna">2 Celoplošná</a>
<a href="#arena" data-v="arena">3 Aréna</a>
</nav>
<main id="scr-catalog" class="page">
<div class="cat-head">
<h1>Poznávačky</h1>
<span class="who">Žák 7 · 6.B</span>
</div>
<div id="catalog"></div>
<details class="credits">
<summary>Fotky: Wikimedia Commons (licence a autoři)</summary>
<ul id="credits"></ul>
</details>
</main>
<div class="scrim" id="sheet-scrim" hidden>
<div class="sheet" role="dialog" aria-modal="true" aria-labelledby="sheet-title">
<h2 id="sheet-title"></h2>
<div class="set-meta" id="sheet-meta"></div>
<div class="lbl">Režim</div>
<div class="seg" id="seg-mode">
<button type="button" data-mode="psani">Psaní<small>max 1000 b.</small></button>
<button type="button" data-mode="abcd">Výběr A–D<small>max 500 b.</small></button>
</div>
<div class="lbl">Délka kola</div>
<div class="seg three" id="seg-len">
<button type="button" data-len="cele">Celá sada<small id="len-all"></small></button>
<button type="button" data-len="rychle">Rychlé<small>5 otázek</small></button>
<button type="button" data-len="chyby">Chyby<small id="len-err"></small></button>
</div>
<button type="button" class="primary" id="start-btn">Hrát</button>
</div>
</div>
<section id="scr-game" class="game" hidden aria-label="Hra">
<header class="hud">
<button type="button" class="quit" id="quit" aria-label="Ukončit kolo">×</button>
<div class="prog"><span id="hud-prog"></span><div class="bar"><i id="hud-progbar"></i></div></div>
<span class="combo" id="hud-combo" hidden></span>
<div class="score"><span id="hud-score">0</span><small>b.</small>
<svg class="ring" viewBox="0 0 58 58" aria-hidden="true">
<circle class="r-bg" cx="29" cy="29" r="25"></circle>
<circle class="r-fg" id="ring-fg" cx="29" cy="29" r="25" stroke-dasharray="157.08" stroke-dashoffset="0"></circle>
</svg>
</div>
</header>
<div class="timer" aria-hidden="true"><div class="track"><i id="timer-fill"></i></div><b id="timer-pts"></b></div>
<div class="photo"><div class="photo-bg" id="photo-bg"></div><img id="photo" alt="Fotka položky"></div>
<div class="controls">
<div class="opts" id="opts" hidden></div>
<form class="wform" id="wform" hidden autocomplete="off">
<input id="winput" type="text" enterkeyhint="send" autocomplete="off" autocapitalize="off"
autocorrect="off" spellcheck="false" placeholder="Název (česky nebo latinsky)" aria-label="Název položky">
<button type="submit" aria-label="Odeslat">›</button>
</form>
</div>
<section class="fb" id="fb" hidden aria-live="polite">
<div class="fb-verdict"><span id="fb-verdict"></span><span class="fb-pts" id="fb-pts"></span></div>
<div class="fb-name" id="fb-name"></div>
<div class="fb-meta" id="fb-meta"></div>
<button type="button" class="primary" id="next-btn">Další</button>
<div class="hint">Ťukni kamkoli pro další otázku</div>
</section>
</section>
<main id="scr-summary" class="page sum" hidden></main>
<script>
"use strict";
const CREDITS = [{"s":"parus-major","a":"Frank Vassen from Brussels, Belgium","l":"CC BY 2.0","p":"https://commons.wikimedia.org/wiki/File:Great_tit_(Parus_major),_Parc_du_Rouge-Cloitre,_For%C3%AAt_de_Soignes,_Brussels_(26194636951).jpg"},{"s":"erinaceus-europaeus","a":"Jörg Hempel","l":"CC BY-SA 2.0 de","p":"https://commons.wikimedia.org/wiki/File:Erinaceus_europaeus_LC0119.jpg"},{"s":"picea-abies","a":"Ivar Leidus","l":"CC BY-SA 3.0 ee","p":"https://commons.wikimedia.org/wiki/File:Kuusk_Keila-Paldiski_rdt_%C3%A4%C3%A4res.jpg"},{"s":"anemone-nemorosa","a":"Lilly M","l":"CC BY-SA 3.0","p":"https://commons.wikimedia.org/wiki/File:Anemone_nemorosa_001.JPG"},{"s":"bufo-bufo","a":"Tythatguy1312","l":"CC BY-SA 4.0","p":"https://commons.wikimedia.org/wiki/File:Common_Toad_Cornwall.jpeg"},{"s":"vulpes-vulpes","a":"ClaudiaTen","l":"CC BY-SA 4.0","p":"https://commons.wikimedia.org/wiki/File:Portrait_of_a_red_fox_in_Rautas_fj%C3%A4llurskog_(4%C3%973).jpg"},{"s":"ciconia-ciconia","a":"Charles J. Sharp","l":"CC BY-SA 4.0","p":"https://commons.wikimedia.org/wiki/File:White_stork_(Ciconia_ciconia)_Bia%C5%82owieza.jpg"},{"s":"salamandra-salamandra","a":"Didier Descouens","l":"CC BY-SA 4.0","p":"https://commons.wikimedia.org/wiki/File:Salamandra_salamandra_MHNT_1.jpg"},{"s":"aglais-io","a":"Charles J. Sharp","l":"CC BY-SA 3.0","p":"https://commons.wikimedia.org/wiki/File:Peacock_butterfly_(Aglais_io)_2.jpg"},{"s":"quercus-robur","a":"autor neuveden","l":"CC BY-SA 3.0","p":"https://commons.wikimedia.org/wiki/File:Quercus_robur.jpg"},{"s":"amanita-muscaria","a":"Kieran Roy Powell","l":"CC BY 4.0","p":"https://commons.wikimedia.org/wiki/File:Amanita_muscaria_Aberystwyth_2023.jpg"},{"s":"sciurus-vulgaris","a":"Peter Trimming","l":"CC BY 2.0","p":"https://commons.wikimedia.org/wiki/File:Squirrel_posing.jpg"}];
const ITEMS = {
"parus-major": { n: "sýkora koňadra", syn: [], lat: "Parus major" },
"erinaceus-europaeus": { n: "ježek západní", syn: ["ježek obecný"], lat: "Erinaceus europaeus" },
"picea-abies": { n: "smrk ztepilý", syn: ["smrk obecný"], lat: "Picea abies" },
"anemone-nemorosa": { n: "sasanka hajní", syn: ["větrnice hajní"], lat: "Anemone nemorosa" },
"bufo-bufo": { n: "ropucha obecná", syn: [], lat: "Bufo bufo" },
"vulpes-vulpes": { n: "liška obecná", syn: [], lat: "Vulpes vulpes" },
"ciconia-ciconia": { n: "čáp bílý", syn: [], lat: "Ciconia ciconia" },
"salamandra-salamandra": { n: "mlok skvrnitý", syn: [], lat: "Salamandra salamandra" },
"aglais-io": { n: "babočka paví oko", syn: [], lat: "Aglais io" },
"quercus-robur": { n: "dub letní", syn: ["dub křemelák"], lat: "Quercus robur" },
"amanita-muscaria": { n: "muchomůrka červená", syn: [], lat: "Amanita muscaria" },
"sciurus-vulgaris": { n: "veverka obecná", syn: [], lat: "Sciurus vulgaris" },
};
const SETS = [
{ id: "les", grade: "6. ročník · Les", name: "Lesní společenstvo", cover: "picea-abies",
items: ["picea-abies", "quercus-robur", "amanita-muscaria", "sciurus-vulgaris", "vulpes-vulpes",
"parus-major", "erinaceus-europaeus", "anemone-nemorosa"], mastery: 62,
record: { psani: 5120, abcd: 3010 }, errors: ["quercus-robur", "parus-major", "anemone-nemorosa"] },
{ id: "louka", grade: "6. ročník · Louka a pole", name: "Louka a okraj vsi", cover: "aglais-io",
items: ["ciconia-ciconia", "aglais-io", "anemone-nemorosa", "erinaceus-europaeus", "vulpes-vulpes", "parus-major"],
mastery: 100, record: { psani: 5480, abcd: 2900 }, errors: [] },
{ id: "voda", grade: "7. ročník · Obratlovci", name: "Obojživelníci a jejich sousedé", cover: "salamandra-salamandra",
items: ["salamandra-salamandra", "bufo-bufo", "ciconia-ciconia", "erinaceus-europaeus", "sciurus-vulgaris"],
mastery: 18, record: { psani: 0, abcd: 1240 }, errors: ["bufo-bufo"] },
{ id: "vse", grade: "7. ročník · Opakování", name: "Velké opakování: všech 12", cover: "vulpes-vulpes",
items: Object.keys(ITEMS), mastery: 0, record: { psani: 0, abcd: 0 }, errors: [] },
];
const SCORE = { grace: 2, max: 15, floor: 0.3, psani: 1000, psaniPart: 500, abcd: 500 };
const SHAPES = [
'<svg viewBox="0 0 10 10"><polygon points="5,0.5 9.5,9.5 0.5,9.5"/></svg>',
'<svg viewBox="0 0 10 10"><polygon points="5,0 10,5 5,10 0,5"/></svg>',
'<svg viewBox="0 0 10 10"><circle cx="5" cy="5" r="4.6"/></svg>',
'<svg viewBox="0 0 10 10"><rect x="0.8" y="0.8" width="8.4" height="8.4"/></svg>'];
const $ = (id) => document.getElementById(id);
const img = (s) => `./img/${s}.webp`;
const esc = (t) => String(t).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));
const fmt = (n) => n.toLocaleString("cs-CZ");
/* ---------- varianta ---------- */
const VARIANTS = ["karta", "celoplosna", "arena"];
function applyVariant() {
const h = location.hash.slice(1);
const v = VARIANTS.includes(h) ? h : "karta";
document.documentElement.dataset.v = v;
document.querySelectorAll("#proto-bar a").forEach((a) => a.setAttribute("aria-current", a.dataset.v === v));
}
window.addEventListener("hashchange", applyVariant);
applyVariant();
/* ---------- katalog ---------- */
function renderCatalog() {
let html = "", last = "";
SETS.forEach((s) => {
if (s.grade !== last) { if (last) html += "</div>"; html += `<h2 class="grade">${esc(s.grade)}</h2><div class="sets">`; last = s.grade; }
const rec = Math.max(s.record.psani, s.record.abcd);
html += `<div><button type="button" class="set-card" data-set="${s.id}">
<img src="${img(s.cover)}" alt="" loading="lazy">
<span class="set-info"><span class="set-name">${esc(s.name)}</span>
<span class="set-meta">${s.items.length} položek · rekord ${rec ? fmt(rec) + " b." : "–"}</span>
<span class="mastery"><span class="bar"><i style="width:${s.mastery}%"></i></span>${s.mastery} %</span></span>
</button></div>`;
});
$("catalog").innerHTML = html + "</div>";
$("credits").innerHTML = CREDITS.map((c) => `<li>${esc(ITEMS[c.s].n)} – ${esc(c.a)}, ${esc(c.l)},
<a href="${c.p}" target="_blank" rel="noopener">Commons</a></li>`).join("");
}
renderCatalog();
/* ---------- výběr režimu ---------- */
let pick = { set: null, mode: "abcd", len: "cele" };
function setPressed(group, attr, val) {
group.querySelectorAll("button").forEach((b) => b.setAttribute("aria-pressed", b.dataset[attr] === val));
}
function openSheet(setId) {
const s = SETS.find((x) => x.id === setId);
pick.set = s;
if (pick.len === "chyby" && !s.errors.length) pick.len = "cele";
$("sheet-title").textContent = s.name;
$("sheet-meta").textContent = `${s.items.length} položek · mistrovství ${s.mastery} %`;
$("len-all").textContent = `${s.items.length} otázek`;
$("len-err").textContent = s.errors.length ? `${s.errors.length} položky` : "žádné";
$("seg-len").querySelector('[data-len="chyby"]').disabled = !s.errors.length;
setPressed($("seg-mode"), "mode", pick.mode);
setPressed($("seg-len"), "len", pick.len);
$("sheet-scrim").hidden = false;
}
$("catalog").addEventListener("click", (e) => {
const b = e.target.closest("[data-set]"); if (b) openSheet(b.dataset.set);
});
$("sheet-scrim").addEventListener("click", (e) => { if (e.target === e.currentTarget) e.currentTarget.hidden = true; });
$("seg-mode").addEventListener("click", (e) => {
const b = e.target.closest("button"); if (!b) return; pick.mode = b.dataset.mode; setPressed($("seg-mode"), "mode", pick.mode);
});
$("seg-len").addEventListener("click", (e) => {
const b = e.target.closest("button"); if (!b || b.disabled) return; pick.len = b.dataset.len; setPressed($("seg-len"), "len", pick.len);
});
$("start-btn").addEventListener("click", () => {
$("sheet-scrim").hidden = true;
const s = pick.set;
let pool = pick.len === "chyby" ? [...s.errors] : shuffle([...s.items]);
if (pick.len === "rychle") pool = pool.slice(0, 5);
startRound(s, pick.mode, shuffle(pool));
});
function shuffle(a) { for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; }
/* ---------- vyhodnocení (zjednodušená kopie serveru) ---------- */
const norm = (t) => t.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9 ]+/g, " ").replace(/\s+/g, " ").trim();
function dl(a, b) {
const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
for (let j = 1; j <= b.length; j++) d[0][j] = j;
for (let i = 1; i <= a.length; i++) for (let j = 1; j <= b.length; j++) {
const c = a[i - 1] === b[j - 1] ? 0 : 1;
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + c);
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
}
return d[a.length][b.length];
}
const targets = (s) => [ITEMS[s].n, ...ITEMS[s].syn, ITEMS[s].lat].map(norm);
function evaluate(slug, input, setItems) {
const n = norm(input), own = targets(slug);
const others = setItems.filter((x) => x !== slug).flatMap(targets);
if (own.includes(n)) return "spravne";
if (own.some((t) => t.length >= 5 && dl(n, t) <= 1) && !others.some((t) => dl(n, t) <= 1)) return "spravne";
for (const t of own) {
const w = t.split(" "); if (w.length < 2) continue;
if (n === w[0] || (w[0].length >= 5 && dl(n, w[0]) <= 1)) return "castecne";
const sp = w.slice(1).join(" ");
if ((n === sp || (sp.length >= 5 && dl(n, sp) <= 1)) && !others.some((o) => o.endsWith(" " + sp))) return "castecne";
}
if (own.some((t) => t.length >= 10 && dl(n, t) === 2) && !others.some((t) => dl(n, t) <= 2)) return "castecne";
return "spatne";
}
function coef(sec) {
if (sec <= SCORE.grace) return 1;
if (sec >= SCORE.max) return SCORE.floor;
return 1 - (1 - SCORE.floor) * (sec - SCORE.grace) / (SCORE.max - SCORE.grace);
}
/* ---------- viewport a klávesnice ---------- */
const root = document.documentElement;
function fitViewport() {
const vv = window.visualViewport;
const h = vv ? vv.height : window.innerHeight;
root.style.setProperty("--vvh", h + "px");
root.style.setProperty("--vvt", (vv ? vv.offsetTop : 0) + "px");
root.classList.toggle("kb", window.innerHeight - h > 120 || (screen.height && screen.height - h > 300 && document.activeElement === $("winput")));
}
if (window.visualViewport) {
visualViewport.addEventListener("resize", fitViewport);
visualViewport.addEventListener("scroll", fitViewport);
}
window.addEventListener("resize", fitViewport);
window.addEventListener("scroll", () => { if (root.classList.contains("in-game")) window.scrollTo(0, 0); });
fitViewport();
/* ---------- hra ---------- */
let G = null, raf = 0;
function show(id) {
["scr-catalog", "scr-game", "scr-summary"].forEach((s) => { $(s).hidden = s !== id; });
$("proto-bar").hidden = id === "scr-game";
root.classList.toggle("in-game", id === "scr-game");
window.scrollTo(0, 0);
fitViewport();
}
function startRound(set, mode, queue) {
G = { set, mode, queue, i: 0, score: 0, combo: 0, best: 0, results: [], phase: "q" };
$("opts").hidden = mode !== "abcd";
$("wform").hidden = mode !== "psani";
show("scr-game");
nextQuestion();
}
function nextQuestion() {
const slug = G.queue[G.i];
G.phase = "loading";
$("fb").hidden = true;
$("scr-game").classList.remove("g-spravne", "g-castecne", "g-spatne");
$("hud-prog").textContent = `${G.i + 1} / ${G.queue.length}`;
$("hud-progbar").style.width = `${(G.i / G.queue.length) * 100}%`;
$("hud-score").textContent = fmt(G.score);
const ph = $("photo");
ph.onload = () => { G.t0 = performance.now(); G.phase = "q"; tick(); };
ph.src = img(slug);
$("photo-bg").style.backgroundImage = `url(${img(slug)})`;
if (G.queue[G.i + 1]) new Image().src = img(G.queue[G.i + 1]);
if (G.mode === "abcd") {
const pool = G.set.items.length >= 4 ? G.set.items : Object.keys(ITEMS);
const opts = shuffle([slug, ...shuffle(pool.filter((x) => x !== slug)).slice(0, 3)]);
$("opts").className = "opts";
$("opts").innerHTML = opts.map((o, k) => `<button type="button" class="opt" data-slug="${o}">
<span class="key">${root.dataset.v === "arena" ? SHAPES[k] : "ABCD"[k]}</span>${esc(ITEMS[o].n)}</button>`).join("");
} else {
const inp = $("winput"); inp.value = ""; inp.focus({ preventScroll: true });
}
}
function tick() {
cancelAnimationFrame(raf);
if (G.phase !== "q") return;
const sec = (performance.now() - G.t0) / 1000;
const c = coef(sec), base = G.mode === "abcd" ? SCORE.abcd : SCORE.psani;
const frac = (c - SCORE.floor) / (1 - SCORE.floor);
$("timer-fill").style.transform = `scaleX(${frac})`;
$("timer-pts").textContent = `${Math.round(base * c)} b.`;
$("ring-fg").setAttribute("stroke-dashoffset", (157.08 * (1 - frac)).toFixed(1));
raf = requestAnimationFrame(tick);
}
function answer(given, verdict) {
if (G.phase !== "q") return;
G.phase = "fb"; cancelAnimationFrame(raf);
const slug = G.queue[G.i], sec = (performance.now() - G.t0) / 1000;
const base = verdict === "spravne" ? (G.mode === "abcd" ? SCORE.abcd : SCORE.psani)
: verdict === "castecne" ? SCORE.psaniPart : 0;
const pts = Math.round(base * coef(sec));
G.score += pts;
G.combo = verdict === "spravne" ? G.combo + 1 : 0;
G.best = Math.max(G.best, G.combo);
G.results.push({ slug, given, verdict, pts });
const it = ITEMS[slug];
$("fb").className = `fb v-${verdict}`;
$("fb-verdict").textContent = { spravne: "Správně!", castecne: "Skoro!", spatne: "Vedle" }[verdict];
$("fb-pts").textContent = `+${pts} b.`;
$("fb-name").innerHTML = `${esc(it.n)} <i>${esc(it.lat)}</i>`;
let meta = verdict === "castecne" ? "Rod sedí, celý název ne. " : "";
if (verdict !== "spravne" && given) meta += `Tvoje odpověď: ${given}. `;
if (it.syn.length) meta += `Také: ${it.syn.join(", ")}.`;
$("fb-meta").textContent = meta;
$("fb").hidden = false;
$("scr-game").classList.add(`g-${verdict}`);
$("hud-score").textContent = fmt(G.score);
const cb = $("hud-combo");
cb.hidden = G.combo < 2;
if (G.combo >= 2) { cb.textContent = `×${G.combo}`; cb.classList.remove("pop"); void cb.offsetWidth; cb.classList.add("pop"); }
if (G.mode === "abcd") {
$("next-btn").focus({ preventScroll: true });
}
}
$("opts").addEventListener("click", (e) => {
const b = e.target.closest(".opt"); if (!b || G.phase !== "q") return;
const slug = G.queue[G.i], ok = b.dataset.slug === slug;
$("opts").classList.add("answered");
b.classList.add(ok ? "is-ok" : "is-bad");
$("opts").querySelector(`[data-slug="${slug}"]`).classList.add("is-ok");
answer(ITEMS[b.dataset.slug].n, ok ? "spravne" : "spatne");
});
$("wform").addEventListener("submit", (e) => {
e.preventDefault();
if (G.phase === "fb") { advance(); return; }
const v = $("winput").value;
if (!norm(v)) return;
answer(v.trim(), evaluate(G.queue[G.i], v, G.set.items));
});
function advance() {
if (G.phase !== "fb") return;
G.i++;
if (G.i >= G.queue.length) { showSummary(); return; }
nextQuestion();
}
$("next-btn").addEventListener("click", advance);
$("fb").addEventListener("click", (e) => { if (root.dataset.v === "arena" && e.target !== $("next-btn")) advance(); });
$("quit").addEventListener("click", () => { cancelAnimationFrame(raf); G.phase = "end"; show("scr-catalog"); });
/* ---------- shrnutí ---------- */
function showSummary() {
G.phase = "end";
const s = G.set, n = G.results.length;
const max = n * (G.mode === "abcd" ? SCORE.abcd : SCORE.psani);
const acc = G.results.reduce((a, r) => a + (r.verdict === "spravne" ? 1 : r.verdict === "castecne" ? 0.5 : 0), 0) / n;
const prevRec = s.record[G.mode], isRec = G.score > prevRec;
if (isRec) s.record[G.mode] = G.score;
const before = s.mastery;
const okSet = new Set(G.results.filter((r) => r.verdict === "spravne").map((r) => r.slug));
s.errors = [...new Set([...s.errors.filter((x) => !okSet.has(x)), ...G.results.filter((r) => r.verdict !== "spravne").map((r) => r.slug)])];
s.mastery = Math.min(100, Math.max(before, Math.round(before + (okSet.size / s.items.length) * 30)));
const mist = G.results.filter((r) => r.verdict !== "spravne");
$("scr-summary").innerHTML = `
<div class="sum-hero">
<span class="lbl note">${esc(s.name)} · ${G.mode === "abcd" ? "Výběr A–D" : "Psaní"}</span>
<span class="big">${fmt(G.score)} b.</span>
<span class="of">z ${fmt(max)} možných</span>
${isRec ? '<span class="badge">Nový osobní rekord</span>' : `<span class="note">Osobní rekord: ${fmt(prevRec)} b.</span>`}
</div>
<div class="stats">
<div class="stat"><b>${Math.round(acc * 100)} %</b><span>přesnost</span></div>
<div class="stat"><b>×${G.best}</b><span>nejdelší série</span></div>
<div class="stat"><b>${before} → ${s.mastery} %</b><span>mistrovství</span></div>
</div>
<div class="mastery"><span class="bar"><i style="width:${s.mastery}%"></i></span>${s.mastery} %</div>
${mist.length ? `<h2>Chyby a skoro správně</h2>` + mist.map((r) => `<div class="mist">
<img src="${img(r.slug)}" alt="">
<div><b>${esc(ITEMS[r.slug].n)}</b><div class="you">${r.given ? "tvoje: " + esc(r.given) : ""}</div></div>
<span class="v v-${r.verdict}">${r.verdict === "castecne" ? "skoro" : "chyba"}</span></div>`).join("")
: `<h2>Bez chyby</h2><p class="note">Všechny položky správně.</p>`}
<div class="actions">
${mist.length ? '<button type="button" class="primary" id="sum-err">Procvičit jen chyby</button>' : ""}
<button type="button" class="${mist.length ? "secondary" : "primary"}" id="sum-again">Hrát znovu</button>
<button type="button" class="secondary" id="sum-cat">Zpět do katalogu</button>
</div>
<p class="note">Mistrovství a rekordy jsou v prototypu jen ilustrativní.</p>`;
show("scr-summary");
$("proto-bar").hidden = false;
renderCatalog();
const errs = mist.map((r) => r.slug);
if (mist.length) $("sum-err").onclick = () => startRound(s, G.mode, shuffle([...errs]));
$("sum-again").onclick = () => startRound(s, G.mode, shuffle([...(G.queue.length < s.items.length ? G.queue : s.items)]));
$("sum-cat").onclick = () => show("scr-catalog");
}
</script>
</body>
</html>