/* ==========================================================================
   MAKAO PRO CHAMPIONSHIP - OFICJALNY STYL TURNIEJOWY
   Elegancki stół, fizyczny stos kart (10-15 pod spodem), animacje lotu,
   poważne stanowiska graczy (bez emotek) oraz pełne UI lobby multiplayer.
   ========================================================================== */

:root {
  /* Kolorystyka stołu mistrzowskiego */
  --felt-green: #0a3d1c;
  --felt-dark: #041d0c;
  --felt-light: #115729;
  --table-rim: #1c110b;
  --table-rim-outer: #100a06;
  --table-gold: #e5b93b;
  --table-gold-light: #fbe282;
  --table-gold-glow: rgba(229, 185, 59, 0.45);
  --table-accent: #1976d2;

  /* Karty */
  --card-width: 96px;
  --card-height: 140px;
  --card-radius: 9px;
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
  --suit-red: #c62828;
  --suit-black: #18191a;

  /* Ciemny interfejs turniejowy */
  --bg-dark: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1f242c;
  --border-color: rgba(229, 185, 59, 0.25);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --status-green: #2ea043;
  --status-yellow: #d29922;
  --status-red: #f85149;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body.tournament-theme {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   STÓŁ TURNIEJOWY (SUKNO MISTRZOWSKIE)
   ========================================================================== */

.table-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: 
    radial-gradient(ellipse at 50% 50%, rgba(17, 87, 41, 0.8) 0%, rgba(10, 61, 28, 0.95) 60%, rgba(4, 29, 12, 1) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.015) 0, rgba(255, 255, 255, 0.015) 2px, transparent 2px, transparent 8px);
  border: 14px solid var(--table-rim);
  border-radius: 28px;
  box-shadow: 
    inset 0 0 100px rgba(0, 0, 0, 0.85),
    inset 0 0 0 2px var(--table-gold),
    0 16px 50px rgba(0, 0, 0, 0.9);
  margin: 10px;
  overflow: hidden;
}

/* GÓRNY PASEK TURNIEJOWY (HEADER) */
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(13, 17, 23, 0.75);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--border-color);
  z-index: 10;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--table-gold) 0%, #aa8016 100%);
  color: #0b0e14;
  font-weight: 900;
  font-size: 0.8rem;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.brand-text h1 {
  font-size: 1.25rem;
  letter-spacing: 2px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.brand-text .sub-title {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  color: var(--table-gold);
  font-weight: 600;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.net-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-subtle);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-yellow);
}

.status-dot.online {
  background: var(--status-green);
  box-shadow: 0 0 8px var(--status-green);
}

.status-dot.offline {
  background: var(--status-red);
}

.status-badge {
  background: rgba(229, 185, 59, 0.15);
  border: 1px solid var(--table-gold);
  color: var(--table-gold-light);
  padding: 4px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.status-badge.active-turn {
  background: linear-gradient(90deg, #1976d2, #2196f3);
  color: #fff;
  border-color: #64b5f6;
  box-shadow: 0 0 12px rgba(33, 150, 243, 0.5);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-header {
  background: rgba(22, 27, 34, 0.85);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header:hover {
  background: var(--bg-card-hover);
  border-color: var(--table-gold);
  transform: translateY(-1px);
}

.btn-header.btn-lobby-nav {
  background: linear-gradient(135deg, rgba(229, 185, 59, 0.2) 0%, rgba(229, 185, 59, 0.05) 100%);
  border-color: var(--table-gold);
  color: var(--table-gold-light);
}

.btn-header.btn-danger-header:hover {
  background: rgba(248, 81, 73, 0.15);
  border-color: var(--status-red);
  color: var(--status-red);
}

/* ==========================================================================
   ARENA GRY I POZYCJONOWANIE STANOWISK
   ========================================================================== */

.game-arena {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "left   top    right"
    "left   center right"
    "bottom bottom bottom";
  position: relative;
  padding: 12px 24px;
  overflow: hidden;
}

/* ==========================================================================
   STANOWISKA ZAWODNIKÓW (ELEGANCKIE, POWAŻNE, BEZ EMOTEK)
   ========================================================================== */

.tournament-seat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 5;
  transition: all 0.3s ease;
}

.seat-top {
  grid-area: top;
  margin-bottom: 8px;
}

.seat-left {
  grid-area: left;
  justify-content: center;
}

.seat-right {
  grid-area: right;
  justify-content: center;
}

.seat-badge {
  background: rgba(18, 22, 28, 0.85);
  border: 1px solid rgba(229, 185, 59, 0.25);
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 190px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  position: relative;
  transition: all 0.25s ease;
}

.tournament-seat.active .seat-badge {
  border-color: var(--table-gold);
  box-shadow: 0 0 20px var(--table-gold-glow), 0 8px 30px rgba(0, 0, 0, 0.7);
  background: rgba(22, 27, 34, 0.95);
  transform: scale(1.03);
}

.seat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.seat-role-pill {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--table-gold);
  background: rgba(229, 185, 59, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.seat-turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: all 0.2s ease;
}

.tournament-seat.active .seat-turn-dot {
  background: var(--table-gold);
  box-shadow: 0 0 10px var(--table-gold);
}

.seat-player-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 6px;
  margin-bottom: 8px;
}

.seat-cards-count {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--table-gold-light);
}

.seat-cards-count.makao-warning {
  color: #ff3838;
  animation: pulse-red 1s infinite alternate;
}

@keyframes pulse-red {
  0% { transform: scale(1); text-shadow: 0 0 4px #ff3838; }
  100% { transform: scale(1.1); text-shadow: 0 0 12px #ff3838; }
}

/* Mini podgląd rewersów kart rywala */
.opponent-hand-preview {
  display: flex;
  justify-content: center;
  gap: -8px;
  height: 24px;
}

.mini-card-back {
  width: 18px;
  height: 26px;
  background: linear-gradient(135deg, #1b263b, #0d1b2a);
  border: 1px solid #415a77;
  border-radius: 3px;
  margin-left: -6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  position: relative;
}

.mini-card-back:first-child {
  margin-left: 0;
}

/* ==========================================================================
   ŚRODEK STOŁU I FIZYCZNY STOS KART
   ========================================================================== */

.table-center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 6;
}

.active-demands-container {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.demand-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  animation: banner-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes banner-pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.demand-battle {
  background: linear-gradient(90deg, #b71c1c, #d32f2f);
  color: #fff;
  border: 1px solid #ff5252;
}

.demand-skip {
  background: linear-gradient(90deg, #e65100, #f57c00);
  color: #fff;
  border: 1px solid #ffb74d;
}

.demand-rank {
  background: linear-gradient(90deg, #4a148c, #7b1fa2);
  color: #fff;
  border: 1px solid #ba68c8;
}

.demand-suit {
  background: linear-gradient(90deg, #0d47a1, #1976d2);
  color: #fff;
  border: 1px solid #64b5f6;
}

.card-piles-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-bottom: 18px;
}

.pile-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pile-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* TALIA DO DOBIERANIA Z FIZYCZNĄ GRUBOŚCIĄ */
.deck-stack {
  width: var(--card-width);
  height: var(--card-height);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.deck-stack:hover {
  transform: translateY(-4px) scale(1.02);
}

.deck-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--card-radius);
  background: #101924;
  border: 1px solid #303e4d;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.deck-layer.layer-3 { transform: translate(-4px, 4px); }
.deck-layer.layer-2 { transform: translate(-2px, 2px); }
.deck-layer.layer-1 { transform: translate(-1px, 1px); }

.deck-card-face {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--card-radius);
  background: linear-gradient(135deg, #162438 0%, #0d1624 100%);
  border: 2px solid #3c5473;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.deck-pattern {
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border: 1px solid rgba(229, 185, 59, 0.35);
  border-radius: 6px;
  background-image: repeating-linear-gradient(45deg, rgba(229, 185, 59, 0.05) 0, rgba(229, 185, 59, 0.05) 4px, transparent 4px, transparent 8px);
}

.deck-emblem {
  font-size: 2.4rem;
  color: var(--table-gold);
  z-index: 2;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.deck-count-badge {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--table-gold);
  color: var(--table-gold-light);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 12px;
  z-index: 2;
  margin-top: 6px;
}

/* ==========================================================================
   WIDOCZNY FIZYCZNY STOS KART NA STOLE (10-15 KART POD SPODEM)
   ========================================================================== */

.discard-stack {
  width: var(--card-width);
  height: var(--card-height);
  position: relative;
  perspective: 1000px;
}

/* Warstwa kart pod spodem - tworzy fizyczny stos na suknie */
.discard-underlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

.pile-under-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  background: #fdfdfd;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.45),
    0 1px 3px rgba(0, 0, 0, 0.25);
  transform-origin: center center;
  transition: transform 0.2s ease;
  overflow: hidden;
}

/* Delikatna tekstura i krawędzie karty pod spodem */
.pile-under-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.08) 100%);
}

.pile-under-card .under-corner {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.75rem;
  font-weight: bold;
  line-height: 1;
}

.pile-under-card.red .under-corner { color: var(--suit-red); }
.pile-under-card.black .under-corner { color: var(--suit-black); }

/* Kontener karty na samej górze stosu */
.discard-top-card-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 20;
}

.discard-slot-outline {
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(229, 185, 59, 0.4);
  border-radius: var(--card-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: rgba(229, 185, 59, 0.6);
  text-align: center;
  padding: 8px;
}

/* ==========================================================================
   TICKER PROTOKOŁU TURNIEJOWEGO
   ========================================================================== */

.action-ticker-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 16px;
  max-width: 540px;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.ticker-badge {
  background: var(--table-gold);
  color: #0b0e14;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.ticker-text {
  font-size: 0.85rem;
  color: #e6edf3;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   DOLNY PANEL GRACZA I KONTROLKI
   ========================================================================== */

.player-panel {
  grid-area: bottom;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  z-index: 10;
}

.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 960px;
  padding: 8px 18px;
  background: rgba(18, 22, 28, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.player-identity-tag {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-identity-tag .role-indicator {
  background: var(--status-green);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.player-display-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.turn-instruction {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.turn-instruction.my-turn {
  color: var(--table-gold-light);
  text-shadow: 0 0 8px var(--table-gold-glow);
  font-weight: 700;
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action {
  background: rgba(22, 27, 34, 0.9);
  color: #fff;
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-action:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--table-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-makao-shout {
  background: linear-gradient(135deg, #b71c1c, #d32f2f);
  border-color: #ff5252;
}

.btn-makao-shout.attention {
  animation: pulse-makao 0.9s infinite alternate;
  border-color: #ffd700;
}

@keyframes pulse-makao {
  0% { transform: scale(1); box-shadow: 0 0 8px rgba(255, 23, 68, 0.6); }
  100% { transform: scale(1.08); box-shadow: 0 0 20px rgba(255, 215, 0, 0.9); }
}

.btn-challenge-makao {
  background: linear-gradient(135deg, #e65100, #ff6f00);
  border-color: #ffab40;
}

.btn-play-selected {
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  border-color: #81c784;
}

/* ==========================================================================
   WACHLARZ KART W RĘKU GRACZA
   ========================================================================== */

.player-hand-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 155px;
  width: 100%;
  padding-bottom: 8px;
  overflow-x: auto;
  overflow-y: visible;
}

.hand-card-wrapper {
  margin-left: -28px;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2), z-index 0.1s ease;
  position: relative;
}

.hand-card-wrapper:first-child {
  margin-left: 0;
}

.hand-card-wrapper:hover {
  transform: translateY(-24px) scale(1.08);
  z-index: 50 !important;
}

/* ==========================================================================
   KARTY KARCIANE (KOMPONENT SVG / HTML)
   ========================================================================== */

.card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: var(--card-shadow);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  cursor: default;
  transition: all 0.2s ease;
}

.card.red {
  color: var(--suit-red);
}

.card.black {
  color: var(--suit-black);
}

.card.playable {
  cursor: pointer;
  box-shadow: 0 0 16px rgba(229, 185, 59, 0.6), 0 4px 10px rgba(0, 0, 0, 0.4);
  border-color: var(--table-gold);
}

.card.playable:hover {
  border-color: #ffd700;
  box-shadow: 0 0 22px rgba(255, 215, 0, 0.9);
}

.card.selected {
  transform: translateY(-18px) scale(1.05);
  border-color: #2e7d32;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.9);
}

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.top-left {
  align-self: flex-start;
}

.card-corner.bottom-right {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-corner .rank {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.card-corner .suit-mini {
  font-size: 0.95rem;
  margin-top: 2px;
}

.card-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-center-suit {
  font-size: 2.2rem;
  line-height: 1;
}

.card-center-art {
  font-size: 2.5rem;
  font-weight: 900;
  opacity: 0.9;
}

/* ==========================================================================
   ANIMACJE LOTU KART PO STOLE (FLIGHT ANIMATIONS)
   ========================================================================== */

.flying-cards-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 1000;
}

.flying-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.25, 1), opacity 0.38s ease;
  will-change: transform, opacity;
  z-index: 1001;
}

.flying-card-draw {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  background: linear-gradient(135deg, #162438 0%, #0d1624 100%);
  border: 2px solid #3c5473;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.25, 1), opacity 0.35s ease;
  will-change: transform, opacity;
  z-index: 1001;
}

/* ==========================================================================
   UI LOBBY MULTIPLAYER & SYSTEM POKOI (MODAL / OVERLAY)
   ========================================================================== */

.lobby-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 8, 14, 0.88);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.lobby-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.lobby-modal {
  width: 92%;
  max-width: 960px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 25px var(--table-gold-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-scale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-scale {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(13, 17, 23, 0.85);
  border-bottom: 1px solid var(--border-subtle);
}

.lobby-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lobby-icon {
  font-size: 2rem;
}

.lobby-brand h2 {
  font-size: 1.25rem;
  letter-spacing: 1.5px;
  color: #fff;
  font-weight: 800;
}

.lobby-brand p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-close-lobby {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s;
}

.btn-close-lobby:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.lobby-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(22, 27, 34, 0.95);
  border-bottom: 1px solid var(--border-subtle);
}

.profile-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-input-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.input-with-button {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-with-button input,
.join-by-code-box input,
.form-group input,
.form-group select {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: #fff;
  padding: 6px 12px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-with-button input:focus,
.join-by-code-box input:focus,
.form-group input:focus,
.form-group select:focus {
  border-color: var(--table-gold);
}

.lobby-server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-yellow);
}

.status-indicator-dot.online {
  background: var(--status-green);
  box-shadow: 0 0 6px var(--status-green);
}

.status-indicator-dot.offline {
  background: var(--status-red);
}

.lobby-body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
}

.lobby-actions-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--table-gold) 0%, #aa8016 100%);
  color: #0b0e14;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(229, 185, 59, 0.4);
}

.btn-secondary {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--table-gold);
  color: #fff;
}

.btn-icon-only {
  background: #21262d;
  border: 1px solid var(--border-subtle);
  color: #c9d1d9;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-only:hover {
  color: var(--table-gold);
  border-color: var(--table-gold);
}

.btn-sm {
  background: #21262d;
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-sm:hover {
  border-color: var(--table-gold);
}

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--status-red);
  color: var(--status-red);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.25);
}

/* TABELA POKOI */
.rooms-table-wrapper {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}

.rooms-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.rooms-table th {
  background: rgba(22, 27, 34, 0.9);
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.rooms-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.rooms-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table-empty-cell {
  text-align: center;
  padding: 28px !important;
  color: var(--text-muted);
  font-style: italic;
}

.room-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.room-status-badge.waiting {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.4);
}

.room-status-badge.in_game {
  background: rgba(210, 153, 34, 0.15);
  color: #e3b341;
  border: 1px solid rgba(210, 153, 34, 0.4);
}

/* ==========================================================================
   WIDOK POCZEKALNI POKOJU (WAITING ROOM)
   ========================================================================== */

.waiting-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.room-badge-tag {
  font-size: 0.65rem;
  letter-spacing: 1px;
  font-weight: 800;
  color: var(--table-gold);
  background: rgba(229, 185, 59, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
}

.room-info-block h3 {
  font-size: 1.3rem;
  color: #fff;
  margin: 4px 0 6px 0;
}

.room-id-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.room-id-chip strong {
  color: var(--table-gold-light);
  font-family: monospace;
  font-size: 0.95rem;
}

.btn-chip-copy {
  background: #21262d;
  border: 1px solid var(--border-subtle);
  color: #c9d1d9;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-chip-copy:hover {
  color: #fff;
  border-color: var(--table-gold);
}

.waiting-slots-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.player-slot-card {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: all 0.2s ease;
}

.player-slot-card.empty {
  border-style: dashed;
  justify-content: center;
  min-height: 140px;
}

.player-slot-card.is-ready {
  border-color: var(--status-green);
  box-shadow: 0 0 10px rgba(46, 160, 67, 0.25);
}

.slot-host-crown {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.9rem;
  color: var(--table-gold);
}

.slot-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #21262d, #161b22);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--table-gold);
  margin-bottom: 8px;
}

.slot-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-ready-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.slot-ready-tag.ready {
  background: rgba(46, 160, 67, 0.2);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.5);
}

.slot-ready-tag.waiting {
  background: rgba(210, 153, 34, 0.2);
  color: #e3b341;
  border: 1px solid rgba(210, 153, 34, 0.5);
}

.slot-ready-tag.bot {
  background: rgba(88, 166, 255, 0.15);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.4);
}

.waiting-room-bottom-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.tournament-chat-card {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 200px;
  overflow: hidden;
}

.chat-card-header {
  padding: 8px 12px;
  background: rgba(22, 27, 34, 0.8);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.chat-messages {
  flex: 1;
  padding: 10px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.chat-msg.system {
  color: var(--table-gold-light);
  font-style: italic;
  font-size: 0.75rem;
}

.chat-msg.user {
  color: #e6edf3;
}

.chat-msg .sender {
  font-weight: 700;
  color: var(--table-gold);
  margin-right: 4px;
}

.chat-input-row {
  display: flex;
  padding: 8px;
  gap: 6px;
  background: #161b22;
  border-top: 1px solid var(--border-subtle);
}

.chat-input-row input {
  flex: 1;
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: #fff;
  padding: 6px 10px;
  font-size: 0.8rem;
  outline: none;
}

.room-controls-card {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.room-controls-card h4 {
  font-size: 0.95rem;
  color: #fff;
}

.room-rules-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 6px 0 14px 0;
}

.ready-buttons-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-ready-toggle {
  background: rgba(46, 160, 67, 0.15);
  border: 1px solid var(--status-green);
  color: #3fb950;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-ready-toggle.active {
  background: var(--status-green);
  color: #fff;
  box-shadow: 0 0 12px rgba(46, 160, 67, 0.6);
}

.btn-start-game {
  background: linear-gradient(135deg, var(--table-gold) 0%, #aa8016 100%);
  border: none;
  color: #0b0e14;
  font-weight: 800;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-start-game:hover:not(:disabled) {
  filter: brightness(1.15);
  box-shadow: 0 0 16px var(--table-gold-glow);
}

.btn-start-game:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.host-management-bar {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.btn-outline {
  background: transparent;
  border: 1px dashed var(--table-gold);
  color: var(--table-gold);
}

/* ==========================================================================
   MODALE (WALET, AS, REGUŁY, GAME OVER)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 8, 14, 0.85);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  width: 90%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 20px var(--table-gold-glow);
  padding: 24px;
  text-align: center;
  animation: modal-scale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header h2 {
  font-size: 1.25rem;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.modal-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.demand-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.demand-option-btn {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.demand-option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--table-gold);
  transform: translateY(-2px);
}

.demand-option-btn.suit-hearts { color: var(--suit-red); border-color: rgba(198, 40, 40, 0.4); }
.demand-option-btn.suit-diamonds { color: var(--suit-red); border-color: rgba(198, 40, 40, 0.4); }
.demand-option-btn.suit-clubs { color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.demand-option-btn.suit-spades { color: #fff; border-color: rgba(255, 255, 255, 0.2); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.form-group-checkbox {
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 18px;
}

.modal-buttons-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.rules-content {
  text-align: left;
  max-height: 55vh;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #c9d1d9;
  padding-right: 8px;
}

.rules-content h3 {
  color: var(--table-gold);
  font-size: 0.95rem;
  margin: 12px 0 6px 0;
}

.rules-content ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.rules-content li {
  margin-bottom: 6px;
}

.victory-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.modal-stats {
  list-style: none;
  background: #0d1117;
  border-radius: 8px;
  padding: 12px;
  margin: 14px 0;
  text-align: left;
  font-size: 0.85rem;
}

.modal-stats li {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-stats li:last-child {
  border-bottom: none;
}

/* ==========================================================================
   DOSTOSOWANIE DO TELEFONÓW I URZĄDZEŃ MOBILNYCH (RESPONSIVE & TOUCH UX)
   ========================================================================== */

/* Podstawowe usprawnienia dotykowe dla urządzeń mobilnych */
html, body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Ukrycie paska przewijania w wachlarzu kart na telefonach */
.player-hand-container {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.player-hand-container::-webkit-scrollbar {
  display: none;
}

/* Przyciski i elementy klikalne zoptymalizowane pod dotyk */
button, .card, .deck-stack, .hand-card-wrapper {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   TABLETY I MNIEJSZE EKRANY (max-width: 900px)
   ========================================================================== */
@media (max-width: 900px) {
  :root {
    --card-width: 76px;
    --card-height: 110px;
    --card-radius: 8px;
  }

  .table-container {
    border-width: 8px;
    border-radius: 12px;
  }

  .game-arena {
    grid-template-columns: 160px 1fr 160px;
    padding: 8px 12px;
    gap: 8px;
  }

  .brand-title h1 {
    font-size: 1.05rem;
  }

  .seat-badge {
    padding: 8px;
  }

  .seat-player-name {
    font-size: 0.8rem;
  }

  .player-hand-container {
    min-height: 125px;
  }

  .hand-card-wrapper {
    margin-left: -24px;
  }
}

/* ==========================================================================
   TELEFONY W PIONIE (PORTRAIT max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --card-width: 66px;
    --card-height: 96px;
    --card-radius: 7px;
  }

  .table-container {
    border-width: 4px;
    border-radius: 8px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Kompaktowy pasek górny (Header) */
  .table-header {
    padding: 4px 8px;
    min-height: 40px;
    gap: 6px;
  }

  .brand-title {
    gap: 6px;
  }

  .brand-badge {
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 4px;
  }

  .brand-title h1 {
    font-size: 0.85rem;
    letter-spacing: 0.5px;
  }

  .sub-title {
    display: none;
  }

  .header-status {
    gap: 6px;
  }

  .net-status-pill {
    padding: 2px 6px;
    font-size: 0.68rem;
  }

  .status-badge {
    padding: 2px 7px;
    font-size: 0.68rem;
  }

  .header-controls {
    gap: 4px;
  }

  .btn-header {
    padding: 4px 6px;
    font-size: 0.72rem;
    gap: 4px;
    border-radius: 6px;
  }

  /* Ukrycie długich etykiet tekstowych w nagłówku na bardzo małych telefonach */
  @media (max-width: 480px) {
    .btn-header span:not(.btn-icon):not(#sound-icon) {
      display: none;
    }
    .btn-header {
      padding: 5px 8px;
    }
  }

  /* Główna arena w układzie kolumnowym dla telefonów */
  .game-arena {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "left   top    right"
      "center center center"
      "bottom bottom bottom";
    padding: 4px 6px;
    gap: 4px;
    height: calc(100% - 42px);
    overflow: hidden;
  }

  .tournament-seat.seat-left { grid-area: left; }
  .tournament-seat.seat-top { grid-area: top; }
  .tournament-seat.seat-right { grid-area: right; }
  .table-center { grid-area: center; }
  .player-panel { grid-area: bottom; }

  /* Stanowiska przeciwników - kompaktowy pasek górny na telefonach */
  .tournament-seat {
    width: 100%;
    margin: 0;
  }

  .seat-badge {
    padding: 4px 6px;
    border-radius: 8px;
    gap: 2px;
    min-height: 48px;
    justify-content: center;
  }

  .seat-header-row {
    margin-bottom: 1px;
  }

  .seat-role-pill {
    font-size: 0.55rem;
    padding: 1px 4px;
    max-width: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .seat-turn-dot {
    width: 6px;
    height: 6px;
  }

  .seat-player-name {
    font-size: 0.72rem;
    max-width: 85px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.1;
  }

  .seat-stats-row {
    font-size: 0.68rem;
    gap: 4px;
  }

  .cards-label {
    display: none; /* Oszczędność miejsca na ekranie telefonu */
  }

  .seat-cards-count {
    font-size: 0.75rem;
    padding: 1px 5px;
    border-radius: 4px;
  }
  .seat-cards-count::before {
    content: "🂠 ";
    font-size: 0.8rem;
  }

  .opponent-hand-preview {
    margin-top: 2px;
    height: 18px;
  }

  .mini-card-back {
    width: 13px;
    height: 18px;
    border-radius: 2px;
    margin-left: -7px;
  }

  /* Środek stołu na telefonie */
  .table-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
    min-height: 0;
  }

  .active-demands-container {
    margin-bottom: 4px;
    gap: 4px;
  }

  .demand-pill {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
  }

  .card-piles-wrapper {
    gap: 18px;
    margin: 4px 0;
  }

  .pile-slot {
    gap: 4px;
  }

  .pile-label {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
  }

  .deck-count-badge {
    font-size: 0.7rem;
    padding: 1px 5px;
    bottom: 3px;
    right: 3px;
  }

  .action-ticker-bar {
    max-width: 96%;
    padding: 3px 8px;
    font-size: 0.7rem;
    border-radius: 12px;
    margin-top: 4px;
  }

  .ticker-text {
    max-width: 250px;
  }

  /* Dolny panel gracza na telefonie */
  .player-panel {
    padding: 2px 0 max(4px, env(safe-area-inset-bottom)) 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.45) 0%, transparent 100%);
  }

  .player-controls-row {
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 4px;
    justify-content: center;
  }

  .turn-instruction {
    width: 100%;
    font-size: 0.72rem;
    padding: 2px 6px;
    text-align: center;
    margin-bottom: 2px;
  }

  .btn-action {
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    min-height: 36px;
    gap: 4px;
  }

  .btn-makao-shout {
    font-weight: 800;
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .player-hand-container {
    min-height: 105px;
    max-height: 115px;
    padding: 6px 8px 2px 8px;
    align-items: flex-end;
  }

  .hand-card-wrapper {
    margin-left: -20px;
  }

  .hand-card-wrapper.selected {
    transform: translateY(-16px);
  }

  /* Karty na telefonie */
  .card {
    padding: 4px;
  }

  .card-corner {
    font-size: 0.75rem;
    line-height: 1;
  }

  .card-corner-suit {
    font-size: 0.65rem;
  }

  .card-center-symbol {
    font-size: 1.3rem;
  }

  .card-figure-badge {
    font-size: 0.85rem;
  }
}

/* ==========================================================================
   BARDZO MAŁE TELEFONY (PORTRAIT max-width: 380px)
   ========================================================================== */
@media (max-width: 380px) {
  :root {
    --card-width: 58px;
    --card-height: 84px;
    --card-radius: 6px;
  }

  .table-header {
    padding: 2px 6px;
  }

  .brand-title h1 {
    font-size: 0.78rem;
  }

  .seat-badge {
    padding: 2px 4px;
  }

  .seat-player-name {
    font-size: 0.65rem;
    max-width: 70px;
  }

  .seat-cards-count {
    font-size: 0.68rem;
  }

  .card-piles-wrapper {
    gap: 12px;
  }

  .player-hand-container {
    min-height: 92px;
    max-height: 102px;
  }

  .hand-card-wrapper {
    margin-left: -24px;
  }

  .btn-action {
    padding: 5px 8px;
    font-size: 0.7rem;
    min-height: 32px;
  }
}

/* ==========================================================================
   TRYB POZIOMY NA TELEFONACH (LANDSCAPE max-height: 520px)
   ========================================================================== */
@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --card-width: 54px;
    --card-height: 78px;
    --card-radius: 6px;
  }

  .table-container {
    border-width: 4px;
    height: 100vh;
    height: 100dvh;
  }

  .table-header {
    min-height: 32px;
    padding: 2px 8px;
  }

  .brand-title h1 {
    font-size: 0.75rem;
  }

  .sub-title {
    display: none;
  }

  .btn-header {
    padding: 2px 6px;
    font-size: 0.68rem;
    min-height: 26px;
  }

  .game-arena {
    grid-template-columns: 110px 1fr 110px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "left   top    right"
      "left   center right"
      "bottom bottom bottom";
    padding: 2px 6px;
    gap: 4px;
    height: calc(100% - 34px);
  }

  .seat-badge {
    padding: 3px 6px;
    min-height: 40px;
  }

  .seat-role-pill {
    font-size: 0.55rem;
  }

  .seat-player-name {
    font-size: 0.68rem;
    max-width: 80px;
  }

  .opponent-hand-preview {
    display: none; /* Ukryj rewersy w trybie landscape by zyskać pion */
  }

  .table-center {
    padding: 0;
  }

  .card-piles-wrapper {
    gap: 14px;
    margin: 2px 0;
  }

  .action-ticker-bar {
    padding: 2px 6px;
    font-size: 0.68rem;
    margin-top: 2px;
  }

  .player-panel {
    padding: 0 0 max(2px, env(safe-area-inset-bottom)) 0;
  }

  .player-controls-row {
    padding: 1px 4px;
    gap: 4px;
  }

  .turn-instruction {
    display: none; /* Oszczędność miejsca w poziomie */
  }

  .btn-action {
    padding: 4px 8px;
    font-size: 0.7rem;
    min-height: 28px;
  }

  .player-hand-container {
    min-height: 84px;
    max-height: 92px;
    padding: 2px 6px;
  }

  .hand-card-wrapper {
    margin-left: -20px;
  }

  .hand-card-wrapper.selected {
    transform: translateY(-12px);
  }
}

/* ==========================================================================
   MODALE NA TELEFONACH (LOBBY, ŻĄDANIA, ZASADY, KONIEC GRY)
   ========================================================================== */
@media (max-width: 680px) {
  .modal-window {
    width: 94%;
    max-width: 380px;
    padding: 14px;
    max-height: 90vh;
    border-radius: 12px;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-header p {
    font-size: 0.75rem;
  }

  /* Grid żądania Waleta - 3 kolumny po 2 wiersze */
  .demand-options-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 10px;
  }

  .demand-option-btn {
    padding: 8px 4px;
    font-size: 0.75rem;
    min-height: 46px;
    border-radius: 8px;
  }

  .demand-option-btn .icon {
    font-size: 1.2rem;
  }

  /* Grid żądania Asa - 2 kolumny po 2 wiersze */
  #modal-ace .demand-options-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  #modal-ace .demand-option-btn {
    min-height: 52px;
    font-size: 0.85rem;
  }

  /* Lobby modal na telefonie */
  .lobby-modal {
    width: 96%;
    max-height: 92vh;
    border-radius: 12px;
  }

  .lobby-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .lobby-brand h2 {
    font-size: 0.95rem;
  }

  .lobby-profile-bar {
    width: 100%;
    justify-content: space-between;
  }

  .lobby-input-nick {
    font-size: 0.78rem;
    padding: 4px 8px;
    max-width: 140px;
  }

  .lobby-body {
    padding: 12px 14px;
  }

  .lobby-actions-toolbar {
    gap: 6px;
  }

  .lobby-actions-toolbar .btn-primary,
  .lobby-actions-toolbar .btn-secondary {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    font-size: 0.78rem;
    padding: 8px 6px;
  }

  .table-header-cell, .table-cell {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  /* Poczekalnia pokoju w układzie 2x2 na telefonach */
  .waiting-room-slots {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .waiting-slot-card {
    padding: 8px;
  }

  .slot-name {
    font-size: 0.75rem;
  }
}

