/* Gra karciana: stół, gracze, karty, ręka, prawy panel, okna, telefon, Rush i Duo. */

#app {
  display: grid;
  grid-template-columns: 220px 1fr var(--right-w);
  grid-template-rows: var(--opp-hand-h) 1fr var(--hand-h);
  grid-template-areas: "opphand opphand right" "left board right" "hand hand right";
  gap: 8px;
  padding: 8px;
  height: calc(100vh - var(--topbar-h));
}

#left { grid-area: left; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-height: 0; }
#board { grid-area: board; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#right { grid-area: right; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#bottom { grid-area: hand; display: flex; gap: 8px; min-width: 0; }

.panel, .player-info {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.panel-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 8px 0 6px; }

/* ---------- Gracze ---------- */
.player-info { transition: box-shadow .2s; }
.player-info.active { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(var(--gold-rgb), .35); }
.pi-top { display: flex; justify-content: space-between; align-items: center; }
.pi-name { font-weight: 700; font-size: 18px; }
.pi-passed { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.pi-score { font-size: 44px; font-weight: 800; color: var(--gold); line-height: 1.1; }
.pi-meta { color: var(--muted); font-size: 13px; }
.gems { display: flex; gap: 6px; margin: 4px 0; }
.gem { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8a7a, #b3201a); box-shadow: 0 0 6px #d33; }
.gem.lost { background: #3a2a52; box-shadow: none; }
.pi-donate { color: var(--gold); font-weight: 600; }
.peek { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.badge-pass { background: #5a1a7a; border: 1px solid var(--twitch); padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }

#round { font-size: 20px; font-weight: 700; color: var(--gold); text-align: center; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Plansza ---------- */
.side { display: flex; flex-direction: column; gap: 3px; }
#divider { height: 4px; margin: 2px 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

/* Czyj ruch: stół świeci (ja – złoto, rywal – róż). */
.side { border-radius: 12px; transition: box-shadow .35s, background-color .35s; }
#app.turn-me #me-rows { background-color: rgba(var(--gold-rgb), .05); animation: turn-glow-me 1.6s ease-in-out infinite alternate; }
#app.turn-opp #opp-rows { background-color: rgba(255, 80, 130, .05); animation: turn-glow-opp 1.6s ease-in-out infinite alternate; }
#app.turn-me #hand { box-shadow: inset 0 0 0 2px rgba(var(--gold-rgb), .55); border-radius: 14px; }
@keyframes turn-glow-me {
  from { box-shadow: 0 0 0 2px rgba(var(--gold-rgb), .55), 0 0 12px rgba(var(--gold-rgb), .18); }
  to   { box-shadow: 0 0 0 2px rgba(var(--gold-rgb), .95), 0 0 28px rgba(var(--gold-rgb), .45); }
}
@keyframes turn-glow-opp {
  from { box-shadow: 0 0 0 2px rgba(255, 80, 130, .45), 0 0 12px rgba(255, 80, 130, .15); }
  to   { box-shadow: 0 0 0 2px rgba(255, 80, 130, .9), 0 0 28px rgba(255, 80, 130, .4); }
}
#divider { position: relative; z-index: 3; }
#divider:not([data-turn=""])[data-turn]::after {
  content: attr(data-turn); position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  padding: 2px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 800; white-space: nowrap;
  background: var(--gold); color: #2a0a40; box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
#app.turn-opp #divider::after { background: #e0446a; color: #fff; }
@media (prefers-reduced-motion: reduce) {
  #app.turn-me #me-rows { animation: none; box-shadow: 0 0 0 2px rgba(var(--gold-rgb), .85), 0 0 20px rgba(var(--gold-rgb), .3); }
  #app.turn-opp #opp-rows { animation: none; box-shadow: 0 0 0 2px rgba(255, 80, 130, .8), 0 0 20px rgba(255, 80, 130, .3); }
}

.zone-Stream { --zc: var(--stream); }
.zone-Offstream { --zc: var(--offstream); }
.zone-RZeczy { --zc: var(--rzeczy); }
.zone-none { --zc: #9a8a70; }

.row {
  position: relative;
  height: var(--row-h);
  display: grid;
  grid-template-columns: 48px max(64px, calc(var(--card-w) * .8 + 8px)) minmax(0, 1fr); /* minmax(0) – karty nie rozpychają rzędu */
  align-items: center;
  background: rgba(10, 3, 22, .5);
  border: 1px solid var(--line);
  border-left: 4px solid var(--zc);
  border-radius: 10px;
  transition: box-shadow .15s, background .15s;
}
.row.target { cursor: pointer; background: rgba(var(--gold-rgb), .08); box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(var(--gold-rgb), .45); }
.row-score {
  width: 34px; height: 34px; margin: 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--zc);
  font-weight: 800;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .4);
}
.status-slot {
  height: calc(var(--card-h) * .8);
  width: max(56px, calc(var(--card-w) * .8));
  border: 1px dashed var(--line);
  border-radius: 5px;
  display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 4px;
  padding: 3px;
  color: var(--line);
  font-size: 10px;
  font-weight: 700;
}
.status-slot.empty { align-items: center; letter-spacing: .5px; font-size: 9px; }
.status-slot .status { border-radius: 4px; padding: 2px 1px; text-align: center; font-size: 10.5px; color: #fff; cursor: help; white-space: nowrap; overflow: hidden; }
.status-slot .status.buff { background: rgba(46, 160, 67, .85); box-shadow: 0 0 8px rgba(46, 160, 67, .6); }
.status-slot .status.debuff { background: rgba(200, 55, 55, .85); box-shadow: 0 0 8px rgba(200, 55, 55, .6); }
.modal.deck-pick .cards { flex-wrap: wrap; justify-content: center; max-height: 60vh; overflow-y: auto; }
.row-label { position: absolute; right: 10px; top: 3px; font-size: 11px; letter-spacing: 2px; color: var(--zc); font-weight: 700; opacity: .8; pointer-events: none; }
.row-cards { display: flex; gap: 4px; justify-content: center; align-items: center; height: 100%; padding: 0 8px; min-width: 0; }
.row-cards .card.slot-closed { display: none; } /* karta jeszcze na środku (GameAnim.OpenSlot) */

/* ---------- Karta ---------- */
/* Ramka to tło-gradient karty, obrazek leży w środku z wcięciem. */
.card {
  --frame: linear-gradient(145deg, #d9d4cc, #8a857d 35%, #4b4741 60%, #b9b3aa);
  --plate: #b9b3aa;
  position: relative;
  flex: none;
  width: var(--card-w);
  height: var(--card-h);
  padding: .2em;
  border-radius: .5em;
  background: var(--frame);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .65);
  display: flex; flex-direction: column; justify-content: flex-end;
  overflow: hidden;
  font-size: calc(var(--card-h) * .11);
  user-select: none;
  transition: transform .12s, box-shadow .12s;
}
/* Ramka = strefy (--frame z Cards.El), jakość = tło kółka z atakiem; Elita – pulsująca złota poświata. */
.card.cat-Elita {
  box-shadow: 0 0 0 .12em #ffe27a, 0 0 .9em .15em rgba(var(--gold-rgb), .75), 0 0 2em rgba(var(--gold-rgb), .35), 0 2px 6px rgba(0, 0, 0, .65);
  animation: elite-glow 2.4s ease-in-out infinite;
}
.card.cat-Elita::before {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  border-radius: inherit; border: .14em solid #ffd84a;
  box-shadow: inset 0 0 .7em rgba(var(--gold-rgb), .75);
}
/* Błysk tylko przy wyborze nagrody. */
.card.cat-Elita[data-action="reward-pick"]::after, .reward-picker .card.cat-Elita::after {
  content: ''; position: absolute; inset: -50%; z-index: 4; pointer-events: none;
  background: linear-gradient(115deg, transparent 43%, rgba(255, 243, 180, .6) 50%, transparent 57%);
  mix-blend-mode: screen;
  animation: elite-shine 3.6s ease-in-out infinite;
}
@keyframes elite-glow {
  50% { box-shadow: 0 0 0 .12em #fff1a8, 0 0 1.4em .3em rgba(var(--gold-rgb), .95), 0 0 3em rgba(var(--gold-rgb), .5), 0 2px 6px rgba(0, 0, 0, .65); }
}
@keyframes elite-shine { 0%, 55% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }
/* Zaznaczona i pokazywana na środku mają własną poświatę. */
#hand .card.selected.cat-Elita, .card.presented.cat-Elita { animation: none; }
/* W menu są dziesiątki kart – animacja w każdej klatce obciążała procesor. */
#screen-menu .card.cat-Elita, #screen-menu .card.any-zone, .card-detail .card { animation: none; }
@media (prefers-reduced-motion: reduce) { .card.cat-Elita { animation: none; } .card.cat-Elita::after { display: none; } }
/* Karta do każdej strefy – tęczowa, płynąca ramka. */
.card.any-zone {
  --frame: linear-gradient(135deg, #ff4d4d, #ffa64d, #fff04d, #5cff7a, #4dc8ff, #8f6bff, #ff4dd2, #ff4d4d);
  --plate: #f0e6ff;
  background-size: 300% 300%;
  animation: rainbow 6s linear infinite;
}
@keyframes rainbow { from { background-position: 0% 50%; } to { background-position: 300% 50%; } }
@media (prefers-reduced-motion: reduce) { .card.any-zone { animation: none; } }

.card .art {
  position: absolute; inset: .2em;
  border-radius: .35em;
  display: grid; place-items: center;
  padding-bottom: 1.6em;
  font-size: 2.4em;
  background-color: #1a0a30;
  background-size: cover; background-position: center top;
}
.card .art::after {
  content: ""; position: absolute; inset: 55% 0 0; border-radius: inherit;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
}

.card .power {
  position: absolute; top: .3em; left: .3em; z-index: 2;
  width: 1.9em; height: 1.9em;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #ffffff, #c9c9c9 55%, #8c8c8c);
  color: #1b130d;
  font-weight: 900; font-size: 1.05em;
  border: .12em solid rgba(0, 0, 0, .55);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.card.cat-Elita .power        { background: radial-gradient(circle at 35% 30%, #fff6c8, #e6b84a 55%, #9a6e10); }
.card.cat-EnemyAbility .power { background: radial-gradient(circle at 35% 30%, #ff9a8a, #c8352a 55%, #6a120c); color: #fff; text-shadow: 0 1px 2px #000; }
.card.cat-Boost .power        { background: radial-gradient(circle at 35% 30%, #b4f5a8, #3f9a3a 55%, #164d12); color: #fff; text-shadow: 0 1px 2px #000; }
.card.cat-Ability .power      { background: radial-gradient(circle at 35% 30%, #d4c6ff, #6a4fd0 55%, #2a1a70); color: #fff; text-shadow: 0 1px 2px #000; }
.card .power.buff   { border-color: #2fff5a; box-shadow: 0 0 .35em #2fff5a, 0 1px 3px rgba(0, 0, 0, .7); }
.card .power.debuff { border-color: #ff3a2a; box-shadow: 0 0 .35em #ff3a2a, 0 1px 3px rgba(0, 0, 0, .7); }

.card .gold {
  position: absolute; top: .3em; right: .3em; z-index: 2;
  min-width: 1.9em; height: 1.9em; padding: 0 .25em;
  border-radius: 1em;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff1a8, #e2a92a 60%, #a8740e);
  color: #3a2502;
  font-weight: 900; font-size: .85em;
  border: .1em solid #7a5208;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}

.card .foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; align-items: flex-end; gap: .2em;
  margin: 0 .15em .2em;
}
.card .kind {
  margin-left: auto;
  font-size: .6em; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
  padding: .1em .45em;
  border-radius: .35em;
  background: rgba(20, 6, 38, .88);
  color: #fff;
  border: .12em solid var(--plate);
  white-space: nowrap;
}
.card .name {
  position: relative; z-index: 1;
  padding: .15em .2em;
  border-radius: 0 0 .35em .35em;
  background: rgba(16, 5, 30, .9);
  border-top: .12em solid var(--plate);
  text-align: center;
  font-size: .78em; font-weight: 700;
  line-height: 1.15;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card.target { cursor: pointer; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 2px var(--gold); } to { box-shadow: 0 0 0 3px var(--gold), 0 0 14px var(--gold); } }

.mini .card { --card-h: 54px; --card-w: 39px; }
.mobile-only, #rotate-hint { display: none; }

/* ---------- Ręka ---------- */
#hand {
  flex: 1;
  display: flex; gap: 6px; align-items: center; justify-content: center;
  padding: 8px;
  background: rgba(10, 3, 22, .55);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-width: 0;
}
#hand .card { --card-h: calc(var(--hand-h) - 28px); --card-w: calc(var(--card-h) * .72); cursor: pointer; }
#hand .card:hover { transform: translateY(-6px); z-index: 5; }
#hand .card.selected { z-index: 6; transform: translateY(-16px) scale(1.06); box-shadow: 0 0 0 3px var(--gold), 0 0 20px var(--gold); }

.card.presented { box-shadow: 0 0 0 3px var(--gold), 0 0 30px rgba(var(--gold-rgb), .8), 0 12px 30px rgba(0, 0, 0, .8); }

.card-back {
  position: relative; flex: none;
  width: 34px; height: 48px;
  border-radius: 5px;
  border: 2px solid var(--gold);
  background:
    radial-gradient(circle at 50% 50%, rgba(var(--gold-rgb), .3) 0 30%, transparent 32%),
    repeating-linear-gradient(45deg, #3d1475 0 5px, #240a48 5px 10px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .6);
}
.card-back::after {
  content: "SM"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 900; color: var(--gold); text-shadow: 0 1px 2px #000;
}
#opp-hand {
  grid-area: opphand;
  display: flex; gap: 6px; align-items: center; justify-content: center;
  padding: 6px 8px;
  background: rgba(10, 3, 22, .55);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-width: 0;
}
#opp-hand .card-back {
  --h: calc(var(--opp-hand-h) - 14px);
  height: var(--h); width: calc(var(--h) * .72);
  border-radius: 7px;
}
#opp-hand .card-back::after { font-size: calc(var(--h) * .22); }
#opp-hand .card { --card-h: calc(var(--opp-hand-h) - 14px); --card-w: calc(var(--card-h) * .72); }
#opp-hand.revealed { box-shadow: inset 0 0 0 1px var(--gold); }
.deck { display: flex; align-items: center; gap: 10px; }
.card-back.stack { box-shadow: 2px 2px 0 #240a48, 3px 3px 0 var(--gold), 5px 5px 0 #240a48, 6px 6px 0 var(--gold), 0 6px 10px rgba(0, 0, 0, .6); }
.card-back.stack::after { content: none; }
.card-back.empty { opacity: .25; box-shadow: none; }
.deck-count {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 15px; font-weight: 900; color: #fff; text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
#hand.disabled .card { cursor: default; filter: saturate(.7); }
#actions { width: 190px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
/* Długa podpowiedź przewija się w miejscu, zamiast wchodzić na przyciski. */
#hint { color: var(--muted); font-size: 13px; min-height: 36px; flex: 0 1 auto; overflow-y: auto; }
#turn-clock { font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; text-align: center; }
#turn-clock.mine { color: var(--gold); border-color: rgba(var(--gold-rgb), .6); }
#turn-clock.urgent { color: #fff; background: #b3263a; border-color: #ff5a6e; animation: clock-pulse 1s ease-in-out infinite; }
@keyframes clock-pulse { 50% { transform: scale(1.06); } }
/* Okno zasłania pasek akcji – zegar wisi nad oknem. */
body:has(#overlay:not(.hidden)) #turn-clock:not(.hidden) { position: fixed; top: 74px; left: 0; right: 0; margin: auto; width: max-content; z-index: 95; background: var(--panel-solid); }

button {
  background: var(--twitch);
  color: #fff;
  border: none;
  border-radius: 26px;
  padding: 9px 20px;
  font: 600 15px "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(145, 70, 255, .35);
  transition: filter .15s, transform .15s;
}
button:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
#btn-buy { font-size: 13px; padding: 7px 12px; }
#btn-pass { background: var(--gold); color: #2a0a40; box-shadow: 0 4px 12px rgba(var(--gold-rgb), .3); }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Prawy panel ---------- */
.piles { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.piles button { padding: 4px 10px; font-size: 13px; }
#preview { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#preview .card { --card-w: calc(var(--right-w) * .62); --card-h: calc(var(--card-w) / .72); flex: none; }
#preview h3 { margin: 2px 0 0; font-size: 20px; color: var(--gold); text-align: center; }
.ptags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ptag { padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, .1); }
.ptag.cat-Elita { background: linear-gradient(#ffe27a, #c99512); color: #2a1a00; }
.ptag.cat-Standard { background: linear-gradient(#f2f2f2, #a5a5a5); color: #1a1a1a; }
.ptag.cat-EnemyAbility { background: #c8352a; }
.ptag.cat-Boost { background: #3f9a3a; }
.ptag.cat-Ability { background: #6a4fd0; }
.ptag.zone { background: var(--zc); }
.ptag.zone.any { background: linear-gradient(90deg, #ff4d4d, #ffa64d, #e6d22a, #3fbf5a, #4dc8ff, #8f6bff); }
.pstats { display: flex; gap: 8px; justify-content: center; }
.pstat { padding: 3px 12px; border-radius: 10px; background: rgba(255, 255, 255, .08); font-size: 15px; font-weight: 800; }
.pstat.gold { color: var(--gold); }
.psection { align-self: stretch; border-radius: 12px; padding: 8px 10px; }
.psection-title { font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 4px; }
.psection.rules { background: rgba(145, 70, 255, .16); border: 1px solid rgba(145, 70, 255, .45); }
.psection.rules .psection-title { color: #c9a8ff; }
.prule + .prule { margin-top: 6px; }
.prule-head { font-weight: 800; font-size: 14px; color: #fff; }
.prule-desc { font-size: 13.5px; line-height: 1.4; color: #eee6ff; }
.pnote { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.psection.flavor { background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .08); }
.psection.flavor .psection-title { color: var(--muted); }
.pflavor { font-style: italic; font-size: 13.5px; line-height: 1.4; color: #d8cbe9; }
.preview-empty { color: var(--muted); font-size: 13px; margin: auto; text-align: center; }
#log { height: 190px; overflow-y: auto; font-size: 12.5px; line-height: 1.45; }
#log .who-0 { color: #9fd18b; }
#log .who-1 { color: #f08f84; }
#log .sys { color: var(--gold); font-weight: 600; }

/* ---------- Okna ---------- */
#overlay { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; background: rgba(8, 2, 18, .8); }
.modal { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); padding: 20px 28px; max-width: 92vw; max-height: 92vh; overflow-y: auto; text-align: center; }
.modal h2 { margin: 0 0 6px; color: var(--gold); }
.modal .cards { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0 8px; }
.modal .card { --card-h: 150px; --card-w: 108px; }
.modal .card[data-action] { cursor: pointer; }
.modal .card[data-action]:hover { transform: translateY(-5px); box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(var(--gold-rgb), .5); }
.modal-desc { color: var(--muted); min-height: 20px; font-size: 14px; }

/* Wybór nagrody: stały rozmiar podglądu, żeby okno nie skakało. */
.preview-box.reward-preview {
  position: static; display: grid; grid-template-columns: 150px 1fr; grid-auto-rows: min-content;
  column-gap: 16px; row-gap: 0; align-items: start; justify-items: start;
  width: min(560px, 84vw); height: 320px; overflow-y: auto; margin: 8px auto 0; text-align: left;
}
.preview-box.reward-preview > .card { --card-w: 150px; --card-h: 208px; grid-column: 1; grid-row: 1 / span 20; }
.preview-box.reward-preview > :not(.card) { grid-column: 2; width: 100%; }
.preview-box.reward-preview > :not(.card) ~ :not(.card) { margin-top: 8px; }
.preview-box.reward-preview .ptags, .preview-box.reward-preview .pstats { justify-content: flex-start; }
.preview-box.reward-preview h3 { text-align: left; margin: 0; }
.reward-cards .card.active { transform: translateY(-5px); box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(var(--gold-rgb), .5); }
.modal .buttons { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.modal table { margin: 12px auto; border-collapse: collapse; }
.modal td, .modal th { padding: 4px 14px; border-bottom: 1px solid var(--line); }

#banner {
  position: fixed; left: 50%; top: 40%; z-index: 95;
  transform: translate(-50%, -50%);
  padding: 22px 48px;
  background: rgba(28, 11, 54, .96);
  border: 2px solid var(--gold);
  border-radius: 18px;
  text-align: center;
  pointer-events: none;
}
.banner-title { font-size: 28px; font-weight: 800; color: var(--gold); }
.banner-score { font-size: 22px; margin-top: 6px; }

#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: rgba(28, 11, 54, .96); border: 1px solid var(--line); border-radius: 20px; padding: 8px 16px; font-size: 14px; transition: opacity .5s; }
.toast.opp { border-color: #c4544a; }
.toast.error { border-color: #e0443a; background: rgba(70, 12, 30, .96); }
.toast.fade { opacity: 0; }


/* ---------- Full HD (1600–2199 px) ---------- */
@media (min-width: 1600px) and (max-width: 2199px) {
  :root { --right-w: clamp(270px, 22vw, 440px); }
  #app { grid-template-columns: 250px 1fr var(--right-w); }
  #topbar .topbar-title { font-size: 15px; }
  .pi-name { font-size: 20px; }
  .pi-meta { font-size: 15px; }
  .panel-title { font-size: 13.5px; }
  #round { font-size: 22px; }
  .muted, #hint { font-size: 15px; }
  #turn-clock { font-size: 15px; }
  #log { height: 220px; font-size: 14.5px; }
  .piles { font-size: 15px; }
  .piles button, #btn-buy { font-size: 14.5px; }
  .ptag { font-size: 13.5px; }
  .psection-title { font-size: 12.5px; }
  .prule-desc, .pflavor { font-size: 15.5px; }
  .pnote { font-size: 14px; }
  .prule-head { font-size: 15.5px; }
  .preview-empty { font-size: 15px; }
  .row-score { width: 36px; height: 36px; font-size: 17px; }
  .row-label { font-size: 12.5px; }
  .status-slot.empty { font-size: 10.5px; }
  .status-slot .status { font-size: 12px; }
  .toast { font-size: 15px; }
}

/* ---------- Duże ekrany (1440p, 4K) ---------- */
@media (min-width: 2200px) {
  :root { --right-w: clamp(270px, 20vw, 560px); --topbar-h: 60px; }
  #app { grid-template-columns: 300px 1fr var(--right-w); }
  #topbar .logo { font-size: 28px; }
  #topbar .topbar-title { font-size: 17px; }
  .pi-name { font-size: 24px; }
  .pi-score { font-size: 60px; }
  .pi-meta { font-size: 17px; }
  .gem { width: 20px; height: 20px; }
  #round { font-size: 26px; }
  .muted, #hint { font-size: 16px; }
  #log { height: 260px; font-size: 16px; }
  .piles { font-size: 17px; }
  .piles button, #btn-buy { font-size: 16px; }
  #actions { width: 250px; }
  button { font-size: 18px; }
  .prule-desc, .pflavor { font-size: 16.5px; }
  .prule-head { font-size: 17px; }
  #preview h3 { font-size: 26px; }
  .row-score { width: 44px; height: 44px; font-size: 20px; }
  .row-label { font-size: 14px; }
  .status-slot.empty { font-size: 12px; }
  .status-slot .status { font-size: 14px; }
}

/* ---------- Telefon (pionowo): jedna kolumna, reszta w wysuwanym arkuszu ---------- */
@media (max-width: 760px) {
  :root {
    --topbar-h: 44px;
    --strip-h: 34px;
    --actions-h: 44px;
    --reveal-h: 0px;
    --hand-h: 74px; /* zwinięta ręka */
    --row-h: calc((100dvh - var(--topbar-h) - 2 * var(--strip-h) - var(--actions-h) - var(--hand-h) - var(--reveal-h) - 46px) / 6);
  }
  body { height: 100dvh; }
  body.opp-revealed { --reveal-h: 58px; }
  .mobile-only { display: revert; }
  button.mobile-only { display: inline-block; }

  #topbar { gap: 8px; padding: 0 8px; }
  #topbar .logo { font-size: 17px; }
  #topbar .topbar-title { padding: 3px 9px; font-size: 12px; }
  #topbar-right { gap: 8px; min-width: 0; }
  #topbar-right button, #topbar-right .pill { padding: 6px 12px; font-size: 13px; }
  .who-name { font-size: 13px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who-avatar { width: 28px; height: 28px; }
  body[data-screen="game"] .who-ratings { display: none; }

  #app {
    height: calc(100dvh - var(--topbar-h));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--strip-h) auto 1fr var(--strip-h) var(--actions-h) var(--hand-h);
    grid-template-areas: "oppinfo" "opphand" "board" "meinfo" "actions" "hand";
    gap: 4px; padding: 4px 4px max(4px, env(safe-area-inset-bottom));
  }
  #left, #bottom { display: contents; }
  #opp-info { grid-area: oppinfo; }
  #me-info { grid-area: meinfo; }
  #mid-info { display: none; }
  #hand { grid-area: hand; position: relative; padding: 4px 70px 4px 4px; border-radius: 12px; cursor: pointer; }
  #hand .card { --card-h: calc(var(--hand-h) - 10px); }
  #hand .card:hover { transform: none; }
  #hand .card.selected { transform: none; z-index: 6; }
  #hand::after {
    content: "▲ Karty"; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); z-index: 8; pointer-events: none;
    padding: 6px 9px; border-radius: 10px; background: var(--twitch); color: #fff; font-size: 12px; font-weight: 800;
  }
  /* Rozwinięta ręka */
  body.hand-open #hand {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 84;
    max-height: 64dvh; overflow-y: auto;
    flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 8px;
    padding: 40px 10px max(14px, env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0; background: var(--panel-solid); box-shadow: 0 -10px 40px rgba(0, 0, 0, .6);
  }
  body.hand-open #hand { max-height: 80dvh; gap: 12px 6px; }
  body.hand-open #hand .card { --card-h: min(124px, 17dvh); }
  .hand-item { width: calc((100% - 12px) / 3); display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .hand-desc { width: 100%; font-size: 11px; line-height: 1.3; text-align: center; color: #e4d9f5; }
  .hand-rule + .hand-rule { margin-top: 3px; }
  .hand-rule b { color: var(--gold); }
  body.hand-open #hand .card.selected { box-shadow: 0 0 0 3px var(--gold), 0 0 16px var(--gold); }
  body.hand-open #hand::after {
    content: "Wybierz kartę"; left: 0; right: 0; top: 10px; transform: none; text-align: center;
    background: none; color: var(--gold); font-size: 15px;
  }
  #hand-backdrop { position: fixed; inset: 0; z-index: 83; background: rgba(8, 2, 18, .6); }
  body:not(.hand-open) #hand-backdrop { display: none; }
  #actions { grid-area: actions; width: auto; flex-direction: row; align-items: center; gap: 6px; }
  #actions button { flex: 1; padding: 8px 8px; font-size: 13.5px; white-space: nowrap; }
  #actions #btn-info { flex: none; }
  #hint { display: none; }
  #btn-buy .long-label { display: none; }
  #turn-clock { flex: none; padding: 4px 8px; }
  body:has(#overlay:not(.hidden)) #turn-clock:not(.hidden) { top: 52px; }

  /* Ręka rywala tylko przy Podglądzie – inaczej liczba kart w pasku. */
  #opp-hand { display: none; grid-area: opphand; height: var(--reveal-h); padding: 3px 6px; border-radius: 10px; }
  body.opp-revealed #opp-hand { display: flex; }
  #opp-hand .card { --card-h: calc(var(--reveal-h) - 8px); }

  /* Pasek gracza w jednej linii */
  .player-info { display: flex; align-items: center; gap: 10px; padding: 2px 12px; border-radius: 12px; }
  .player-info .pi-top { flex: 1; min-width: 0; }
  .pi-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pi-score { font-size: 22px; line-height: 1; order: -1; min-width: 30px; text-align: center; }
  .player-info .gems { margin: 0; gap: 4px; }
  .gem { width: 12px; height: 12px; }
  .pi-meta { font-size: 12.5px; white-space: nowrap; }
  .pi-label { display: none; }
  .pi-cards::before { content: "🃏 "; }
  .pi-donate::before { content: "💰 "; }

  #board { gap: 2px; }
  .side { gap: 2px; }
  #divider { height: 3px; margin: 1px 0; }
  .row { grid-template-columns: 30px 44px minmax(0, 1fr); border-radius: 8px; border-left-width: 3px; }
  .row-score { width: 24px; height: 24px; font-size: 12.5px; }
  .status-slot { width: 40px; height: calc(var(--row-h) - 12px); padding: 2px; gap: 2px; }
  .status-slot.empty { font-size: 7px; letter-spacing: 0; }
  .status-slot .status { font-size: 10px; padding: 1px 0; }
  .status-slot .status.debuff .s-txt { display: none; } /* wąskie pole – sama ikona */
  .row-label { font-size: 8.5px; letter-spacing: 1px; right: 6px; top: 1px; }
  .row-cards { padding: 0 4px; gap: 3px; }

  /* Prawy panel = arkusz od dołu */
  #right {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 86;
    height: min(78dvh, 640px); padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    background: var(--panel-solid); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .6);
    overflow-y: auto; transform: translateY(105%); transition: transform .22s ease-out;
  }
  body.sheet-open #right { transform: none; }
  #sheet-backdrop { position: fixed; inset: 0; z-index: 85; background: rgba(8, 2, 18, .6); }
  body:not(.sheet-open) #sheet-backdrop { display: none; }
  .sheet-head { display: flex; justify-content: space-between; align-items: center; }
  #sheet-round { font-weight: 800; color: var(--gold); font-size: 17px; }
  #right #preview { flex: none; min-height: 0; overflow: visible; }
  #right #preview .card { --card-w: min(46vw, 190px); }
  #right #log { height: 180px; flex: none; }

  .modal { padding: 14px 12px; max-width: 96vw; max-height: 88dvh; }
  .modal .cards { gap: 6px; margin: 10px 0 6px; }
  .modal .card { --card-h: 116px; --card-w: 84px; }
  .modal.deck-pick .cards { max-height: 52dvh; }
  .modal td, .modal th { padding: 3px 8px; }
  .preview-box.reward-preview { grid-template-columns: 96px 1fr; column-gap: 10px; height: 240px; width: 92vw; }
  .preview-box.reward-preview > .card { --card-w: 96px; --card-h: 133px; }
  #banner { padding: 14px 22px; width: max-content; max-width: 90vw; }
  .banner-title { font-size: 22px; }
  .toast { font-size: 13px; max-width: 92vw; }
}

/* Telefon poziomo: za mało miejsca na sześć stref – prośba o obrócenie. */
@media (orientation: landscape) and (max-height: 500px) {
  body[data-screen="game"] #rotate-hint {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 200;
    background: var(--bg); color: var(--gold); font-size: 22px; font-weight: 800; text-align: center; line-height: 1.6;
  }
}

/* ---------- Rush ---------- */
.rush-line { color: var(--gold); }
.rush-team { color: var(--muted, #b9a8d6); font-size: .9em; }
/* Duo: ręka partnera przy mojej talii. */
.piles { flex-wrap: wrap; }
.partner-hand { flex-basis: 100%; margin-top: 6px; }
.partner-label { font-size: 12px; color: var(--muted, #b9a8d6); margin-bottom: 2px; }
.partner-cards { display: flex; flex-wrap: wrap; gap: 2px; }
.partner-cards .card { zoom: .42; cursor: default; }
.rush-score { font-size: 34px; font-weight: 800; color: var(--gold); text-align: center; margin: 4px 0 8px; }
.rush-stats { margin: 0 auto 10px; }
.rush-stats td { padding: 3px 10px; }
.rush-stats td:last-child { text-align: right; font-weight: 700; }
@media (max-width: 760px) {
  /* Telefon: z Rush tylko punkty (rywal ma numer etapu w nazwie). */
  .rush-opp, .rush-line .rush-extra, .rush-team { display: none; }
}

/* ---------- Wynik i tabliczka „PAS” ---------- */
.pi-score-row { display: flex; align-items: center; gap: 12px; }
.pi-score { transition: text-shadow .3s, color .3s; }
.pi-score.leading { color: #8dffb0; text-shadow: 0 0 10px rgba(40, 230, 110, .9), 0 0 24px rgba(40, 230, 110, .55); }
.pi-score.trailing { color: #ffa3a3; text-shadow: 0 0 10px rgba(255, 60, 60, .9), 0 0 24px rgba(255, 60, 60, .5); }
.pass-plaque {
  display: inline-block; padding: 4px 12px; border-radius: 8px; transform: rotate(-4deg);
  background: linear-gradient(#f1e4c4, #d8c49a); color: #3b2a12; border: 2px solid #8a6a32;
  box-shadow: 0 2px 0 #6b4f22, 0 4px 10px rgba(0, 0, 0, .45);
  font-size: 18px; font-weight: 900; letter-spacing: .12em; line-height: 1.1;
}
@media (max-width: 760px) {
  .pi-score-row { order: -1; gap: 6px; }
  .pass-plaque { padding: 1px 6px; font-size: 11px; border-width: 1px; transform: rotate(-3deg); }
}

/* ---------- PAS nad stołem, czyja tura, zwinięte okno, ręka partnera ---------- */
.side { position: relative; }
.pass-stamp {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.pass-stamp span {
  padding: 6px 30px; border-radius: 12px; transform: rotate(-6deg);
  background: rgba(241, 228, 196, .92); color: #3b2a12; border: 3px solid #8a6a32;
  box-shadow: 0 4px 0 #6b4f22, 0 10px 30px rgba(0, 0, 0, .55);
  font-size: 46px; font-weight: 900; letter-spacing: .18em; line-height: 1;
}
.pass-stamp small { margin-top: 8px; padding: 2px 10px; border-radius: 999px; background: rgba(10, 3, 22, .75); color: #f1e4c4; font-size: 13px; font-weight: 700; }
.pass-stamp.fresh span { animation: stamp-in .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes stamp-in { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }
.side-passed .row-cards { opacity: .75; }

.pi-turn { margin-left: 8px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--gold); color: #2a0a40; white-space: nowrap; }
.pi-turn.partner { background: #7a4dff; color: #fff; animation: turn-pulse 1.2s ease-in-out infinite alternate; }
.pi-turn.opp { background: #e0446a; color: #fff; animation: turn-pulse 1.2s ease-in-out infinite alternate; }
@keyframes turn-pulse { from { opacity: .65; } to { opacity: 1; } }
.rush-partner { display: inline-block; margin-top: 3px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(122, 77, 255, .25); color: #fff; font-size: 12px; cursor: pointer; }

.modal { position: relative; }
.modal-min-btn { position: absolute; top: 8px; right: 10px; padding: 3px 10px; font-size: 12px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: var(--muted); }
#overlay.minimized { inset: auto 0 calc(var(--hand-h, 0px) + 70px) 0; background: none; pointer-events: none; }
#overlay.minimized .modal-mini { pointer-events: auto; }
.modal-mini { padding: 10px 18px; border-radius: 999px; background: var(--gold); color: #2a0a40; font-weight: 800; box-shadow: 0 6px 20px rgba(0, 0, 0, .6); }

.partner-mulligan { position: relative; margin: 12px auto 4px; padding: 8px 10px 10px; border: 2px solid var(--line); border-radius: 14px; background: rgba(10, 3, 22, .5); }
.partner-mulligan.ready { border-color: #3ddc84; box-shadow: 0 0 0 1px #3ddc84, 0 0 18px rgba(61, 220, 132, .55); }
.pm-head { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-align: left; }
.pm-ready { position: absolute; top: 6px; right: 10px; padding: 1px 10px; border-radius: 999px; background: #3ddc84; color: #07210f; font-size: 12px; font-weight: 900; }
.pm-cards { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.pm-cards .card { zoom: .5; cursor: default; }
.partner-pop { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; background: rgba(8, 2, 18, .7); }
.partner-pop-box { max-width: 92vw; max-height: 80vh; overflow-y: auto; padding: 14px; border-radius: 16px; background: var(--panel-solid); border: 1px solid var(--line); text-align: center; }
.partner-pop-box .pm-cards .card { zoom: .7; }

@media (max-width: 760px) {
  /* Telefon: pasek gracza nie wychodzi poza ekran */
  .player-info { min-width: 0; overflow: hidden; }
  .player-info .pi-top { display: flex; align-items: center; gap: 4px; }
  .pi-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pi-score { font-size: 28px; }
  .pi-score.leading { text-shadow: 0 0 8px rgba(40, 230, 110, 1), 0 0 18px rgba(40, 230, 110, .8); }
  .pi-score.trailing { text-shadow: 0 0 8px rgba(255, 60, 60, 1), 0 0 18px rgba(255, 60, 60, .8); }
  .pass-plaque { padding: 2px 8px; font-size: 14px; border-width: 2px; }
  .pi-turn { margin-left: 4px; padding: 1px 6px; font-size: 10.5px; }
  .pass-stamp span { padding: 4px 18px; font-size: 30px; border-width: 2px; }
  .pass-stamp small { font-size: 11px; margin-top: 4px; }
  .rush-line .rush-partner { display: inline-block; margin: 0 0 0 6px; padding: 1px 7px; font-size: 11px; }
  .rush-line { display: flex; align-items: center; }
  .modal-min-btn { top: 6px; right: 8px; }
  #overlay.minimized { bottom: calc(var(--hand-h) + var(--actions-h) + 12px); }
  .pm-cards .card { zoom: .38; }
}
@media (max-width: 760px) {
  /* Duo: wskaźnik tury zamiast imienia, partner jako „🤝 🃏 10” – żeby zmieściły się liczby */
  .player-info .pi-top:has(.pi-turn) .pi-name { display: none; }
  .rush-partner .rp-name { display: none; }
  .gem { width: 10px; height: 10px; }
  .player-info .gems { gap: 3px; }
  /* Zegar nad oknem – okno niżej, żeby nie zasłaniał tytułu */
  body:has(#turn-clock:not(.hidden)) #overlay:not(.minimized) .modal { margin-top: 44px; max-height: calc(88dvh - 44px); }
}
@media (max-width: 760px) {
  .player-info .gems, .player-info .pi-score-row { flex-shrink: 0; } /* kurczą się opisy, nie życia i wynik */
}

/* ---------- Duo: karta i strefy wybierane przez partnera ---------- */
.row.partner-target { box-shadow: inset 0 0 0 2px #a07bff, 0 0 14px rgba(160, 123, 255, .45); border-style: dashed; }
.card.partner-pick { outline: 3px solid #a07bff; outline-offset: 2px; box-shadow: 0 0 18px rgba(160, 123, 255, .8); position: relative; }
.card.partner-pick::after {
  content: attr(data-pick-label); position: absolute; left: 50%; top: -14px; transform: translateX(-50%); z-index: 5;
  padding: 1px 8px; border-radius: 999px; background: #7a4dff; color: #fff; font-size: 11px; font-weight: 800; white-space: nowrap;
}
.partner-cards .card.partner-pick::after, .pm-cards .card.partner-pick::after { font-size: 22px; top: -30px; } /* małe karty (zoom) */
.modal.partner-choice h2 { color: #c4a8ff; }
.modal:has(> .modal-min-btn) { padding-top: 38px; } /* „Zwiń” nie zasłania tytułu */

/* Pasek „Nowa wersja gry” (Net.ShowUpdateBar). */
#update-bar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  background: rgba(28, 11, 54, .97); border: 1px solid var(--gold); border-radius: 999px; padding: 6px 6px 6px 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5); font-size: 14px;
}
#update-bar button { padding: 6px 16px; border-radius: 999px; white-space: nowrap; }
#update-bar span { white-space: nowrap; }

/* Telefon: okno wyboru / wymiany (GameModals.PhonePick). */
.pick-bar {
  position: sticky; top: -14px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 8px -12px 0; padding: 8px 12px; background: var(--panel-solid); border-bottom: 1px solid var(--line);
}
.pick-name { font-size: 13px; color: var(--muted); text-align: left; overflow: hidden; text-overflow: ellipsis; }
.pick-go { flex: none; padding: 8px 22px; font-weight: 800; }
.pick-go:disabled { opacity: .45; }
.modal.phone-pick .card[data-action]:hover { transform: none; box-shadow: none; }
.modal.phone-pick .pick-list { gap: 12px 6px; align-items: flex-start; }
.modal.phone-pick .pick-item .card { --card-h: 116px; --card-w: 84px; }
.modal.phone-pick .pick-item.selected .card { box-shadow: 0 0 0 3px var(--gold), 0 0 16px var(--gold); transform: translateY(-3px); }
.modal.phone-pick .pick-item.selected .hand-desc { color: #fff; }

/* Telefon: karty w oknach wyboru o 25% mniejsze. */
@media (max-width: 760px) {
  body.hand-open #hand .card { --card-h: min(93px, 12.75dvh); }
  .modal.phone-pick.deck-pick .pick-item .card { --card-h: 87px; --card-w: 63px; }
}
.rush-out { margin: 8px 0; padding: 8px 12px; border-radius: 12px; background: rgba(var(--gold-rgb), .1); border: 1px solid rgba(var(--gold-rgb), .45); color: #ffe9a8; }

/* Telefon: mniejsze karty na stole, status jako ikona, przy wielu kartach dwie linie (GameUI.LayoutRow). */
@media (max-width: 760px) {
  .row { grid-template-columns: 30px minmax(0, 1fr); }
  .status-slot.empty { display: none; }
  .status-slot:not(.empty) {
    position: absolute; left: 3px; bottom: 3px; z-index: 2; width: 24px; height: auto;
    padding: 0; gap: 2px; border: 0;
  }
  .status-slot .status { font-size: 10px; padding: 1px 0; }
  .status-slot .status .s-txt { display: none; }
  .row-cards .card { --card-h: calc((var(--row-h) - 10px) * .7); --card-w: calc(var(--card-h) * .72); font-size: max(7.5px, calc(var(--card-h) * .11)); }
  .row-cards .card .foot, .row-cards .card .name { display: none; }
  .row-cards.two-lines { display: grid; grid-template-rows: repeat(2, auto); gap: 2px 3px; align-content: center; justify-content: center; justify-items: start; }
  .row-cards.two-lines .card { --card-h: calc((var(--row-h) - 12px) / 2); --card-w: calc(var(--card-h) * .72); }
  .row-cards.two-lines .card .gold { display: none; } /* moneta zasłaniała siłę */
}
