/* KIDS GAMES — společný vzhled. Každá hra má vlastní soubor hry/<id>.css
   a všechno v něm začíná .hra-<id>, aby se hry navzájem neovlivňovaly. */
:root {
  --pismo: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Arial Rounded MT Bold", system-ui, sans-serif;
  --nebe1: #8fd3ff;
  --nebe2: #d8f3ff;
  --stin: 0 6px 0 rgba(0, 0, 0, .18), 0 10px 24px rgba(0, 0, 0, .12);
  --bezpecne-nahore: env(safe-area-inset-top, 0px);
  --bezpecne-dole: env(safe-area-inset-bottom, 0px);
  --bezpecne-vlevo: env(safe-area-inset-left, 0px);
  --bezpecne-vpravo: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: var(--pismo); color: #233;
  background: linear-gradient(180deg, var(--nebe1), var(--nebe2));
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
#app { position: fixed; inset: 0; }

/* ---------- načítání ---------- */
.k-nacitam { position: absolute; inset: 0; display: grid; place-items: center; }
.k-nacitam span { width: 72px; height: 72px; border-radius: 50%; background: #ffd93d; animation: k-skok .8s ease-in-out infinite alternate; box-shadow: var(--stin); }

/* ---------- menu ---------- */
.k-menu { display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(10px + var(--bezpecne-nahore)) calc(14px + var(--bezpecne-vpravo)) calc(18px + var(--bezpecne-dole)) calc(14px + var(--bezpecne-vlevo)); }
.k-hlava { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; min-height: 86px; }
.k-logo { display: flex; align-items: baseline; gap: 2px; font-weight: 900; font-size: 50px; letter-spacing: 1px; }
.k-logo span { color: var(--b); -webkit-text-stroke: 3px #fff; paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(0,0,0,.15); display: inline-block; animation: k-houpani 2.4s ease-in-out infinite; }
.k-logo span:nth-child(2) { animation-delay: .15s } .k-logo span:nth-child(3) { animation-delay: .3s } .k-logo span:nth-child(4) { animation-delay: .45s }
.k-logo small { font-size: 22px; color: #fff; margin-left: 8px; letter-spacing: 3px; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
.k-zvuk { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.7); color: #3a6; display: grid; place-items: center; }
.k-zvuk svg { width: 30px; height: 30px; }
.k-zvuk .krizek { display: none; }
.k-zvuk.vyp { color: #c55; } .k-zvuk.vyp .vlny { display: none; } .k-zvuk.vyp .krizek { display: inline; }

.k-mriz { position: relative; z-index: 2; flex: 1; display: grid; gap: 16px; align-content: center;
  grid-template-columns: repeat(2, 1fr); max-width: 520px; width: 100%; margin: 0 auto; padding: 8px 0 16px; }
/* tablet a širší: 3 sloupce, velikost podle výšky, ať je vidět všech 6 dlaždic bez posouvání */
@media (min-width: 600px) {
  .k-mriz { grid-template-columns: repeat(3, 1fr); max-width: min(900px, calc((100vh - 170px) / 2 / 1.08 * 3 + 32px)); max-width: min(900px, calc((100dvh - 170px) / 2 / 1.08 * 3 + 32px)); }
}
.k-dlazdice { position: relative; aspect-ratio: 1 / 1.08; border-radius: 30px; background: var(--b);
  box-shadow: inset 0 -10px 0 rgba(0,0,0,.14), inset 0 6px 0 rgba(255,255,255,.35), var(--stin);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px;
  animation: k-prilet .5s cubic-bezier(.3,1.6,.5,1) both; transition: transform .12s; }
.k-dlazdice:active { transform: scale(.93) translateY(4px); }
.k-obr { width: 78%; flex: 1; display: grid; place-items: center; }
.k-obr svg { width: 100%; height: 100%; max-height: 140px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.15)); }
.k-nazev { font-weight: 800; font-size: 17px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.2); margin-top: 4px; opacity: .95; }

/* mraky v pozadí menu */
.k-mraky { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.k-mraky i { position: absolute; width: 160px; height: 52px; background: #fff; border-radius: 40px; opacity: .8; animation: k-mrak 38s linear infinite; }
.k-mraky i::before, .k-mraky i::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.k-mraky i::before { width: 70px; height: 70px; left: 24px; top: -34px; }
.k-mraky i::after { width: 54px; height: 54px; left: 80px; top: -22px; }
.k-mraky i:nth-child(1) { top: 14%; animation-duration: 46s; animation-delay: -10s; }
.k-mraky i:nth-child(2) { top: 48%; transform: scale(.7); animation-duration: 60s; animation-delay: -35s; opacity: .6; }
.k-mraky i:nth-child(3) { top: 80%; transform: scale(1.2); animation-duration: 52s; animation-delay: -22s; opacity: .55; }

/* ---------- ve hře ---------- */
.k-vhre { overflow: hidden; }
.hra { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.k-domu { position: absolute; z-index: 50; left: calc(10px + var(--bezpecne-vlevo)); top: calc(10px + var(--bezpecne-nahore));
  width: 58px; height: 58px; border-radius: 50%; background: #ff9f1c; display: grid; place-items: center;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), 0 4px 10px rgba(0,0,0,.2); border: 4px solid #fff; transition: transform .1s; }
.k-domu:active { transform: scale(.9); }
.k-domu svg { width: 32px; height: 32px; }

.k-oslava { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 100; pointer-events: none; }

/* ---------- společné kousky, které můžou hry použít ---------- */
.k-tlacitko { border-radius: 24px; background: #fff; box-shadow: inset 0 -6px 0 rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.15);
  display: grid; place-items: center; transition: transform .1s; }
.k-tlacitko:active { transform: scale(.92) translateY(3px); }
.k-vyber { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: calc(84px + var(--bezpecne-nahore)) calc(14px + var(--bezpecne-vpravo)) calc(20px + var(--bezpecne-dole)) calc(14px + var(--bezpecne-vlevo));
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(130px, 40vw), 1fr)); align-content: start; }

@keyframes k-prilet { from { transform: scale(.3) translateY(40px); opacity: 0; } }
@keyframes k-houpani { 50% { transform: translateY(-6px) rotate(-3deg); } }
@keyframes k-skok { to { transform: translateY(-30px) scale(1.05); } }
@keyframes k-mrak { from { left: -200px; } to { left: 110%; } }
@media (prefers-reduced-motion: reduce) { .k-mraky i, .k-logo span { animation: none; } }
@media (max-height: 500px) and (orientation: landscape) {
  .k-hlava { min-height: 56px; } .k-logo { font-size: 36px; }
  .k-mriz { grid-template-columns: repeat(6, 1fr); max-width: 900px; gap: 12px; }
  .k-nazev { font-size: 14px; } .k-dlazdice { border-radius: 24px; }
}
