/* BASE DEFINITIONS & MODERN RESET */
:root {
  --bg-primary: #020617; /* Deep space black */
  --bg-table: radial-gradient(circle at center, #0f4626 0%, #082414 70%, #030e08 100%); /* Green felt gradient */
  --panel-glass: rgba(15, 23, 42, 0.45);
  --border-glass: rgba(255, 255, 255, 0.08);
  --accent-gold: #dfb45b;
  --accent-gold-hover: #f1c46d;
  --accent-red: #f43f5e;
  --accent-blue: #0ea5e9;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --card-dark: #1e293b;
  --card-light: #ffffff;
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.5);
  
  --font-display: 'Outfit', sans-serif;
  --font-serif: 'Playfair Display', serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent page-level scrollbars */
}

body {
  font-family: var(--font-display);
  background-color: var(--bg-primary);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

/* APPCONTAINER */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* SCROLLBARS */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* HEADER */
.main-header {
  height: 70px;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

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

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 10px rgba(223, 180, 91, 0.3));
}

.logo h1 {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 2px;
}

.accent-text {
  color: var(--accent-gold);
  text-shadow: 0 0 15px rgba(223, 180, 91, 0.4);
}

.user-status {
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-glass);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.username-display {
  color: var(--accent-gold);
  font-weight: 600;
}

/* SCREENS SYSTEM */
.screen {
  display: none;
  flex: 1;
  width: 100%;
  height: calc(100vh - 70px);
  position: relative;
  overflow: auto;
  min-height: 0;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* GLASS CARD COMMON */
.glass-card {
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  gap: 8px;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #c4953c 100%);
  color: #1e1b15;
  box-shadow: 0 4px 20px rgba(223, 180, 91, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(223, 180, 91, 0.5);
  background: linear-gradient(135deg, var(--accent-gold-hover) 0%, var(--accent-gold) 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: var(--text-main);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-action {
  padding: 16px 36px;
  font-size: 18px;
  letter-spacing: 1px;
  border-radius: 30px;
  text-transform: uppercase;
  font-weight: 800;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.btn-gold {
  background: linear-gradient(135deg, #ffe082 0%, #d4af37 50%, #b38f1d 100%);
  color: #2c2205;
  border: 2px solid #fff2c2;
}

.btn-gold:not(.disabled):hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 15px 30px rgba(212, 175, 55, 0.4);
  background: linear-gradient(135deg, #fff2c2 0%, #e5c158 50%, #cfa62b 100%);
}

.btn.disabled, .btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

/* CHIPS FOR PLAYERS COUNT */
.player-select-chips {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 10px 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chip.active {
  background: var(--accent-gold);
  color: #1e1b15;
  border-color: var(--accent-gold);
  box-shadow: 0 0 15px rgba(223, 180, 91, 0.2);
}

/* SCREEN 1: NAME SCREEN */
#screen-name {
  align-items: center;
  justify-content: center;
}

.name-card {
  width: 480px;
  text-align: center;
}

.name-card h2 {
  font-size: 28px;
  margin-bottom: 8px;
  font-weight: 800;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.standard-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.input-group input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 16px;
  outline: none;
  transition: all 0.25s ease;
}

.input-group input[type="text"]:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 15px rgba(223, 180, 91, 0.15);
  background: rgba(0, 0, 0, 0.4);
}

/* SCREEN 2: LOBBIES */
.lobbies-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 30px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
  height: calc(100% - 80px);
}

.lobbies-list-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.lobbies-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.lobbies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  overflow-y: auto;
  padding-right: 5px;
  flex-grow: 1;
}

.lobby-item-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 170px;
  transition: all 0.25s ease;
}

.lobby-item-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(223, 180, 91, 0.3);
  transform: translateY(-2px);
}

.lobby-item-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-item-players {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lobby-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.lobby-status-dot.waiting {
  background: #10b981; /* Green */
}

.lobby-status-dot.playing {
  background: var(--accent-gold);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 0;
  color: var(--text-muted);
  font-size: 15px;
}

/* SCREEN 3: WAITING LOBBY */
.waiting-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 30px;
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 20px;
  height: calc(100vh - 150px);
  max-height: calc(100vh - 150px);
  overflow: hidden;
}

.waiting-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

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

.lobby-badge {
  background: rgba(223, 180, 91, 0.1);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  padding: 6px 14px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 14px;
}

.players-list-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 5px;
}

.players-list-container h3 {
  font-size: 16px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 15px;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.player-lobby-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.player-lobby-card.creator {
  border-color: rgba(223, 180, 91, 0.4);
}

.player-info-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-gold);
}

.player-lobby-name {
  font-weight: 600;
  font-size: 15px;
}

.player-badge-owner {
  font-size: 12px;
  color: var(--accent-gold);
}

.player-offline-mask {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-red);
  font-weight: bold;
  font-size: 12px;
}

.btn-kick {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-kick:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

/* CHAT STYLING */
.chat-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  margin: 15px 0;
}

.chat-msg {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  margin-bottom: 8px;
}

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

.chat-msg-text {
  color: var(--text-main);
}

.chat-msg-sys {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
}

.chat-form input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-display);
}

.chat-form input:focus {
  border-color: var(--accent-gold);
}

.chat-form .btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
}

/* SCREEN 4: GAME SCREEN & THE CASINO BOARD */
#screen-game {
  overflow: hidden !important;
  background: var(--bg-primary);
  height: calc(100vh - 70px);
  min-height: 0;
}

.game-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.game-table-container {
  height: 100%;
  background: var(--bg-table);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.poker-table {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  overflow: hidden;
}

/* Opponent Seats around the table */
.opponents-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.opponent-seat {
  position: absolute;
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid var(--border-glass);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
}

.opponent-seat.is-attacker {
  border-color: var(--accent-red);
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.4);
}

.opponent-seat.is-defender {
  border-color: #eab308; /* Yellow */
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.4);
}

.opponent-seat.offline {
  opacity: 0.4;
}

/* Positions for up to 5 opponents */
.opponent-seat:nth-child(1) { top: 20px; left: 50%; transform: translateX(-50%); } /* Top Center */
.opponent-seat:nth-child(2) { top: 120px; right: 40px; } /* Top Right */
.opponent-seat:nth-child(3) { bottom: 250px; right: 40px; } /* Mid Right */
.opponent-seat:nth-child(4) { bottom: 250px; left: 40px; } /* Mid Left */
.opponent-seat:nth-child(5) { top: 120px; left: 40px; } /* Top Left */

.opponent-info {
  display: flex;
  flex-direction: column;
}

.opponent-name {
  font-weight: 600;
  font-size: 14px;
}

.opponent-cards-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.mini-card-icon {
  font-size: 14px;
}

.opponent-card-count {
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: bold;
}

.status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
  text-align: center;
}

.status-badge.attack {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.status-badge.defend {
  background: rgba(234, 179, 8, 0.2);
  color: #f59e0b;
  border: 1px solid #f59e0b;
}

.status-badge.taking {
  background: rgba(244, 63, 94, 0.25);
  color: #f43f5e;
  border: 1px solid #f43f5e;
  animation: pulse 1s infinite alternate;
}

.status-badge.finished {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid #10b981;
}

@keyframes pulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* TABLE CENTER: FIELD AND DECK */
.table-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  margin-top: 80px;
  margin-bottom: 240px; /* Leave space for player HUD and hand */
  min-height: 0;
}

/* Deck & Trump card area */
.deck-area {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 15;
}

.deck-stack {
  position: relative;
  width: 75px;
  height: 110px;
}

.deck-card-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  box-shadow: -2px 2px 5px rgba(0,0,0,0.5);
  transform: rotate(-3deg);
}

.deck-stack::before {
  content: '';
  position: absolute;
  top: 2px; left: -2px;
  width: 75px; height: 110px;
  background: #0f172a;
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  transform: rotate(-1deg);
  z-index: -1;
  box-shadow: -1px 1px 3px rgba(0,0,0,0.3);
}

.deck-stack::after {
  content: '';
  position: absolute;
  top: 4px; left: -4px;
  width: 75px; height: 110px;
  background: #0f172a;
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  transform: rotate(1deg);
  z-index: -2;
  box-shadow: -1px 1px 3px rgba(0,0,0,0.3);
}

.deck-count {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  border: 1px solid var(--accent-gold);
  pointer-events: none;
}

.trump-card-holder {
  width: 110px;
  height: 75px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
}

.trump-card-rotated {
  transform: rotate(90deg) translate(-15px, -18px);
  transform-origin: center;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.4);
}

/* Battle Field (Attack-Defense Pairs) */
.battle-field {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 25px 40px;
  justify-content: center;
  align-content: center;
  max-width: 600px;
  width: 60%;
}

.card-pair-slot {
  width: 85px;
  height: 125px;
  position: relative;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-pair-slot.has-attack {
  border: none;
}

.card-on-table {
  position: absolute !important;
  width: 80px;
  height: 120px;
  transition: all 0.3s ease;
}

.card-attack {
  top: 0;
  left: 0;
  z-index: 2;
  transform: rotate(-4deg);
}

.card-defend {
  top: 15px;
  left: 20px;
  z-index: 3;
  transform: rotate(6deg);
  box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
  animation: defendPlace 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes defendPlace {
  from { transform: scale(1.3) rotate(20deg); opacity: 0; }
  to { transform: scale(1) rotate(6deg); opacity: 1; }
}

/* Discard Pile */
.discard-area {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.discard-card-back {
  width: 75px;
  height: 110px;
  opacity: 0.8;
  transform: rotate(5deg);
  box-shadow: 2px 2px 5px rgba(0,0,0,0.4);
}

.discard-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 1px;
}

/* Status Banner info */
.game-status-banner {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(8px);
  padding: 6px 20px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
  z-index: 20;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  text-align: center;
  margin-bottom: 5px;
}

/* PLAYER HUD: bottom of table */
.player-hud {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  z-index: 30;
  position: absolute;
  bottom: 15px;
  left: 0;
  padding: 0 20px;
}

.hud-controls {
  width: 100%;
  display: flex;
  justify-content: center;
}

.hud-buttons {
  display: flex;
  gap: 15px;
}

.player-hand-container {
  width: 100%;
  max-width: 800px;
  height: 130px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.player-hand {
  display: flex;
  justify-content: center;
  position: relative;
  height: 120px;
  width: 100%;
}

/* CARDS STYLING - DETAILED AND GORGEOUS */
.card {
  width: 80px;
  height: 120px;
  border-radius: 8px;
  position: relative;
  background-color: var(--card-light);
  color: #000000;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.25s ease, border-color 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Modern Cyber Dark Cards option */
.card-dark-style {
  background-color: #0f172a;
  color: var(--text-main);
  border: 1.5px solid rgba(255,255,255,0.12);
}

/* Suit specific colors */
.card.suit-H, .card.suit-D {
  color: var(--accent-red);
}
.card.suit-C, .card.suit-S {
  color: #1e293b;
}

.card-dark-style.suit-C, .card-dark-style.suit-S {
  color: #cbd5e1;
}

/* Card rank corner elements */
.card-corners {
  display: flex;
  justify-content: space-between;
  line-height: 1;
}

.card-corner-top {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-rank {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-display);
}

.card-suit-symbol {
  font-size: 12px;
}

.card-center-suit {
  font-size: 32px;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Card Back Design */
.card-back {
  background: radial-gradient(circle at center, #1e3a8a 0%, #0f172a 100%);
  border: 2.5px solid #dfb45b;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-back::before {
  content: '♦ ♣ ♠ ♥';
  font-size: 10px;
  color: rgba(223, 180, 91, 0.15);
  position: absolute;
  width: 150%;
  text-align: center;
  letter-spacing: 4px;
  transform: rotate(-45deg);
  line-height: 2.2;
}

.card-back::after {
  content: '🃏';
  font-size: 28px;
  color: var(--accent-gold);
  filter: drop-shadow(0 0 6px rgba(223, 180, 91, 0.4));
  z-index: 2;
}

/* Local Player hand interactions */
.player-hand .card {
  position: absolute;
  cursor: pointer;
  transform-origin: bottom center;
}

.player-hand .card:hover {
  transform: translateY(-25px) scale(1.1) !important;
  z-index: 100 !important;
  box-shadow: 0 20px 30px rgba(0,0,0,0.6), 0 0 15px rgba(223, 180, 91, 0.3);
}

.player-hand .card.selected {
  transform: translateY(-35px) scale(1.1) !important;
  z-index: 99 !important;
  border: 2px solid var(--accent-gold);
  box-shadow: 0 20px 35px rgba(0,0,0,0.7), 0 0 25px rgba(223, 180, 91, 0.5);
}

.player-hand .card.unselectable {
  filter: brightness(0.6);
  cursor: not-allowed;
}

.player-hand .card.unselectable:hover {
  transform: none !important;
  box-shadow: var(--card-shadow);
}

/* SIDE PANEL (LOGS AND CHAT) */
.game-side-panel {
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  background: rgba(2, 6, 23, 0.95);
  padding: 15px;
  gap: 15px;
  z-index: 40;
}

.history-card {
  height: calc(43vh - 50px);
  max-height: calc(43vh - 50px);
  display: flex;
  flex-direction: column;
  padding: 15px;
  box-sizing: border-box;
  overflow: hidden;
}

.history-card h3, .game-chat-card h3 {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.history-log {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
  padding-right: 5px;
}

.log-entry {
  border-bottom: 1px solid rgba(255,255,255,0.02);
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.game-chat-card {
  height: calc(43vh - 50px);
  max-height: calc(43vh - 50px);
  display: flex;
  flex-direction: column;
  padding: 15px;
  box-sizing: border-box;
  overflow: hidden;
}

/* MODAL OVERLAY (END GAME) */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 460px;
  text-align: center;
}

.modal-content h2 {
  font-size: 32px;
  font-family: var(--font-serif);
  color: var(--accent-gold);
  margin-bottom: 20px;
  font-weight: bold;
}

.ended-results {
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
}

.ended-results ul {
  list-style: none;
  margin-top: 10px;
}

.ended-results li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ended-results li:last-child {
  border: none;
}

.ended-results .place-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  text-align: center;
  line-height: 22px;
  font-size: 12px;
  margin-right: 8px;
  font-weight: bold;
}

.ended-results .place-badge.winner {
  background: var(--accent-gold);
  color: #000;
}

.ended-results .place-badge.durak {
  background: var(--accent-red);
  color: #fff;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.animate-pop {
  animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* RESPONSIVE LAYOUTS */
@media (max-width: 1024px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 220px;
  }
  
  .game-side-panel {
    border-left: none;
    border-top: 1px solid var(--border-glass);
    flex-direction: row;
  }

  .history-card, .game-chat-card {
    height: 100% !important;
    flex: 1;
  }
  
  #exit-game-btn {
    align-self: center;
    width: auto !important;
  }
}

@media (max-width: 768px) {
  .main-header {
    padding: 0 15px;
  }
  
  .lobbies-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .waiting-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .chat-card {
    height: 300px;
  }

  /* Shrink cards for small screens */
  .card, .card-on-table {
    width: 65px;
    height: 100px;
  }

  .card-rank {
    font-size: 14px;
  }

  .card-center-suit {
    font-size: 24px;
  }

  .card-pair-slot {
    width: 70px;
    height: 105px;
  }

  .card-defend {
    top: 10px;
    left: 12px;
  }

  .battle-field {
    gap: 15px 25px;
    width: 75%;
  }

  .deck-area {
    left: 10px;
  }

  .deck-stack {
    width: 60px;
    height: 90px;
  }

  .deck-stack::before, .deck-stack::after {
    width: 60px;
    height: 90px;
  }

  .trump-card-holder {
    width: 90px;
    height: 60px;
  }

  .trump-card-rotated {
    transform: rotate(90deg) translate(-15px, -15px);
  }

  .discard-area {
    right: 10px;
  }

  .discard-card-back {
    width: 60px;
    height: 90px;
  }

  /* Adjust seat positioning for smaller screens */
  .opponent-seat {
    padding: 6px 10px;
  }

  .opponent-seat:nth-child(2) { right: 10px; top: 120px; }
  .opponent-seat:nth-child(3) { right: 10px; bottom: 230px; }
  .opponent-seat:nth-child(4) { left: 10px; bottom: 230px; }
  .opponent-seat:nth-child(5) { left: 10px; top: 120px; }
}

/* TOAST NOTIFICATION CONTAINER & STYLES */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-message {
  background: rgba(220, 38, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  animation: slideDown 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), fadeOut 0.5s ease 4.5s forwards;
  max-width: 90vw;
  text-align: center;
}

@keyframes slideDown {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-20px); }
}
