/* FLAF.cz — Housenka (Snake), herní CSS.
 * Glass styl „ala Sčítátko" (projektový kánon), 6. sourozenec
 * Člobrda (první arkádový): tmavé kosmické pozadí (gradienty + bloby + hvězdy), hrací
 * plocha = <canvas> v glass panelu, HUD chipy Skóre/Rekord, overlay PAUZA, hint badge.
 * Vše SCOPED pod .housenka-shell. Canvas si velikost počítá JS (sizeCanvas) z #boardZone
 * a :root --board-cap — proto tu NENÍ container-query čtverec jako u deskových sourozenců. */

/* strop hrany hrací plochy — JS ho čte z documentElement (NESMÍ být jen v shellu!) */
:root { --board-cap: 640px; }
@media (min-width: 768px) { :root { --board-cap: 700px; } }
@media (min-width: 2560px) { :root { --board-cap: 860px; } }

.housenka-shell {
  --hs-gold: #FFD700;
  --hs-accent: #7FFFD4;
  --hs-accent-hover: #5fffc4;
  --hs-green: #AED581;          /* housenkově zelená (světlá varianta pro text/glow) */
  --hs-panel-a: #2a2358;
  --hs-panel-b: #3b2f74;
  /* glass tokeny převzaté ze Sčítátka (game-core.css) */
  --hs-glass-1: rgba(255, 255, 255, .07);
  --hs-glass-3: rgba(255, 255, 255, .17);
  --hs-glass-edge: rgba(255, 255, 255, .28);
  --hs-glass-inner: rgba(255, 255, 255, .5);
  --hs-shadow-deep: 0 30px 60px -20px rgba(0, 0, 0, .6), inset 0 1px 0 var(--hs-glass-inner), inset 0 -1px 0 rgba(0, 0, 0, .25);

  /* fullscreen shell (jako .mlyn-shell) — self-contained */
  position: relative; z-index: 0;
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: .5rem .75rem; padding-bottom: max(.75rem, env(safe-area-inset-bottom));
  gap: .5rem;
  font-family: var(--font-body, sans-serif);
}
@media (max-height: 640px) { .housenka-shell { padding: .35rem .5rem .5rem; gap: .35rem; } }

/* ---------- tmavé kosmické pozadí (styl Sčítátka), vždy — nezávislé na light/dark ---------- */
body.game-housenka {
  background:
    radial-gradient(at 15% 10%, #3a2a78 0, transparent 55%),
    radial-gradient(at 85% 15%, #1e4d9c 0, transparent 55%),
    radial-gradient(at 75% 90%, #5b2a9c 0, transparent 55%),
    radial-gradient(at 10% 85%, #2a6db5 0, transparent 55%),
    #0e0d2b;
}
.housenka-shell .hs-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.housenka-shell .hs-blob { position: absolute; border-radius: 50%; filter: blur(52px); opacity: .42; animation: hsFloat 22s ease-in-out infinite; }
.housenka-shell .hs-blob--1 { width: 46vw; height: 46vw; background: #4f9d2f; top: -14vw; left: -10vw; }
.housenka-shell .hs-blob--2 { width: 52vw; height: 52vw; background: #00b4d8; bottom: -16vw; right: -12vw; animation-delay: -7s; }
.housenka-shell .hs-blob--3 { width: 40vw; height: 40vw; background: #6f3fff; top: 40%; right: -12vw; animation-delay: -14s; }
@keyframes hsFloat { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(4vw, -5vw) scale(1.1); } }
.housenka-shell .hs-stars {
  position: absolute; inset: 0; opacity: .55;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 32% 68%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 56% 34%, #fff, transparent),
    radial-gradient(1px 1px at 82% 78%, #fff, transparent),
    radial-gradient(1px 1px at 91% 24%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 22% 48%, #fff, transparent),
    radial-gradient(1px 1px at 66% 60%, #fff, transparent),
    radial-gradient(1px 1px at 46% 88%, #fff, transparent);
  animation: hsTwinkle 4s ease-in-out infinite;
}
@keyframes hsTwinkle { 50% { opacity: .28; } }
/* obsah nad pozadím */
.housenka-shell .hud, .housenka-shell .board-zone { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .housenka-shell .hs-blob, .housenka-shell .hs-stars { animation: none; } }

.housenka-shell__game {
  display: flex; flex-direction: column; align-items: center;
  gap: .5rem; width: 100%; min-height: 0; flex: 1 1 auto;
  -webkit-user-select: none; user-select: none;
}
.housenka-shell button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.housenka-shell .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- HUD: chipy Skóre / Rekord ---------- */
.housenka-shell .hud {
  flex: 0 0 auto; order: -1;
  display: flex; gap: .6rem; align-items: center; justify-content: center; flex-wrap: wrap;
}
.housenka-shell .chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .95rem; border-radius: 9999px;
  border: 1px solid var(--hs-glass-edge);
  background: linear-gradient(160deg, var(--hs-glass-3), var(--hs-glass-1));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-family: var(--font-heading, sans-serif); font-weight: 700; font-size: .95rem;
  color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 18px rgba(0, 0, 0, .3);
}
.housenka-shell .chip b {
  color: var(--hs-gold); font-variant-numeric: tabular-nums; min-width: 1ch; text-align: right;
  text-shadow: 0 0 10px rgba(255, 215, 0, .55), 0 2px 5px rgba(0, 0, 0, .5);
}
.housenka-shell .chip.bump { animation: hsBump 0.3s ease-out; }
@keyframes hsBump { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }

/* ---------- hrací plocha (canvas v glass panelu) ---------- */
.housenka-shell .board-zone {
  flex: 1 1 auto; min-height: 0; min-width: 0; width: 100%;
  display: grid; place-items: center;
  padding: 2px;
}
.housenka-shell .board-wrap {
  position: relative;
  box-sizing: border-box;
  padding: clamp(6px, 1.4vmin, 14px);
  border-radius: 24px;
  border: 1px solid var(--hs-glass-edge);
  background:
    linear-gradient(160deg, var(--hs-glass-3) 0%, var(--hs-glass-1) 42%, transparent 100%),
    radial-gradient(circle at 50% 38%, rgba(174, 213, 129, .10), transparent 55%),
    linear-gradient(150deg, var(--hs-panel-b), var(--hs-panel-a));
  box-shadow:
    var(--hs-shadow-deep),
    0 0 48px rgba(124, 179, 66, .14),
    inset 0 0 0 1px rgba(255, 215, 0, .12);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  max-width: 100%; max-height: 100%;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
/* horní odlesk skla */
.housenka-shell .board-wrap::before {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--hs-glass-inner), transparent); pointer-events: none; z-index: 2;
}
.housenka-shell canvas {
  display: block;
  border-radius: 14px;
  background: #0A0F1D;
  touch-action: none; -webkit-touch-callout: none;
}

/* ---------- overlay PAUZA nad deskou ---------- */
.housenka-shell .overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: none; z-index: 5; text-align: center;
  padding: clamp(0.7rem, 2.2vh, 1.2rem) clamp(1.2rem, 4vw, 2.2rem);
  border-radius: 22px;
  font-family: var(--font-heading, sans-serif); font-weight: 800; letter-spacing: 0.02em;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.housenka-shell .overlay.show { display: block; }
.housenka-shell .overlay-pause {
  background: linear-gradient(135deg, #ffd166, #ffa94d);
  color: #123; border: 1px solid rgba(255, 255, 255, .5);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}
.housenka-shell .overlay.show.overlay-pause { animation: hsPausePulse 1.4s ease-in-out infinite; }
@keyframes hsPausePulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.05); } }

/* startovní nápověda dole nad deskou */
.housenka-shell .hint-badge {
  position: absolute; left: 50%; bottom: clamp(8px, 2.5%, 18px); transform: translateX(-50%);
  z-index: 4; display: none;
  padding: 0.45rem 1rem; border-radius: 9999px;
  background: rgba(14, 13, 43, 0.8); border: 1px solid var(--hs-glass-edge);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #fff; font-family: var(--font-heading, sans-serif);
  font-size: clamp(0.75rem, 1.9vw, 0.9rem); font-weight: 700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  white-space: nowrap; pointer-events: none;
}
.housenka-shell .hint-badge.show { display: block; animation: hsHintPulse 2.4s ease-in-out infinite; }
@keyframes hsHintPulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

/* ---------- tlačítka ---------- */
.housenka-shell .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .5rem 1.1rem;
  font-family: var(--font-heading, sans-serif); font-weight: 700; font-size: .95rem;
  border: 2px solid rgba(255, 255, 255, .3); border-radius: 9999px;
  background: rgba(255, 255, 255, .1); color: #fff;
  cursor: pointer; transition: transform .12s ease, background .2s ease, border-color .2s ease;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.housenka-shell .btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, .16); }
.housenka-shell .btn:active { transform: translateY(1px); }
.housenka-shell .btn:focus-visible { outline: 3px solid var(--hs-accent); outline-offset: 2px; }
.housenka-shell .btn-primary { background: var(--hs-accent); color: #123; border-color: var(--hs-accent); }
.housenka-shell .btn-primary:hover { background: var(--hs-accent-hover); }

/* ---------- dialogy (styl Sčítátka: fullscreen glass, prvky plavou BEZ rámečků/karty) ---------- */
.housenka-shell .dlg {
  margin: 0; padding: 0; max-width: none; max-height: none; width: 100%; height: 100%;
  background: none; border: 0; color: #fff; overflow-y: auto;
}
.housenka-shell .dlg::backdrop {
  background:
    radial-gradient(at 20% 20%, rgba(107, 91, 149, .75) 0, transparent 55%),
    radial-gradient(at 80% 80%, rgba(72, 61, 139, .75) 0, transparent 55%),
    rgba(14, 13, 43, .82);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
}
.housenka-shell .dlg[open] {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: calc(64px + env(safe-area-inset-top, 0px)) 22px calc(28px + env(safe-area-inset-bottom, 0px));
  animation: hsDlgPop .35s cubic-bezier(.34, 1.56, .64, 1);
}
.housenka-shell .dlg > * { width: min(420px, 100%); }
@keyframes hsDlgPop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.housenka-shell .dlg h2 { font-family: var(--font-display, sans-serif); font-size: 1.7rem; color: #fff; text-align: center; text-shadow: 0 2px 10px rgba(0, 0, 0, .5); margin: 0; }
.housenka-shell .dlg fieldset { border: 0; margin: 0; padding: 0; }
.housenka-shell .dlg legend { display: block; width: 100%; text-align: center; font-family: var(--font-heading, sans-serif); font-weight: 700; font-size: 1.15rem; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .45); margin-bottom: .7rem; padding: 0; }
/* segment voleb — měkká glass tlačítka bez tvrdého rámečku (styl Sčítátka) */
.housenka-shell .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .6rem; }
.housenka-shell .seg label {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 56px; padding: .5rem .4rem; border-radius: 18px; cursor: pointer;
  background: rgba(255, 255, 255, .08); border: 0;
  font-family: var(--font-heading, sans-serif); font-weight: 800; font-size: 1rem; color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
.housenka-shell .seg label:hover { background: rgba(255, 255, 255, .14); transform: translateY(-1px); }
.housenka-shell .seg input { position: absolute; opacity: 0; pointer-events: none; }
.housenka-shell .seg label:has(input:checked) { background: var(--hs-accent); color: #123; text-shadow: none; box-shadow: 0 0 18px rgba(127, 255, 212, .5); }
.housenka-shell .seg label:has(input:focus-visible) { outline: 3px solid #fff; outline-offset: 2px; }
.housenka-shell .dlg-hint { color: rgba(255, 255, 255, .75); font-size: .88rem; line-height: 1.45; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .4); margin: -6px 0 0; }

/* velké CTA HRÁT (styl Sčítátka menu-cta, pulsující) */
.housenka-shell .dlg-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px 32px; min-height: 60px; width: min(420px, 100%);
  font-family: var(--font-heading, sans-serif); font-weight: 800; font-size: 1.5rem; letter-spacing: .04em;
  color: #123; background: var(--hs-accent); border: 0; border-radius: 9999px; cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .18), 0 10px 28px rgba(127, 255, 212, .35);
  animation: hsMenuPulse 2s infinite; transition: transform .12s ease, background .2s ease;
}
.housenka-shell .dlg-cta:hover { background: var(--hs-accent-hover); transform: translateY(-2px); }
.housenka-shell .dlg-cta:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2), 0 4px 16px rgba(127, 255, 212, .3); }
@keyframes hsMenuPulse {
  0%, 100% { box-shadow: 0 6px 0 rgba(0, 0, 0, .18), 0 0 0 0 rgba(127, 255, 212, .7), 0 10px 28px rgba(127, 255, 212, .35); }
  50% { box-shadow: 0 6px 0 rgba(0, 0, 0, .18), 0 0 0 18px rgba(127, 255, 212, 0), 0 10px 28px rgba(127, 255, 212, .35); }
}

/* konec hry */
.housenka-shell .result-emoji { display: block; text-align: center; font-size: 3.2rem; margin-bottom: .2rem; }
.housenka-shell .winstats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.housenka-shell .winstats div {
  padding: .7rem .6rem; text-align: center;
  border: 1px solid var(--hs-glass-edge); border-radius: 18px;
  background: linear-gradient(160deg, var(--hs-glass-3), var(--hs-glass-1));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-family: var(--font-heading, sans-serif); font-weight: 700; font-size: .9rem;
  color: rgba(255, 255, 255, .85); text-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.housenka-shell .winstats b {
  display: block; font-size: 1.5rem; color: var(--hs-gold); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(255, 215, 0, .55), 0 2px 5px rgba(0, 0, 0, .5);
}
.housenka-shell .record {
  text-align: center; color: var(--hs-gold); font-family: var(--font-heading, sans-serif);
  font-weight: 800; font-size: 1.2rem; margin: 0;
  text-shadow: 0 0 16px rgba(255, 215, 0, .6), 0 2px 6px rgba(0, 0, 0, .5);
}
.housenka-shell .record[hidden] { display: none; }
.housenka-shell .dlg-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.housenka-shell .dlg-actions .btn { flex: 1 1 auto; }
.housenka-shell .dlg-actions .btn-primary { color: #123; }

/* ---------- landscape: kompaktnější svislý rytmus ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .housenka-shell__game { gap: .3rem; }
  .housenka-shell .hud { gap: .45rem; }
  .housenka-shell .chip { padding: .2rem .75rem; font-size: .85rem; }
}
@media (max-height: 640px) { .housenka-shell__game { gap: .35rem; } }

/* výkon: na malých displejích vypnout smyčkové animace (pulzy) */
@media (max-width: 768px) {
  .housenka-shell .overlay.show.overlay-pause { animation: none; }
  .housenka-shell .hint-badge.show { animation: none; }
}

/* ---------- omezený pohyb: bez smyčkových animací (zvuk se NEvypíná) ---------- */
@media (prefers-reduced-motion: reduce) {
  .housenka-shell .dlg { animation: none; }
  .housenka-shell .dlg-cta { animation: none; }
  .housenka-shell .overlay.show.overlay-pause { animation: none; }
  .housenka-shell .hint-badge.show { animation: none; }
  .housenka-shell .chip.bump { animation: none; }
}
