/* WERSJA: v1.6
 * ZMIANY:
 *   - 2026-11-24: Zachowanie kompaktowego rozmiaru przycisku domku (.summary-lobby-exit) obok głównej akcji po rundzie.
 *   - 2026-11-19: Kontrakty bez rozszerzania stołu i układ sterowania dla niskiego ekranu iPhone'a.
 *   - 2026-11-16: Ukrywanie nieaktywnych przycisków poprzedniej lewy/musika na wąskich ekranach mobilnych.
 *   - 2026-11-12: Zwarty układ pionowy na telefonie (jednowierszowy pasek narzędzi i topbar bez ucinania), przycisk ← Lobby oraz kolory atutów.
 *   - 2026-11-03: Opcjonalny układ wachlarza (.hand[data-layout="fan"] .hand-row .card) oraz obsługa pozycji napisów (data-toast-mode).
 *   - 2026-10-27: Czytelne symbole kart bez nakładania w wachlarzu, pełne kolory kart przy wyborze kontraktu/deklaracji oraz przycisk wyjścia do lobby.
 *   - 2026-10-26: Responsywny stół 3-5-8, ustawienia i dwurzędowa ręka.
 */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #072911; color: #eef6ed; }
button, select { font: inherit; }
button, select, .back-link { touch-action: manipulation; }
.hand, .hand .card { touch-action: pan-x pinch-zoom; }
button { cursor: pointer; border: 1px solid #f3c66355; border-radius: 9px; background: #0d431d; color: #eef6ed; padding: 10px 14px; min-height: 40px; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible { outline: 3px solid #f3c663; outline-offset: 3px; }
a { color: #f3c663; }
.primary { background: #f3c663; color: #19301b; font-weight: 750; }
.back-link { display: inline-block; padding: 8px 0; text-decoration: none; }
.setup-pane { width: min(760px, 100%); margin: 0 auto; padding: 24px max(20px, env(safe-area-inset-left)) 40px; }
.eyebrow { display: block; margin-top: 28px; font-size: 12px; letter-spacing: .13em; color: #bbd1bb; }
h1 { font-size: clamp(44px, 9vw, 68px); color: #f3c663; margin: 8px 0; letter-spacing: .06em; }
h1 span { color: #668d6b; }
.intro { font-size: 19px; line-height: 1.6; max-width: 560px; }
.setup-fields { display: grid; gap: 18px; padding: 22px; border: 1px solid #f3c66344; border-radius: 16px; margin-top: 26px; background: #0d431d; }
.setup-fields label { display: flex; gap: 12px; align-items: center; justify-content: space-between; line-height: 1.5; min-width: 0; }
.setup-fields .check-field { justify-content: flex-start; }
.setup-fields select { min-width: 0; max-width: 100%; }
select { background: #072911; color: #eef6ed; border: 1px solid #f3c66366; padding: 10px; border-radius: 8px; }
input[type=checkbox] { width: 21px; height: 21px; flex: 0 0 21px; accent-color: #f3c663; }
.muted { color: #b1c8b6; font-size: 13px; line-height: 1.6; }
.setup-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 22px 0; }
.rules { border-top: 1px solid #f3c66333; padding: 20px 0; line-height: 1.7; }
.rules summary { color: #f3c663; font-size: 20px; cursor: pointer; }
.rules p { font-size: 15px; }
.game-layout { max-width: 1100px; margin: auto; height: 100dvh; min-height: 560px; padding: max(5px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); display: grid; grid-template-rows: 46px 34px 68px minmax(130px, 1fr) auto; gap: 7px; }
.topbar { display: flex; align-items: center; gap: 8px; }
.topbar .back-link { display: inline-flex; align-items: center; gap: 4px; width: auto; min-height: 34px; padding: 5px 10px; font-size: 13px; font-weight: 750; white-space: nowrap; border: 1px solid #f3c66355; border-radius: 8px; background: #0d431d; color: #eef6ed; }
.topbar .back-link::before { content: none; }
.brand { margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #f3c663; }
.brand small { font-size: 11px; color: #b7d6b9; font-weight: 400; }
.topbar button { padding: 6px 11px; font-size: 13px; min-height: 34px; }
.round-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; }
.round-bar strong { color: #f3c663; }
.opponents { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seat { border: 1px solid #f3c66344; padding: 8px 12px; font-size: 13px; display: grid; gap: 4px; }
.seat.active { box-shadow: inset 0 0 0 1px #f3c663; }
.seat .seat-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seat .seat-detail { color: #c3d7c5; font-size: 12px; }
.arena { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; min-width: 0; }
.table-hint { text-align: center; color: #d1e4ce; font-size: 13px; line-height: 1.5; margin-bottom: 10px; }
.played { display: flex; justify-content: center; gap: 22px; }
.played.kitty-preview { --card-w: 54px; --card-h: 76px; gap: 10px; }
.played-entry { display: grid; justify-items: center; gap: 6px; font-size: 12px; }
.played-entry.winner .card { outline: 3px solid #f3c663; }
.card { position: relative; display: block; width: var(--card-w, 66px); height: var(--card-h, 94px); padding: 5px; text-align: left; min-height: 0; line-height: 1; border-radius: 7px; }
.card .corner { display: grid; gap: 1px; font: bold 20px/.95 Georgia, serif; position: relative; z-index: 1; width: 22px; text-align: center; }
.card .corner small { font-size: 17px; }
.card .pip, .hand .card .pip { inset: auto 5px 4px auto; font-size: 24px; line-height: 1; }
.hand .card .pip { font-size: 19px; inset: auto 4px 3px auto; opacity: .85; }
.card.selected { transform: translateY(-7px); outline: 3px solid #f3c663; }
.card:disabled { opacity: 1; }
.hand:not(.dim-disabled) .card:disabled { background: var(--card-face); color: var(--card-ink); filter: none; }
.hand:not(.dim-disabled) .card.red:disabled { color: var(--card-red); }
.hand.dim-disabled .card:disabled { filter: saturate(.45); }
.contracts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; width: min(410px, 100%); }
.contracts button { background: #072911e8; border-color: #f3c66388; font-weight: 750; }
.contracts button.suit-red { border-color: rgba(255, 115, 130, 0.65); }
.contracts button.suit-black { border-color: rgba(226, 232, 240, 0.5); }
.contracts button:disabled { opacity: .3; }
.round-result { width: min(440px, 100%); text-align: center; }
.round-result h2 { font-size: 20px; margin: 0 0 8px; color: #f3c663; }
.score-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.score-table th, .score-table td { padding: 8px 6px; border-bottom: 1px solid #f3c66333; text-align: right; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table caption { padding-bottom: 10px; text-align: left; }
.player-summary { display: flex; gap: 12px; justify-content: center; font-size: 13px; padding: 4px; color: #f3c663; }
.hand-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; }
.hand-toolbar > span { margin-right: auto; }
.hand-toolbar button { padding: 4px 7px; min-height: 30px; font-size: 11px; }
.turn-status { margin: 5px 0 8px; min-height: 20px; font-size: 13px; color: #f3c663; text-align: center; }
.hand { --card-w: 62px; --card-h: 84px; display: grid; gap: 10px; padding: 8px 3px 3px; max-width: 760px; margin: auto; }
.hand-row { display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr)); padding-right: calc(var(--card-w) - 27px); }
.hand[data-layout="fan"] .hand-row .card { transform: translateY(var(--fan-y, 0px)) rotate(var(--fan-angle, 0deg)); transform-origin: 50% 100%; }
.hand[data-layout="fan"] .hand-row .card.selected { transform: translateY(calc(var(--fan-y, 0px) - 7px)) rotate(var(--fan-angle, 0deg)); }
.player-area { display: flex; flex-direction: column; }
body[data-toast-mode="bottom"] .player-area .turn-status { order: 4; margin: 4px 0 0; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; padding-top: 8px; }
.action-row button { font-size: 14px; min-height: 40px; padding: 8px 14px; }
.storage-warning { position: fixed; bottom: 0; margin: 0; width: 100%; text-align: center; padding: 6px; background: #6c381c; color: white; font-size: 12px; z-index: 200; }
.game-modal-body .mini-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0; }
.game-modal-body .score-scroll { max-height: 45dvh; overflow: auto; }
.game-modal-body .card { --card-w: 54px; --card-h: 76px; }
@media (max-width: 520px) {
  .setup-fields label:not(.check-field) { flex-direction: column; align-items: stretch; gap: 6px; }
  .setup-fields select { width: 100%; font-size: 16px; }
  .contracts { gap: 6px; }
  .contracts button { padding: 6px 2px; min-height: 44px; }
  .game-layout { grid-template-rows: 40px 28px 58px minmax(120px, 1fr) auto; gap: 4px; }
  .topbar { gap: 5px; }
  .topbar .back-link, .topbar button { padding: 4px 8px; font-size: 12px; min-height: 32px; }
  .topbar .shared-game-menu > summary { width: 34px; height: 34px; }
  .topbar .brand small { display: none; }
  .hand { --card-w: 55px; --card-h: 76px; }
  .card .corner { font-size: 18px; width: 19px; }
  .card .corner small { font-size: 15px; }
  .hand .card .pip { font-size: 17px; inset: auto 4px 3px auto; }
  .seat { padding: 6px 8px; font-size: 12px; }
  .seat .seat-detail { font-size: 11px; }
  .played { gap: 14px; }
  .hand-toolbar { gap: 4px; justify-content: center; flex-wrap: nowrap; margin-top: 2px; }
  .hand-toolbar > span { display: none; }
  .hand-toolbar button:disabled { display: none; }
  .hand-toolbar button { padding: 3px 6px; font-size: 10.5px; min-height: 26px; white-space: nowrap; }
  .player-summary { gap: 6px; font-size: 11.5px; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .turn-status { margin: 3px 0 5px; font-size: 12px; }
  .round-result h2 { font-size: 17px; }
  .score-table th, .score-table td { padding: 6px 4px; }
}
@media (max-height: 700px) and (orientation: portrait) {
  .game-layout { min-height: 0; grid-template-rows: 38px 25px 54px minmax(70px, 1fr) auto; gap: 4px; }
  .seat { padding: 5px 7px; gap: 2px; }
  .hand { --card-h: 64px; gap: 8px; padding-top: 6px; }
  .hand .card .pip { font-size: 15px; inset: auto 3px 2px auto; }
  .hand-toolbar button { min-height: 26px; }
  .turn-status { font-size: 12px; margin: 3px 0 5px; }
  .action-row { padding-top: 5px; }
  .action-row button { min-height: 34px; padding: 6px 12px; }
}
@media (max-height: 550px) and (orientation: landscape) {
  .game-layout { min-height: 0; grid-template-rows: 38px 20px 40px minmax(0, 1fr) auto; gap: 3px; }
  .topbar button { min-height: 29px; padding: 3px 10px; }
  .opponents { width: 100%; }
  .seat { padding: 3px 10px; gap: 1px; }
  .arena { padding: 5px; flex-direction: row; gap: 8px; overflow: auto; align-items: safe center; }
  .table-hint { max-width: 240px; margin: 0; font-size: 12px; }
  .played { --card-w: 42px; --card-h: 54px; gap: 14px; }
  .played.kitty-preview { --card-w: 42px; --card-h: 54px; }
  .played-entry { gap: 1px; font-size: 10px; }
  .played .card { padding: 3px; }
  .played .card .corner { font-size: 14px; }
  .played .card .corner small { font-size: 12px; }
  .played .card .pip { font-size: 15px; inset: auto 3px 2px auto; }
  .hand { --card-w: 49px; --card-h: 58px; gap: 8px; padding-top: 7px; }
  .hand .card { padding: 3px; }
  .hand .card .pip { font-size: 14px; inset: auto 3px 2px auto; }
  .player-area { position: relative; }
  .player-summary { position: absolute; top: 0; left: 0; justify-content: flex-start; }
  .hand-toolbar { margin-left: auto; margin-top: 0; justify-content: flex-end; }
  .hand-toolbar > span { display: none; }
  .hand-toolbar button:disabled { display: none; }
  .turn-status { margin: 3px 0 0; font-size: 12px; min-height: 15px; }
  .hand-toolbar button { min-height: 24px; padding: 3px 6px; }
  .action-row { padding-top: 4px; }
  .action-row button { min-height: 30px; padding: 4px 15px; font-size: 13px; }
  .arena:has(.contracts:not([hidden])) { flex-direction: column; gap: 3px; justify-content: safe center; }
  .contracts { grid-template-columns: repeat(6, minmax(0, 1fr)); width: min(100%, 540px); gap: 5px; }
  .contracts button { min-height: 36px; padding: 5px 3px; font-size: 12px; }
  .round-result { display: flex; align-items: center; gap: 15px; width: auto; }
  .round-result h2 { font-size: 15px; white-space: nowrap; margin: 0; }
  .round-result .score-table { font-size: 11px; }
  .round-result .score-table th, .round-result .score-table td { padding: 3px 6px; }
}
@media (max-height: 330px) and (orientation: landscape) {
  .hand { --card-h: 48px; gap: 5px; padding-top: 4px; }
  .played, .played.kitty-preview { --card-h: 43px; }
  .arena:has(.contracts:not([hidden])) { flex-direction: row; }
  .arena:has(.contracts:not([hidden])) .table-hint { display: none; }
  .player-area .action-row:not(:has(button:not([hidden]):not(:disabled), a)) { padding-top: 0; }
}
