/* Riftbound herní stůl — TABLETOP styly (kontrakt: CONTRACTS.md, sekce Tabletop).
   Základ dávají tokeny z /account/theme.css (--bg, --card, --card-border,
   --text, --text-dim), akcenty stejné jako builder (hextech tyrkys). Plstěný
   povrch je záměrně tmavý v obou tématech (je to obsah — herní stůl), okolní
   chrome (topbar, lobby, panel) jede na tokenech. Desktop-first. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* display:flex/grid jinak přebije atribut hidden */

:root {
  --rb-accent: #3ec6c9;
  --rb-accent2: #7fdfe1;
  --rb-accent-dim: #26797b;
  --rb-red: #d95c5c;
  --rb-green: #5cb884;
  --rb-gold: #d4b23f;
  --radius: 10px;
  /* doménové barvy (obsah, ne téma) */
  --rb-fury: #e0533f;
  --rb-calm: #4caf7d;
  --rb-mind: #4a8fd4;
  --rb-body: #d98a3d;
  --rb-chaos: #a05fd0;
  --rb-order: #d4b23f;
  /* rozměry fyzických karet — poměr 744:1039 */
  --cw: 72px;                            /* karta na stole */
  --ch: calc(var(--cw) * 1.3965);
  --hw: 104px;                           /* karta v ruce */
  --hh: calc(var(--hw) * 1.3965);
  --rw: 44px;                            /* runa — 30px byla nečitelná (stížnost 2026-08-20) */
  --card-radius: calc(var(--cw) * 0.055);
}
:root[data-theme="light"] {
  --rb-accent: #17888b;
  --rb-accent2: #0e6b6e;
  --rb-accent-dim: #5ba7a9;
}

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(62,198,201,.06), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(90,70,140,.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}
/* stránka nikdy nescrolluje do strany (konvence) — dřív jen ≤900px */
html, body { overflow-x: clip; }
body { display: flex; flex-direction: column; min-height: 100vh; }
/* flex řetěz body → .rb-app → .table/.lobby — bez tohohle je .rb-app obyčejný
   block, .table{flex:1} nemá rodiče a log roste do nekonečna (viz .log) */
.rb-app { flex: 1; display: flex; flex-direction: column; min-height: 0; }

* { scrollbar-width: thin; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 6px; }

h1, h2, h3 { font-family: var(--serif); letter-spacing: .02em; }
h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; color: var(--rb-accent2); display: flex; align-items: center; gap: 9px; }
h1 svg { color: var(--rb-accent); }
h2 { margin: 0 0 12px; font-size: 1.2rem; color: var(--rb-accent2); }
h3 { margin: 12px 0 6px; font-size: 1rem; color: var(--rb-accent2); }

.icon { width: 15px; height: 15px; vertical-align: -2px; flex-shrink: 0; }
.dim { color: var(--text-dim); }
kbd {
  font-family: inherit; font-size: .75em; border: 1px solid var(--card-border);
  border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--text-dim);
}

button {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--card-border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button:hover:not(:disabled) { border-color: var(--rb-accent-dim); color: var(--rb-accent2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--rb-accent-dim); border-color: var(--rb-accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--rb-accent); color: #08282a; }
button.danger:hover:not(:disabled) { border-color: var(--rb-red); color: var(--rb-red); }
button.on { border-color: var(--rb-gold); color: var(--rb-gold); box-shadow: 0 0 6px rgba(212,178,63,.35); }

select, input {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--card-border); border-radius: 8px; padding: 6px 8px;
}

/* ═══ gate ═══ */
.rb-gate { display: none; }
html.rb-locked .rb-app { display: none !important; }
html.rb-locked .rb-gate {
  display: flex; position: fixed; inset: 0; align-items: center;
  justify-content: center; background: var(--bg); z-index: 100;
}
.rb-gate-box {
  text-align: center; background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 34px 44px;
}
.rb-gate-box h2 { display: flex; align-items: center; justify-content: center; gap: 9px; }
.rb-gate-box p { color: var(--text-dim); margin: 8px 0 18px; }

/* ═══ topbar ═══ */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--card) 65%, transparent);
}
.topbar .back { color: var(--text-dim); display: flex; padding: 6px; border-radius: 8px; }
.topbar .back:hover { color: var(--rb-accent2); background: rgba(255,255,255,.04); }
.topbar .back .icon { width: 18px; height: 18px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#pl-status { font-size: .8rem; white-space: nowrap; }

/* navigace appky (nav.js ji injektuje i sem) — zrcadlí style.css */
.rb-nav { display: flex; gap: 3px; margin-left: 8px; min-width: 0; overflow-x: auto; }
.rb-nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: .84rem;
  white-space: nowrap;
}
.rb-nav a:hover { color: var(--rb-accent2); background: rgba(255,255,255,.04); }
.rb-nav a.on {
  color: var(--rb-accent2);
  background: rgba(62,198,201,.15);
  box-shadow: inset 0 0 0 1px rgba(62,198,201,.35);
}

/* ═══ lobby (fancy pass — sladěno s buildrem; stůl níž se NEMĚNÍ) ═══ */
.lobby { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; position: relative; }
/* gradient mesh za lobby boxem */
.lobby::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(560px 300px at 50% 6%, rgba(62,198,201,.09), transparent 70%),
    radial-gradient(430px 260px at 16% 82%, rgba(122,90,190,.08), transparent 70%);
}
.lobby-box {
  position: relative; width: 480px; max-width: 100%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 93%, var(--rb-accent)), var(--card) 52%);
  border: 1px solid var(--card-border); border-radius: 16px; padding: 26px 30px;
  box-shadow: 0 18px 50px -18px rgba(0,0,0,.5);
}
/* akcentová linka po horní hraně boxu */
.lobby-box::before {
  content: ''; position: absolute; inset: -1px -1px auto; height: 2px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, transparent 6%, var(--rb-accent), transparent 94%);
  opacity: .75;
}
.lb-row { display: block; margin: 0 0 14px; }
.lb-row select, .lb-row input { width: 100%; margin-top: 5px; }
.lb-row > span:first-child, .lb-label {
  font-size: .74rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-dim);
}
.lb-label { display: block; margin-bottom: 7px; }
.lobby-box select:focus, .lobby-box input:focus {
  outline: none; border-color: var(--rb-accent-dim);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rb-accent) 16%, transparent);
}
/* režimy jako segmentované chipy (radio zůstává — jen dostal kabát) */
.lb-modes { display: flex; gap: 7px; flex-wrap: wrap; }
.lb-modes label {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--card-border); border-radius: 999px;
  color: var(--text-dim); font-size: .88rem;
  background: color-mix(in srgb, var(--bg-soft, var(--card)) 60%, transparent);
  transition: color .18s ease, border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}
.lb-modes label:hover { border-color: var(--rb-accent-dim); color: var(--text); }
.lb-modes label:has(input:checked) {
  border-color: var(--rb-accent); color: var(--rb-accent2);
  background: color-mix(in srgb, var(--rb-accent) 15%, transparent);
  box-shadow: 0 0 12px -5px color-mix(in srgb, var(--rb-accent) 60%, transparent);
}
.lb-modes input { accent-color: var(--rb-accent); margin: 0; }
.lb-warn { margin: 0 0 14px; font-size: .88rem; }
.lb-warn .w { color: var(--rb-gold); }
.lb-warn .e { color: var(--rb-red); }
.lb-warn div { margin: 2px 0; }
/* linka v barvě řádku (w zlatá / e červená / „legální“ zelená přes inline color) */
.lb-warn div.w, .lb-warn div.e { padding-left: 9px; border-left: 2px solid currentColor; }
.lb-note { font-size: .85rem; margin: 12px 0 0; }
.lb-note a { color: var(--rb-accent); }
#lb-start {
  width: 100%; justify-content: center; padding: 10px;
  background: linear-gradient(160deg, var(--rb-accent) 20%, color-mix(in srgb, var(--rb-accent) 76%, #063032));
  border-color: transparent; color: #06272a; font-weight: 600;
  transition: filter .18s ease, box-shadow .18s ease;
}
#lb-start:hover:not(:disabled) {
  background: linear-gradient(160deg, var(--rb-accent) 20%, color-mix(in srgb, var(--rb-accent) 76%, #063032));
  color: #06272a; filter: brightness(1.1);
  box-shadow: 0 0 20px -6px color-mix(in srgb, var(--rb-accent) 50%, transparent);
}
:root[data-theme="light"] #lb-start,
:root[data-theme="light"] #lb-start:hover:not(:disabled) { color: #f4fbfb; }
@media (prefers-reduced-motion: reduce) {
  .lobby-box, .lb-modes label, #lb-start { transition: none !important; animation: none !important; }
}
/* online multiplayer řádek (#lb-mp-row) — vzor .lb-row, kód velkým s prostrkáním */
.lb-mp #rb-mp-create { width: 100%; justify-content: center; margin-top: 7px; }
.lb-mp .mp-join { display: flex; gap: 7px; margin-top: 7px; }
.lb-mp .mp-join input {
  flex: 1; width: auto; margin-top: 0;
  text-transform: uppercase; letter-spacing: .22em; font-weight: 600; text-align: center;
}
.lb-mp .mp-join button { flex-shrink: 0; }
#rb-mp-status { display: block; margin-top: 8px; font-size: .82rem; overflow-wrap: anywhere; }

/* ═══ stůl — kostra ═══ */
.table { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 0; min-height: 0; }
.table-main { padding: 8px 10px; display: flex; flex-direction: column; gap: 7px; min-width: 0; min-height: 0; }
.table-side {
  width: 300px; border-left: 1px solid var(--card-border); padding: 10px 12px;
  display: flex; flex-direction: column; min-height: 0; position: relative;
  background: color-mix(in srgb, var(--card) 40%, transparent);
  transition: width .2s ease;
}
.table-side .side-content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.table-side.collapsed { width: 38px; padding: 10px 4px; }
.table-side.collapsed .side-content { display: none; }
.side-toggle {
  position: absolute; top: 8px; left: -1px; z-index: 5; padding: 4px 5px;
  border-radius: 0 8px 8px 0; border-left: none;
}
.side-toggle .icon { transition: transform .2s; }
.table-side.collapsed .side-toggle .icon { transform: rotate(180deg); }
.side-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 26px; }
.side-btns button { flex: 1 1 44%; justify-content: center; font-size: .85rem; padding: 6px 6px; }
.log {
  flex: 1; overflow-y: auto; font-size: .82rem; line-height: 1.45;
  border: 1px solid var(--card-border); border-radius: 8px; padding: 8px 10px;
  background: var(--card); min-height: 120px;
}
.log .turnhead { color: var(--rb-accent2); font-weight: 600; margin-top: 4px; }
.log .undoline { color: var(--rb-gold); }
/* obal drží pilulku „N nových ↓" ukotvenou dole nad logem */
.logwrap { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.log-pill {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  padding: 3px 12px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: var(--rb-accent); color: #04191b; border: none; cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.5);
}

.turnbar {
  display: flex; align-items: center; gap: 14px; padding: 6px 12px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  font-size: .92rem; flex-wrap: wrap;
}
.turnbar .who { color: var(--rb-accent2); font-weight: 600; }
.turnbar .pts { margin-left: auto; display: flex; gap: 14px; }
.turnbar .pts b { color: var(--rb-gold); }

/* ═══ plstěný povrch ═══ */
.felt {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px;
  border-radius: 16px; padding: 8px 10px; position: relative;
  border: 1px solid #0a2a28;
  box-shadow:
    inset 0 0 0 2px rgba(62,198,201,.10),
    inset 0 0 70px rgba(0,0,0,.55),
    0 8px 30px rgba(0,0,0,.45);
  background:
    radial-gradient(1200px 500px at 50% 42%, rgba(62,198,201,.07), transparent 65%),
    repeating-linear-gradient(41deg, rgba(255,255,255,.014) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(-49deg, rgba(0,0,0,.05) 0 1px, transparent 1px 4px),
    radial-gradient(140% 120% at 50% 45%, #103330 0%, #0b2422 55%, #071716 100%);
  color: #cfe6e4;                        /* text na plsti — nezávislý na tématu */
  overflow: hidden;
}
.felt .dim { color: rgba(207,230,228,.45); }
/* božský mód — odlišený okraj stolu */
.felt.godmode {
  box-shadow:
    inset 0 0 0 3px rgba(212,178,63,.5),
    inset 0 0 70px rgba(0,0,0,.55),
    0 8px 30px rgba(0,0,0,.45);
}

/* ═══ fyzická karta ═══ */
/* .cardw = vnější obal (FLIP animace, layout), .card = líc/rub (rotace exhaust) */
.cardw {
  width: var(--cw); height: var(--ch); position: relative; flex-shrink: 0;
  cursor: pointer; touch-action: none;   /* pointer drag bez scroll gest */
  z-index: 0;                            /* stacking context — attgear (z-index:-1) zůstane pod kartou */
}
.card {
  width: 100%; height: 100%; border-radius: var(--card-radius); overflow: hidden;
  background: #1a2c2e; border: 1px solid rgba(0,0,0,.6); position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,.55), 0 6px 14px rgba(0,0,0,.3);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .25s ease, box-shadow .2s ease;
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .ph {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: .62rem; line-height: 1.2; padding: 4px;
  color: #9fc4c2; background: linear-gradient(160deg, #17393b, #0d2224);
}
.card.ex { transform: rotate(calc(90deg + var(--tilt, 0deg))); }
.cardw:hover .card { box-shadow: 0 0 0 2px rgba(62,198,201,.55), 0 6px 16px rgba(0,0,0,.5); }

/* rub karty — čistě CSS (logo setu = hexagon rift symbolu), žádný obrázek */
.cardback {
  width: 100%; height: 100%; border-radius: var(--card-radius); position: relative;
  border: 1px solid rgba(0,0,0,.65); overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,.55);
  background:
    radial-gradient(90% 70% at 50% 30%, rgba(62,198,201,.22), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.12) 0 2px, transparent 2px 6px),
    linear-gradient(165deg, #16444a 0%, #0d282c 55%, #081b1e 100%);
}
.cardback::before {
  content: ''; position: absolute; inset: 7%; border-radius: inherit;
  border: 1px solid rgba(62,198,201,.3);
}
.cardback svg {
  position: absolute; left: 50%; top: 50%; width: 46%; height: 46%;
  transform: translate(-50%, -50%); color: rgba(127,223,225,.75);
}

/* žetony na kartě */
.cbadge {
  position: absolute; z-index: 3; display: inline-flex; align-items: center;
  justify-content: center; min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 50%; font-size: .72rem; font-weight: 700; color: #fff;
  border: 1px solid rgba(0,0,0,.55); box-shadow: 0 1px 3px rgba(0,0,0,.6);
  pointer-events: none;
}
.b-might { left: -6px; bottom: -6px; background: radial-gradient(circle at 35% 30%, #4b8f92, #235e60); }
.b-dmg { right: -6px; bottom: -6px; background: radial-gradient(circle at 35% 30%, #e07a7a, #a33232); }
.b-cost { left: -6px; top: -6px; background: rgba(8,20,22,.9); border-color: rgba(62,198,201,.5); border-radius: 10px; white-space: nowrap; }
.b-flags {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 2px; font-size: .64rem; white-space: nowrap; pointer-events: none;
}
.b-flags span {
  background: rgba(8,20,22,.88); border: 1px solid rgba(212,178,63,.5);
  color: #ecd98a; padding: 0 5px; border-radius: 8px;
}
.cardw.token .card { outline: 1px dashed rgba(207,230,228,.4); outline-offset: -3px; }
.cardw.token .ph { font-style: italic; }

/* vlastní skrytá (facedown) karta — vidím líc, orámovaná jako rub */
.card.hiddenown::after {
  content: '🂠'; position: absolute; right: 3px; top: 1px; font-size: .9rem;
  color: #e7d9a5; text-shadow: 0 1px 2px #000;
}
.card.hiddenown { outline: 2px dashed rgba(160,95,208,.7); outline-offset: -2px; opacity: .92; }

/* připnutý gear — vykukuje zpod nositele */
.attgear {
  position: absolute; z-index: -1; width: 72%; height: 72%;
  right: -26%; top: 10%; cursor: pointer;
}
.attgear .card { box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.attgear .glabel {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  background: rgba(8,20,22,.9); color: #cfe6e4; font-size: .58rem; padding: 0 4px;
  border-radius: 6px; white-space: nowrap; max-width: 130%; overflow: hidden;
  text-overflow: ellipsis; pointer-events: none;
}

/* zvýraznění cílů / výběru */
.targetable .card, .targetable.card { box-shadow: 0 0 0 3px var(--rb-gold), 0 0 14px rgba(212,178,63,.5) !important; cursor: crosshair; }
.selected-unit .card { box-shadow: 0 0 0 3px var(--rb-accent), 0 0 12px rgba(62,198,201,.5) !important; }
.playable .card, .chip-card.playable { box-shadow: 0 0 0 2px rgba(62,198,201,.6), 0 0 10px rgba(62,198,201,.35); }

/* ═══ řady hráčů (rail + ruka) ═══ */
.prow { display: flex; align-items: flex-end; gap: 12px; min-height: calc(var(--ch) + 22px); }
.prow.opp { flex-direction: row-reverse; align-items: flex-start; min-height: calc(var(--ch) * .82 + 20px); }
.rail { display: flex; align-items: flex-end; gap: 10px; }
.prow.opp .rail { align-items: flex-start; }
.rail.rside { flex-wrap: wrap; justify-content: flex-end; max-width: 40%; row-gap: 4px; }

/* stohy (deck / rune deck) */
.pile { position: relative; width: var(--cw); height: var(--ch); flex-shrink: 0; }
.pile .layer { position: absolute; inset: 0; }
.pile .layer:nth-child(1) { transform: translate(4px, 4px); filter: brightness(.75); }
.pile .layer:nth-child(2) { transform: translate(2px, 2px); filter: brightness(.88); }
.pile.rd { width: calc(var(--cw) * .72); height: calc(var(--ch) * .72); }
.pile .pcount {
  position: absolute; right: -7px; top: -7px; z-index: 4; min-width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
  background: rgba(8,20,22,.92); border: 1px solid rgba(62,198,201,.55); color: #bfeeef;
  font-size: .74rem; font-weight: 700; border-radius: 11px; pointer-events: none;
}
.pile .plab {
  position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%);
  font-size: .62rem; color: rgba(207,230,228,.5); white-space: nowrap; pointer-events: none;
}
.prow.opp .pile .plab { bottom: auto; top: -15px; }
.pile.empty .cardback, .pile.empty .card { opacity: .22; }

/* trash — vrchní karta */
.pile.trash .card img { filter: grayscale(.5) brightness(.8); }
.pile.trash .outline {
  position: absolute; inset: 0; border: 1px dashed rgba(207,230,228,.3);
  border-radius: var(--card-radius);
}

/* legenda + champion zóna */
.legslot { position: relative; flex-shrink: 0; }
.legslot .slab {
  position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%);
  font-size: .62rem; color: rgba(207,230,228,.5); white-space: nowrap; pointer-events: none;
}
.prow.opp .legslot .slab { bottom: auto; top: -15px; }
.legslot .star {
  position: absolute; left: -6px; top: -7px; z-index: 3; font-size: .8rem;
  color: var(--rb-gold); text-shadow: 0 1px 3px #000; pointer-events: none;
}

/* runy v řadě */
.runerow { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; max-width: calc(12 * (var(--rw) + 3px) / 2 + 40px); }
.runecard {
  width: var(--rw); height: calc(var(--rw) * 1.3965); border-radius: 3px; overflow: hidden;
  border: 1px solid rgba(0,0,0,.6); box-shadow: 0 1px 3px rgba(0,0,0,.5);
  transition: transform .25s ease, opacity .2s; position: relative; background: #142d2f;
}
.runecard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.runecard .rph { position: absolute; inset: 0; }
.runecard.ex { transform: rotate(90deg); opacity: .55; }

/* pool + body jako žetony */
.toks { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tok {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  font-size: .8rem; font-weight: 800; color: #fff;
  border: 2px solid rgba(0,0,0,.5);
  box-shadow: inset 0 2px 4px rgba(255,255,255,.25), inset 0 -3px 5px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.5);
}
.tok.en { background: radial-gradient(circle at 35% 30%, #6f7a8a, #3d4652); }
.tok.pw { font-size: .76rem; }
.tok.pts { background: radial-gradient(circle at 35% 30%, #e8cb62, #937a1f); color: #241d04; }
.tok.dimtok { opacity: .35; }

/* soupeřova ruka — rub vějířem */
.opphand { flex: 1; display: flex; justify-content: center; align-items: flex-start; min-height: calc(var(--ch) * .62); }
.opphand .oc {
  width: calc(var(--cw) * .62); height: calc(var(--ch) * .62); margin: 0 -9px;
  transform: rotate(var(--rot, 0deg)) translateY(var(--ty, 0px));
}
.opphand .oc .cardback { box-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* ═══ battlefieldy — landscape podložky ═══ */
.bf-row { flex: 1; min-height: calc(var(--ch) * 1.9); display: flex; justify-content: center; align-items: center; gap: 26px; }
.mat-holder { position: relative; }
.mat {
  width: clamp(300px, 33vw, 460px); aspect-ratio: 1039 / 744; position: relative;
  border-radius: 12px; border: 1px solid rgba(0,0,0,.6);
  box-shadow: 0 4px 14px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.06);
  background: linear-gradient(160deg, #1b3a3c, #0e2426);
  transition: box-shadow .2s ease;
}
.mat .mat-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  border-radius: inherit; opacity: .85;
}
.mat::after {                            /* vinětace, ať karty na podložce vyniknou */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(100% 90% at 50% 50%, transparent 45%, rgba(0,0,0,.45) 100%);
}
.mat.ctrl-me { box-shadow: 0 0 0 2px var(--rb-green), 0 4px 16px rgba(0,0,0,.55); }
.mat.ctrl-opp { box-shadow: 0 0 0 2px var(--rb-red), 0 4px 16px rgba(0,0,0,.55); }
.mat.contested { box-shadow: 0 0 0 2px var(--rb-gold), 0 0 18px rgba(212,178,63,.35); }
.mat.fight { box-shadow: 0 0 0 3px var(--rb-gold), 0 0 26px rgba(212,178,63,.55); }
.mat-name {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none;
  max-width: 92%;
}
.mat-name .bfname {
  background: rgba(8,20,22,.82); color: #dff3f2; font-size: .78rem; font-weight: 600;
  padding: 2px 10px; border-radius: 9px; pointer-events: auto; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.mat-name .badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.mat-name .badge {
  font-size: .66rem; padding: 0 7px; border-radius: 8px; border: 1px solid currentColor;
  background: rgba(8,20,22,.82); pointer-events: none;
}
.badge.me { color: var(--rb-green); }
.badge.opp { color: var(--rb-red); }
.badge.contest { color: var(--rb-gold); }
.badge.facedown { color: #c99ae8; }
.mat.empty { display: flex; align-items: center; justify-content: center; }
.mat.empty .mat-name { position: static; transform: none; }

/* jednotky LEŽÍ na podložce — soupeř nahoře, moje dole, mírný překryv */
.mat-units {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
  justify-content: space-between; padding: 4px 6px;
}
.mat-row { display: flex; justify-content: center; align-items: center; min-height: calc(var(--ch) * .8); }
.mat-row .cardw { margin: 0 -11px; }
.mat-row .cardw:hover { z-index: 6; }
.mat-row.opp .cardw { margin-top: calc(var(--ch) * -0.18); }
.mat-row.mine .cardw { margin-bottom: calc(var(--ch) * -0.18); }

/* facedown zóna podložky */
.fd-slot { position: absolute; right: 6px; bottom: 6px; z-index: 3; width: calc(var(--cw) * .8); height: calc(var(--ch) * .8); }
.fd-slot .cardw { width: 100%; height: 100%; }
.fd-slot.theirs { bottom: auto; top: 6px; }

/* ═══ base řady ═══ */
.baserow {
  min-height: calc(var(--ch) * .9 + 14px); display: flex; align-items: center; gap: 4px;
  border: 1px dashed rgba(207,230,228,.18); border-radius: 12px; padding: 6px 12px;
  background: rgba(0,0,0,.14);
}
.baserow .zlabel {
  font-size: .68rem; color: rgba(207,230,228,.45); margin-right: 8px;
  writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; flex-shrink: 0;
  letter-spacing: .06em;
}
.baserow .cardw { margin-right: -8px; }
.baserow .cardw:hover { z-index: 6; }

/* ═══ drop zóny (drag & drop) ═══ */
.drop-ok { outline: 2px dashed rgba(62,198,201,.85); outline-offset: -3px; }
.drop-ok.mat, .mat.drop-ok { outline: none; box-shadow: 0 0 0 3px var(--rb-accent), 0 0 22px rgba(62,198,201,.5); }
.drop-hover { outline-style: solid; background-color: rgba(62,198,201,.10); }
.mat.drop-hover { box-shadow: 0 0 0 4px var(--rb-accent2), 0 0 26px rgba(62,198,201,.7); }
.felt.drop-cast { box-shadow: inset 0 0 0 3px rgba(62,198,201,.55), inset 0 0 70px rgba(0,0,0,.55); }
.felt.drop-cast.drop-cast-hover { box-shadow: inset 0 0 0 4px var(--rb-accent2), inset 0 0 80px rgba(6,40,42,.7); }

/* tažená karta */
.cardw.dragging { opacity: .3; }
.drag-ghost {
  position: fixed; z-index: 90; pointer-events: none; will-change: transform;
  filter: drop-shadow(0 14px 20px rgba(0,0,0,.55));
}
.drag-ghost .card, .drag-ghost .cardback { box-shadow: 0 0 0 2px rgba(62,198,201,.6); }
.drag-ghost.returning { transition: transform .25s ease, opacity .25s ease; }

/* popover volby varianty dropu */
.dropmenu {
  position: fixed; z-index: 95; background: var(--card); border: 1px solid var(--rb-accent-dim);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.55); padding: 6px;
  display: flex; flex-direction: column; gap: 4px; max-width: 320px;
}
.dropmenu button { justify-content: flex-start; text-align: left; font-size: .84rem; padding: 5px 10px; }

/* ═══ ruka — vějíř ═══ */
.hand {
  flex: 1; display: flex; justify-content: center; align-items: flex-end;
  min-height: calc(var(--hh) * .8); padding: 0 10px; position: relative;
}
.hand .cardw {
  width: var(--hw); height: var(--hh); margin: 0 -17px;
  transform: rotate(var(--rot, 0deg)) translateY(var(--ty, 0px));
  transform-origin: 50% 120%;
  transition: transform .18s ease;
}
.hand .cardw:hover {
  transform: rotate(0deg) translateY(-30px) scale(1.13);
  z-index: 40 !important;
}
.hand .cardw.unplayable { filter: saturate(.55) brightness(.75); }
/* právě líznutá karta — zlatý dosvit, po ~3 s zůstane jen tenký okraj */
.hand .cardw.just-drawn .card {
  outline: 2px solid var(--rb-gold);
  outline-offset: -1px;
  animation: rb-drawglow 3s ease-out forwards;
}
@keyframes rb-drawglow {
  from { box-shadow: 0 0 22px rgba(212, 178, 63, .85); }
  to   { box-shadow: 0 0 0 rgba(212, 178, 63, 0); }
}
.hand .cardw .b-cost { left: -3px; top: -3px; }
.hand-empty { align-self: center; font-size: .85rem; }

/* badge s počtem units na ghostu při hromadném dragu — POZOR: .drag-ghost
   nesmí dostat position:relative (přebilo by position:fixed základního
   pravidla a ghost by se choval jako blok v layoutu — review 2026-08-16);
   fixed sám tvoří containing block pro absolutní badge */
.drag-ghost .drag-count {
  position: absolute;
  top: -9px;
  right: -9px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: var(--rb-accent);
  color: #06272b;
  font-weight: 700;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}

/* rychlé nástroje v manual promptu (efekt karty bez Božského módu) */
.manual-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 2px; }
.manual-tools button { font-size: .78rem; }
.manual-tools .tool-active { outline: 2px solid var(--rb-gold); }
.hint-zone { margin-left: 4px; }

/* champion karta v zóně */
.champslot { position: relative; }

/* ═══ hintbar ═══ */
.hintbar {
  position: sticky; bottom: 0; padding: 8px 12px; border-radius: var(--radius);
  background: var(--rb-accent-dim); color: #fff; font-size: .9rem;
  display: flex; align-items: center; gap: 10px; z-index: 20;
}
.hintbar button { background: rgba(0,0,0,.25); border-color: transparent; color: #fff; }

/* ═══ god mode paleta ═══ */
.godpanel {
  margin-top: 8px; border: 1px solid var(--rb-gold); border-radius: var(--radius);
  padding: 8px; font-size: .82rem; display: flex; flex-direction: column; gap: 6px;
}
.godpanel .grow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.godpanel button { font-size: .78rem; padding: 3px 8px; }
.godpanel button.tool-active { border-color: var(--rb-gold); color: var(--rb-gold); }
.godpanel select, .godpanel input { font-size: .78rem; padding: 3px 6px; }

/* ═══ preview ═══ */
.preview {
  position: fixed; z-index: 60; width: 290px; pointer-events: none;
  background: var(--card); border: 1px solid var(--rb-accent-dim); border-radius: 12px;
  padding: 10px; box-shadow: 0 10px 34px rgba(0,0,0,.5); font-size: .85rem;
}
.preview img { width: 100%; border-radius: 8px; display: block; margin-bottom: 8px; }
.preview .pname { font-weight: 700; color: var(--rb-accent2); margin-bottom: 4px; }
.preview .ptext { line-height: 1.45; }
.preview .pcs { margin-top: 6px; color: var(--text-dim); font-style: italic; }

/* symboly v textech karet */
.rb-sym {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 3px; border-radius: 50%;
  font-size: .7rem; font-weight: 700; color: #fff; vertical-align: -3px;
}
.rb-energy { background: #555a66; border: 1px solid #888; }
.rb-might { background: #7a3a3a; }
.rb-exhaust { background: #46617a; }
.rb-pt { background: #8a7a2a; }
.rb-rune { border: 1px solid rgba(0,0,0,.4); }
.rb-d-fury { background: var(--rb-fury); }
.rb-d-calm { background: var(--rb-calm); }
.rb-d-mind { background: var(--rb-mind); }
.rb-d-body { background: var(--rb-body); }
.rb-d-chaos { background: var(--rb-chaos); }
.rb-d-order { background: var(--rb-order); }
.rb-kw { color: var(--rb-accent2); }

/* ═══ modal ═══ */
.modal-wrap {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center;
  justify-content: center; background: rgba(0,0,0,.55);
}
.modal-box {
  background: var(--card); border: 1px solid var(--rb-accent-dim); border-radius: 14px;
  padding: 20px 24px; max-width: 640px; width: calc(100% - 40px); max-height: 84vh;
  overflow-y: auto; box-shadow: 0 14px 44px rgba(0,0,0,.55);
}
/* Undo nad overlayem promptu — jediná klikatelná cesta zpět, dokud je prompt
   otevřený (postranní tlačítko je pod overlayem). */
.modal-undo { position: absolute; top: 14px; right: 16px; z-index: 1; }
.modal-undo[disabled] { opacity: .45; }
.modal-box h3 { margin-top: 0; }
.modal-cards { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.mcard {
  width: 110px; cursor: pointer; border: 2px solid var(--card-border); border-radius: 9px;
  overflow: hidden; background: var(--bg-soft, var(--bg)); position: relative;
}
.mcard img { width: 100%; display: block; }
.mcard .ph { height: 140px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .72rem; color: var(--text-dim); padding: 6px; }
.mcard.sel { border-color: var(--rb-accent); box-shadow: 0 0 8px rgba(62,198,201,.4); }
.mcard .mname { font-size: .7rem; padding: 3px 5px; text-align: center; }
.modal-btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.menu-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 2px; }
.menu-list button { justify-content: flex-start; text-align: left; }
.assign-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; }
.assign-row .aname { flex: 1; }
.assign-row input { width: 64px; }
.assign-row .abadge { font-size: .7rem; color: var(--rb-gold); }
.assign-sum { margin-top: 8px; font-weight: 600; }
.assign-sum.bad { color: var(--rb-red); }
.manual-text { margin: 8px 0; line-height: 1.5; border-left: 3px solid var(--rb-accent-dim); padding-left: 10px; }

/* chip (trash počet v modalech, legacy) */
.chip-card {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border: 1px solid var(--card-border); border-radius: 7px; background: var(--card);
  cursor: pointer; white-space: nowrap;
}
.chip-card:hover { border-color: var(--rb-accent-dim); }

/* ═══ FX animace (FLIP + kill let) ═══ */
.fx-anim { transition: transform .3s cubic-bezier(.2,.8,.3,1); }
.fx-fly {
  position: fixed; z-index: 85; pointer-events: none; margin: 0;
  transition: transform .4s cubic-bezier(.5,.05,.7,.5), opacity .4s ease;
}
@media (prefers-reduced-motion: reduce) {
  .card, .runecard, .hand .cardw, .fx-anim, .fx-fly, .drag-ghost.returning { transition: none !important; }
}

@media (max-width: 1100px) {
  :root { --cw: 60px; --hw: 88px; --rw: 34px; }
  .bf-row { gap: 14px; }
}

/* ═══ MOBIL (kontrakt: sekce MOBIL) ═══
   Stůl se pod ~640 px škáluje transform scale dle šířky (nav.js nastavuje
   inline transform + kompenzační marginy na #felt — layout uvnitř stolu se
   nemění, jen se zmenší celý povrch). Tady jen chrome kolem stolu. */
@media (max-width: 900px) {

  .table { grid-template-columns: 1fr; }
  .table-side { width: auto; border-left: none; border-top: 1px solid var(--card-border); }
  /* stacked layout: grid řádek je content-driven, flex:1 logu tu nic
     neomezuje — tvrdý strop, ať log neroztahuje stránku */
  .log { max-height: 35vh; }
  .table-side.collapsed { width: auto; }
  .side-btns { margin-top: 0; }
  .side-toggle { display: none; }
  .topbar h1 span { display: none; }
  .rail.rside { max-width: 46%; }

  .lobby { padding: 26px 12px; }
  .lobby-box { padding: 22px 18px; }
  .modal-box { padding: 16px 14px; width: calc(100% - 20px); }
  .dropmenu { max-width: min(320px, calc(100vw - 16px)); }
}
@media (max-width: 600px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  #pl-status { display: none; }   /* stav DB se na malém displeji nevejde */
  .rb-nav a { padding: 7px 12px; }
  .table-main { padding: 6px; }
  .turnbar { gap: 8px 12px; padding: 5px 8px; font-size: .82rem; }
  .side-btns button { padding: 8px 6px; }
  .modal-btns button, .menu-list button { padding: 8px 12px; }
}

/* hint „otoč telefon“ — jen malé displeje na výšku (stůl je použitelný na
   šířku); sedí uvnitř #table, takže v lobby není vidět. Nepřekáží (bez
   pointer-events), obě témata pokrývá tmavá pilulka nad tmavou plstí. */
.rotate-hint { display: none; }
@media (max-width: 700px) and (orientation: portrait) {
  .rotate-hint {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 65;
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(8,20,22,.92);
    color: #cfe6e4;
    border: 1px solid rgba(62,198,201,.5);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: .84rem;
    white-space: nowrap;
    pointer-events: none;
  }
}

/* touch: hover preview vypnutý — detail/menu karty je na klik (kontrakt) */
@media (hover: none) {
  .preview { display: none !important; }
}
