:root {
  --bg: #fdf3dc;
  --ink: #3b2a1e;
  --muted: #8a7461;
  --card: #fffaf0;
  --line: #e6d3b1;
  --wood: #7a5638;
  --ground: #a5d97f;
  --ground-alt: #97cf70;
  --frame: #7a5638;
  --frame-dark: #5e422b;
  --go: #43a047;
  --stop: #e53935;

  --up: #3b82f6;
  --right: #f59e0b;
  --down: #a855f7;
  --left: #ec4899;

  --key: clamp(56px, 12vmin, 96px);
  --slot: clamp(40px, 8.5vmin, 66px);
  --gap: clamp(8px, 2vmin, 16px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  transition: background-color 0.3s;
  color: var(--ink);
  font-family: ui-rounded, "Nunito", "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
  font-weight: 700;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
}
button:disabled { cursor: default; }
button:focus-visible { outline: 4px solid #1d4ed8; outline-offset: 3px; }

svg, img.art { display: block; width: 100%; height: 100%; }
img.art { object-fit: contain; -webkit-user-drag: none; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

/* ------------------------------------------------------------ tlačítka */

.round {
  --size: 56px;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  padding: calc(var(--size) * 0.24);
  background: var(--card);
  color: var(--wood);
  box-shadow: 0 4px 0 var(--line);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.15s;
}
.round:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.round:disabled { opacity: 0.4; }
.round, .key { position: relative; }
.ico { display: block; width: 100%; height: 100%; }

/* Nápověda klávesy v rohu tlačítka. Na dotykových zařízeních se schová,
   dokud někdo nezmáčkne skutečnou klávesu (třída has-keyboard z app.js). */
kbd.hint {
  position: absolute;
  right: -6px;
  bottom: -8px;
  min-width: 26px;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font: 700 14px/1.35 system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}
@media (pointer: coarse) {
  kbd.hint { display: none; }
  .has-keyboard kbd.hint { display: block; }
}
.round.small { --size: 52px; }
.round.big { --size: calc(var(--key) * 0.9); }
.round.huge { --size: calc(var(--key) * 1.25); }
.round.ghost { background: transparent; box-shadow: none; }
.round.ghost.active { background: var(--stop); color: #fff; }
.sound-toggle.off { color: var(--muted); opacity: 0.7; }
.age-button { padding: 0; font-size: 24px; }
.bar-group { display: flex; align-items: center; gap: 10px; flex: none; }
.bar .bar-group { flex: 0 1 auto; min-width: 0; }
.round.go { background: var(--go); color: #fff; box-shadow: 0 5px 0 #2e7031; }
.round.go.stop { background: var(--stop); box-shadow: 0 5px 0 #a52723; }

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 16px 0 8px;
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--line);
  font-size: 18px;
  max-width: 46vw;
  min-width: 0;
}
.chip .avatar { font-size: 30px; line-height: 1; }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  background: #efe2c6;
  font-size: 18px;
}
.btn.primary { background: var(--go); color: #fff; }
.btn.danger { background: var(--stop); color: #fff; }

/* -------------------------------------------------------- výběr hráče */

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Logo: SVG, výška podle obrazovky; text v h1 je jen pro čtečky a než se SVG vloží. */
.logo { margin: 0; min-width: 0; width: min(100%, clamp(260px, 52vw, 560px)); font-size: clamp(24px, 6vmin, 44px); line-height: 1.1; }
.logo svg { display: block; width: 100%; height: auto; }
.logo .logo-img { display: block; width: auto; max-width: 100%; height: clamp(56px, 13vmin, 120px); object-fit: contain; }
.hint-text { margin: clamp(12px, 3vmin, 28px) 0; text-align: center; font-size: clamp(20px, 4.5vmin, 30px); color: var(--muted); }

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(130px, 28vmin, 190px), 1fr));
  gap: var(--gap);
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.player {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px 12px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 6px 0 var(--line);
  transition: transform 0.08s, box-shadow 0.08s;
}
.player:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.player .avatar { font-size: clamp(56px, 14vmin, 92px); line-height: 1.1; }
.player .name { font-size: clamp(18px, 4vmin, 26px); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .score { font-size: 16px; color: var(--muted); }

.player.add { background: transparent; box-shadow: none; border: 4px dashed var(--line); color: var(--muted); }
.player.add .avatar { width: clamp(56px, 14vmin, 92px); aspect-ratio: 1; padding: clamp(12px, 3vmin, 20px); margin: 0.05em 0; }

.player.removable { animation: jiggle 0.5s ease-in-out infinite alternate; }
.player .remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 44px;
  height: 44px;
  padding: 11px;
  border-radius: 50%;
  background: var(--stop);
  color: #fff;
}
@keyframes jiggle { from { rotate: -1.2deg; } to { rotate: 1.2deg; } }

/* --------------------------------------------------------------- lišta */

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }

.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; flex: 1; min-width: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dot.done { background: #e53935; }
.dot.current { outline: 3px solid var(--wood); outline-offset: 2px; }

.unsaved { font-size: 24px; }

/* ------------------------------------------------------ přehled úrovní */

/* Přehled úrovní: vlevo sloupec témat, vpravo úrovně. Obě části se rolují
   samy, stránka jako celek ne. */
#map { height: 100dvh; }
.map-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: clamp(12px, 3vw, 32px);
  width: 100%;
  max-width: 1100px;
  margin: clamp(8px, 2.5vmin, 20px) auto 0;
}

.theme-strip {
  flex: none;
  width: clamp(170px, 30vw, 300px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  overflow: hidden auto;
  padding: 6px 6px 12px;
  margin: -6px 0 0 -6px;
  border-right: 3px dashed var(--line);
  padding-right: clamp(10px, 2vw, 20px);
}
.theme-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 7px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line);
  font-size: clamp(12px, 1.9vmin, 15px);
  transition: transform 0.08s, box-shadow 0.08s;
}
.theme-choice:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.theme-choice.chosen { background: #fde9b8; box-shadow: 0 0 0 5px var(--right); }
.theme-choice .swatch {
  display: flex;
  justify-content: center;
  gap: 4%;
  width: 100%;
  height: clamp(44px, 8vmin, 70px);
  padding: 5px;
  border-radius: 13px;
}
.theme-choice .swatch span { flex: 1 1 0; min-width: 0; height: 100%; }
.theme-choice .name { max-width: 100%; overflow: hidden; line-height: 1.15; text-align: center; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }

/* Úzká obrazovka: jeden sloupec malých dlaždic bez názvů. */
@media (max-width: 600px) {
  .theme-strip { width: 86px; grid-template-columns: 1fr; gap: 8px; padding-right: 10px; }
  .theme-choice { padding: 5px; border-radius: 14px; }
  .theme-choice .swatch { height: 46px; padding: 4px; }
  .theme-choice .name { display: none; }
}

.level-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(72px, 15vmin, 116px), 1fr));
  align-content: start;
  gap: var(--gap);
  /* Jen svislé rolování; odznak hotové úrovně přečnívá, proto místo vpravo a nahoře. */
  overflow: hidden auto;
  padding: 14px 16px 12px 4px;
}

.level {
  position: relative;
  aspect-ratio: 1;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 6px 0 var(--line);
  font-size: clamp(34px, 9vmin, 60px);
  display: grid;
  place-items: center;
}
.level:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.level.done { background: #e7f5d9; box-shadow: 0 6px 0 #c2dfa6; }
.level.current { outline: 5px solid var(--wood); outline-offset: -5px; }
.level:disabled { background: #efe6d2; box-shadow: none; color: #c9b79a; }
.level .lock { width: 42%; height: 42%; }
.level .badge { position: absolute; top: -8%; right: -8%; width: 42%; height: 42%; }

/* ----------------------------------------------------------------- hra */

#game { height: 100dvh; position: relative; overflow: hidden; }

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding-top: var(--gap);
}

/* Levý sloupec hry: zadání (od 8 let) nad hřištěm. */
.board-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.task {
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: inset 0 0 0 3px var(--line);
  font-size: clamp(14px, 2.2vmin, 18px);
  line-height: 1.35;
}
.task p { margin: 0; }
.task-icon { display: inline-block; width: 1.5em; height: 1.5em; vertical-align: -0.4em; }
.task .tip { color: var(--muted); }
.task-hint { margin-top: 4px !important; color: var(--stop); }

.board-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  padding: 8px 8px 18px; /* místo na dřevěný rámeček */
}

.board {
  --cols: 5;
  --rows: 3;
  --w: min(100cqw, calc(100cqh * var(--cols) / var(--rows)));
  position: relative;
  width: var(--w);
  aspect-ratio: var(--cols) / var(--rows);
  font-size: calc(var(--w) / var(--cols)); /* 1em = jedno políčko */
  border-radius: 0.14em;
  box-shadow: 0 0 0 6px var(--frame), 0 10px 0 6px var(--frame-dark);
}

.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  border-radius: inherit;
  overflow: hidden;
}
.cell { background: var(--ground); padding: 4%; transition: background-color 0.3s; }
.cell.alt { background: var(--ground-alt); }
/* Barevná políčka pro podmínky: tónovaná barva s výrazným rámečkem. */
/* Barevná podložka: sytá barva, bílý a barevný okraj, ať se neplete s podkladem tématu. */
.cell.paint { background: color-mix(in srgb, var(--paint) 72%, #fff); box-shadow: inset 0 0 0 0.05em #fff, inset 0 0 0 0.1em var(--paint); }
.paint-r, .cond-r { --paint: #e53935; }
.paint-g, .cond-g { --paint: #2e9e44; }
.paint-b, .cond-b { --paint: #1e78d6; }

.item, .enemy, .hero {
  position: absolute;
  width: 1em;
  height: 1em;
  left: calc(var(--x) * 1em);
  top: calc(var(--y) * 1em);
}

.item > * { transform: scale(0.62); transition: transform 0.25s, opacity 0.25s; animation: bob 1.6s ease-in-out infinite alternate; }
.item.eaten > * { transform: scale(0); opacity: 0; animation: none; }
@keyframes bob { from { translate: 0 -3%; } to { translate: 0 3%; } }

.enemy > * { transform: scale(0.8); transition: transform 0.2s; }
.enemy.chomp { z-index: 3; }
.enemy.chomp > * { animation: chomp 0.5s ease-out; }
@keyframes chomp { 40% { transform: scale(1.25) rotate(-8deg); } 70% { transform: scale(1.1) rotate(6deg); } }

.hero { transition: left 0.38s ease-in-out, top 0.38s ease-in-out; z-index: 2; }
.hero.jump, .hero.jump .hero-turn { transition: none; }
.hero.gone .hero-turn { transform: scale(0); }
.hero-turn {
  width: 100%;
  height: 100%;
  transform: rotate(var(--angle, 0deg)) scaleX(var(--flip, 1)) scale(0.88);
  transition: transform 0.22s;
  filter: drop-shadow(0 0.04em 0 rgb(0 0 0 / 0.2));
}
/* Šipka směru pohledu (v úrovních s otočkami). */
.heading {
  display: none;
  position: absolute;
  inset: 0;
  padding: 0.02em 0.02em 0.72em 0.36em;
  color: var(--ink);
  opacity: 0.85;
  transform: rotate(calc(var(--heading, 0deg) + 90deg));
  transform-origin: 50% 50%;
  transition: transform 0.22s;
  pointer-events: none;
}
.heading svg { width: 0.3em; height: 0.3em; margin: 0 auto; filter: drop-shadow(0 0 0.03em #fff); }
.hero.show-heading .heading { display: block; }
.hero.jump .heading { transition: none; }
.hero.gone .heading { opacity: 0; }
.hero.bump { animation: bump 0.42s ease-out; }
@keyframes bump {
  35% { translate: calc(var(--bx) * 26%) calc(var(--by) * 26%); }
  55% { translate: calc(var(--bx) * -6%) calc(var(--by) * -6%); }
}

.bubble {
  position: absolute;
  top: -0.42em;
  right: -0.3em;
  font-size: 0.5em;
  line-height: 1;
  scale: 0;
  transition: scale 0.2s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.bubble.on { scale: 1; }

/* ------------------------------------------------------------- program */

.panel { display: flex; flex-direction: column; gap: var(--gap); align-items: center; container-type: inline-size; }

.program {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: inset 0 0 0 3px var(--line);
  max-width: 100%;
}
.prog-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; border-radius: 14px; padding: 2px; }
.program.rows .prog-row { justify-content: flex-start; padding: 6px; }
.program.rows .prog-row.active { background: #fde9b8; box-shadow: inset 0 0 0 3px var(--right); }
.row-label {
  width: calc(var(--slot) * 0.8);
  height: var(--slot);
  border-radius: 12px;
  background: #efe2c6;
  color: var(--wood);
  padding: 10px 6px;
  flex: none;
}
.fn { display: grid; place-items: center; width: 100%; height: 100%; font-size: calc(var(--slot) * 0.36); font-weight: 900; letter-spacing: -0.02em; }
.prog-row.drop-end::after { content: ''; width: 6px; height: var(--slot); border-radius: 3px; background: var(--ink); }

.slot {
  width: var(--slot);
  height: var(--slot);
  border-radius: 14px;
  flex: none;
}
.slot.empty { border: 3px dashed var(--line); }
button.slot { padding: calc(var(--slot) * 0.16); color: #fff; background: var(--c); box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 70%, #000); transition: transform 0.12s; }
button.slot.active { transform: scale(1.18); outline: 5px solid var(--ink); outline-offset: 1px; z-index: 1; }
button.slot.bad { outline: 5px solid var(--stop); outline-offset: 1px; animation: wiggle 0.35s; }
button.slot.skipped { opacity: 0.45; transform: scale(0.92); outline: 4px dashed var(--ink); }
button.slot { position: relative; }
button.slot .ico { display: block; width: 100%; height: 100%; }
/* Počet opakování v rohu příkazu. */
.count {
  position: absolute;
  right: -7px;
  bottom: -7px;
  min-width: 26px;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  line-height: 1.3;
}
/* Podmínka: barevný rámeček a tečka. */
button.slot.cond { box-shadow: 0 0 0 4px var(--paint), 0 6px 0 2px color-mix(in srgb, var(--paint) 70%, #000); }
button.slot.cond::before {
  content: '';
  position: absolute;
  left: -6px;
  top: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paint);
  border: 2px solid #fff;
}
.drop-before { box-shadow: -7px 0 0 -1px var(--ink) !important; }

.cmd-U { --c: var(--up); }
.cmd-R { --c: var(--right); }
.cmd-D { --c: var(--down); }
.cmd-L { --c: var(--left); }
.cmd-F { --c: #2f80ed; }
.cmd-TL { --c: var(--left); }
.cmd-TR { --c: var(--right); }
.cmd-FN { --c: #10a37f; }
.cmd-R svg { rotate: 90deg; }
.cmd-D svg { rotate: 180deg; }
.cmd-L svg { rotate: 270deg; }

/* Šipky + tlačítka se musí vejít vedle sebe do šířky panelu (cqw). */
.controls {
  --key: min(clamp(56px, 12vmin, 96px), calc((94cqw - 16px) / 4.25));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5cqw;
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, var(--key));
  grid-template-rows: repeat(2, var(--key));
  gap: 8px;
}
.pad .cmd-U { grid-area: 1 / 2; }
.pad .cmd-L { grid-area: 2 / 1; }
.pad .cmd-D { grid-area: 2 / 2; }
.pad .cmd-R { grid-area: 2 / 3; }
/* Otočky: vpřed nahoře, otočky po stranách, F1 uprostřed dole. */
.pad.rel .cmd-F { grid-area: 1 / 2; }
.pad.rel .cmd-TL { grid-area: 2 / 1; }
.pad.rel .cmd-TR { grid-area: 2 / 3; }
.pad.rel .cmd-FN { grid-area: 2 / 2; }
.key .ico { display: block; width: 100%; height: 100%; }
.key .fn { font-size: calc(var(--key) * 0.34); }

/* Přetahování */
.draggable { touch-action: none; }
.drag-origin { opacity: 0.35; }
.drag-ghost {
  position: fixed;
  z-index: 50;
  width: var(--slot) !important;
  height: var(--slot) !important;
  padding: calc(var(--slot) * 0.16) !important;
  border-radius: 14px;
  pointer-events: none;
  translate: -50% -60%;
  scale: 1.1;
  opacity: 0.92;
  color: #fff;
  background: var(--c);
  box-shadow: 0 10px 20px rgb(0 0 0 / 0.25);
}
.drag-ghost .hint { display: none; }
.dragging, .dragging * { cursor: grabbing !important; user-select: none; }

/* Nabídka u příkazu: kolikrát, barva, smazat. */
.tok-menu {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 340px);
  padding: 10px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25), inset 0 0 0 3px var(--line);
}
.tok-counts { display: grid; grid-template-columns: repeat(5, 48px); gap: 6px; }
.tok-count { height: 44px; border-radius: 12px; background: #efe2c6; font-size: 18px; }
.tok-count.chosen { background: var(--ink); color: #fff; }
.tok-colors { display: flex; gap: 10px; }
.tok-color { width: 44px; height: 44px; border-radius: 50%; background: var(--paint); border: 4px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.tok-color.none { background: repeating-linear-gradient(45deg, #fff 0 6px, #e7dcc6 6px 12px); }
.tok-color.chosen { box-shadow: 0 0 0 4px var(--ink); }
.tok-delete { width: 52px; height: 44px; padding: 8px; border-radius: 12px; background: var(--stop); color: #fff; }

.key {
  border-radius: 22%;
  padding: 18%;
  color: #fff;
  background: var(--c);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 70%, #000);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.15s;
}
.key:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 70%, #000); }
.key:disabled { opacity: 0.4; }

.actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#win-next svg { rotate: 90deg; }
#win-next.to-map svg { rotate: none; }
.key svg, button.slot svg { pointer-events: none; }

.wiggle { animation: wiggle 0.35s; }
@keyframes wiggle {
  20% { translate: -6px 0; }
  40% { translate: 6px 0; }
  60% { translate: -4px 0; }
  80% { translate: 4px 0; }
}

/* Na šířku: hřiště vlevo, ovládání vpravo. */
@media (orientation: landscape) and (min-width: 640px) {
  .stage { flex-direction: row; align-items: stretch; }
  .panel { width: clamp(300px, 38vw, 460px); justify-content: center; }
}

/* --------------------------------------------------------------- výhra */

.win {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgb(253 243 220 / 0.86);
  animation: fade 0.25s;
}
.win-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: clamp(16px, 5vmin, 40px); }
.win-prize { width: clamp(140px, 36vmin, 280px); aspect-ratio: 1; animation: pop 0.6s cubic-bezier(0.3, 1.6, 0.6, 1); }
.win-prize .trophy { display: block; font-size: clamp(120px, 30vmin, 240px); line-height: 1.1; text-align: center; }
.win-actions { display: flex; align-items: center; gap: clamp(20px, 6vmin, 48px); }

.stars { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.stars span { position: absolute; top: -12%; font-size: clamp(24px, 6vmin, 44px); animation: fall 2.6s linear infinite; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { scale: 0; } }
@keyframes fall { to { translate: 0 125vh; rotate: 360deg; } }

/* -------------------------------------------------------------- dialogy */

dialog {
  border: 0;
  border-radius: 24px;
  padding: 24px;
  width: min(92vw, 460px);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
  -webkit-user-select: text;
  user-select: text;
}
dialog::backdrop { background: rgb(59 42 30 / 0.5); }
dialog h2 { margin: 0 0 16px; font-size: 24px; }
dialog label, dialog .label, .card label { display: block; margin: 12px 0 6px; font-size: 16px; color: var(--muted); }
dialog input, .card input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 3px solid var(--line);
  border-radius: 14px;
  font: inherit;
  font-size: 20px;
  color: inherit;
  background: #fff;
}
dialog input:focus, .card input:focus { outline: none; border-color: var(--up); }

.note { margin: 14px 0 0; font-size: 15px; font-weight: 500; color: var(--muted); }

.age-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.age-choice { height: 48px; border-radius: 14px; font-size: 22px; background: #efe2c6; }
.age-grid.big .age-choice { height: 72px; font-size: 34px; }
.age-choice.chosen { background: var(--right); color: #fff; }

.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.avatar-choice { aspect-ratio: 1; border-radius: 14px; font-size: 30px; background: transparent; }
.avatar-choice.chosen { background: #fde9b8; box-shadow: inset 0 0 0 4px var(--right); }

.error { min-height: 1.4em; margin: 10px 0 0; color: var(--stop); font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* -------------------------------------------------- rodiny a rodiče */

.family-screen, .parents-screen { overflow: hidden auto; -webkit-user-select: text; user-select: text; }
.family-screen { display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3vmin, 28px); padding: 12px 4px 24px; }
.family-logo { margin-top: 2vh; }
.family-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; width: min(100%, 820px); }
.family-note { text-align: center; }
.card { padding: 20px; border-radius: 24px; background: var(--card); box-shadow: 0 6px 0 var(--line); }
.card h2, .card h3 { margin: 0 0 8px; }
.card p { margin: 0 0 10px; font-weight: 500; line-height: 1.4; }
.card .btn { margin-top: 6px; }

.family-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 16px; }

.parents-title { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 22px; }
.parents-body { display: grid; gap: 16px; width: min(100%, 860px); margin: 16px auto 24px; }
.parents-body > * { min-width: 0; }
.kids { width: 100%; border-collapse: collapse; font-size: 16px; }
.kids th { text-align: left; color: var(--muted); font-size: 14px; font-weight: 600; padding: 4px 6px; }
.kids td { padding: 8px 6px; border-top: 2px solid var(--line); }
.kids td.avatar { font-size: 30px; width: 1%; }
.kids td.kid-actions { width: 1%; white-space: nowrap; text-align: right; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.card .kids .btn { margin-top: 0; }
.key-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 600px) {
  .kids th:nth-child(6), .kids td:nth-child(6) { display: none; }
  .kids { font-size: 15px; }
  .kids th, .kids td { padding-left: 4px; padding-right: 4px; }
  .kids td.kid-actions { white-space: normal; }
  .kids .btn.small { padding: 4px 8px; line-height: 1.15; font-size: 14px; }
}

.key-dialog { width: min(94vw, 620px); }
.key-box { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 12px; }
.key-qr { flex: none; width: min(220px, 60vw); }
.key-qr svg { display: block; width: 100%; height: auto; border-radius: 8px; }
.key-text { flex: 1; min-width: 200px; }
.key-words { margin: 0; font-size: 26px; line-height: 1.3; word-spacing: 0.25em; }
.key-link { margin: 4px 0 10px; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.key-link a { color: var(--up); }

.fatal { margin: 20vh auto; max-width: 30ch; text-align: center; font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
  .item > *, .player.removable, .stars span { animation: none; }
  .stars { display: none; }
}
