/* FLAF.cz — Mlýn (Nine Men's Morris), herní CSS.
 * Glass styl „ala Sčítátko" (projektový kánon), 5. sourozenec
 * Člobrda/Piškvorek/Lodí/Dámy: tmavé kosmické pozadí (gradienty + bloby + hvězdy), deska =
 * glass panel s 24 průsečíky a zlatými linkami, kameny slonovina/grafit (CSS radial-gradient,
 * literální barvy — žádné SVG defs), zvýraznění tahů zlatě, kameny k sebrání červeně.
 * Vše SCOPED pod .mlyn-shell. */

.mlyn-shell {
  --ml-gold: #FFD700;
  --ml-accent: #7FFFD4;
  --ml-accent-hover: #5fffc4;
  --ml-danger: #ff6b81;
  /* linky a uzly desky (zlato sladěné s FLAF --star-gold) */
  --ml-line: rgba(255, 215, 0, 0.5);
  --ml-node: rgba(255, 215, 0, 0.32);
  --ml-pt: 12%;          /* velikost průsečíku vůči desce */
  /* pozadí je vždy tmavé kosmické (styl Sčítátka) → prvky stylované pro tmavé, ne theme-aware */
  --ml-panel-a: #2a2358;
  --ml-panel-b: #3b2f74;
  /* glass tokeny převzaté ze Sčítátka (game-core.css) */
  --ml-glass-1: rgba(255, 255, 255, .07);
  --ml-glass-3: rgba(255, 255, 255, .17);
  --ml-glass-edge: rgba(255, 255, 255, .28);
  --ml-glass-inner: rgba(255, 255, 255, .5);
  --ml-shadow-deep: 0 30px 60px -20px rgba(0, 0, 0, .6), inset 0 1px 0 var(--ml-glass-inner), inset 0 -1px 0 rgba(0, 0, 0, .25);

  /* fullscreen shell (jako .dama-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) { .mlyn-shell { padding: .35rem .5rem .5rem; gap: .35rem; } }

/* ---------- tmavé kosmické pozadí (styl Sčítátka), vždy — nezávislé na light/dark ---------- */
body.game-mlyn {
  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;
}
.mlyn-shell .ml-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.mlyn-shell .ml-blob { position: absolute; border-radius: 50%; filter: blur(52px); opacity: .42; animation: mlFloat 22s ease-in-out infinite; }
.mlyn-shell .ml-blob--1 { width: 46vw; height: 46vw; background: #6f3fff; top: -14vw; left: -10vw; }
.mlyn-shell .ml-blob--2 { width: 52vw; height: 52vw; background: #00b4d8; bottom: -16vw; right: -12vw; animation-delay: -7s; }
.mlyn-shell .ml-blob--3 { width: 40vw; height: 40vw; background: #ff5f9e; top: 40%; right: -12vw; animation-delay: -14s; }
@keyframes mlFloat { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(4vw, -5vw) scale(1.1); } }
.mlyn-shell .ml-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: mlTwinkle 4s ease-in-out infinite;
}
@keyframes mlTwinkle { 50% { opacity: .28; } }
/* obsah nad pozadím */
.mlyn-shell .status, .mlyn-shell .board-zone, .mlyn-shell .under-bar { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .mlyn-shell .ml-blob, .mlyn-shell .ml-stars { animation: none; } }

.mlyn-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;
}
.mlyn-shell button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.mlyn-shell svg { display: block; }
.mlyn-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;
}

/* ---------- status (velký barevný „na tahu") ---------- */
.mlyn-shell .status {
  flex: 0 0 auto; margin: 0; order: -1;
  font-family: var(--font-heading, sans-serif); font-weight: 800;
  font-size: clamp(1.1rem, 5vw, 1.6rem); letter-spacing: .01em;
  color: #d6d0f5; min-height: 1.4em; text-align: center; line-height: 1.15;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
.mlyn-shell .status.thinking { color: var(--ml-accent); }
.mlyn-shell .status.capture { color: var(--ml-danger); text-shadow: 0 0 16px currentColor, 0 2px 5px rgba(0, 0, 0, .6); }
.mlyn-shell .status.over { color: var(--ml-gold); }
/* dětský barevný popisek „na tahu" — velké písmo v barvě hráče + glow v barvě */
.mlyn-shell .status.turn { text-shadow: 0 0 16px currentColor, 0 2px 5px rgba(0, 0, 0, .6); }
.mlyn-shell .status.turn.w { color: #FFF0B8; }
.mlyn-shell .status.turn.b { color: #9BF0E2; }

/* ---------- deska (glass panel, čtverec přes container-query) ---------- */
.mlyn-shell .board-zone {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  container-type: size;   /* deska = největší ČTVEREC, co se vejde */
}
.mlyn-shell .board-wrap {
  width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); aspect-ratio: 1;
  padding: 5%; border-radius: 24px;
  border: 1px solid var(--ml-glass-edge);
  background:
    linear-gradient(160deg, var(--ml-glass-3) 0%, var(--ml-glass-1) 42%, transparent 100%),
    radial-gradient(circle at 50% 38%, rgba(255, 215, 0, .10), transparent 55%),
    linear-gradient(150deg, var(--ml-panel-b), var(--ml-panel-a));
  box-shadow:
    var(--ml-shadow-deep),
    0 0 48px rgba(255, 215, 0, .12),
    inset 0 0 0 1px rgba(255, 215, 0, .16);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation;
  position: relative; overflow: hidden;
  -webkit-user-select: none; user-select: none;
}
/* horní odlesk skla */
.mlyn-shell .board-wrap::before {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--ml-glass-inner), transparent); pointer-events: none; z-index: 2;
}
.mlyn-shell .board {
  position: relative;
  width: 100%; height: 100%;
}
.mlyn-shell .board-lines {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.mlyn-shell .board-lines rect, .mlyn-shell .board-lines line {
  fill: none; stroke: var(--ml-line); stroke-width: 1.3;
  stroke-linejoin: round; stroke-linecap: round;
}

/* ---------- průsečíky a kameny ---------- */
.mlyn-shell .point {
  position: absolute;
  width: var(--ml-pt); height: var(--ml-pt);
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  border-radius: 50%;
  padding: 0;
}
/* uzel (značka volného průsečíku) */
.mlyn-shell .point::before {
  content: ''; position: absolute;
  width: 26%; height: 26%;
  border-radius: 50%;
  background: var(--ml-node);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.mlyn-shell .point.w::before, .mlyn-shell .point.b::before { opacity: 0; }

.mlyn-shell .point:focus { outline: none; }
.mlyn-shell .point:focus-visible {
  outline: 3px solid var(--ml-accent);
  outline-offset: 0;
  z-index: 4;
}

.mlyn-shell .stone {
  position: relative;
  width: 86%; height: 86%;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.18s ease-out, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}
.mlyn-shell .point.w .stone, .mlyn-shell .point.b .stone { opacity: 1; transform: scale(1); }
.mlyn-shell .point.w .stone {
  background:
    radial-gradient(circle at 38% 30%, #FFFDF4 0%, #F0E2C4 55%, #C6AE82 100%);
  box-shadow: inset 0 -3px 6px rgba(120, 95, 50, 0.45), inset 0 2px 5px rgba(255, 255, 255, 0.7);
}
.mlyn-shell .point.b .stone {
  background:
    radial-gradient(circle at 38% 30%, #5C6878 0%, #28303F 55%, #0E131C 100%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.6), inset 0 2px 5px rgba(150, 165, 185, 0.35);
}

/* legální cíl (tečka) — jen prázdné body */
.mlyn-shell .point.dst::after {
  content: ''; position: absolute;
  width: 34%; height: 34%;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.85);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  animation: mlDstIn 0.18s ease-out;
}
@keyframes mlDstIn { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* vybraný kámen — zlatý prstenec + levitace */
.mlyn-shell .point.sel { z-index: 3; }
.mlyn-shell .point.sel .stone {
  box-shadow: 0 0 0 3px var(--ml-gold), 0 0 16px rgba(255, 215, 0, 0.7);
  animation: mlSelFloat 1.4s ease-in-out infinite;
}
@keyframes mlSelFloat { 0%, 100% { transform: scale(1.04) translateY(0); } 50% { transform: scale(1.04) translateY(-7%); } }

/* sebratelný soupeřův kámen — červený prstenec */
.mlyn-shell .point.removable { z-index: 3; cursor: pointer; }
.mlyn-shell .point.removable .stone {
  box-shadow: 0 0 0 3px var(--ml-danger), 0 0 14px rgba(255, 107, 129, 0.7);
  animation: mlRmPulse 1s ease-in-out infinite;
}
@keyframes mlRmPulse { 0%, 100% { filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5)) brightness(1); } 50% { filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5)) brightness(1.25); } }

/* kameny v hotovém mlýnu — zlatá záře */
.mlyn-shell .point.mill .stone { box-shadow: inset 0 0 0 2px rgba(255, 215, 0, 0.9), 0 0 18px rgba(255, 215, 0, 0.65); }

/* poslední tah */
.mlyn-shell .point.last::before { opacity: 1; background: rgba(255, 215, 0, 0.6); transform: scale(1.5); }
.mlyn-shell .point.placed .stone { animation: mlPlacePop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes mlPlacePop { 0% { transform: scale(0.3); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------- lišta pod deskou: počty kamenů + Vrátit tah ---------- */
.mlyn-shell .under-bar {
  flex: 0 0 auto;
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  flex-wrap: wrap;
}
.mlyn-shell .counts {
  display: flex; gap: 0.6rem; align-items: center;
  font-family: var(--font-heading, sans-serif);
  font-weight: 800; font-size: 1.05rem; color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.mlyn-shell .counts .cnt { opacity: .65; transition: opacity .15s ease; }
.mlyn-shell .counts .cnt.active { opacity: 1; text-shadow: 0 0 12px rgba(255, 215, 0, .55), 0 2px 6px rgba(0, 0, 0, .45); }
.mlyn-shell .counts .dot { color: rgba(255, 255, 255, .5); }

/* ---------- tlačítka ---------- */
.mlyn-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);
}
.mlyn-shell .btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, .16); }
.mlyn-shell .btn:active { transform: translateY(1px); }
.mlyn-shell .btn:focus-visible { outline: 3px solid var(--ml-accent); outline-offset: 2px; }
.mlyn-shell .btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.mlyn-shell .btn-primary { background: var(--ml-accent); color: #123; border-color: var(--ml-accent); }
.mlyn-shell .btn-primary:hover { background: var(--ml-accent-hover); }

/* ---------- úvodní menu (styl Sčítátka: fullscreen glass, prvky plavou BEZ rámečků/karty) ---------- */
.mlyn-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;
}
.mlyn-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%);
}
.mlyn-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: mlDlgPop .35s cubic-bezier(.34, 1.56, .64, 1);
}
.mlyn-shell .dlg > * { width: min(420px, 100%); }
@keyframes mlDlgPop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.mlyn-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; }
.mlyn-shell .dlg fieldset { border: 0; margin: 0; padding: 0; }
.mlyn-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) */
.mlyn-shell .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .6rem; }
.mlyn-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;
}
.mlyn-shell .seg label:hover { background: rgba(255, 255, 255, .14); transform: translateY(-1px); }
.mlyn-shell .seg input { position: absolute; opacity: 0; pointer-events: none; }
.mlyn-shell .seg label:has(input:checked) { background: var(--ml-accent); color: #123; text-shadow: none; box-shadow: 0 0 18px rgba(127, 255, 212, .5); }
.mlyn-shell .seg label:has(input:focus-visible) { outline: 3px solid #fff; outline-offset: 2px; }

/* velké CTA HRÁT (styl Sčítátka menu-cta, pulsující) */
.mlyn-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(--ml-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: mlMenuPulse 2s infinite; transition: transform .12s ease, background .2s ease;
}
.mlyn-shell .dlg-cta:hover { background: var(--ml-accent-hover); transform: translateY(-2px); }
.mlyn-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 mlMenuPulse {
  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); }
}
/* sekundární tlačítko (NOVÁ HRA v menu rozehrané hry) — styl Sčítátka menu-secondary */
.mlyn-shell .dlg-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  width: min(420px, 100%); padding: 14px 28px; min-height: 52px;
  font-family: var(--font-heading, sans-serif); font-weight: 700; font-size: 1.15rem; letter-spacing: .04em;
  color: #fff; background: transparent; border: 3px solid rgba(255, 255, 255, .85); border-radius: 9999px; cursor: pointer;
  transition: transform .12s ease, background .2s ease;
}
.mlyn-shell .dlg-secondary:hover { background: rgba(255, 255, 255, .12); transform: translateY(-2px); }
.mlyn-shell .dlg-secondary:active { transform: translateY(2px); }
/* konec hry */
.mlyn-shell .dlg-text { color: rgba(255, 255, 255, .9); font-size: 1.05rem; line-height: 1.5; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .4); margin: 0; }
.mlyn-shell .result-emoji { display: block; text-align: center; font-size: 3.2rem; margin-bottom: .2rem; }
.mlyn-shell .dlg-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.mlyn-shell .dlg-actions .btn { flex: 1 1 auto; }
.mlyn-shell .dlg-actions .btn-primary { color: #123; }

/* ---------- konfety ---------- */
.mlyn-shell .confetti, .confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; }

/* ---------- landscape: kompaktnější svislý rytmus ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .mlyn-shell__game { gap: .3rem; }
  .mlyn-shell .status { font-size: clamp(1rem, 4vw, 1.3rem); }
  .mlyn-shell .under-bar { gap: .6rem; }
  .mlyn-shell .btn { min-height: 38px; padding: .35rem .8rem; font-size: .85rem; }
  .mlyn-shell .counts { font-size: .95rem; }
}
@media (max-height: 640px) { .mlyn-shell__game { gap: .35rem; } }

/* výkon: na malých displejích vypnout smyčkové animace (levitace/pulz) */
@media (max-width: 768px) {
  .mlyn-shell .point.sel .stone { animation: none; }
  .mlyn-shell .point.removable .stone { animation: none; }
}

/* ---------- omezený pohyb: bez smyčkových animací (zvuk se NEvypíná) ---------- */
@media (prefers-reduced-motion: reduce) {
  .mlyn-shell .dlg { animation: none; }
  .mlyn-shell .dlg-cta { animation: none; }
  .mlyn-shell .point.sel .stone, .mlyn-shell .point.removable .stone { animation: none; }
  .mlyn-shell .stone, .mlyn-shell * { transition-duration: 0.01ms; }
}
