/* =====================================================================
   spojuj.cz – vizuální systém „Sešit“
   Tečky a čtverečky na zadní straně čtverečkovaného sešitu: papír, tužka,
   červená a modrá propiska, zvýrazňovač. Jediné téma (papír je papír).
   Převzato z pisqorky.cz a potapej.cz, sekce 5 (herní obrazovka) je nová:
   tečky tužkou, čárky hráče modrou propiskou, soupeře červenou,
   uzavřený čtvereček šrafovaný s iniciálou, poslední série zvýrazňovačem.

   Struktura souboru:
   1. tokeny   2. základ   3. komponenty (znovupoužitelné i pro statistiky)
   4. úvodní obrazovka   5. herní obrazovka (tečky, čárky, čtverečky)   6. Čtveráček
   7. responzivita   8. multiplayer
   ===================================================================== */

/* ---------- 0. Písma (uložená u nás, viz fonts/README.md) ---------- */
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/caveat-latin-ext.woff2?v=1") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/caveat-latin.woff2?v=1") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/nunito-sans-latin-ext.woff2?v=1") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/nunito-sans-latin.woff2?v=1") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- 1. Tokeny ---------- */
:root {
  --paper: #f9f6ee;
  --paper-2: #fffdf6;          /* štítek, bubliny */
  --grid: #c7d5e6;             /* čtverečky */
  --graphite: #3b3b3b;         /* tužka */
  --graphite-soft: #6d6d6d;
  --graphite-faint: #a9a49a;
  --red: #c8342b;              /* červená propiska – čárky soupeře, poznámky na okraji */
  --blue: #1f4db0;             /* modrá propiska – čárky a jméno hráče */
  --blue-soft: rgba(31, 77, 176, .18);
  --red-soft: rgba(200, 52, 43, .16);
  --marker: #ffe86a;           /* zvýrazňovač – poslední série čárek */
  --shadow: 2px 3px 0 rgba(59, 59, 59, .15);

  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --text: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* velikost čtverečku sešitu; stránka je stejnou mřížkou podložená. Jeden čtvereček hry = 2 × 2 čtverečky
     sešitu (tečky na každé druhé křižovatce), takže deska má stejné měřítko jako papír okolo. */
  --cell: clamp(24px, min(3.6vw, 5.6vh), 46px);

  /* typografická škála (rukopis je opticky menší než sans, proto větší hodnoty) */
  --fs-body: 1.125rem;         /* 18px */
  --fs-hand: 1.7rem;
  --fs-hand-lg: 2.4rem;
  --fs-hand-xl: clamp(3.2rem, 9vw, 5rem);
}

/* ---------- 2. Základ ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: var(--fs-body)/1.45 var(--text);
  color: var(--graphite);
  background: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: calc(var(--cell) / 2) calc(var(--cell) / 2);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
.screen { min-height: 100vh; min-height: 100dvh; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- 3. Komponenty ---------- */
/* Rukopisné písmo */
.hand, .hand-title, .name, .say, .note, .margin-note, .link-wavy, .tally, .opt > span, .row .k, .line-input, .btn-graphite, .btn-pencil, .score-line {
  font-family: var(--hand);
}
.hand-title { margin: 0; font-weight: 700; font-size: var(--fs-hand-xl); line-height: 1; letter-spacing: -.01em; }
.hand-title small { display: block; font-weight: 500; font-size: var(--fs-hand); line-height: 1.2; color: var(--graphite-soft); margin-top: 6px; }

/* Štítek na sešitu (červený dvojitý rámeček, mírně nakřivo) */
.label {
  background: var(--paper-2);
  border: 3px solid var(--red);
  outline: 1.5px solid var(--red); outline-offset: 3px;
  padding: 30px 34px 28px;
  box-shadow: var(--shadow);
  display: grid; gap: 20px;
  transform: rotate(-1.2deg);
}

/* Tužkový rámeček (hrací pole, později karty statistik) */
.pencil-box { position: relative; background: var(--paper); }
.pencil-box::after {
  content: ""; position: absolute; inset: -3px; pointer-events: none;
  border: 2.5px solid var(--graphite);
  border-radius: 2px 4px 3px 5px;
  transform: rotate(-.5deg);
}

/* Řádek formuláře „Popisek: ______“ */
.row { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: baseline; font-size: var(--fs-hand); font-weight: 500; }
.row .k { color: var(--graphite-soft); }
.line-input {
  width: 100%; background: transparent; border: 0; border-bottom: 2px dotted var(--graphite-soft);
  padding: 0 6px 2px; font-weight: 700; font-size: 2rem; line-height: 1.15; color: var(--blue); border-radius: 0;
}
.line-input::placeholder { color: var(--graphite-faint); font-weight: 500; }
.line-input:focus-visible { outline: none; border-bottom-color: var(--blue); border-bottom-style: solid; }

.line-static { border-bottom: 2px dotted var(--graphite-soft); padding: 0 6px 2px; font-size: 2rem; line-height: 1.15; font-weight: 700; display: flex; gap: 14px; align-items: baseline; }
.nick-blue { color: var(--blue); }
.auth-rows { display: grid; gap: 20px; }
.label[data-mode="login"] .register-only { display: none; }
.check { display: flex; gap: 10px; align-items: baseline; font-family: var(--text); font-size: .95rem; color: var(--graphite-soft); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--graphite); flex: none; }
.actions { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.link-wavy.small { font-size: 1.2rem; }

/* Volba zakroužkovaná tužkou */
.opts { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.opt { position: relative; padding: 4px 12px; cursor: pointer; display: grid; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt > span { font-size: var(--fs-hand); font-weight: 500; line-height: 1.1; }
.opt small { font-family: var(--text); font-size: .85rem; color: var(--graphite-soft); }
.opt::before {
  content: ""; position: absolute; inset: -6px -12px -8px -10px; pointer-events: none;
  border: 2.5px solid transparent; border-radius: 48% 52% 50% 46% / 58% 42% 56% 44%; transform: rotate(-2deg);
  transition: border-color .15s;
}
.opt:has(input:checked)::before, .opt.checked::before { border-color: var(--graphite); }
.opt:has(input:focus-visible)::before { border-color: var(--blue); }
.opt:hover::before { border-color: var(--graphite-faint); }

/* Tlačítko „vygumovaný“ grafitový blok */
.btn-graphite {
  justify-self: start; font-weight: 700; font-size: 1.9rem; line-height: 1;
  color: var(--paper-2); background: var(--graphite);
  padding: 14px 30px 16px; border-radius: 14px 12px 16px 10px / 10px 16px 12px 14px;
  box-shadow: 2px 2px 0 var(--graphite-soft); transform: rotate(.6deg);
}
.btn-graphite:hover { background: #222; }
.btn-graphite:disabled { opacity: .5; cursor: default; }
.btn-graphite.small { font-size: 1.5rem; padding: 10px 22px 12px; }
/* Druhé tlačítko vedle grafitového: jen obtažené tužkou (vyzkoušet bez registrace) */
.btn-pencil {
  font-weight: 700; font-size: 1.5rem; line-height: 1; color: var(--graphite);
  padding: 11px 22px 13px; border: 2.5px solid var(--graphite);
  border-radius: 12px 16px 10px 14px / 14px 10px 16px 12px; transform: rotate(-.8deg);
}
.btn-pencil:hover { color: var(--blue); border-color: var(--blue); }
.btn-pencil:disabled { opacity: .5; cursor: default; }
.guest-note { font-family: var(--text); font-size: .95rem; color: var(--graphite-soft); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }

/* Odkaz s vlnovkou (propiska) */
.link-wavy {
  font-size: 1.55rem; font-weight: 500; color: var(--graphite);
  text-decoration: underline wavy var(--graphite-soft); text-underline-offset: 4px;
}
.link-wavy:hover { color: var(--blue); text-decoration-color: var(--blue); }
.link-wavy.faint { color: var(--graphite-faint); }
.faint-text { color: var(--graphite-faint); font-size: .85em; }

/* Poznámky: na okraji sešitu (červeně) a volné (tužkou) */
.note { font-size: 1.4rem; font-weight: 500; line-height: 1.15; color: var(--graphite-soft); }
.margin-notes { display: grid; gap: 8px; align-content: start; }
.margin-note { font-size: 1.5rem; font-weight: 500; line-height: 1.1; transform: rotate(-6deg); display: inline-block; }
.margin-note.red { color: var(--red); }

/* Jméno + symbol */
.who { display: flex; gap: 12px; align-items: baseline; }
.name { font-size: var(--fs-hand-lg); font-weight: 700; line-height: 1; }
.name.me { color: var(--blue); }
.name.them { color: var(--red); }

/* Skóre čárkami (po pěti se škrtá) */
.tally { display: flex; gap: 22px; flex-wrap: wrap; justify-content: flex-end; font-size: 1.55rem; font-weight: 500; }
.tally .t { display: inline-flex; align-items: center; gap: 10px; }
.tally .t b { font-weight: 700; }
.tally .marks { display: inline-flex; gap: 10px; }
.tally .g { display: inline-flex; gap: 4px; position: relative; height: 26px; }
.tally .g i { display: block; width: 3px; height: 26px; background: var(--graphite); border-radius: 2px; transform: rotate(-3deg); }
.tally .g.full::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 3px; background: var(--graphite); border-radius: 2px; transform: rotate(-32deg); }
.tally .zero { color: var(--graphite-faint); }
.tally .num { font-weight: 700; }

.error { color: var(--red); margin: 0; font-family: var(--text); }

/* ---------- 4. Úvodní obrazovka ---------- */
.screen-start { display: grid; place-items: center; padding: 24px 16px 40px; }
.label-wrap { position: relative; width: min(600px, 100%); margin-bottom: 250px; }
.mascot-start { position: absolute; right: -44px; bottom: -160px; width: 220px; transform: rotate(3deg); pointer-events: none; }
.note-start { position: absolute; left: 4px; top: calc(100% + 26px); max-width: 400px; margin: 0; transform: rotate(-2deg); font-size: 1.55rem; line-height: 1.2; }

/* patička úvodu: provozovatel a povinné odkazy, na mobilu pod sebou */
.screen-start { grid-template-rows: 1fr auto auto; align-content: space-between; }
.site-foot { justify-self: center; align-self: end; display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: center; align-items: baseline;
  font-family: var(--hand); font-size: 1.25rem; color: var(--graphite-soft); padding-top: 24px; }
.site-foot a { color: var(--graphite-soft); text-decoration: underline wavy var(--graphite-faint); text-underline-offset: 4px; }
.site-foot a:hover, .site-foot a:focus-visible { color: var(--blue); }

.hand-title .h1-tail { display: block; font-weight: 500; font-size: var(--fs-hand-lg); color: var(--red); margin-top: 2px; }
.subtitle { margin: -8px 0 0; font-family: var(--hand); font-weight: 500; font-size: var(--fs-hand); line-height: 1.2; color: var(--graphite-soft); }

/* indexovatelný text „o hře“ pod štítkem – běžný text, rukopisné nadpisy */
.about { justify-self: center; width: min(600px, 100%); display: grid; gap: 10px; margin-top: 40px; padding-top: 24px; border-top: 2px dotted var(--graphite-faint); }
.about-title { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 2.1rem; line-height: 1.05; }
.about h3 { margin: 8px 0 0; font-family: var(--hand); font-weight: 700; font-size: 1.6rem; line-height: 1.1; color: var(--red); }
.about p { margin: 0; font-size: 1.02rem; line-height: 1.55; max-width: 66ch; }
.about a { color: var(--blue); }

/* Široký monitor: úvod jako otevřený sešit – vlevo štítek s Čtveráčkem, vpravo „zápisky o hře“
   s červenou linkou okraje. Text je součást papíru; na mobilu zůstává pod štítkem. */
@media (min-width: 1100px) {
  .screen-start { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 0; padding: 40px 32px 40px; }
  .label-wrap { grid-column: 1; margin-bottom: 240px; justify-self: center; align-self: center; }
  .note-start { left: 40px; }
  .about {
    grid-column: 2; align-self: center; margin: 0 0 0 40px; padding: 28px 28px 28px 56px; border: 0;
    width: min(520px, 100%); position: relative; box-shadow: inset 1px 0 0 var(--grid);
  }
  .about::before { content: ""; position: absolute; left: 36px; top: 0; bottom: 0; border-left: 2px solid rgba(200, 52, 43, .55); }  /* okraj sešitu */
  .about::after { content: attr(data-margin-note); position: absolute; left: 52px; top: -6px; font-family: var(--hand); color: var(--red); font-size: 1.2rem; transform: rotate(-4deg); }
  .about-title { font-size: 2.3rem; }
  .about p { font-family: var(--hand); font-size: 1.45rem; line-height: 1.25; color: var(--graphite); }
  .site-foot { grid-column: 1 / -1; padding-top: 10px; }
}

/* ---------- 5. Herní obrazovka ---------- */
/* Jedno pole uprostřed jako v piškvorkách: Čtveráček vpravo nahoře, hráč vlevo dole, skóre a odkazy vpravo dole. */
.screen-game {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "notes  board bot"
    ".      board ."
    "player board corner";
  gap: 14px; padding: 22px 24px;
}
.margin-notes { grid-area: notes; justify-self: start; }
.board-wrap { grid-area: board; display: grid; justify-items: center; align-content: center; gap: 6px; }
.bot { grid-area: bot; justify-self: end; align-self: start; }
.player { grid-area: player; justify-self: start; align-self: end; display: grid; gap: 4px; }
.corner { grid-area: corner; justify-self: end; align-self: end; display: grid; gap: 10px; justify-items: end; }
.links { display: flex; gap: 12px 22px; flex-wrap: wrap; justify-content: flex-end; }
.links .link-wavy { white-space: nowrap; }
.status { color: var(--graphite-soft); font-size: 1.05rem; min-height: 1.5em; max-width: 340px; }
.margin-note.small { font-size: 1.15rem; transform: rotate(-3deg); }

/* skóre partie nad polem: „ty 3 : 2 Čtveráček“ */
.score-line { margin: 0; display: flex; gap: 12px; align-items: baseline; font-weight: 500; font-size: 1.7rem; line-height: 1; color: var(--graphite-soft); transform: rotate(-1deg); }
.score-line b { font-weight: 700; font-size: 2.1rem; }
.score-line .me b { color: var(--blue); }
.score-line .them b { color: var(--red); }
.score-line .sc-sep { color: var(--graphite-faint); }

/* Deska = SVG: 1 čtvereček hry = 40 jednotek = 2 čtverečky sešitu, okraj půl čtverečku hry.
   Šířku drží proměnné --w/--h (počet čtverečků) nastavené v app.js; na malém displeji se zmenší. */
.board {
  --w: 5; --h: 5;
  width: min(calc(var(--cell) * (2 * var(--w) + 2)), 94vw, calc((100vh - 130px) * (var(--w) + 1) / (var(--h) + 1)));
  height: auto; display: block; overflow: visible; touch-action: manipulation; user-select: none;
}
.board .paper { fill: var(--paper); }
.board .gridline { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.board .frame { fill: none; stroke: var(--graphite); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.board .dot { fill: var(--graphite); }
/* čárky: tah propiskou (animace dasharray přes pathLength = 1) */
.board .ln { fill: none; stroke-width: 2.4; stroke-linecap: round; }
.board .ln.me { stroke: var(--blue); }
.board .ln.them { stroke: var(--red); }
.board .ln.fresh { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw-line .32s ease-out forwards; }
@keyframes draw-line { to { stroke-dashoffset: 0; } }
/* zvýrazňovač pod poslední sérií čárek */
.board .hl { fill: none; stroke: var(--marker); stroke-width: 9; stroke-linecap: round; mix-blend-mode: multiply; opacity: .9; animation: scribble .3s ease-out; }
/* uzavřený čtvereček: šrafování v barvě majitele + iniciála rukou */
.board .box .hatch { opacity: 0; animation: scribble .35s ease-out .1s forwards; }
.board .box.me .hatch { fill: url(#hatch-me); }
.board .box.them .hatch { fill: url(#hatch-them); }
.board .box text { font-family: var(--hand); font-weight: 700; font-size: 24px; text-anchor: middle; dominant-baseline: central; animation: pop .35s ease-out; }
.board .box.me text { fill: var(--blue); }
.board .box.them text { fill: var(--red); }
@keyframes pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
.board .box text { transform-box: fill-box; transform-origin: center; }
/* zóny pro kliknutí: kosočtverec okolo každé volné čárky (celá plocha se jimi vydláždí → tap na nejbližší hranu) */
.board .hit { cursor: pointer; }
.board .hit polygon { fill: transparent; }
.board .hit .pv { fill: none; stroke: var(--blue); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 2 6; opacity: 0; transition: opacity .12s; pointer-events: none; }
.board:not(.locked) .hit:hover .pv, .board:not(.locked) .hit:focus-visible .pv { opacity: .75; }
.board .hit:focus-visible { outline: none; }
.board.locked .hit { cursor: default; }
@media (hover: none) { .board:not(.locked) .hit:hover .pv { opacity: 0; } }

@keyframes scribble { from { opacity: 0; } to { opacity: 1; } }
@keyframes swipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* ---------- 6. Čtveráček ---------- */
/* Kresba a nálady jsou v ctveracek.css (SVG se vkládá do .figure-slot). Tady jen umístění a poznámka. */
.bot { position: relative; width: min(200px, 24vw); display: grid; justify-items: center; gap: 2px; }
.bot-img { width: 100%; }
.figure-slot svg { width: 100%; height: auto; display: block; overflow: visible; }
.say {
  position: absolute; right: 90%; top: 6px; width: 190px; text-align: right;
  font-size: 1.45rem; font-weight: 500; line-height: 1.1; color: var(--graphite);
  transform: rotate(-4deg); transition: opacity .3s;
}
.say::after { content: ""; position: absolute; right: -32px; top: 60%; width: 28px; border-top: 2px solid var(--graphite-soft); transform: rotate(-25deg); }
.say:empty { opacity: 0; }

/* ---------- 7. Responzivita ---------- */
@media (max-width: 820px) {
  :root { --cell: min(8vw, 5vh); --fs-body: 1rem; --fs-hand: 1.45rem; --fs-hand-lg: 2rem; }
  .screen-game {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "notes bot" "board board" "player player" "corner corner";
    padding: 12px; gap: 10px;
  }
  .board { width: min(calc(var(--cell) * (2 * var(--w) + 2)), calc(100vw - 24px)); }
  .player, .corner { justify-self: center; text-align: center; }
  .player .who { justify-content: center; }
  .status { max-width: none; }
  .bot { width: min(150px, 40vw); }
  .say { width: 130px; font-size: 1.15rem; right: 80%; }
  .mascot-start { width: 130px; right: -10px; bottom: -110px; }
  .site-foot { padding-top: 20px; font-size: 1.15rem; }
  .label-wrap { margin-bottom: 130px; }
  .about { margin-top: 10px; }
  .note-start { display: none; }
  .label { padding: 22px 20px; }
  .link-wavy { font-size: 1.3rem; }
  .tally { font-size: 1.3rem; gap: 14px; justify-content: center; }
  .links { justify-content: center; }
  .score-line { font-size: 1.4rem; }
  .score-line b { font-size: 1.8rem; }
}

/* ---------- 8. Multiplayer ---------- */
.margin-note.link { cursor: pointer; text-decoration: underline wavy var(--graphite-soft); text-underline-offset: 4px; color: var(--graphite); }
.margin-note.link:hover { color: var(--blue); }
.margin-note .count { color: var(--blue); }
.margin-note.faint { color: var(--graphite-faint); font-size: 1.15rem; transform: none; }

/* Lístek – kus papíru přilepený přes stránku */
.slip {
  position: absolute; z-index: 5; background: var(--paper-2); padding: 20px 24px; box-shadow: var(--shadow);
  border: 1.5px solid var(--graphite-soft); border-radius: 3px 6px 4px 5px; width: min(380px, calc(100vw - 32px));
  display: grid; gap: 12px; transform: rotate(-.8deg);
}
.slip::before { /* izolepa */
  content: ""; position: absolute; top: -12px; left: 50%; width: 70px; height: 22px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 232, 106, .45); border: 1px solid rgba(59, 59, 59, .08);
}
.slip-title { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 1.9rem; line-height: 1.05; }
.slip-text { margin: 0; font-size: .95rem; color: var(--graphite-soft); }
.slip-text.hand-note { font-family: var(--hand); font-size: 1.35rem; color: var(--graphite); }
.slip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-family: var(--hand); font-size: 1.55rem; }
.slip-list li { display: flex; gap: 14px; align-items: baseline; }
.slip-list .nick { font-weight: 700; color: var(--blue); }
.slip-list .muted { color: var(--graphite-faint); font-size: 1.2rem; }
.slip-blocked { font-size: .9rem; color: var(--graphite-soft); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.slip-actions { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.mp-panel { left: 24px; top: 90px; }
.invite-note { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) rotate(1deg); }

/* soupeř vpravo nahoře, Čtveráček pod ním jako menší divák */
.opp { grid-area: bot; justify-self: end; align-self: start; display: grid; gap: 4px; justify-items: end; text-align: right; }
.screen-game.human .bot { margin-top: 90px; }
.screen-game.human .bot { width: min(130px, 16vw); }
.screen-game.human .bot .who { display: none; }
.screen-game.human .bot .say { width: 130px; font-size: 1.15rem; }
.opp .status.turn { color: var(--red); font-weight: 600; }

/* chat – lístek v pravém dolním rohu */
.chat { display: grid; gap: 8px; width: min(340px, 100%); justify-items: stretch; margin-bottom: 8px; }
.chat-title { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 1.5rem; }
.chat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 150px; overflow-y: auto; font-size: .95rem; }
.chat-list li { padding: 2px 0; border-bottom: 1px dotted var(--grid); }
.chat-list li b { font-family: var(--hand); font-size: 1.15rem; font-weight: 700; margin-right: 6px; color: var(--red); }
.chat-list li.mine b { color: var(--blue); }       /* já modře jako moje čárky, soupeř červeně */
.chat-quick { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.chat-quick button { font-family: var(--hand); font-size: 1.15rem; color: var(--graphite-soft); text-decoration: underline dotted; text-underline-offset: 3px; }
.chat-quick button:hover { color: var(--blue); }
.chat-form { display: flex; gap: 10px; align-items: baseline; }
.chat-input { font-size: 1.35rem; font-weight: 500; color: var(--graphite); }

@media (max-width: 820px) {
  .mp-panel { left: 12px; top: 70px; }
  .chat { width: 100%; }
  .screen-game.human .bot { width: 90px; margin-top: 64px; }
}

/* vlajka jazyka hráče (CZ / EN) – malý „razítkový“ obdélník, inline SVG z app.js */
.flag { display: inline-block; width: 26px; height: 18px; vertical-align: -2px; border: 1px solid var(--graphite-soft); border-radius: 2px; overflow: hidden; box-shadow: 1px 1px 0 rgba(59,59,59,.15); transform: rotate(-3deg); }
.flag svg { display: block; width: 100%; height: 100%; }
.flag:empty { display: none; }
.slip-list .flag { width: 22px; height: 15px; }

/* ---------- 9. Záložky sešitu (hlavička všech stránek) ---------- */
/* Rejstříkové záložky: každá = vlastní stránka s vlastní adresou. Na telefonu se stěhují dolů pod palec. */
:root { --head-h: 74px; }
.site-head { display: grid; grid-template-columns: auto 1fr; gap: 8px 28px; align-items: end; padding: 10px 24px 0; border-bottom: 2.5px solid var(--graphite); background: var(--paper); min-height: var(--head-h); }
.brand { text-decoration: none; color: var(--graphite); display: grid; padding-bottom: 7px; }
.brand b { font-family: var(--hand); font-weight: 700; font-size: 2.3rem; line-height: .95; }
.brand small { font-size: .76rem; color: var(--graphite-soft); }
.tabs { display: flex; gap: 6px; align-items: flex-end; margin-bottom: -2.5px; min-width: 0; }
.tab { position: relative; font-family: var(--hand); font-size: 1.45rem; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none; color: var(--graphite-soft);
  padding: 12px 15px 8px; background: var(--paper-2); border: 2px solid var(--graphite-faint); border-bottom: 2.5px solid var(--graphite); border-radius: 9px 11px 0 0; display: flex; gap: 8px; align-items: center; }
.tab::before { content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 3px; background: var(--c, var(--graphite-faint)); opacity: .8; }
.tab:nth-child(1) { --c: var(--red); } .tab:nth-child(2) { --c: var(--blue); } .tab:nth-child(3) { --c: var(--marker); } .tab:nth-child(4) { --c: var(--graphite-soft); }
.tab:hover, .tab:focus-visible { color: var(--blue); }
.tab.on { color: var(--graphite); font-weight: 700; font-size: 1.65rem; padding: 15px 19px 10px; border-color: var(--graphite); border-bottom-color: var(--paper); background: var(--paper); }
.tab-gap { flex: 1; }
.tab.ext { font-size: 1.25rem; padding: 8px 12px 6px; --c: transparent; }
.tab.ext img { width: 22px; height: 22px; border-radius: 5px; border: 1.5px solid var(--graphite-soft); display: block; }
.has-head .screen { min-height: calc(100vh - var(--head-h)); min-height: calc(100dvh - var(--head-h)); }
.has-head { --cell: clamp(24px, min(3.6vw, 5.1vh), 46px); }

@media (max-width: 820px) {
  :root { --head-h: 52px; }
  .has-head { --cell: min(8vw, 5vh); }
  .site-head { grid-template-columns: 1fr; padding: 8px 14px 4px; }
  .brand { grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 10px; padding-bottom: 2px; }
  .brand b { font-size: 1.9rem; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; padding: 0 6px; gap: 4px; align-items: flex-start; background: var(--paper); border-top: 2.5px solid var(--graphite); }
  .tab, .tab.on { flex: 1; justify-content: center; font-size: 1.2rem; padding: 8px 4px 12px; margin-top: -2.5px; border-radius: 0 0 10px 9px; border: 2px solid var(--graphite-faint); border-top: 2.5px solid var(--graphite); }
  .tab.on { border-color: var(--graphite); border-top-color: var(--paper); }
  .tab::before { top: auto; bottom: 4px; }
  .tab-gap { display: none; }
  .tab.ext { flex: 0 0 auto; padding-inline: 8px; }
  .tab.ext span { display: none; }
  body.has-head, body.page { padding-bottom: 58px; }
  /* při rozehrané partii na telefonu záložky uhnou, pole potřebuje celou výšku */
  .playing .site-head { display: none; }
  body.has-head.playing { padding-bottom: 0; }
  .playing.has-head .screen { min-height: 100vh; min-height: 100dvh; }
}

/* ---------- 10. Stránky s textem (pravidla, tipy, právní informace) ---------- */
/* Stránka s texty – stejný sešit, ale čitelný dlouhý text: karta na papíře, řádky max ~70 znaků */
.doc { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.doc-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.doc-head .back { font-family: var(--hand); font-size: 1.45rem; }
.doc-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 22px; padding: 0; list-style: none; font-family: var(--hand); font-size: 1.35rem; }
.doc-nav a { color: var(--graphite); text-decoration: underline wavy var(--graphite-soft); text-underline-offset: 4px; }
.doc-nav a:hover { color: var(--blue); }
.sheet { background: var(--paper-2); border: 1.5px solid var(--graphite-soft); border-radius: 3px 6px 4px 5px; box-shadow: var(--shadow); padding: clamp(18px, 4vw, 36px); display: grid; gap: 34px; }
.sheet section { display: grid; gap: 10px; scroll-margin-top: 16px; }
.sheet h1 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: clamp(2.4rem, 7vw, 3.4rem); line-height: 1; }
.sheet h2 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 2rem; line-height: 1.05; color: var(--red); }
.sheet h3 { margin: 8px 0 0; font-size: 1.05rem; font-weight: 700; }
.sheet p, .sheet li { margin: 0; font-size: 1.02rem; line-height: 1.55; max-width: 68ch; }
.sheet ul, .sheet ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.sheet a { color: var(--blue); }
.meta { color: var(--graphite-soft); font-size: .95rem; }
.id { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 1.02rem; max-width: 60ch; }
.id dt { color: var(--graphite-soft); }
.id dd { margin: 0; }
table.data { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.data th, table.data td { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px dotted var(--graphite-faint); }
table.data th { font-weight: 700; color: var(--graphite-soft); font-size: .85rem; }
.table-wrap { overflow-x: auto; }
.doc-foot { margin-top: 22px; color: var(--graphite-soft); font-size: .9rem; text-align: center; }
@media (max-width: 560px) { .id { grid-template-columns: 1fr; gap: 2px 0; } .id dt { margin-top: 8px; } }
.sheet .lead { font-size: 1.12rem; }
.sheet .hand-note { font-family: var(--hand); font-size: 1.5rem; line-height: 1.15; color: var(--red); transform: rotate(-1deg); max-width: 46ch; }
.sheet .cta { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.sheet .cta a { text-decoration: none; }
.sheet .cta .btn-graphite { color: var(--paper-2); display: inline-block; }
.sheet .cta .btn-pencil { color: var(--graphite); display: inline-block; }
.sheet .more { display: flex; flex-wrap: wrap; gap: 6px 22px; font-family: var(--hand); font-size: 1.4rem; }
.crumbs { font-size: .9rem; color: var(--graphite-soft); margin: 0 0 14px; }
.crumbs a { color: var(--graphite-soft); }

/* ---------- 11. Pozvánka odkazem a přidání na plochu ---------- */
.link-banner { display: grid; gap: 8px; padding: 12px 14px; background: linear-gradient(transparent 6%, var(--marker) 6% 94%, transparent 94%); border-radius: 4px; }
.link-banner b { font-family: var(--hand); font-size: 1.7rem; line-height: 1.1; }
.link-banner span { font-size: .92rem; color: var(--graphite); }
.link-banner .btn-graphite { justify-self: start; }
.link-slip { left: 50%; top: 38%; transform: translate(-50%, -50%) rotate(-.6deg); position: fixed; width: min(440px, calc(100vw - 32px)); }
.link-url { width: 100%; font: 600 1rem/1.3 var(--text); color: var(--blue); background: var(--paper); border: 2px dotted var(--graphite-soft); border-radius: 4px; padding: 8px 10px; }
.install-hint { font-family: var(--text); font-size: .9rem; color: var(--graphite-soft); flex-basis: 100%; text-align: center; }
.install-link { font: inherit; color: var(--graphite-soft); text-decoration: underline wavy var(--graphite-faint); text-underline-offset: 4px; }
.install-link:hover { color: var(--blue); }
.install-link { font: inherit; color: var(--graphite-soft); text-decoration: underline wavy var(--graphite-faint); text-underline-offset: 4px; }
.install-link:hover { color: var(--blue); }

/* ---------- 12. Žebříček, moje partie, vysvědčení (obsah plní pages.js) ---------- */
.tab:nth-child(5) { --c: var(--red); } .tab:nth-child(6) { --c: var(--blue); } .tab:nth-child(7) { --c: var(--marker); }
.sheet [data-view] { display: grid; gap: 18px; min-height: 120px; }
.sheet [data-view] h2 { margin-top: 6px; }
/* velká čísla psaná propiskou */
.nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 22px; }
.num { display: grid; }
.num b { font-family: var(--hand); font-weight: 700; font-size: 3.1rem; line-height: .95; color: var(--blue); white-space: nowrap; }
.num span { font-size: .9rem; color: var(--graphite-soft); }
/* řádek „popisek ...... hodnota“ jako v obsahu sešitu */
.toc { display: grid; gap: 6px; margin: 0; }
.toc-row { display: flex; align-items: baseline; gap: 8px; }
.toc-row dt { font-size: 1.02rem; }
.toc-row i { flex: 1; border-bottom: 2px dotted var(--graphite-faint); transform: translateY(-4px); min-width: 20px; }
.toc-row dd { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 1.6rem; line-height: 1; color: var(--blue); white-space: nowrap; }
.toc-row dd.grade { color: var(--red); font-size: 2.4rem; min-width: 1ch; text-align: center; transform: rotate(-5deg); }
/* šrafovaný pruh: podíl výher */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 7.5em 1fr auto; gap: 12px; align-items: center; }
.bar-k { font-family: var(--hand); font-size: 1.5rem; font-weight: 500; line-height: 1; }
.bar { position: relative; height: 22px; border: 2px solid var(--graphite); border-radius: 3px 5px 4px 6px; transform: rotate(-.4deg); background: var(--paper); }
.bar i { position: absolute; inset: 0 auto 0 0; width: var(--w); background: repeating-linear-gradient(-55deg, var(--blue) 0 1.5px, transparent 1.5px 6px); border-right: 2px solid var(--blue); }
.bar-v { font-size: .9rem; color: var(--graphite-soft); white-space: nowrap; }
.bar-v b { font-family: var(--hand); font-size: 1.5rem; color: var(--graphite); }
/* forma a výsledek partie: V / P / R v kroužku */
.form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fm { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; font-family: var(--hand); font-weight: 700; font-size: 1.35rem; line-height: 1;
  border: 2px solid var(--graphite-faint); color: var(--graphite-soft); border-radius: 48% 52% 50% 46% / 54% 46% 56% 44%; }
.fm.v { border-color: var(--blue); color: var(--blue); background: rgba(31, 77, 176, .18); }
.fm.p { border-color: var(--red); color: var(--red); }
/* žebříček */
.lb { width: 100%; border-collapse: collapse; }
.lb th { font: 600 .8rem/1.2 var(--text); color: var(--graphite-soft); text-align: left; padding: 0 10px 6px; border-bottom: 2px solid var(--graphite); }
.lb td { padding: 5px 10px; border-bottom: 1px dotted var(--graphite-faint); vertical-align: baseline; font-variant-numeric: tabular-nums; }
.lb .rk { width: 2.8em; font-family: var(--hand); font-size: 1.5rem; font-weight: 700; color: var(--graphite-soft); }
.lb .rk .top { color: var(--red); display: inline-block; padding: 0 5px; border: 2px solid var(--red); border-radius: 50% 46% 52% 48% / 48% 52% 46% 54%; transform: rotate(-6deg); }
.lb .nk { white-space: nowrap; }
.lb .nick { font-family: var(--hand); font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--blue); margin-right: 8px; }
.lb .nk small { font-size: .8rem; color: var(--graphite-soft); margin-left: 6px; }
.lb .pt { text-align: right; font-weight: 700; }
.lb .wl { text-align: right; color: var(--graphite-soft); font-size: .95rem; white-space: nowrap; }
.lb .gap td { text-align: center; color: var(--graphite-faint); border-bottom: 0; padding: 0; letter-spacing: .3em; }
.lb tr.me td { background: linear-gradient(transparent 12%, var(--marker) 12% 88%, transparent 88%); border-bottom-color: transparent; }
.lb tr.me .nick { color: var(--graphite); }
.lb .flag { width: 20px; height: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.filters .k { font-size: .85rem; color: var(--graphite-soft); }
.filters .opts { gap: 4px 14px; }
.filters .opt > span { font-size: 1.4rem; }
.filters .opt::before { inset: -3px -8px -5px -7px; }
/* moje partie */
.hist { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.sheet .hist li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px dotted var(--graphite-faint); max-width: none; }
.hist .h-when { font-size: .85rem; color: var(--graphite-soft); white-space: nowrap; }
.replay { display: grid; gap: 12px; justify-items: start; padding-top: 14px; border-top: 2px dotted var(--graphite-faint); --cell: min(30px, 5.4vw); }
.replay svg { display: block; width: min(100%, 420px); height: auto; }
.replay-pos { white-space: nowrap; }
.replay-ctl { display: flex; gap: 10px; align-items: center; font-family: var(--hand); font-size: 1.4rem; }
.replay-ctl button { font-size: 1.3rem; padding: 2px 10px; border: 2px solid var(--graphite); border-radius: 10px 12px 9px 11px; }
.replay-ctl button:hover { color: var(--blue); border-color: var(--blue); }
/* vysvědčení */
.report { border: 3px double var(--graphite); padding: 20px 24px; display: grid; gap: 14px; background: var(--paper); transform: rotate(-.4deg); }
.report-meta { display: flex; flex-wrap: wrap; gap: 4px 28px; font-size: .9rem; color: var(--graphite-soft); }
.report-meta b { font-family: var(--hand); font-size: 1.5rem; color: var(--blue); margin-left: 6px; }
.report .toc-row dt { font-family: var(--hand); font-size: 1.7rem; font-weight: 500; }
.sheet .report .remark { font-family: var(--hand); font-size: 1.45rem; line-height: 1.15; color: var(--red); transform: rotate(-1deg); }
.sheet .report-sign { display: flex; justify-content: space-between; align-items: end; gap: 16px; font-size: .8rem; color: var(--graphite-soft); max-width: none; }
.report-sign b { display: block; font-family: var(--hand); font-size: 1.7rem; color: var(--graphite); border-bottom: 2px dotted var(--graphite-soft); padding: 0 10px; transform: rotate(-3deg); }
@media (max-width: 820px) {
  /* víc záložek, než se vejde: lišta dole se posouvá do stran */
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab, .tab.on { flex: 0 0 auto; padding-inline: 12px; }
  .nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 6.2em 1fr auto; gap: 8px; }
  .lb td, .lb th { padding-inline: 5px; }
  .lb .wl { display: none; }
  .sheet .hist li { grid-template-columns: auto 1fr auto; }
  .hist .h-when { display: none; }
}

/* užší monitor a tablet: záložky se zmenší a sesterské hry zůstanou jen jako ikony, ať se lišta vejde na jeden řádek */
@media (min-width: 821px) and (max-width: 1180px) {
  .site-head { padding-inline: 14px; column-gap: 14px; }
  .brand b { font-size: 1.7rem; }
  .tabs { gap: 3px; }
  .tab { font-size: 1.2rem; padding: 10px 9px 7px; }
  .tab.on { font-size: 1.35rem; padding: 13px 12px 9px; }
  .tab.ext { padding: 7px 8px 5px; }
  .tab.ext span { display: none; }
}
