/* FLAF.cz — Dáma (česká dáma), herní CSS.
 * Glass styl „ala Sčítátko" (projektový kánon), 4. sourozenec
 * Člobrda/Piškvorek/Lodí: tmavé kosmické pozadí (gradienty + bloby + hvězdy), deska =
 * glass panel se šachovnicí 8×8 (dřevěné tóny sladěné do fialovo-zlaté), zvýraznění
 * tahů zlatě, oběti braní červeně. Vše SCOPED pod .dama-shell.
 * Kameny = SVG <use> z defs v markupu stránky (literální barvy — fungují i mimo shell). */

.dama-shell {
  --dm-gold: #FFD700;
  --dm-accent: #7FFFD4;
  --dm-accent-hover: #5fffc4;
  --dm-danger: #ff6b81;
  /* šachovnice: světlá/tmavá pole (teplé dřevo, ladí se zlatou) */
  --dm-cell-light-1: #E8D5B5;
  --dm-cell-light-2: #F0DDC0;
  --dm-cell-dark-1: #7a5c8f;
  --dm-cell-dark-2: #8b6ba0;
  /* pozadí je vždy tmavé kosmické (styl Sčítátka) → prvky stylované pro tmavé, ne theme-aware */
  --dm-panel-a: #2a2358;
  --dm-panel-b: #3b2f74;
  /* glass tokeny převzaté ze Sčítátka (game-core.css) */
  --dm-glass-1: rgba(255, 255, 255, .07);
  --dm-glass-3: rgba(255, 255, 255, .17);
  --dm-glass-edge: rgba(255, 255, 255, .28);
  --dm-glass-inner: rgba(255, 255, 255, .5);
  --dm-shadow-deep: 0 30px 60px -20px rgba(0, 0, 0, .6), inset 0 1px 0 var(--dm-glass-inner), inset 0 -1px 0 rgba(0, 0, 0, .25);

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

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

.dama-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;
}
.dama-shell button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.dama-shell svg { display: block; }
.dama-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") ---------- */
.dama-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);
}
.dama-shell .status.thinking { color: var(--dm-accent); }
.dama-shell .status.over { color: var(--dm-gold); }
/* dětský barevný popisek „na tahu" — velké písmo v barvě hráče + glow v barvě */
.dama-shell .status.turn { text-shadow: 0 0 16px currentColor, 0 2px 5px rgba(0, 0, 0, .6); }
.dama-shell .status.turn.w { color: #FFF0B8; }
.dama-shell .status.turn.b { color: #9BF0E2; }

/* ---------- deska (glass panel, čtverec přes container-query) ---------- */
.dama-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 */
}
.dama-shell .board-wrap {
  width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); aspect-ratio: 1;
  padding: 2.6%; border-radius: 24px;
  border: 1px solid var(--dm-glass-edge);
  background:
    linear-gradient(160deg, var(--dm-glass-3) 0%, var(--dm-glass-1) 42%, transparent 100%),
    radial-gradient(circle at 50% 38%, rgba(255, 215, 0, .10), transparent 55%),
    linear-gradient(150deg, var(--dm-panel-b), var(--dm-panel-a));
  box-shadow:
    var(--dm-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);
  /* none ⊃ manipulation: řeší dvojklik-zoom A umožní drag&drop bez rušení scrollem */
  touch-action: none;
  position: relative; overflow: hidden;
  -webkit-user-select: none; user-select: none;
}
/* horní odlesk skla */
.dama-shell .board-wrap::before {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--dm-glass-inner), transparent); pointer-events: none; z-index: 2;
}
.dama-shell .board-inner { position: relative; z-index: 1; width: 100%; height: 100%; }
.dama-shell .board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%; height: 100%;
  border-radius: 10px; overflow: hidden;
}
/* ARIA řádky (role="row") se layoutu neúčastní — gridem jsou přímo buňky */
.dama-shell .brow { display: contents; }

.dama-shell .cell { position: relative; background: linear-gradient(135deg, var(--dm-cell-light-1), var(--dm-cell-light-2)); }
.dama-shell .cell.dark { background: linear-gradient(135deg, var(--dm-cell-dark-1), var(--dm-cell-dark-2)); cursor: pointer; }

.dama-shell .cell:focus { outline: none; }
.dama-shell .cell:focus-visible {
  outline: 3px solid var(--dm-accent);
  outline-offset: -3px;
  z-index: 2;
}

/* poslední tah — jemný zlatý nádech */
.dama-shell .cell.last::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(255, 215, 0, .28);
}
/* vybraný kámen — zvýrazněné pole */
.dama-shell .cell.sel::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(255, 215, 0, .42);
  box-shadow: inset 0 0 0 3px var(--dm-gold);
}
/* legální cíl — tečka */
.dama-shell .cell.dst::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 26%; height: 26%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 215, 0, .85);
  box-shadow: 0 0 8px rgba(255, 215, 0, .6);
}
/* cíl povinného braní — zlatý prstenec */
.dama-shell .cell.cap-dst::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 62%; height: 62%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: transparent;
  border: 3px solid var(--dm-gold);
  box-shadow: 0 0 10px rgba(255, 215, 0, .7), inset 0 0 6px rgba(255, 215, 0, .4);
}
/* oběť braní — červený kroužek */
.dama-shell .cell.victim::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 78%; height: 78%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid var(--dm-danger);
  box-shadow: 0 0 10px rgba(255, 107, 129, .7);
}

/* ---------- kameny ---------- */
.dama-shell .pieces { position: absolute; inset: 0; pointer-events: none; }

.dama-shell .piece {
  position: absolute; left: 0; top: 0;
  width: 12.5%; height: 12.5%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease-out, opacity 0.25s ease-out;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}
.dama-shell .piece > svg { width: 84%; height: 84%; }

.dama-shell .piece.selected { z-index: 3; }
/* jemná levitace nad vlastním polem — animuje se vnitřní SVG, ne kontejner
 * (scale/transform na kontejneru by se skládaly s pozičním translate) */
.dama-shell .piece.selected > svg { animation: dmSelFloat 1.4s ease-in-out infinite; }
.dama-shell .piece.dragging { transition: none; z-index: 5; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.55)); }
.dama-shell .piece.returning { z-index: 4; }
.dama-shell .piece.dying { opacity: 0; z-index: 1; } /* scale řídí JS v inline transformu */
.dama-shell .piece.crowned > svg { animation: dmCrownShine 0.6s ease-out; }

@keyframes dmSelFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9%); }
}
@keyframes dmCrownShine {
  0% { filter: brightness(1); }
  35% { filter: brightness(2.1) drop-shadow(0 0 14px rgba(255, 215, 0, 0.95)); }
  100% { filter: brightness(1); }
}

/* ---------- lišta pod deskou: počty kamenů + Vrátit tah ---------- */
.dama-shell .under-bar {
  flex: 0 0 auto;
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  flex-wrap: wrap;
}
.dama-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);
}
.dama-shell .counts .dot { color: rgba(255, 255, 255, .5); }

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

/* ---------- úvodní menu (styl Sčítátka: fullscreen glass, prvky plavou BEZ rámečků/karty) ---------- */
.dama-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;
}
.dama-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%);
}
.dama-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: dmDlgPop .35s cubic-bezier(.34, 1.56, .64, 1);
}
.dama-shell .dlg > * { width: min(420px, 100%); }
@keyframes dmDlgPop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.dama-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; }
.dama-shell .dlg fieldset { border: 0; margin: 0; padding: 0; }
.dama-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) */
.dama-shell .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .6rem; }
.dama-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;
}
.dama-shell .seg label:hover { background: rgba(255, 255, 255, .14); transform: translateY(-1px); }
.dama-shell .seg input { position: absolute; opacity: 0; pointer-events: none; }
.dama-shell .seg label:has(input:checked) { background: var(--dm-accent); color: #123; text-shadow: none; box-shadow: 0 0 18px rgba(127, 255, 212, .5); }
.dama-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í) */
.dama-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(--dm-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: dmMenuPulse 2s infinite; transition: transform .12s ease, background .2s ease;
}
.dama-shell .dlg-cta:hover { background: var(--dm-accent-hover); transform: translateY(-2px); }
.dama-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 dmMenuPulse {
  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 */
.dama-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;
}
.dama-shell .dlg-secondary:hover { background: rgba(255, 255, 255, .12); transform: translateY(-2px); }
.dama-shell .dlg-secondary:active { transform: translateY(2px); }
/* konec hry */
.dama-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; }
.dama-shell .result-emoji { display: block; text-align: center; font-size: 3.2rem; margin-bottom: .2rem; }
.dama-shell .dlg-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.dama-shell .dlg-actions .btn { flex: 1 1 auto; }
.dama-shell .dlg-actions .btn-primary { color: #123; }

/* ---------- konfety ---------- */
.dama-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) {
  .dama-shell__game { gap: .3rem; }
  .dama-shell .status { font-size: clamp(1rem, 4vw, 1.3rem); }
  .dama-shell .under-bar { gap: .6rem; }
  .dama-shell .btn { min-height: 38px; padding: .35rem .8rem; font-size: .85rem; }
  .dama-shell .counts { font-size: .95rem; }
}
@media (max-height: 640px) { .dama-shell__game { gap: .35rem; } }

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