/* WERSJA: v1.2
 * ZMIANY:
 *   - 2026-11-24: Zachowanie kompaktowego rozmiaru przycisku domku (.summary-lobby-exit) po rozdaniu.
 *   - 2026-11-12: Dopasowanie wysokości nagłówka stołu Remika i czterech przycisków narzędziowych (z bezpośrednim Lobby) bez ucinania tablicy wyników.
 *   - 2026-10-25: Zwarty stół inspirowany wzorem iPhone: duże awersy, zachodzące indeksy i akcje po dotknięciu.
 */
:is([data-game="remik"],body[data-game="remik"]) {
  --meld-card-width: clamp(50px, 15vw, 74px);
  --meld-card-height: calc(var(--meld-card-width) * 1.42);
  --meld-card-step: clamp(15px, 4.2vw, 21px);
  --meld-index-size: clamp(14px, 3.9vw, 19px);
}
.remik-table-card {
  position: relative;
  display: block;
  flex: 0 0 var(--meld-card-width);
  width: var(--meld-card-width);
  height: var(--meld-card-height);
  border: 1px solid #c6ccbf;
  border-radius: 5px;
  background: #fffef8;
  color: #17231b;
  box-shadow: -1px 1px 3px #001a0c55;
  font-family: Georgia, 'Times New Roman', serif;
  box-sizing: border-box;
  pointer-events: none;
}
.remik-table-card + .remik-table-card { margin-left: calc(var(--meld-card-step) - var(--meld-card-width)); }
.remik-table-card.red { color: #c6283e; }
.remik-table-corner { position: absolute; top: 3px; left: 1px; display: flex; flex-direction: column; align-items: center; line-height: .94; }
.remik-table-corner b { font-size: var(--meld-index-size); font-weight: 700; letter-spacing: -1px; }
.remik-table-corner i { font-size: calc(var(--meld-index-size) - 1px); font-style: normal; line-height: 1.1; }
.remik-table-corner.bottom { top: auto; left: auto; right: 2px; bottom: 3px; transform: rotate(180deg); }
.remik-table-center { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--meld-card-width) * .52); }
.remik-joker-word { position: absolute; left: 3px; top: 30px; writing-mode: vertical-rl; text-orientation: upright; font: 7px/1 Georgia,serif; letter-spacing: -1px; }
.remik-joker-binding { position: absolute; right: 2px; bottom: 19px; padding: 1px 3px; border-radius: 3px; background: #fff0b9; color: #49320a; font: 700 10px/1.2 system-ui,sans-serif; }

/* Zamknięty kafelek zajmuje wyłącznie miejsce potrzebne na zachodzące karty. */
.remik-meld-group,body[data-game="remik"] .meld-row {
  display: block;
  flex: 0 0 auto;
  align-self: flex-start;
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  max-width: 100%;
}
.remik-meld-cards,body[data-game="remik"] .meld-cards {
  display: flex;
  align-items: flex-start;
  width: max-content;
  max-width: 100%;
  padding: 0;
  overflow: visible;
  list-style: none;
  cursor: pointer;
  touch-action: pan-y pinch-zoom;
}
.remik-meld-cards::-webkit-details-marker,body[data-game="remik"] .meld-cards::-webkit-details-marker { display: none; }
.remik-meld-cards:focus-visible,body[data-game="remik"] .meld-cards:focus-visible { outline: 3px solid #f3c663; outline-offset: 3px; }
.remik-meld-group.staged-meld { border: 0; background: none; box-shadow: 0 0 0 2px #eab864; }
.remik-meld-group:not([open]) > .remik-meld-header,body[data-game="remik"] .meld-row:not([open]) > .remik-meld-header { display: none; }
.remik-meld-group[open] > .remik-meld-header,body[data-game="remik"] .meld-row[open] > .remik-meld-header {
  position: absolute;
  z-index: 60;
  top: calc(var(--meld-card-height) + 6px);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(250px, 70vw);
  padding: 10px;
  border: 1px solid #c8e0c080;
  border-radius: 9px;
  background: #082e17fa;
  color: #eef6e8;
  box-shadow: 0 5px 18px #00120888;
  font: 12px/1.4 system-ui,sans-serif;
}
.remik-meld-header > div { flex-wrap: wrap; }
.remik-meld-header :is(button,.remik-meld-quick-btn) { min-height: 44px; padding: 8px 10px; font-size: 12px; }

/* Solo: pełna powierzchnia stołu, bez wewnętrznej ramki i podwójnego przewijania. */
#tableViewport[data-game="remik"] {
  --card-width: clamp(68px, 21vw, 94px);
  --pile-card-w: clamp(56px, 16vw, 72px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
#tableViewport[data-game="remik"] .table-workspace { display: flex; flex-direction: column; flex: 1; width: 100%; min-height: 0; gap: 5px; }
#tableViewport[data-game="remik"] .table-header-controls { position: relative; display: flex; flex: 0 0 auto; flex-direction: row; width: 100%; height: auto; min-height: 88px; padding: 0; gap: 8px; overflow: visible; }
#tableViewport[data-game="remik"] .decks-zone { flex-direction: row; flex-wrap: nowrap; width: auto; gap: 9px; justify-content: flex-start; }
#tableViewport[data-game="remik"] .remik-score-mini { position: absolute; right: 0; top: 44px; min-width: 132px; max-width: 150px; width: 144px; font-size: 10px; }
#tableViewport[data-game="remik"] .remik-score-head { font-size: 9px; padding: 4px 2px; }
#tableViewport[data-game="remik"] .side-controls { flex: 0 0 auto; width: auto; align-items: flex-end; }
#tableViewport[data-game="remik"] .action-row { flex-wrap: nowrap; gap: 3px; }
#tableViewport[data-game="remik"] .glass-btn { width: 35px; height: 40px; }
#tableViewport[data-game="remik"] .opponents-layer { display: none; }
#tableViewport[data-game="remik"] .landscape-status-bar { display: none !important; }
#tableViewport[data-game="remik"] #playArena {
  flex: 1;
  height: 0;
  width: 100%;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}
#tableViewport[data-game="remik"] .thrown-cards-container { display: block; height: 100%; }
#tableViewport[data-game="remik"] .remik-table-layout { gap: 7px; padding: 0; align-items: stretch; }
#tableViewport[data-game="remik"] .remik-hud-row { position: static; flex-shrink: 0; min-height: 27px; justify-content: space-between; gap: 4px; width: 100%; }
#tableViewport[data-game="remik"] .remik-hud-row > :nth-child(-n+2) { display: none; }
#tableViewport[data-game="remik"] .remik-hud-pill { padding: 4px 7px; font-size: 10px; background: #062e1455; border-color: #ffffff1a; }
#tableViewport[data-game="remik"] .remik-hud-row { height: auto; }
#tableViewport[data-game="remik"] .remik-melds-container { flex: 1; justify-content: flex-start; align-content: flex-start; gap: 12px 10px; padding: 3px 3px 90px; overflow-x: hidden; overflow-y: auto; touch-action: pan-y pinch-zoom; overscroll-behavior: contain; }
#tableViewport[data-game="remik"] .remik-empty-table { padding: 12px !important; border: 0 !important; background: none !important; margin: 0 !important; font-size: 12px !important; box-shadow: none; }
#tableViewport[data-game="remik"] .remik-action-bar { flex-shrink: 0; max-height: 100px; overflow-y: auto; margin-top: 0; gap: 5px; padding: 4px 0; }
#tableViewport[data-game="remik"] .remik-action-bar .remik-btn { min-height: 44px; font-size: 12px; padding: 7px 10px; }
.remik-suggestions { width: 100%; font: 12px/1.4 system-ui,sans-serif; }
.remik-suggestions > summary { min-height: 40px; padding: 10px; text-align: center; cursor: pointer; color: #d9e5cd; }
.remik-suggestions > div { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; padding-bottom: 6px; }
#tableViewport[data-game="remik"] .hand-zone { flex: 0 0 clamp(122px, 18dvh, 172px); width: 100%; height: clamp(122px, 18dvh, 172px); }
#tableViewport[data-game="remik"] .hand-fan-container .card-rank { font-size: 18px; }
#tableViewport[data-game="remik"] .hand-fan-container .card-corner-tl { left: 3px; }
#tableViewport[data-game="remik"] .status-toast { max-width: calc(100% - 16px); font-size: 11px; pointer-events: none; }

/* Online: układy w tej samej powierzchni gry, nad własną ręką. */
body[data-game="remik"] #table { display: flex; flex-direction: column; height: calc(100dvh - 220px); min-height: 440px; padding: 12px; margin: 8px 0; }
body[data-game="remik"] #table[hidden] { display: none; }
body[data-game="remik"] .remik-online-toolbar { display: flex; flex: 0 0 auto; gap: 12px; margin-bottom: 10px; }
body[data-game="remik"] .remik-online-information { flex: 1; min-width: 0; }
body[data-game="remik"] #table > .center { display: contents; }
body[data-game="remik"] #roundLabel { display: none; }
body[data-game="remik"] #status { order: 0; min-height: 0; margin: 0 0 6px; font-size: 12px; }
body[data-game="remik"] #trick { order: 0; flex: 0 0 62px; width: 62px; height: auto; min-height: 0; justify-content: flex-start; align-items: flex-start; margin: 0; }
body[data-game="remik"] #trick .played { margin: 0; }
body[data-game="remik"] #trick .card { width: 58px; height: 82px; }
body[data-game="remik"] #meldArea { order: 2; padding: 0; margin: 0; border: 0; background: none; box-shadow: none; flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y pinch-zoom; }
body[data-game="remik"] #meldArea > :is(h2,p) { display: none; }
body[data-game="remik"] #melds { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 12px 10px; padding: 3px 0 80px; }
body[data-game="remik"] #actions { order: 3; position: static; display: flex; flex-wrap: wrap; margin: 8px 0; gap: 6px; }
body[data-game="remik"] #actions button { min-height: 44px; }
body[data-game="remik"] #actions .hint { min-height: 0; line-height: 1.3; margin: 0; }
body[data-game="remik"] .hand-area { position: relative; order: 4; inset: auto; width: 100%; }
body[data-game="remik"] .hand-label { margin-bottom: 4px; }
body[data-game="remik"] .players { position: static; inset: auto; display: flex; flex-shrink: 0; gap: 5px; margin-bottom: 6px; pointer-events: auto; }
body[data-game="remik"] .players .seat { position: relative; inset: auto; transform: none; min-width: 0; max-width: none; flex: 1; padding: 4px; font-size: 10px; text-align: center; }
body[data-game="remik"] .players .seat small { font-size: 9px; }
body[data-game="remik"] #hand { --online-hand-card-width: clamp(58px,17vw,78px); --online-hand-step: clamp(14px,calc((100vw - 90px - var(--online-hand-card-width)) / var(--hand-gaps,12)),32px); padding: 18px 6px 6px; }
body[data-game="remik"] #hand .card { width: var(--online-hand-card-width); height: calc(var(--online-hand-card-width) * 1.42); padding: 3px; flex-shrink: 0; }
body[data-game="remik"] #hand .card + .card { margin-left: calc(var(--online-hand-step) - var(--online-hand-card-width)); }
body[data-game="remik"] #hand .card > span:first-child,body[data-game="remik"] #hand .card .bottom { font-size: 18px; }

@media (orientation: landscape) and (max-height: 600px) {
  #tableViewport[data-game="remik"] { --meld-card-width: 45px; --meld-card-step: 15px; --meld-index-size: 13px; --pile-card-w: 42px; --card-width: 55px; gap: 2px; }
  #tableViewport[data-game="remik"] .table-workspace { gap: 2px; }
  #tableViewport[data-game="remik"] .remik-score-mini { top: 0; right: 152px; width: 136px; }
  #tableViewport[data-game="remik"] .table-header-controls { min-height: 59px; }
  #tableViewport[data-game="remik"] .hand-zone { flex-basis: 68px; height: 68px; }
  #tableViewport[data-game="remik"] .remik-action-bar { max-height: 48px; }
  #tableViewport[data-game="remik"] .remik-hud-row { min-height: 22px; }
  #tableViewport[data-game="remik"] .remik-hud-pill { padding: 2px 6px; }
  #tableViewport[data-game="remik"] .remik-table-layout { gap: 3px; }
  #tableViewport[data-game="remik"] .remik-melds-container { gap: 9px; }
}
