/* Układ: ciemny salon o zmierzchu, stół w perspektywie na środku, panel przeciwników z boku, ręka gracza na dole */
:root {
  --bg: #0e0d0c;
  --ink: #ece5d6;
  --muted: #a39a8a;
  --gold: #c9a86a;
  --gold-2: #e3c993;
  --line: rgba(201, 168, 106, .34);
  --line-soft: rgba(201, 168, 106, .16);
  --glass: rgba(18, 16, 14, .74);
  --glass-2: rgba(24, 21, 18, .92);
  --danger: #c4584b;
  --felt: #1a1c1f;
  --f-display: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
  --f-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
#svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- tło: salon z oknem ---------- */
#bg { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; display: block; background: #0d0b09; }

/* ---------- elementy wspólne ---------- */
.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  padding: 10px 18px;
  border-radius: 999px;
  letter-spacing: .05em;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--gold); background: rgba(201, 168, 106, .1); }
.btn.gold { background: linear-gradient(180deg, #dcc086, #b8975a); color: #1b150c; border-color: transparent; font-weight: 600; }
.btn.gold:hover:not(:disabled) { background: linear-gradient(180deg, #e6cc95, #c4a265); }
.btn.sm { padding: 6px 13px; font-size: 12.5px; }
.btn:disabled { opacity: .38; }
.note { margin: 0; color: var(--muted); font-size: 12.5px; }
.hint { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.warn { color: var(--danger); }

.card {
  width: var(--cw, 60px);
  aspect-ratio: 5 / 7;
  flex: none;
  display: block;
  border: 0;
  padding: 0;
  background: none;
  border-radius: calc(var(--cw) * .065);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.card svg { width: 100%; height: 100%; display: block; }

/* ---------- menu ---------- */
.menu-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding-block: 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.panel {
  width: min(460px, 100%);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel.wide { width: min(560px, 100%); }
@media (max-width: 420px) { .panel { padding: 24px 18px 20px; } }

.brand { text-align: center; }
.brand h1 {
  margin: 0;
  font: 300 clamp(30px, 7vw, 42px)/1 var(--f-display);
  letter-spacing: .42em;
  padding-left: .42em;
  color: var(--gold-2);
}
.rule { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; }
.rule span { width: 64px; height: 1px; background: var(--line); }
.rule i { width: 7px; height: 7px; border: 1px solid var(--gold); transform: rotate(45deg); }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; background: none; border: 0; padding: 10px 0; color: var(--muted);
  letter-spacing: .14em; text-transform: uppercase; font-size: 11.5px;
  border-bottom: 1px solid transparent; margin-bottom: -1px;
}
.tabs .on { color: var(--gold-2); border-color: var(--gold); }

.form { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; gap: 8px;
}
.fld > span b { color: var(--gold-2); font-weight: 600; letter-spacing: .02em; text-transform: none; font-size: 13px; font-variant-numeric: tabular-nums; }
input, select {
  width: 100%;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(201, 168, 106, .25);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  font: inherit;
}
input:focus, select:focus { border-color: var(--gold); outline: none; }
select option { background: #1a1816; color: var(--ink); }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--gold); height: 28px; }
.code-input { font: 500 26px var(--f-display); letter-spacing: .5em; text-align: center; text-transform: uppercase; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 44px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid rgba(201, 168, 106, .22); background: rgba(255, 255, 255, .03);
}
.seg .on { border-color: var(--gold); background: rgba(201, 168, 106, .14); color: var(--gold-2); }
.seg button:disabled { opacity: .35; }

.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sw { background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); }
.sw i {
  width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .18), transparent 55%), var(--sw);
  border: 3px solid #4a3220;
  box-shadow: inset 0 0 0 1px rgba(201, 168, 106, .45);
}
.sw.on i { outline: 2px solid var(--gold); outline-offset: 2px; }
.sw.on { color: var(--gold-2); }
.sw small { font-size: 10.5px; }
@media (max-width: 420px) { .swatches { grid-template-columns: repeat(3, 1fr); } }

.backs { display: flex; gap: 12px; }
.bk { background: none; border: 1px solid transparent; border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); }
.bk .card { --cw: 54px; }
.bk.on { border-color: var(--gold); color: var(--gold-2); }

.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

.profile-chip { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.profile-chip > div { flex: 1; min-width: 0; }
.profile-chip b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(#2c2620, #1a1714);
  border: 1px solid var(--gold);
  color: var(--gold-2);
  font: 600 18px var(--f-display);
}
.avatar.empty { border-style: dashed; border-color: var(--line); background: none; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; color: var(--gold); flex: none; }
.icon-btn svg { width: 18px; height: 18px; }

.menu-list { display: flex; flex-direction: column; }
.mi {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: 0; border-top: 1px solid var(--line-soft);
  padding: 13px 30px 13px 4px; text-align: left; position: relative;
}
.mi:last-child { border-bottom: 1px solid var(--line-soft); }
.mi span { font: 500 21px/1.2 var(--f-display); letter-spacing: .04em; }
.mi small { color: var(--muted); font-size: 12px; }
.mi::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 8px; height: 8px;
  border-top: 1px solid var(--gold); border-right: 1px solid var(--gold);
  transform: translateY(-50%) rotate(45deg);
}
.mi:hover span { color: var(--gold-2); }

.banner {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 14px; border: 1px solid var(--gold); border-radius: 12px;
  background: rgba(201, 168, 106, .08); font-size: 13px;
}
.banner.warn { border-color: rgba(196, 88, 75, .7); background: rgba(196, 88, 75, .1); color: var(--ink); }

.sub-head { display: flex; align-items: center; gap: 12px; }
.sub-head h2 { margin: 0; font: 500 24px/1.15 var(--f-display); letter-spacing: .04em; flex: 1; text-align: right; text-wrap: balance; min-width: 0; }
.back { background: none; border: 0; color: var(--muted); padding: 4px 0; letter-spacing: .04em; }
.back:hover { color: var(--gold-2); }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; padding-top: 2px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.room-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.room-row { border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.rr-main { flex: 1; min-width: 0; }
.rr-main b { display: block; font: 600 18px/1.2 var(--f-display); overflow-wrap: anywhere; }
.rr-main small { color: var(--muted); font-size: 12px; }
.rr-side { display: flex; align-items: center; gap: 10px; }
.cnt { font-variant-numeric: tabular-nums; color: var(--gold-2); }
.lock-ico { width: 14px; height: 14px; color: var(--muted); }
.pw-row { flex-basis: 100%; display: flex; gap: 8px; }
.empty-list { text-align: center; color: var(--muted); padding: 18px 0; }

.code-box { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.code-box span { color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.code-box b { font: 600 26px var(--f-display); letter-spacing: .3em; color: var(--gold-2); }
.facts { color: var(--muted); font-size: 12.5px; text-align: center; }
.seat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seat-list li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 12px; }
.seat-list li > div { flex: 1; min-width: 0; }
.seat-list b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-list small { color: var(--muted); font-size: 12px; }
.seat-list em { font-style: normal; font-size: 10.5px; color: var(--gold-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 6px; }
.team { font-style: normal; font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--gold-2); }

.rules { display: flex; flex-direction: column; gap: 14px; max-height: 62vh; overflow: auto; padding-right: 4px; }
.rules h3 { margin: 0 0 4px; font: 600 19px var(--f-display); color: var(--gold-2); letter-spacing: .03em; }
.rules ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.rules li { max-width: 65ch; }
.rules table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rules td { padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.rules td:last-child { text-align: right; color: var(--gold-2); }

/* ==========================================================
   STÓŁ – scena: salon o zmierzchu, lampa, stół w perspektywie
   ========================================================== */
body[data-screen="table"] { overflow: hidden; }
.game {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  padding-block: 8px 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow: hidden;
}

.g-top { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; min-width: 0; }
.brand-sm { font: 300 20px/1 var(--f-display); letter-spacing: .38em; color: var(--gold-2); }
.scores { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.sc { border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px 12px; display: flex; gap: 8px; align-items: baseline; background: rgba(0, 0, 0, .4); max-width: 100%; }
.sc small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc b { font-variant-numeric: tabular-nums; font-weight: 600; }
.sc.neg b { color: #f08a7c; }
.sc.me { border-color: var(--gold); box-shadow: inset 0 0 12px rgba(201, 168, 106, .15); }
.meta { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.top-btns { display: flex; gap: 8px; }

/* scena */
.scene {
  position: relative;
  min-height: 0;
  container-type: size;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
/* zegar tury – lewy górny róg */
.turnbox {
  position: absolute; left: 0; top: 0; z-index: 4;
  min-width: 168px;
  padding: 10px 14px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(30, 26, 22, .88), rgba(14, 12, 10, .88));
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 230, 190, .08);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 2px;
}
.turnbox small { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.turnbox.mine { border-color: var(--gold); box-shadow: 0 0 30px rgba(227, 201, 147, .18), 0 12px 30px rgba(0, 0, 0, .5); }
.tb-name { font: 600 17px/1.2 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.tb-time { font: 500 36px/1.05 var(--f-display); color: var(--gold-2); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.tb-time.small { font-size: 15px; color: var(--muted); padding: 6px 0; }
.tb-time.low { color: #f08a7c; }
.tb-bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 4px; }
.tb-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a8864c, #f0d9a6); transition: width .25s linear; }
.tb-bar i.low { background: #d8665a; }

.strip-warn {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); z-index: 4;
  padding: 6px 14px; border: 1px solid rgba(196, 88, 75, .6); background: rgba(60, 20, 16, .8); border-radius: 999px; font-size: 13px;
}

.plates { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.plate {
  position: absolute;
  transform: translate(-50%, 0);
  display: flex; align-items: center; gap: 9px;
  padding: 5px 14px 5px 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(28, 24, 20, .9), rgba(12, 11, 9, .9));
  border: 1px solid var(--line-soft);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 230, 190, .06);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  max-width: 30%;
  text-align: left;
  pointer-events: auto;
}
.plate:hover { border-color: var(--gold); }
.plate.turn { border-color: var(--gold); box-shadow: 0 0 26px rgba(227, 201, 147, .3), 0 10px 24px rgba(0, 0, 0, .45); }
.plate.gone { opacity: .45; }
.pl-av { width: 40px; height: 40px; border-radius: 50%; padding: 2px; background: rgba(255, 255, 255, .08); flex: none; display: block; }
.pl-av.ring { background: conic-gradient(from 0deg, #f0d9a6, #a8864c, #f0d9a6); animation: spin 3s linear infinite; }
.pl-av > span { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #34302a, #15130f); color: var(--gold-2); font: 600 17px var(--f-display); }
.pl-av.ring > span { animation: spin 3s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.pl-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pl-txt b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-txt small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-stats { color: var(--gold-2) !important; opacity: .85; font-variant-numeric: tabular-nums; }
.team { font-style: normal; font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--gold-2); }

.log {
  position: absolute; right: 0; bottom: 4px; z-index: 2;
  width: min(300px, 26%);
  font-size: 11.5px; line-height: 1.4; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}
.log p { margin: 0; }
.log p:first-child { color: var(--ink); }
@media (max-width: 760px) { .log { display: none; } }

/* stół 3D (table3d.js) */
.gl3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.piles3d { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.hit {
  position: absolute; pointer-events: auto;
  background: none; border: 0; padding: 0; border-radius: 10px;
}
.hit:disabled { cursor: default; }
.hit .pile-n { position: absolute; left: 50%; top: calc(100% + 10px); transform: translateX(-50%); }
.hit.live { box-shadow: 0 0 0 2px rgba(240, 217, 166, .85), 0 0 30px rgba(240, 217, 166, .45); }
.hit.live .pile-n { border-color: var(--gold); color: var(--gold-2); }
.hit.blocked .pile-n { color: #f0aaa0; }
.hit:not(:disabled):hover { box-shadow: 0 0 0 2px rgba(240, 217, 166, .6); }
.plate.anchored { transform: translate(-50%, -100%); }

/* stół 2D – zapas, gdy przeglądarka nie obsługuje WebGL */
.table-wrap {
  position: relative;
  aspect-ratio: 2.35 / 1;
  width: min(96%, 1100px);
  width: min(94cqw, calc(96cqh * 2.35));
  container-type: inline-size;
}
.tablecv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.piles {
  position: absolute; left: 0; right: 0; top: 0; height: 86%;
  display: flex; align-items: center; justify-content: center; gap: 9%;
  --cw: clamp(40px, 7.6cqw, 120px);
}
.pile { background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; }
.pile:not(:disabled):hover .stack { transform: translateY(-4px); }
.stack { position: relative; width: var(--cw); aspect-ratio: 5 / 7; display: block; transition: transform .15s ease; }
.stack .card { position: absolute; inset: 0; width: 100%; transform: translate(calc(var(--i) * -1.5px), calc(var(--i) * -2px)); box-shadow: 0 1px 1px rgba(0, 0, 0, .4), 0 8px 18px rgba(0, 0, 0, .45); }
.stack .card.under { background: #e6dcc6; transform: translate(3px, 2px) rotate(4deg); }
.pile-n { font-size: 12px; background: rgba(0, 0, 0, .6); padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; border: 1px solid rgba(214, 178, 112, .2); }
.pile.live .stack { filter: drop-shadow(0 0 10px rgba(240, 217, 166, .6)); }
.pile.live .pile-n { border-color: var(--gold); color: var(--gold-2); }
.pile.blocked .pile-n { color: #f0aaa0; }
.slot { width: 100%; height: 100%; border: 1px dashed rgba(214, 178, 112, .5); border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; }
.slot.big { width: 200px; height: 280px; }

/* pasek „Mój stół” */
.mytable {
  display: flex; align-items: center; gap: 16px;
  width: 100%; min-width: 0;
  padding: 8px 16px;
  border-radius: 16px;
  text-align: left;
  background: linear-gradient(180deg, rgba(34, 29, 24, .85), rgba(16, 14, 12, .85));
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 230, 190, .06);
}
.mytable:hover { border-color: var(--gold); }
.mt-label { display: flex; flex-direction: column; flex: none; }
.mt-label b { font: 600 18px/1.1 var(--f-display); letter-spacing: .04em; color: var(--gold-2); }
.mt-label small { color: var(--muted); font-size: 11.5px; }
.mt-row { flex: 1; min-width: 0; display: flex; gap: 18px; overflow: hidden; align-items: flex-end; }
.mt-group { display: flex; flex-direction: column; gap: 3px; flex: none; }
.mt-group > small { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.mt-items { display: flex; gap: 8px; }
.mt-empty { color: var(--muted); font-size: 13px; }
.mt-open { flex: none; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.mini { --cw: clamp(26px, min(2.8vw, 5vh), 44px); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mini-card { position: relative; }
.mini-card .card { box-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.mini-card b { position: absolute; right: -6px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #15120e; border: 1px solid var(--gold); color: var(--gold-2); font-size: 10.5px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.mini small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.mini.canasta.red small { color: #ee9d92; }
.mini.canasta.golden small { color: var(--gold-2); }
.mini.canasta.black small { color: #d9d0c0; }

/* ręka */
.hand-zone { min-width: 0; padding: 18px 4px 2px; }
.hand { display: flex; justify-content: center; --cw: clamp(46px, min(6.4vw, 12vh), 106px); }
.hand .card { --cw: inherit; flex: none; transition: transform .14s ease, box-shadow .14s ease; box-shadow: -2px 0 6px rgba(0, 0, 0, .35), 0 8px 16px rgba(0, 0, 0, .45); }
.hand .card + .card { margin-left: var(--ml, calc(var(--cw) * -.4)); }
.hand .card:hover:not(:disabled) { transform: translateY(-8px); }
.hand .card.sel { transform: translateY(-16px); box-shadow: 0 0 0 2px var(--gold-2), 0 14px 26px rgba(0, 0, 0, .6); }
.hand .card:disabled { cursor: default; }
.hand-empty { text-align: center; color: var(--muted); padding: 16px 0; margin: 0; }

.controls {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(30, 26, 22, .82), rgba(14, 12, 10, .82));
  border: 1px solid var(--line-soft);
  border-radius: 16px;
}
.controls .hint-txt { flex: 1; min-width: min(240px, 100%); font-size: 13px; }
.controls .hint-txt small { display: block; color: var(--muted); font-size: 12px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- okna nad stołem ---------- */
.ov {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 9, 8, .55), rgba(4, 3, 2, .85));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 12px max(12px, env(safe-area-inset-left, 0px));
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(1240px, 100%);
  height: min(94vh, 960px);
  height: min(94dvh, 960px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: linear-gradient(180deg, rgba(30, 26, 22, .97), rgba(16, 14, 12, .97));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 230, 190, .07);
  overflow: hidden;
}
.sheet.short { height: auto; max-height: min(90vh, 900px); grid-template-rows: auto minmax(0, 1fr); }
.sheet-head { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.sh-title { flex: 1; min-width: min(280px, 100%); }
.sh-title h3 { margin: 0; font: 500 26px/1.1 var(--f-display); letter-spacing: .05em; color: var(--gold-2); }
.sh-title p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; max-width: 80ch; }
.sh-top { --cw: 48px; }
.sh-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.lim { font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(196, 88, 75, .6); color: #f0aaa0; font-size: 13px; }
.lim.ok { border-color: var(--gold); color: var(--gold-2); }
.sheet-body { overflow: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.dsec h5 { margin: 0 0 8px; font: 500 11px var(--f-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.dmelds { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.r3row { display: flex; gap: 6px; --cw: clamp(40px, min(4vw, 7vh), 62px); }
.dmeld {
  --cw: clamp(44px, min(4.6vw, 8.4vh), 76px);
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px 8px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .02);
}
.dmeld .fan { display: flex; padding-top: 8px; }
.dmeld .fan .card { --cw: inherit; flex: none; }
.dmeld .fan .card + .card { margin-left: calc(var(--cw) * -.62); }
.dmeld.canasta { border-color: rgba(214, 178, 112, .4); background: rgba(214, 178, 112, .06); }
.dmeld.canasta.golden { border-color: var(--gold); background: rgba(214, 178, 112, .14); }
.dmeld.target { cursor: pointer; border-style: dashed; border-color: var(--gold); }
.dmeld.target:hover { background: rgba(214, 178, 112, .14); }
.dmeld .card.added { box-shadow: 0 0 0 2px #e7c983, 0 4px 10px rgba(0, 0, 0, .5); }
.dmeld .card.movable { cursor: pointer; }
.dmeld .card.movable:hover { transform: translateY(-4px); }
.dmeld .card.wsel { transform: translateY(-10px); box-shadow: 0 0 0 3px #f0d9a6, 0 0 18px rgba(240, 217, 166, .6); }
.meld-cap { display: flex; flex-direction: column; font-size: 11.5px; line-height: 1.25; }
.meld-cap b { font-weight: 600; }
.meld-cap span { color: var(--muted); }
.dmeld.canasta.red .meld-cap span { color: #ee9d92; }
.dmeld.canasta.golden .meld-cap span { color: var(--gold-2); }
.empty { color: var(--muted); font-size: 13px; margin: 0; }
.sheet-hand { border-top: 1px solid var(--line-soft); padding: 8px 20px 12px; background: rgba(0, 0, 0, .25); }
.sh-hand-head { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.sh-hand-head b { font: 600 16px var(--f-display); }
.sh-hand-head span { color: var(--muted); font-size: 12.5px; flex: 1; }
.sheet-hand .hand { --cw: clamp(44px, min(5.4vw, 10.5vh), 92px); }

.zoom {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 24px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 26, 22, .96), rgba(16, 14, 12, .96));
  border: 1px solid var(--line);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .7);
  max-width: 100%;
  text-align: center;
}
.zoom .card.big { --cw: min(240px, 60vw, calc(56vh * 5 / 7)); box-shadow: 0 30px 60px rgba(0, 0, 0, .6); animation: lift .2s ease; }
.zoom-info { margin: 0; font: 500 18px var(--f-display); letter-spacing: .04em; }
.zoom .note { max-width: 40ch; }
.zoom .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
@keyframes lift { from { transform: translateY(10px) scale(.96); opacity: 0; } }

.ov.recv { cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.recv-title { margin: 0; font: 500 30px var(--f-display); letter-spacing: .08em; color: var(--gold-2); }
.recv-cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 92vw; --cw: clamp(120px, min(17vw, 38vh), 240px); }
.recv-cards .card { box-shadow: 0 24px 50px rgba(0, 0, 0, .65); animation: deal .35s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--d) * 70ms); }
.recv-hint { margin: 0; color: var(--muted); font-size: 12.5px; }
@keyframes deal { from { transform: translateY(-40px) rotate(-6deg); opacity: 0; } }

/* ---------- okna komunikatów ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(6, 5, 4, .66);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  padding: 16px;
  overflow-y: auto;
}
.modal-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(30, 26, 22, .97), rgba(16, 14, 12, .97));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.modal-card.wide { width: min(760px, 100%); }
.modal-card h3 { margin: 0; font: 500 28px/1.15 var(--f-display); letter-spacing: .05em; color: var(--gold-2); text-wrap: balance; }
.modal-card .lead { margin: 0; }
.modal-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.big-count { font: 300 64px/1 var(--f-display); font-variant-numeric: tabular-nums; color: var(--gold-2); }
.winner { font: 500 24px var(--f-display); margin: 0; }
.tbl-wrap { overflow-x: auto; }
table.res { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.res th, .res td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
.res tbody th { text-align: left; font-weight: 600; }
.res thead th { color: var(--muted); font-weight: 500; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; }
.res thead th:first-child { text-align: left; }
.res tr.me th { color: var(--gold-2); }
.res .tot { color: var(--gold-2); font-weight: 600; }

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 8px; z-index: 60;
  width: min(480px, calc(100% - 32px));
  pointer-events: none;
}
.toast { background: #1d1a16; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: toast-in .2s ease; }
.toast.err { border-color: rgba(214, 100, 86, .9); background: #2a1512; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

body.offline::before {
  content: "Łączenie z serwerem…";
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  text-align: center; background: #7a3a2f; color: #fff; font-size: 12px;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 16px 4px;
}

/* ---------- telefony ---------- */
@media (max-width: 640px) {
  .brand-sm, .meta { display: none; }
  .turnbox { min-width: 0; padding: 6px 10px 8px; }
  .tb-time { font-size: 24px; }
  .tb-name { font-size: 14px; max-width: 120px; }
  .plate { max-width: 44%; padding-right: 10px; gap: 6px; }
  .pl-av { width: 32px; height: 32px; }
  .pl-stats { display: none; }
  .mytable { gap: 10px; padding: 6px 10px; }
  .mt-open { display: none; }
  .hand-zone { padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==========================================================
   STÓŁ NA ZDJĘCIU SALONU (public/img/room.jpg)
   ========================================================== */
.pgame { position: fixed; inset: 0; overflow: hidden; }
.p-left {
  position: absolute; z-index: 5;
  left: max(28px, env(safe-area-inset-left, 0px)); top: calc(22px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 14px;
  width: min(250px, 40vw);
}
.p-brand h1 {
  margin: 0;
  font: 300 clamp(26px, 3.2vw, 44px)/1 var(--f-display);
  letter-spacing: .38em;
  color: #efe3cb;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .6);
}
.p-brand .rule { justify-content: flex-start; margin: 10px 0 0 calc(50% - 90px); }
.p-left .turnbox { position: static; min-width: 0; }
.p-players { display: flex; flex-direction: column; gap: 8px; }
.pp {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: rgba(14, 12, 10, .55);
  border: 1px solid rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  text-align: left;
  min-width: 0;
}
.pp:hover { border-color: var(--line); }
.pp.turn { border-color: var(--gold); box-shadow: 0 0 22px rgba(227, 201, 147, .22); background: rgba(30, 24, 16, .7); }
.pp.me .pp-av { color: var(--gold-2); border-color: var(--gold); }
.pp.gone { opacity: .45; }
.pp-av {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, .25);
  background: radial-gradient(circle at 35% 30%, #3a3631, #16130f);
  color: #cfc6b6; font: 600 15px var(--f-display);
}
.pp-av svg { width: 18px; height: 18px; }
.pp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.pp-txt b { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-txt small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-pts { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--gold-2); }
.pp-pts.neg, .badge b.neg { color: #f08a7c; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: #6f6a62; }
.dot.on { background: #58c26a; box-shadow: 0 0 6px rgba(88, 194, 106, .7); }
.dot.bot { background: #8a8170; }

.p-right {
  position: absolute; z-index: 6;
  right: max(28px, env(safe-area-inset-right, 0px)); top: calc(22px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.gear-wrap { position: relative; }
.icon-btn.gear { width: 46px; height: 46px; background: rgba(14, 12, 10, .45); border-color: rgba(239, 227, 203, .55); color: #efe3cb; }
.icon-btn.gear svg { width: 22px; height: 22px; }
.gear-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 190px;
  display: flex; flex-direction: column;
  padding: 6px; border-radius: 14px;
  background: var(--glass-2); border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
}
.gear-menu button { background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 9px; }
.gear-menu button:hover { background: rgba(201, 168, 106, .12); color: var(--gold-2); }
.p-log { width: min(300px, 30vw); text-align: right; font-size: 11.5px; line-height: 1.4; color: var(--muted); text-shadow: 0 1px 3px #000; pointer-events: none; }
.p-log p { margin: 0; }
.p-log p:first-child { color: var(--ink); }
@media (max-width: 760px) { .p-log { display: none; } }

/* karty leżące na stole */
.tpile {
  position: absolute; z-index: 3;
  transform: translate(-50%, -50%);
  width: var(--tw);
  background: none; border: 0; padding: 0;
}
.tstack {
  position: relative; display: block;
  width: var(--tw); aspect-ratio: 5 / 7;
  transform: perspective(1100px) rotateX(63deg);
  transform-style: preserve-3d;
}
.tstack::before {
  content: ""; position: absolute; inset: 4% -2% -6% 6%;
  background: rgba(0, 0, 0, .65); filter: blur(7px); border-radius: 10px;
  transform: translateZ(-1px);
}
.tc { position: absolute; inset: 0; border-radius: 6%; overflow: hidden; transform: translateZ(calc(var(--i) * 2.4px)); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.tc svg { width: 100%; height: 100%; display: block; }
.tc.under { background: #e9e0cb; transform: translateZ(0) rotate(7deg) translate(4%, 2%); }
.tslot { position: absolute; inset: 0; border: 1px dashed rgba(214, 178, 112, .45); border-radius: 8px; }
.tpile .pile-n { position: absolute; left: 50%; top: calc(100% - 6%); transform: translateX(-50%); }
.tpile.live .tstack { filter: drop-shadow(0 0 12px rgba(240, 217, 166, .75)); }
.tpile.live .pile-n { border-color: var(--gold); color: var(--gold-2); }
.tpile.blocked .pile-n { color: #f0aaa0; }
.tpile:not(:disabled):hover .tstack { filter: drop-shadow(0 0 10px rgba(240, 217, 166, .55)); }

/* ręka w wachlarzu */
.hand-fan { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.fc {
  position: absolute; pointer-events: auto;
  aspect-ratio: 5 / 7;
  padding: 0; border: 0; background: none;
  border-radius: 7%;
  box-shadow: -3px 0 8px rgba(0, 0, 0, .35), 0 10px 22px rgba(0, 0, 0, .5);
  transition: translate .12s ease, box-shadow .12s ease;
}
.fc svg { width: 100%; height: 100%; display: block; }
.fc:hover { translate: 0 -12px; }
.fc.sel { box-shadow: 0 0 0 2px var(--gold-2), 0 16px 30px rgba(0, 0, 0, .6); }

/* mój stół – lewy dół */
.mypanel {
  position: absolute; z-index: 5;
  left: max(28px, env(safe-area-inset-left, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-width: min(30vw, 420px);
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px; border-radius: 16px; text-align: left;
  background: rgba(14, 12, 10, .62); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.mypanel:hover { border-color: var(--gold); }
.mp-head { display: flex; align-items: baseline; gap: 10px; }
.mp-head b { font: 600 17px var(--f-display); color: var(--gold-2); letter-spacing: .04em; }
.mp-head small { color: var(--muted); font-size: 11.5px; }
.mp-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }

/* akcje i wynik – prawy dół */
.p-actions {
  position: absolute; z-index: 5;
  right: max(28px, env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  max-width: min(32vw, 420px);
}
.p-hint { margin: 0; text-align: right; font-size: 12.5px; color: #e6dccb; text-shadow: 0 1px 3px #000; }
.p-hint span { display: block; color: var(--muted); }
.badge {
  padding: 10px 22px; border-radius: 999px;
  border: 1px solid rgba(239, 227, 203, .55);
  background: rgba(14, 12, 10, .5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 15px; color: #efe3cb; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pgame .strip-warn { position: absolute; top: calc(22px + env(safe-area-inset-top, 0px)); }

@media (max-width: 900px) {
  .p-left { width: min(200px, 42vw); gap: 10px; }
  .pp-txt small { display: none; }
  .mypanel { max-width: 44vw; }
  .p-actions { max-width: 50vw; }
}
@media (max-height: 700px) {
  .p-left { gap: 8px; }
  .p-brand h1 { font-size: 26px; }
  .pp { padding-block: 2px; }
  .pp-av { width: 28px; height: 28px; }
  .pp-txt small { display: none; }
}

/* przenoszenie dzikich kart w oknie stołu */
.dguide { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, .03); color: var(--muted); font-size: 13px; max-width: 90ch; }
.dguide.on { border-color: var(--gold); color: var(--ink); background: rgba(214, 178, 112, .1); }
.dmeld .card.movable { box-shadow: 0 0 0 2px rgba(240, 217, 166, .95), 0 0 14px rgba(240, 217, 166, .45); }

/* ==========================================================
   KANASTY: złota (ruchoma obwódka i błysk), czerwona, czarna
   ========================================================== */
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes goldspin { to { --ang: 360deg; } }
@keyframes goldsweep { 0% { transform: translateX(-120%) skewX(-18deg); } 60%, 100% { transform: translateX(220%) skewX(-18deg); } }
@keyframes goldpulse { 0%, 100% { box-shadow: 0 0 0 2px #e9cf8f, 0 0 10px rgba(240, 210, 140, .45); } 50% { box-shadow: 0 0 0 2px #fff1c4, 0 0 22px rgba(255, 220, 150, .85); } }

.dmeld.canasta.golden {
  position: relative;
  border-color: transparent;
  background: radial-gradient(120% 90% at 50% 0%, rgba(240, 205, 130, .22), rgba(120, 90, 30, .1) 70%);
  box-shadow: 0 0 26px rgba(232, 196, 120, .35);
  overflow: hidden;
}
.dmeld.canasta.golden::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 2px;
  background: conic-gradient(from var(--ang), #7d5d26, #f6dfa0, #c49a4f, #fff6d6, #9b7533, #f6dfa0, #7d5d26);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: goldspin 3.2s linear infinite;
  pointer-events: none;
}
.dmeld.canasta.golden::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 245, 210, .38), transparent);
  animation: goldsweep 3.6s ease-in-out infinite;
  pointer-events: none;
}
.dmeld.canasta.golden .meld-cap b, .dmeld.canasta.golden .meld-cap span {
  background: linear-gradient(90deg, #c9a35e, #fff1c4, #c9a35e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.dmeld.canasta.red {
  border-color: rgba(214, 84, 72, .8);
  background: linear-gradient(180deg, rgba(150, 32, 28, .22), rgba(70, 10, 10, .14));
  box-shadow: 0 0 18px rgba(200, 60, 50, .28), inset 0 0 0 1px rgba(255, 140, 120, .12);
}
.dmeld.canasta.red .meld-cap span { color: #f2a096; font-weight: 600; }

.dmeld.canasta.black {
  border-color: rgba(205, 205, 215, .4);
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(0, 0, 0, .12));
}
.dmeld.canasta.black .meld-cap span { color: #d6d3cc; }

/* małe kanasty na panelu „Mój stół” */
.mini.canasta.golden .mini-card .card { animation: goldpulse 2s ease-in-out infinite; }
.mini.canasta.golden small { color: #f2dba0; font-weight: 600; }
.mini.canasta.red .mini-card .card { box-shadow: 0 0 0 2px #d0564a, 0 0 10px rgba(208, 86, 74, .5); }
.mini.canasta.red small { color: #f2a096; font-weight: 600; }
.mini.canasta.black .mini-card .card { box-shadow: 0 0 0 2px rgba(210, 210, 220, .55); }

/* efekt ułożenia kanasty */
.celebrate { position: fixed; inset: 0; z-index: 80; pointer-events: none; display: grid; place-items: center; }
.celebrate canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.celebrate .cb-text { position: relative; text-align: center; animation: cbin 3.2s ease both; }
.celebrate h2 {
  margin: 0; font: 500 clamp(40px, 7vw, 96px)/1 var(--f-display); letter-spacing: .22em; padding-left: .22em;
  background: linear-gradient(100deg, #9b7533 10%, #fff3cf 30%, #d9b46a 45%, #fff8e0 55%, #b8904a 75%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, .7));
  animation: cbshine 2.4s linear infinite;
}
.celebrate p { margin: 14px 0 0; font: 500 clamp(16px, 2vw, 22px) var(--f-ui); color: #f5e6c2; text-shadow: 0 2px 12px #000; letter-spacing: .06em; }
.celebrate.red h2 { background: linear-gradient(100deg, #8e2a22, #ffb3a6 40%, #d0564a 60%, #8e2a22); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; font-size: clamp(30px, 5vw, 64px); }
.celebrate::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(40% 35% at 50% 50%, rgba(255, 220, 150, .35), transparent 70%);
  animation: cbflash 3.2s ease both;
}
.celebrate.red::before { background: radial-gradient(35% 30% at 50% 50%, rgba(220, 80, 70, .3), transparent 70%); }
@keyframes cbin { 0% { opacity: 0; transform: scale(.7); } 12% { opacity: 1; transform: scale(1.06); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.04); } }
@keyframes cbshine { to { background-position: -250% 0; } }
@keyframes cbflash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .dmeld.canasta.golden::after { display: none; }
}

.skip-note { color: var(--gold-2) !important; }

/* znaczki kanast przy graczach */
.cbadges { display: flex; align-items: center; gap: 6px; flex: none; }
.cb-item { display: inline-flex; align-items: flex-start; gap: 1px; perspective: 80px; }
.cb-item sup { font-size: 10px; color: var(--gold-2); line-height: 1; }
.spin {
  display: block; width: 13px; height: 18px; border-radius: 2.5px;
  animation: cardspin 2.6s linear infinite;
  border: 1px solid rgba(255, 255, 255, .5);
}
.spin.gold {
  background: linear-gradient(135deg, #8a6a33, #fff1c4 42%, #d6b066 58%, #8a6a33);
  box-shadow: 0 0 9px rgba(255, 215, 140, .85);
}
.spin.red {
  background: linear-gradient(135deg, #6e1712, #ff9d8f 42%, #c8463b 58%, #6e1712);
  box-shadow: 0 0 8px rgba(225, 80, 70, .75);
  animation-duration: 3.4s;
}
@keyframes cardspin { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* okno stołu nie może być szersze niż ekran; ręka przewija się, gdy kart jest dużo */
.sheet { grid-template-columns: minmax(0, 1fr); }
.sheet-head, .sheet-body, .sheet-hand { min-width: 0; }
.sheet-hand .hand-zone { overflow-x: auto; overflow-y: hidden; padding-bottom: 10px; scrollbar-width: thin; scrollbar-color: var(--gold) rgba(255, 255, 255, .08); }
.sheet-hand .hand { width: max-content; min-width: 100%; }
.sheet-hand .hand-zone::-webkit-scrollbar { height: 10px; }
.sheet-hand .hand-zone::-webkit-scrollbar-track { background: rgba(255, 255, 255, .06); border-radius: 6px; }
.sheet-hand .hand-zone::-webkit-scrollbar-thumb { background: linear-gradient(90deg, #a8864c, #e3c993); border-radius: 6px; }

/* ==========================================================
   KONIEC GRY: podium i tabela końcowa
   ========================================================== */
.end-modal { cursor: pointer; z-index: 70; background: radial-gradient(ellipse at 50% 40%, rgba(20, 16, 10, .72), rgba(4, 3, 2, .9)); }
.podium-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; width: min(820px, 100%); }
.end-title {
  margin: 0; text-align: center;
  font: 500 clamp(34px, 5vw, 62px)/1.05 var(--f-display); letter-spacing: .08em;
  background: linear-gradient(100deg, #9b7533 10%, #fff3cf 35%, #d9b46a 50%, #fff8e0 62%, #b8904a 85%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: cbshine 3s linear infinite;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, .6));
}
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 14px; width: 100%; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; animation: podin .7s cubic-bezier(.2, .8, .2, 1) both; }
.pod.p1 { animation-delay: .35s; }
.pod.p2 { animation-delay: .15s; }
.pod.p3 { animation-delay: .5s; }
@keyframes podin { from { opacity: 0; transform: translateY(40px); } }
.pod .crown { width: 46px; height: 46px; color: #f2d48e; filter: drop-shadow(0 0 12px rgba(255, 215, 140, .8)); animation: crownbob 2.4s ease-in-out infinite; }
@keyframes crownbob { 50% { transform: translateY(-5px) rotate(-4deg); } }
.pod-name { font: 600 clamp(16px, 2vw, 22px) var(--f-display); text-align: center; overflow-wrap: anywhere; }
.pod.me .pod-name { color: var(--gold-2); }
.pod-pts { font-variant-numeric: tabular-nums; color: var(--muted); }
.pod-block {
  width: 100%; display: grid; place-items: center;
  border-radius: 12px 12px 4px 4px;
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 20px 40px rgba(0, 0, 0, .5);
}
.pod-block span { font: 500 clamp(36px, 5vw, 64px) var(--f-display); color: rgba(255, 255, 255, .85); text-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.pod.p1 .pod-block { height: clamp(150px, 26vh, 230px); background: linear-gradient(180deg, #e6c47c, #8a6a33); }
.pod.p2 .pod-block { height: clamp(110px, 19vh, 170px); background: linear-gradient(180deg, #d9dde3, #7d838c); }
.pod.p3 .pod-block { height: clamp(80px, 14vh, 125px); background: linear-gradient(180deg, #d79a62, #7a4a22); }
.pod.empty { visibility: hidden; }

.medal {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font: 700 14px var(--f-ui); color: #1b150c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 0 2px rgba(0, 0, 0, .25);
}
.pod .medal { width: 46px; height: 46px; font-size: 20px; }
.medal.gold { background: radial-gradient(circle at 35% 30%, #fff3cf, #e0b860 55%, #9b7533); box-shadow: 0 0 16px rgba(255, 210, 120, .7), inset 0 1px 0 #fff; }
.medal.silver { background: radial-gradient(circle at 35% 30%, #ffffff, #c4c9d0 55%, #7d838c); box-shadow: 0 0 12px rgba(220, 225, 235, .5), inset 0 1px 0 #fff; }
.medal.bronze { background: radial-gradient(circle at 35% 30%, #ffd9b3, #c98a4b 55%, #7a4a22); box-shadow: 0 0 12px rgba(220, 150, 90, .5), inset 0 1px 0 #fff; }
.medal.none { background: rgba(255, 255, 255, .08); color: var(--muted); box-shadow: none; }
.pp .medal { width: 24px; height: 24px; font-size: 12px; }

.final-card { width: min(980px, 100%); cursor: pointer; }
.res.final td.pl { width: 40px; }
.res.final td.neg { color: #f08a7c; }
.res.final tr.gone { opacity: .5; }
.res.final tbody tr:first-child th { color: var(--gold-2); }
.end-hint { margin: 0; color: var(--gold-2); font-size: 13px; text-align: center; letter-spacing: .04em; animation: hintpulse 2s ease-in-out infinite; }
@keyframes hintpulse { 50% { opacity: .55; } }
.celebrate.confetti::before { display: none; }
.res.final thead th:nth-child(2) { text-align: left; }

/* ==========================================================
   TELEFON (szerokość < 720 px)
   ========================================================== */
.pgame.m .m-top {
  position: absolute; z-index: 6; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(10, 9, 8, .85), rgba(10, 9, 8, 0));
}
.m-brand { font: 300 18px/1 var(--f-display); letter-spacing: .3em; color: #efe3cb; }
.m-turn {
  flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: rgba(14, 12, 10, .7); border: 1px solid var(--line-soft);
}
.m-turn.mine { border-color: var(--gold); }
.m-turn small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-turn b { font: 500 20px/1 var(--f-display); color: var(--gold-2); font-variant-numeric: tabular-nums; }
.m-turn b.sm { font: 500 12px var(--f-ui); color: var(--muted); }
.m-turn b.low { color: #f08a7c; }
.pgame.m .icon-btn.gear { width: 38px; height: 38px; }
.pgame.m .gear-menu { right: 0; }

.m-players {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(56px + env(safe-area-inset-top, 0px));
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 2px max(12px, env(safe-area-inset-left, 0px)) 6px;
}
.m-players::-webkit-scrollbar { display: none; }
.pgame.m .pp { flex: none; padding: 3px 10px 3px 3px; gap: 6px; max-width: 46vw; }
.pgame.m .pp-av { width: 26px; height: 26px; font-size: 13px; }
.pgame.m .pp-av svg { width: 14px; height: 14px; }
.pgame.m .pp-txt b { font-size: 12.5px; }
.pgame.m .pp-txt small { display: block; font-size: 10px; }
.pgame.m .pp-pts { font-size: 12px; }
.pgame.m .dot { display: none; }
.pgame.m .spin { width: 10px; height: 14px; }
.m-score {
  flex: none; align-self: center; padding: 6px 10px; border-radius: 999px;
  border: 1px solid rgba(239, 227, 203, .4); background: rgba(14, 12, 10, .55);
  font-size: 12px; color: #efe3cb; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.m-score .neg { color: #f08a7c; }

.pgame.m .tpile .pile-n { font-size: 11px; padding: 1px 8px; }
.m-hint {
  position: absolute; z-index: 4; left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  margin: 0; text-align: center; font-size: 11.5px; color: #e6dccb; text-shadow: 0 1px 3px #000;
  pointer-events: none; transform: translateY(-100%);
  display: none;
}
.pgame.m .fc { box-shadow: -2px 0 5px rgba(0, 0, 0, .35), 0 6px 14px rgba(0, 0, 0, .5); }
.pgame.m .fc:hover { translate: none; }

.m-bar {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: 0;
  display: flex; gap: 8px; align-items: center;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(0deg, rgba(10, 9, 8, .95), rgba(10, 9, 8, .75));
  border-top: 1px solid var(--line-soft);
}
.m-bar .btn { padding: 10px 14px; font-size: 13px; white-space: nowrap; }
.m-bar .m-table { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; padding: 6px 14px; margin-right: auto; }
.m-bar .m-table small { font-size: 10.5px; color: var(--muted); }

@media (max-width: 720px) {
  .sheet { height: 100%; height: 100dvh; border-radius: 0; }
  .ov { padding: 0; }
  .sheet-head { padding: 10px 14px; }
  .sh-title h3 { font-size: 21px; }
  .sh-title p { font-size: 11.5px; }
  .sheet-body { padding: 10px 14px; }
  .dmeld { --cw: 44px; padding: 6px; }
  .sheet-hand { padding: 6px 14px 10px; }
  .sheet-hand .hand { --cw: 50px; }
  .zoom .card.big { --cw: min(200px, 56vw); }
  .podium { gap: 6px; }
  .pod .medal { width: 34px; height: 34px; font-size: 15px; }
  .pod-name { font-size: 14px; }
}
