:root {
  /* Card dimensions - fluid scaling with clamp, maintaining 5:7 ratio */
  --card-width: clamp(40px, 5.5vw, 72px);
  --card-height: calc(var(--card-width) * 1.4);
  --card-back-width: calc(var(--card-width) * 1.2);
  --card-back-height: calc(var(--card-height) * 1.2);
  --card-border-radius: clamp(4px, 0.5vw, 6px);
  --card-stack-offset: calc(var(--card-height) * -0.36);
  
  /* Fluid typography with clamp */
  --font-card-corner: clamp(10px, 1.2vw, 14px);
  --font-xs: clamp(11px, 1.4vw, 14px);
  --font-sm: clamp(12px, 1.5vw, 16px);
  --font-md: clamp(14px, 1.6vw, 18px);
  --font-lg: clamp(16px, 1.8vw, 20px);
  --font-xl: clamp(18px, 2vw, 24px);
  --font-2xl: clamp(20px, 2.4vw, 28px);
  --font-3xl: clamp(24px, 3vw, 40px);
  
  /* Fluid spacing with clamp */
  --spacing-xs: clamp(3px, 0.5vw, 6px);
  --spacing-sm: clamp(4px, 0.6vw, 8px);
  --spacing-md: clamp(6px, 0.8vw, 10px);
  --spacing-lg: clamp(8px, 1vw, 12px);
  --spacing-xl: clamp(10px, 1.2vw, 16px);
  --spacing-2xl: clamp(12px, 1.5vw, 20px);
  --spacing-3xl: clamp(16px, 2vw, 24px);
  --spacing-4xl: clamp(20px, 2.5vw, 36px);
  --spacing-5xl: clamp(24px, 3vw, 48px);
  
  /* Fluid border radius */
  --radius-sm: clamp(4px, 0.5vw, 6px);
  --radius-md: clamp(5px, 0.6vw, 8px);
  --radius-lg: clamp(6px, 0.8vw, 10px);
  --radius-xl: clamp(8px, 1vw, 14px);
  --radius-2xl: clamp(12px, 1.5vw, 20px);
  --radius-3xl: clamp(20px, 3vw, 48px);
  
  /* Button and interaction sizes */
  --touch-target-min: 48px;
  --btn-padding-xs: clamp(3px, 0.4vw, 6px) clamp(6px, 0.8vw, 10px);
  --btn-padding-sm: clamp(4px, 0.6vw, 8px) clamp(8px, 1vw, 14px);
  --btn-padding-md: clamp(6px, 0.8vw, 10px) clamp(10px, 1.2vw, 16px);
  --btn-padding-lg: clamp(10px, 1.5vw, 18px) clamp(16px, 2vw, 28px);
  
  /* Table and layout dimensions */
  --table-max-width: clamp(900px, 90vw, 1400px);
  --table-min-height: clamp(300px, 35vh, 450px);
  --table-border-width: clamp(6px, 0.8vw, 12px);
  
  /* Deck and discard pile */
  --discard-min-height: clamp(120px, 15vh, 200px);
  --discard-width: var(--card-width);
  
  /* Card fan spacing - proportional to card width */
  --fan-offset-base: calc(var(--card-width) * 0.1);
  --fan-offset-wide: calc(var(--card-width) * 0.12);
  --fan-hover-lift: calc(var(--spacing-sm) * -1);
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f5f7fb;
  color: #222;
  overflow-x: hidden;
  overflow-y: auto; /* Allow vertical scroll if content overflows */
  padding-top: var(--header-height, 60px); /* Space for fixed header, calculated dynamically */
  padding-bottom: 10px;
  min-height: 100vh; /* Fallback for older browsers */
  min-height: 100dvh; /* Dynamic viewport height - accounts for browser chrome/toolbars */
  max-height: 100vh;
  max-height: 100dvh;
}

/* Start Screen Modal */
#start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#start-screen-content {
  background: white;
  padding: var(--spacing-5xl);
  border-radius: var(--radius-2xl);
  text-align: center;
  box-shadow: 0 var(--spacing-md) var(--spacing-4xl) rgba(0, 0, 0, 0.3);
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  width: 90%;
}

/* Multiplayer Lobby - Professional Design */
#multiplayer-lobby {
  margin-top: 0 !important;
  padding: var(--spacing-xl) 0;
}

#multiplayer-lobby p {
  font-size: var(--font-md) !important;
  margin: var(--spacing-lg) 0 var(--spacing-md) 0 !important;
  color: #444;
  font-weight: 500;
}

#multiplayer-lobby .start-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--spacing-lg) var(--spacing-xl) !important;
  margin: var(--spacing-sm) 0 !important;
  font-size: var(--font-md) !important;
  min-height: 50px !important;
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#multiplayer-lobby .start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
}

#multiplayer-lobby .start-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

#multiplayer-lobby input {
  padding: var(--spacing-lg) var(--spacing-xl) !important;
  font-size: var(--font-lg) !important;
  width: 100% !important;
  box-sizing: border-box !important;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-lg);
  text-align: center;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: all 0.3s ease;
  background: #fafafa;
}

#multiplayer-lobby input:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#multiplayer-lobby button[style*="background: #f44336"] {
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%) !important;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.25);
}

#multiplayer-lobby button[style*="background: #f44336"]:hover {
  background: linear-gradient(135deg, #e53935 0%, #c62828 100%) !important;
  box-shadow: 0 6px 16px rgba(244, 67, 54, 0.4);
}

/* Mobile specific adjustments */
@media (max-width: 480px) {
  #start-screen-content {
    padding: var(--spacing-3xl) var(--spacing-xl);
    width: 95%;
    max-height: 95vh;
  }
  
  #start-screen-content h1 {
    font-size: var(--font-2xl) !important;
    margin-bottom: var(--spacing-lg) !important;
  }
  
  #start-screen-content p {
    font-size: var(--font-sm) !important;
    margin-bottom: var(--spacing-md) !important;
  }
  
  .start-btn {
    padding: var(--spacing-md) var(--spacing-lg) !important;
    margin: var(--spacing-sm) 0 !important;
    font-size: var(--font-sm) !important;
    min-height: 42px !important;
  }
  
  #multiplayer-lobby p {
    font-size: var(--font-sm) !important;
    margin: var(--spacing-sm) 0 !important;
  }
  
  #multiplayer-lobby .start-btn {
    padding: var(--spacing-sm) var(--spacing-md) !important;
    margin: var(--spacing-xs) 0 !important;
    font-size: var(--font-sm) !important;
  }
  
  /* Extra compact lobby player selection buttons on mobile */
  .lobby-btn {
    padding: 10px 12px !important;
    min-height: 40px !important;
    font-size: 14px !important;
  }
  
  .lobby-btn-compact {
    padding: 10px !important;
    min-height: 40px !important;
    font-size: 16px !important;
    min-width: 50px !important;
  }
  
  /* Make join code input more visible on mobile */
  #join-code-input {
    font-size: 18px !important;
    padding: 10px !important;
  }
}

#start-screen-content h1 {
  margin: 0 0 var(--spacing-xl) 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: var(--font-3xl);
  font-weight: 700;
  letter-spacing: -0.5px;
}

#start-screen-content p {
  font-size: var(--font-lg);
  margin-bottom: var(--spacing-2xl);
  color: #666;
  font-weight: 500;
}

.start-btn {
  display: block;
  width: 100%;
  padding: var(--btn-padding-lg);
  margin: var(--spacing-md) 0;
  font-size: var(--font-lg);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: var(--touch-target-min);
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
}

.start-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transition: left 0.5s ease;
}

.start-btn:hover::before {
  left: 100%;
}

#start-multiplayer {
  background: linear-gradient(135deg, #28a745 0%, #20833a 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
}

#start-multiplayer.disabled {
  background: #ccc !important;
  color: #888 !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

#start-multiplayer:hover:not(.disabled) {
  background: linear-gradient(135deg, #218838 0%, #1c6e2f 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

#start-multiplayer.disabled:hover {
  background: #ccc !important;
  transform: none !important;
  box-shadow: none !important;
}

#start-singleplayer {
  background: linear-gradient(135deg, #0077ff 0%, #0056cc 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 119, 255, 0.25);
}

#start-singleplayer:hover {
  background: linear-gradient(135deg, #0056cc 0%, #003d99 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 119, 255, 0.4);
}

/* Compact lobby player count buttons */
.lobby-btn-compact {
  display: inline-block;
  width: auto;
  padding: 14px 20px;
  margin: 4px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 50px;
  min-width: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.lobby-btn-compact:hover {
  background: linear-gradient(135deg, #5568d3 0%, #653a8e 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* Auth buttons professional styling */
#login-btn {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%) !important;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.25);
  font-weight: 600;
  letter-spacing: 0.3px;
}

#login-btn:hover {
  background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

#logout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(244, 67, 54, 0.4);
}

button[style*="background: #FF9800"] {
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%) !important;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.25);
}

button[style*="background: #FF9800"]:hover {
  background: linear-gradient(135deg, #F57C00 0%, #E65100 100%) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.4);
}

.start-btn.disabled {
  background: #ccc;
  color: #888;
  cursor: not-allowed;
  opacity: 0.6;
}

.start-btn.disabled:hover {
  background: #ccc;
  transform: none;
  box-shadow: none;
}

/* Difficulty selection buttons */
#difficulty-buttons {
  display: flex;
  gap: var(--spacing-lg);
  justify-content: center;
  flex-wrap: wrap;
}

.difficulty-btn {
  padding: var(--btn-padding-md);
  font-size: var(--font-md);
  font-weight: bold;
  border: 2px solid #ccc;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 100px;
  min-height: 48px;
  background: white;
  color: #333;
}

.difficulty-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.difficulty-btn[data-difficulty="easy"] {
  border-color: #4caf50;
  color: #4caf50;
}

.difficulty-btn[data-difficulty="easy"]:hover {
  background: #4caf50;
  color: white;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.difficulty-btn[data-difficulty="medium"] {
  border-color: #ff9800;
  color: #ff9800;
}

.difficulty-btn[data-difficulty="medium"]:hover {
  background: #ff9800;
  color: white;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.difficulty-btn[data-difficulty="hard"] {
  border-color: #f44336;
  color: #f44336;
}

.difficulty-btn[data-difficulty="hard"]:hover {
  background: #f44336;
  color: white;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

/* AI Thinking Indicator */
#ai-thinking-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  padding: var(--spacing-4xl) var(--spacing-5xl);
  border-radius: var(--radius-2xl);
  box-shadow: 0 var(--spacing-md) var(--spacing-4xl) rgba(0, 0, 0, 0.5);
  z-index: 8888;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.ai-thinking-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-3xl);
}

.ai-thinking-content p {
  color: white;
  font-size: var(--font-xl);
  font-weight: bold;
  margin: 0;
}

.spinner {
  width: clamp(40px, 5vw, 60px);
  height: clamp(40px, 5vw, 60px);
  border: clamp(4px, 0.5vw, 6px) solid rgba(255, 255, 255, 0.3);
  border-top-color: #0077ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Game header - title left, scores right */
#game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 2px solid #dee2e6;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
}

#game-header h1 {
  margin: 0;
  font-size: var(--font-xl);
  color: #0077ff;
}

#team-scores {
  font-weight: bold;
  font-size: var(--font-md);
  color: #333;
  margin-right: 12px;
}

/* Player position indicators - colored dots on table border */
.player-indicator {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 8px;
  border: 2px solid;
  z-index: 60;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Player colors matching meld headers - uses data-logical-player (not data-player which is view position) */
.player-indicator[data-logical-player="0"] { background: rgba(255, 193, 7, 0.95); border-color: #f57f17; color: #000; }
.player-indicator[data-logical-player="1"] { background: rgba(76, 175, 80, 0.95); border-color: #2e7d32; color: #fff; }
.player-indicator[data-logical-player="2"] { background: rgba(156, 39, 176, 0.95); border-color: #6a1b9a; color: #fff; }
.player-indicator[data-logical-player="3"] { background: rgba(33, 150, 243, 0.95); border-color: #1565c0; color: #fff; }
.player-indicator[data-logical-player="4"] { background: rgba(121, 85, 72, 0.95); border-color: #4e342e; color: #fff; }
.player-indicator[data-logical-player="5"] { background: rgba(244, 67, 54, 0.95); border-color: #c62828; color: #fff; }

/* Active player indicator - glowing pulse animation */
.player-indicator.active {
  animation: indicatorPulse 1.5s ease-in-out infinite;
  z-index: 70;
}

/* Keep position transforms for active indicators */
.player-indicator.active.player-indicator-p1 { animation: indicatorPulse 1.5s ease-in-out infinite, positionP1 1.5s ease-in-out infinite; }
.player-indicator.active.player-indicator-p2 { animation: indicatorPulse 1.5s ease-in-out infinite, positionP2 1.5s ease-in-out infinite; }
.player-indicator.active.player-indicator-p3 { animation: indicatorPulse 1.5s ease-in-out infinite, positionP3 1.5s ease-in-out infinite; }
.player-indicator.active.player-indicator-p4 { animation: indicatorPulse 1.5s ease-in-out infinite, positionP4 1.5s ease-in-out infinite; }
.player-indicator.active.player-indicator-p5 { animation: indicatorPulse 1.5s ease-in-out infinite, positionP5 1.5s ease-in-out infinite; }
.player-indicator.active.player-indicator-p6 { animation: indicatorPulse 1.5s ease-in-out infinite, positionP6 1.5s ease-in-out infinite; }

@keyframes indicatorPulse {
  0%, 100% { 
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.6), 0 0 20px currentColor;
  }
  50% { 
    transform: scale(1.5);
    box-shadow: 0 0 25px rgba(255, 255, 255, 1), 0 0 45px currentColor, 0 0 65px currentColor;
  }
}

@keyframes positionP1 { 0%, 100% { transform: translateX(-50%) scale(1.2); } 50% { transform: translateX(-50%) scale(1.5); } }
@keyframes positionP2 { 0%, 100% { transform: translateY(50%) scale(1.2); } 50% { transform: translateY(50%) scale(1.5); } }
@keyframes positionP3 { 0%, 100% { transform: translateY(50%) scale(1.2); } 50% { transform: translateY(50%) scale(1.5); } }
@keyframes positionP4 { 0%, 100% { transform: translateX(-50%) scale(1.2); } 50% { transform: translateX(-50%) scale(1.5); } }
@keyframes positionP5 { 0%, 100% { transform: translateY(50%) scale(1.2); } 50% { transform: translateY(50%) scale(1.5); } }
@keyframes positionP6 { 0%, 100% { transform: translateY(50%) scale(1.2); } 50% { transform: translateY(50%) scale(1.5); } }

/* Inactive player melds - dimmed */
.player-licences.inactive {
  opacity: 0.5;
}

/* Final hands displayed on table at round end */
#final-hands-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 45;
}

.final-hand-fan {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: handReveal 0.5s ease-out;
}

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

.final-hand-label {
  font-size: 11px;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 10px;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.final-hand-label.team-a {
  background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
}

.final-hand-label.team-b {
  background: linear-gradient(135deg, #2196f3 0%, #1565c0 100%);
}

.final-hand-cards {
  display: flex;
  position: relative;
  pointer-events: all;
}

.final-hand-cards .card {
  position: absolute;
  left: calc(var(--card-index) * 12px);
  transform-origin: bottom center;
  transform: translateY(calc(var(--card-index) * -2px)) rotate(calc((var(--card-index) - 2) * 4deg));
  transition: transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.final-hand-cards .card:hover {
  transform: translateY(calc(var(--card-index) * -2px - 15px)) rotate(calc((var(--card-index) - 2) * 4deg));
  z-index: 100;
}

/* Position indicators centered on the brown border */
.player-indicator-p1 { bottom: -4px; left: 50%; transform: translateX(-50%); }
.player-indicator-p2 { bottom: 33%; right: -4px; transform: translateY(50%); }
.player-indicator-p3 { bottom: 66%; right: -4px; transform: translateY(50%); }
.player-indicator-p4 { top: -4px; left: 50%; transform: translateX(-50%); }
.player-indicator-p5 { bottom: 66%; left: -4px; transform: translateY(50%); }
.player-indicator-p6 { bottom: 33%; left: -4px; transform: translateY(50%); }

/* Table layout - realistic 6-player card table */
#table-wrap {
  max-width: var(--table-max-width);
  margin: 0 auto;
  padding: var(--spacing-xs) var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  max-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Game info footer - discreet version/game number display */
#game-info-footer {
  position: fixed;
  bottom: var(--spacing-xs);
  right: var(--spacing-md);
  font-size: 10px;
  color: #666;
  opacity: 0.5;
  font-family: monospace;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
}

#game-info-footer .separator {
  margin: 0 4px;
}

/* Realistic table surface - simplified layout for licences only */
#game-table {
  background: radial-gradient(ellipse at center, #1a7a4b 0%, #136038 70%, #0f4d2e 100%);
  border: var(--table-border-width) solid #5a3310;
  border-radius: var(--radius-xl);
  box-shadow: 
    0 var(--spacing-sm) var(--spacing-xl) rgba(0, 0, 0, 0.5),
    inset 0 var(--spacing-xs) var(--spacing-sm) rgba(0, 0, 0, 0.3);
  padding: var(--spacing-sm);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto auto auto auto;
  grid-template-areas:
    ".          p4-lic        ."
    "p5-lic     .             p3-lic"
    ".          center        ."
    ".          center        ."
    "p6-lic     p1-lic        p2-lic";
  gap: var(--spacing-xs);
  position: relative;
  min-height: var(--table-min-height);
  max-height: 75vh;
}

/* Player seats - hide names and hands on table for cleaner look */
.seat {
  display: none;
}

/* Vertical table seat positions */
.seat-p1 { grid-area: p1-area; }
.seat-p2 { grid-area: p2-area; }
.seat-p3 { grid-area: p3-area; flex-direction: row-reverse; }
.seat-p4 { grid-area: p4-area; }
.seat-p5 { grid-area: p5-area; flex-direction: row; }
.seat-p6 { grid-area: p6-area; }

/* Player licence areas */
.player-licences[data-player="0"] { grid-area: p1-lic; }
.player-licences[data-player="1"] { grid-area: p6-lic; }
.player-licences[data-player="2"] { grid-area: p5-lic; }
.player-licences[data-player="3"] { grid-area: p4-lic; }
.player-licences[data-player="4"] { grid-area: p3-lic; }
.player-licences[data-player="5"] { grid-area: p2-lic; }

.player-info {
  background: rgba(255, 255, 255, 0.95);
  padding: var(--spacing-sm) var(--spacing-xl);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: 0 var(--spacing-xs) var(--spacing-md) rgba(0, 0, 0, 0.2);
}

.player-info h3 {
  margin: 0;
  font-size: var(--font-sm);
  color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.you-label {
  color: #0077ff;
  font-weight: bold;
}

.toggle-display-btn {
  background: transparent;
  border: none;
  font-size: var(--font-md);
  cursor: pointer;
  padding: var(--spacing-xs);
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
}

.toggle-display-btn:hover {
  opacity: 1;
  transform: scale(1.2);
}

.player.team-a .player-info { border: clamp(1px, 0.15vw, 3px) solid #4a9eff; }
.player.team-b .player-info { border: clamp(1px, 0.15vw, 3px) solid #ff6b6b; }

/* Center piles */
#center-piles {
  grid-area: center;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  justify-content: center;
  padding: var(--spacing-xs);
  align-items: center;
}

.pile-deck {
  text-align: center;
}

.deck-visual {
  width: var(--card-width);
  height: var(--card-height);
  background: linear-gradient(135deg, #0b3565, #4a86c5);
  border: clamp(1px, 0.15vw, 3px) solid #0b3565;
  border-radius: var(--radius-md);
  margin: 0 auto;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 var(--spacing-xs) var(--spacing-md) rgba(0, 0, 0, 0.3);
  transform: rotate(90deg);
}

.deck-visual:hover {
  transform: rotate(90deg) translateY(calc(var(--spacing-xs) * -1));
  box-shadow: 0 var(--spacing-md) var(--spacing-2xl) rgba(0, 119, 255, 0.4);
}

.pile-label {
  display: none;
}

.pile-discard {
  text-align: center;
  min-height: var(--discard-min-height);
  border: none;
}

#discard-cards {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: var(--discard-min-height);
  width: var(--discard-width);
  margin: 0 auto;
  padding: var(--spacing-xs);
  border: none;
  outline: none;
}

#discard-cards .card {
  transition: box-shadow 0.2s, filter 0.2s;
  cursor: pointer;
}

/* Picked cards zones - Natural table layout (no white box) */
#forced-licence-zones {
  margin-top: var(--spacing-md);
  padding: var(--spacing-xs);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  background: transparent;
  border: none;
}

#forced-card-zone, #picked-bundle-zone {
  background: transparent;
  padding: 0;
  text-align: center;
  position: relative;
}

.zone-label {
  font-size: 10px;
  font-weight: bold;
  color: #ffa500;
  text-shadow: 0 0 3px rgba(0,0,0,0.8), 0 1px 2px rgba(0,0,0,0.5);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#forced-card-display, #picked-bundle-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: var(--card-height);
  flex-wrap: wrap;
}

/* Forced card styling - subtle golden glow */
#forced-card-display .card {
  box-shadow: 0 0 8px 2px rgba(255, 215, 0, 0.5), 0 4px 8px rgba(0,0,0,0.3);
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(255, 215, 0, 0.5), 0 4px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 12px 4px rgba(255, 215, 0, 0.7), 0 4px 8px rgba(0,0,0,0.3); }
}

/* Selectable bundle cards - interactive cursor */
.selectable-bundle-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.selectable-bundle-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.selectable-bundle-card.selected {
  transform: translateY(-8px);
  box-shadow: 0 0 12px 3px rgba(33, 150, 243, 0.8), 0 8px 16px rgba(0,0,0,0.4);
}

.cancel-pickup-btn {
  width: auto;
  margin: var(--spacing-sm) auto 0;
  padding: 6px 16px;
  background: #d9534f;
  color: white;
  border: 2px solid #c9302c;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  display: block;
}

.cancel-pickup-btn:hover {
  background: #c9302c;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

/* Player licence areas - display side-by-side horizontally */
.player-licences {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  align-items: flex-start;
  justify-content: flex-start;
  min-height: clamp(40px, 8vh, 80px);
  padding: var(--spacing-xs);
  max-width: 100%;
  transition: opacity 0.3s ease;
}

/* Top tier: horizontal addon cards (contributor cards) */
.licence-addon-strip {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  align-items: flex-start;
  min-height: clamp(20px, 4vh, 50px);
  width: 100%;
}

/* Bottom tier: horizontal meld track (full melds) */
.licence-meld-track {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  align-items: flex-start;
  width: 100%;
  min-width: 0;
}

/* Allow cards in melds to wrap when too many */
.player-licences .meld .cards {
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

/* Current player panel - below table - ULTRA COMPACT */
#current-player-panel {
  background: #fff;
  border: clamp(1px, 0.15vw, 2px) solid #0077ff;
  border-radius: var(--radius-md);
  padding: var(--spacing-xs) var(--spacing-sm);
  box-shadow: 0 var(--spacing-xs) var(--spacing-sm) rgba(0, 119, 255, 0.2);
  max-height: 30vh;
  overflow-y: auto;
}

#current-player-panel h2 {
  margin: 0;
  padding: var(--spacing-xs) 0;
  font-size: var(--font-sm);
  display: inline-block;
}

#current-hand {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0; /* No gap - cards will overlap */
  padding: var(--spacing-2xl) var(--spacing-md) var(--spacing-md) var(--spacing-md);
  min-height: clamp(80px, 12vh, 120px); /* More height for fan arc */
  width: 100%;
  position: relative;
  perspective: 1000px; /* 3D perspective for fan effect */
}

/* Cards - Standard playing card dimensions (5:7 ratio) */
.card {
  position: relative;
  display: inline-block;
  width: var(--card-width);
  height: var(--card-height);
  border: clamp(1px, 0.08vw, 2px) solid #000;
  border-radius: var(--card-border-radius);
  background: #fff;
  user-select: none;
  box-sizing: border-box;
}

.card-corner {
  position: absolute;
  font-size: var(--font-card-corner);
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;
}

.card-corner.top-left {
  top: 1px;
  left: 1px;
}

.card-corner.bottom-right {
  bottom: var(--spacing-xs);
  right: var(--spacing-xs);
  transform: rotate(180deg);
}

/* Mobile: large center value for easy reading (40px cards) */
.card-center-mobile {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  pointer-events: none;
  text-align: center;
}

/* Center pip container */
.card-pips {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Individual pips (suit symbols in center) */
.pip {
  position: absolute;
  font-size: var(--font-lg);
  font-weight: bold;
  transform: translate(-50%, -50%);
  line-height: 1;
}

/* Face card center layout (J, Q, K) - realistic sizing for 50×70px cards */
.card-face-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.face-letter {
  font-size: var(--font-2xl);
  font-weight: bold;
  line-height: 1;
  margin: 0;
}

.face-suit {
  font-size: var(--font-lg);
  font-weight: bold;
  margin-top: var(--spacing-xs);
  line-height: 1;
}

.card.red { color: #c40000; }
.card.black { color: #111; }

.card.selected {
  background: #222;
  color: #fff !important;
}

.hand-hidden {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
  justify-content: center;
  min-height: clamp(40px, 6vh, 60px);
  position: relative;
}

.card-back {
  width: var(--card-back-width);
  height: var(--card-back-height);
  background: linear-gradient(135deg, #0b3565, #4a86c5);
  border-radius: var(--radius-md);
  border: clamp(1px, 0.08vw, 2px) solid #0b3565;
}

/* Poker-style fan for opponent hands */
.card-in-fan {
  position: absolute;
  left: 50%;
  transform-origin: center bottom;
  transition: transform 0.2s ease;
}

/* Default horizontal fan */
.card-in-fan {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5));
}

/* Left seat (P1) - fan tilts right */
.card-in-fan[data-orientation="left"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5deg + 10deg));
}

.card-in-fan[data-orientation="left"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5deg + 10deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Top-left seat (P2) - fan arcs down-right */
.card-in-fan[data-orientation="top-left"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5)) 
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 4.5deg + 15deg));
}

.card-in-fan[data-orientation="top-left"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5)) 
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 4.5deg + 15deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Top-right seat (P3) - fan arcs down-left */
.card-in-fan[data-orientation="top-right"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5)) 
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 4.5deg - 15deg));
}

.card-in-fan[data-orientation="top-right"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5)) 
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 4.5deg - 15deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Right seat (P4) - fan tilts left */
.card-in-fan[data-orientation="right"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5deg - 10deg));
}

.card-in-fan[data-orientation="right"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5deg - 10deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Bottom-right seat (P5) - wider fan, tilts slightly left */
.card-in-fan[data-orientation="bottom-right"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg - 5deg));
}

.card-in-fan[data-orientation="bottom-right"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg - 5deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Bottom-left seat (P6) - wider fan, tilts slightly right */
.card-in-fan[data-orientation="bottom-left"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg + 5deg));
}

.card-in-fan[data-orientation="bottom-left"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg + 5deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Bottom center seat (P1) - wide fan, no tilt */
.card-in-fan[data-orientation="bottom"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg));
}

.card-in-fan[data-orientation="bottom"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Top center seat (P4) - wide fan pointing down, no tilt */
.card-in-fan[data-orientation="top"] {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg));
}

.card-in-fan[data-orientation="top"]:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-wide) - var(--total-cards) * var(--fan-offset-wide) * 0.5))
             rotate(calc((var(--card-index) - var(--total-cards) / 2) * 5.5deg))
             translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Default hover */
.card-in-fan:hover {
  transform: translateX(-50%) translateX(calc(var(--card-index) * var(--fan-offset-base) - var(--total-cards) * var(--fan-offset-base) * 0.5)) translateY(var(--fan-hover-lift)) scale(1.1);
}

/* Hidden state */
.hand-concealed {
  padding: var(--btn-padding-md);
  background: #333;
  color: #fff;
  border-radius: var(--radius-md);
  font-size: var(--font-xs);
  font-weight: bold;
}

/* Melds */
#table-melds { grid-column: 2 / 3; text-align: center; }
#table-melds h2 { margin: var(--spacing-md) 0; font-size: var(--font-xl); }

#melds-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
  justify-content: center;
}

/* Licence rotation wrapper (preserves hover effects) */
.meld-orientation {
  display: inline-block;
  transform-origin: center center;
  transition: transform 0.3s ease;
  flex-shrink: 0;
  margin: 0 var(--spacing-sm);
  vertical-align: top;
}

/* Player-specific rotations - licences face their owner */
.player-0-orientation {
  transform: rotate(0deg); /* P1 bottom center - no rotation */
}

.player-1-orientation,
.player-2-orientation {
  transform: rotate(90deg); /* Left side players (P6, P5) - rotate clockwise */
}

.player-3-orientation {
  transform: rotate(180deg); /* Top player (P4) - upside down */
}

.player-4-orientation,
.player-5-orientation {
  transform: rotate(270deg); /* Right side players (P3, P2) - rotate counter-clockwise */
}

/* Horizontal overflow melds (4th+ cards in same-value sets) - always horizontal, facing right */
.horizontal-overflow-orientation {
  transform: rotate(-90deg) !important;
}

/* Licence tiles - no background, just the cards */
.meld {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  border: none;
  padding: var(--spacing-xs);
  transition: all 0.2s ease;
  width: auto;
  max-width: clamp(140px, 22vw, 260px);
}

/* Clickable melds when in "add to licence" mode */
.meld.clickable-meld {
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  background: rgba(0, 119, 255, 0.15);
  box-shadow: 0 0 var(--spacing-xl) rgba(0, 119, 255, 0.6);
  animation: pulse 1.5s infinite;
}

.meld.clickable-meld:hover {
  transform: scale(1.05);
  background: rgba(0, 204, 0, 0.2);
  box-shadow: 0 0 var(--spacing-2xl) rgba(0, 204, 0, 0.8);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 var(--spacing-xl) rgba(0, 119, 255, 0.6); }
  50% { box-shadow: 0 0 var(--spacing-3xl) rgba(0, 119, 255, 0.9); }
}

/* Sets: vertical stack with overlapping cards (same as runs) */
.meld.set .cards {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: auto;
  padding-top: var(--spacing-xs);
}

.meld.set .cards .card {
  position: relative;
  transform: translateY(calc(var(--stack-index) * var(--card-stack-offset)));
  margin-bottom: var(--card-stack-offset);
}

.meld.set .cards .card:last-child {
  margin-bottom: 0;
}

/* Individual set contributions: display horizontally (rotated 90 degrees) */
.meld.set.individual-contribution .cards {
  flex-direction: row;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs);
}

.meld.set.individual-contribution .cards .card {
  transform: rotate(90deg);
  margin: 0;
}

/* Runs: vertical stack with overlapping cards */
.meld.run .cards {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: auto;
  padding-top: var(--spacing-xs);
}

.meld.run .cards .card {
  position: relative;
  transform: translateY(calc(var(--stack-index) * var(--card-stack-offset)));
  margin-bottom: var(--card-stack-offset);
}

.meld.run .cards .card:last-child {
  margin-bottom: 0;
}

/* Individual run contributions: display horizontally (rotated 90 degrees) */
.meld.run.individual-contribution .cards {
  flex-direction: row;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs);
}

.meld.run.individual-contribution .cards .card {
  transform: rotate(90deg);
  margin: 0;
}

/* Consolidated run tiles: display all cards horizontally with visible spacing */
.meld.run.consolidated-run .cards {
  flex-direction: row;
  gap: 8px;  /* Visible spacing between cards */
  padding: var(--spacing-xs);
}

.meld.run.consolidated-run .cards .card {
  transform: rotate(90deg);
  margin: 0;
}

/* Controls - COMPACT LAYOUT */
#controls, #tools, #ai-controls {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--spacing-sm);
}

#controls {
  margin-top: var(--spacing-md);
}
button {
  padding: var(--btn-padding-xs);
  border-radius: var(--radius-md);
  border: clamp(1px, 0.08vw, 2px) solid #888;
  background: #fff;
  cursor: pointer;
  min-height: var(--touch-target-min);
  font-size: var(--font-xs);
  white-space: nowrap;
}
button:hover { 
  background: #f0f0f0;
}

/* Icon buttons in tools and controls sections - compact squares */
#tools button,
#controls button {
  min-width: var(--touch-target-min);
  padding: var(--spacing-sm);
  font-size: var(--font-lg);
  font-weight: bold;
}

/* Sort buttons in orange */
#tools button {
  background: #ff8c00;
  color: white;
  border-color: #ff6600;
}

/* Discard pile stacking */
#discard-cards .card {
  position: absolute;
  cursor: pointer;
}

/* Top discard card highlights and has hover effect */
#discard-cards .top-discard { 
  outline: clamp(1px, 0.15vw, 3px) solid #444;
  z-index: 100 !important;
}

/* Hover effect on all discard cards - scale only, preserve position */
#discard-cards .card:hover {
  box-shadow: 0 var(--spacing-md) var(--spacing-2xl) rgba(0, 0, 0, 0.4);
  z-index: 150 !important;
  filter: brightness(1.1);
}

#ai-controls {
  border-top: clamp(1px, 0.15vw, 3px) solid #0077ff;
  padding-top: var(--spacing-xl);
  margin-top: var(--spacing-xl);
}

#ai-controls button {
  background: #0077ff;
  color: white;
  font-weight: bold;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Mobile devices (320px - 767px) */
@media (max-width: 767px) {
  :root {
    /* Larger cards on mobile for better readability */
    --card-width: clamp(55px, 8vw, 80px);
    --card-height: calc(var(--card-width) * 1.4);
    
    /* Bigger fonts for card values */
    --font-card-corner: clamp(13px, 2vw, 18px);
    
    /* Larger touch targets */
    --touch-target-min: 52px;
    
    /* Adjusted spacing for mobile */
    --spacing-xs: clamp(4px, 0.8vw, 8px);
    --spacing-sm: clamp(6px, 1vw, 10px);
    --spacing-md: clamp(8px, 1.2vw, 12px);
    
    /* Aggressive card overlap to fit 18 cards in one row (320px screen) */
    --fan-offset-base: calc(var(--card-width) * 0.25);
    --fan-offset-wide: calc(var(--card-width) * 0.25);
    
    /* Increase table height on mobile */
    --table-min-height: clamp(300px, 50vh, 500px);
  }
  
  /* Increase table height on mobile to show more content */
  #game-table {
    max-height: 50vh;
  }
  
  /* Reduce player panel height to save space */
  #current-player-panel {
    min-height: auto;
    max-height: 24vh;
    padding: 4px;
    overflow: visible;
  }
  
  /* Compact heading */
  #current-player-panel h2 {
    font-size: 14px;
    padding: 2px 0;
    margin: 0;
  }
  
  /* Buttons in single row, compact */
  #controls,
  #tools {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 4px;
    justify-content: center;
    margin: 2px;
  }
  
  /* Parent container for buttons */
  #current-player-panel {
    text-align: center;
  }
  
  /* Make buttons compact but touchable */
  #controls button,
  #tools button {
    min-width: 44px;
    min-height: 44px;
    font-size: clamp(15px, 2vw, 18px);
    padding: 6px;
    flex-shrink: 0;
    touch-action: manipulation;
    position: relative;
    z-index: 100;
  }
  
  /* Mobile hand - FAN LAYOUT like real card holder */
  #current-hand {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-end;
    margin: -40px 0 0 0; /* Negative margin to move cards higher */
    padding: 0 4px 4px 4px; /* Minimal padding */
    width: 100%;
    min-height: 80px;
    overflow: visible;
    position: relative;
    perspective: 600px; /* 3D perspective for fan depth */
  }
  
  /* Cards in FAN layout - each card rotates and positions uniquely */
  #current-hand .card {
    width: var(--card-width, 40px);
    height: var(--card-height, 56px);
    cursor: pointer;
    flex-shrink: 0;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform-origin: center bottom;
    transition: transform 0.2s ease-out, z-index 0s, box-shadow 0.2s ease-out;
    touch-action: manipulation;
  }
  
  /* Fan spread using nth-child - spreads cards in arc */
  #current-hand .card:nth-child(1) { transform: translateX(-50%) rotate(-24deg) translateY(12px); }
  #current-hand .card:nth-child(2) { transform: translateX(-50%) rotate(-20deg) translateY(8px); }
  #current-hand .card:nth-child(3) { transform: translateX(-50%) rotate(-16deg) translateY(5px); }
  #current-hand .card:nth-child(4) { transform: translateX(-50%) rotate(-12deg) translateY(3px); }
  #current-hand .card:nth-child(5) { transform: translateX(-50%) rotate(-8deg) translateY(1px); }
  #current-hand .card:nth-child(6) { transform: translateX(-50%) rotate(-4deg) translateY(0px); }
  #current-hand .card:nth-child(7) { transform: translateX(-50%) rotate(0deg) translateY(0px); }
  #current-hand .card:nth-child(8) { transform: translateX(-50%) rotate(4deg) translateY(0px); }
  #current-hand .card:nth-child(9) { transform: translateX(-50%) rotate(8deg) translateY(1px); }
  #current-hand .card:nth-child(10) { transform: translateX(-50%) rotate(12deg) translateY(3px); }
  #current-hand .card:nth-child(11) { transform: translateX(-50%) rotate(16deg) translateY(5px); }
  #current-hand .card:nth-child(12) { transform: translateX(-50%) rotate(20deg) translateY(8px); }
  #current-hand .card:nth-child(13) { transform: translateX(-50%) rotate(24deg) translateY(12px); }
  #current-hand .card:nth-child(14) { transform: translateX(-50%) rotate(28deg) translateY(16px); }
  #current-hand .card:nth-child(15) { transform: translateX(-50%) rotate(32deg) translateY(20px); }
  #current-hand .card:nth-child(16) { transform: translateX(-50%) rotate(36deg) translateY(24px); }
  
  /* Hover/selected card pops forward in the fan */
  #current-hand .card:hover,
  #current-hand .card.selected {
    z-index: 100 !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
  }
  
  /* Draggable card styling - works with fan layout */
  .draggable-card {
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
    user-select: none;
    -webkit-user-select: none;
  }
  
  .draggable-card.dragging {
    opacity: 0.9;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    cursor: grabbing;
    z-index: 1000 !important;
    transition: none; /* Disable transition while dragging for immediate response */
  }
  
  /* Discard pile highlight when card is being dragged over it */
  #discard-cards.drop-target-active {
    outline: 3px solid #4CAF50;
    outline-offset: 4px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 8px;
  }
  
  /* Cards that are being reordered (making space) - maintain fan position */
  .draggable-card.reordering {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  /* No horizontal scroll needed - cards fit within screen width */
  body {
    overflow-x: hidden !important;
    overflow-y: auto !important; /* Allow vertical scroll if needed */
    margin: 0;
    padding: 0;
  }
  
  /* Table wrap can hide overflow since hand doesn't scroll */
  #table-wrap {
    overflow: visible !important;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    margin-top: 50px; /* Push below fixed header */
    padding: 0 8px 20px 8px; /* Add padding for player indicators on sides and bottom */
  }
  
  /* Mobile table - free-form table for draggable melds */
  #game-table {
    position: relative;
    width: calc(100% - 40px);
    max-width: calc(100% - 40px);
    height: 70vh;
    min-height: 450px;
    max-height: 750px;
    overflow: visible;
    box-sizing: border-box;
    margin: 0 auto 10px auto;
    padding: 4px;
  }
  
  /* Hide all fixed player areas */
  .player-licences {
    display: none !important;
  }
  
  /* Hide quadrant wrappers */
  #top-right-quadrant,
  #bottom-right-quadrant {
    display: none !important;
  }
  
  /* Center deck/discard in fixed position */
  #center-area {
    position: absolute;
    left: 50%;
    top: 25%;
    transform: translate(-50%, -50%);
    z-index: 50;
    pointer-events: none;
  }
  
  #center-area > * {
    pointer-events: auto;
  }
  
  /* Adjust center pile spacing for mobile */
  #center-piles {
    gap: 0;
    flex-direction: column;
    align-items: center;
    background: none;
    padding: 0;
    border-radius: 0;
    border: none;
  }
  
  #deck-pile, #discard-pile {
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
  }
  
  .pile-label {
    font-size: 9px;
  }
  
  /* Discard pile cards - match hand card size on mobile */
  #discard-cards {
    padding: 0;
    margin: 0;
    min-height: auto;
  }
  
  #discard-cards .card {
    width: var(--card-width, 40px);
    height: var(--card-height, 56px);
    font-size: 11px;
  }
  
  .pile-deck, .pile-discard {
    margin: 0;
    padding: 0;
    min-height: auto;
  }
  
  .deck-visual {
    margin: 0;
  }
  
  /* Draggable melds container */
  #draggable-melds-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
  }
  
  /* Individual draggable melds */
  .draggable-meld {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
    z-index: 20;
    transform-origin: top left;
  }
  
  .draggable-meld.dragging {
    cursor: grabbing;
    opacity: 0.8;
    z-index: 100;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  }
  
  /* Meld header with player label */
  .draggable-meld .meld-header {
    font-size: 10px;
    font-weight: bold;
    padding: 2px 4px;
    margin-bottom: 4px;
    border-radius: 3px;
    text-align: center;
  }
  
  /* Player color headers */
  /* Meld header colors use data-logical-player for consistent player colors across all views */
  .draggable-meld[data-logical-player="0"] .meld-header { background: rgba(255, 193, 7, 0.9); color: #000; }
  .draggable-meld[data-logical-player="1"] .meld-header { background: rgba(76, 175, 80, 0.9); color: #fff; }
  .draggable-meld[data-logical-player="2"] .meld-header { background: rgba(156, 39, 176, 0.9); color: #fff; }
  .draggable-meld[data-logical-player="3"] .meld-header { background: rgba(33, 150, 243, 0.9); color: #fff; }
  .draggable-meld[data-logical-player="4"] .meld-header { background: rgba(121, 85, 72, 0.9); color: #fff; }
  .draggable-meld[data-logical-player="5"] .meld-header { background: rgba(244, 67, 54, 0.9); color: #fff; }
  
  /* Meld cards container - stacked vertically top to bottom */
  .draggable-meld .meld-cards {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 35px;
  }
  
  .draggable-meld .meld-cards .card {
    width: 35px;
    height: 49px;
    font-size: 10px;
    position: relative;
    margin-top: -35px; /* Overlap cards vertically */
  }
  
  .draggable-meld .meld-cards .card:first-child {
    margin-top: 0; /* First card not offset */
  }
  
  /* Horizontal overflow melds - display cards side-by-side */
  .draggable-meld.horizontal-overflow {
    min-width: auto;
    width: auto;
    padding: 3px; /* Padding so border wraps all sides evenly */
    box-sizing: border-box;
    display: inline-block; /* Ensure proper wrapping */
  }

  .draggable-meld.horizontal-overflow .meld-cards {
    flex-direction: row;
    min-width: auto;
    min-height: 35px; /* Width of rotated card (original height) */
    height: 35px;
    align-items: center;
  }

  .draggable-meld.horizontal-overflow .meld-cards .card {
    margin-top: 0;
    margin-left: -20px; /* Reduced overlap so all cards are visible */
    transform: rotate(-90deg);
    transform-origin: center center;
  }

  .draggable-meld.horizontal-overflow .meld-cards .card:first-child {
    margin-left: 0; /* First card not offset */
  }
  
  /* Hide desktop seats on mobile */
  .desktop-only {
    display: none !important;
  }
  
  /* License areas - compact layout with visible labels and color coding */
  .player-licences {
    border-radius: var(--radius-md);
    padding: 4px;
    min-height: 50px;
    position: relative;
    overflow-x: auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  
  /* Color coding for each player area matching diagram */
  .player-licences-p1 {
    background: rgba(255, 235, 59, 0.15); /* Yellow */
    border: 2px solid rgba(255, 235, 59, 0.5);
  }
  
  .player-licences-p2 {
    background: rgba(244, 67, 54, 0.15); /* Red */
    border: 2px solid rgba(244, 67, 54, 0.5);
  }
  
  .player-licences-p3 {
    background: rgba(121, 85, 72, 0.15); /* Brown */
    border: 2px solid rgba(121, 85, 72, 0.5);
  }
  
  .player-licences-p4 {
    background: rgba(33, 150, 243, 0.15); /* Blue */
    border: 2px solid rgba(33, 150, 243, 0.5);
  }
  
  .player-licences-p5 {
    background: rgba(156, 39, 176, 0.15); /* Purple */
    border: 2px solid rgba(156, 39, 176, 0.5);
  }
  
  .player-licences-p6 {
    background: rgba(76, 175, 80, 0.15); /* Green */
    border: 2px solid rgba(76, 175, 80, 0.5);
  }
  
  /* Quadrant containers */
  #top-right-quadrant,
  #bottom-right-quadrant {
    flex: 1;
  }
  
  #top-right-quadrant .player-licences,
  #bottom-right-quadrant .player-licences {
    flex: 1;
  }
  
  /* Add player labels to license areas on mobile */
  .player-licences::before {
    content: "Player " attr(data-player);
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 10px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 3px 6px;
    border-radius: 4px;
    z-index: 10;
  }
  
  /* Show player numbers with matching colors */
  .player-licences-p1::before { content: "P1 (You)"; background: rgba(255, 193, 7, 0.9); color: #000; }
  .player-licences-p2::before { content: "P2"; background: rgba(244, 67, 54, 0.9); }
  .player-licences-p3::before { content: "P3"; background: rgba(121, 85, 72, 0.9); }
  .player-licences-p4::before { content: "P4"; background: rgba(33, 150, 243, 0.9); }
  .player-licences-p5::before { content: "P5"; background: rgba(156, 39, 176, 0.9); }
  .player-licences-p6::before { content: "P6"; background: rgba(76, 175, 80, 0.9); }
  
  /* Card flow directions - melds displayed in flex layout */
  .player-licences-p1 .licence-area,
  .player-licences-p4 .licence-area {
    /* P1 (Yellow) and P4 (Blue): center outward */
    justify-content: center;
  }
  
  .player-licences-p2 .licence-area,
  .player-licences-p5 .licence-area {
    /* P2 (Red) and P5 (Purple): right to left */
    justify-content: flex-end;
    flex-direction: row-reverse;
  }
  
  .player-licences-p3 .licence-area,
  .player-licences-p6 .licence-area {
    /* P3 (Brown) and P6 (Green): left to right */
    justify-content: flex-start;
  }
  
  .licence-area {
    max-height: none;
    overflow: visible;
    margin-top: 16px;
  }
  
  /* License label - smaller on mobile */
  .licence-label {
    font-size: var(--font-xs);
    padding: 2px 4px;
  }
  
  /* Two-tier license layout - more compact on mobile */
  .licence-area .addon-strip,
  .licence-area .meld-track {
    gap: 2px;
  }
  
  /* Make melds more visible on mobile */
  .player-licences .meld {
    background: rgba(255, 255, 255, 0.95);
    padding: 4px;
    border-radius: 4px;
    margin: 2px 0;
  }
  
  /* Reduce header and scoreboard spacing */
  header {
    padding: var(--spacing-sm);
  }
  
  /* Compact header on mobile */
  #game-header {
    padding: 6px 10px;
    flex-wrap: nowrap;
  }
  
  #game-header h1 {
    font-size: var(--font-lg);
  }
  
  #team-scores {
    font-size: var(--font-sm);
    white-space: nowrap;
  }
  
  /* Adjust player indicator positions on mobile - players sitting outside the table */
  .player-indicator-p4 {
    top: -24px !important; /* Sit outside top border */
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 100 !important;
  }
  
  .player-indicator-p1 {
    bottom: -24px !important; /* Sit outside bottom border */
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 100 !important;
  }
  
  /* Side player indicators - sit outside side borders */
  .player-indicator-p2 {
    bottom: 30% !important;
    right: -24px !important;
    transform: translateY(50%) !important;
    z-index: 100 !important;
  }
  
  .player-indicator-p3 {
    bottom: 60% !important;
    right: -24px !important;
    transform: translateY(50%) !important;
    z-index: 100 !important;
  }
  
  .player-indicator-p5 {
    bottom: 60% !important;
    left: -24px !important;
    transform: translateY(50%) !important;
    z-index: 100 !important;
  }
  
  .player-indicator-p6 {
    bottom: 30% !important;
    left: -24px !important;
    transform: translateY(50%) !important;
    z-index: 100 !important;
  }
}

/* Tablet devices (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  :root {
    /* Slightly larger cards on tablet */
    --card-width: clamp(50px, 6.5vw, 75px);
    --card-height: calc(var(--card-width) * 1.4);
    
    /* Better font sizes for tablet */
    --font-card-corner: clamp(12px, 1.5vw, 16px);
  }
}

/* Ready-up overlay after round ends */
#ready-up-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  display: none;
  z-index: 10000;
}

.ready-up-modal {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 15px 25px;
  max-width: 700px;
  width: auto;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
}

.minimize-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: background 0.2s;
}

.minimize-btn:hover {
  background: rgba(0, 0, 0, 0.2);
}

.restore-btn {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(33, 150, 243, 0.95);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  transition: background 0.3s;
  z-index: 10001;
}

.restore-btn:hover {
  background: rgba(25, 118, 210, 0.95);
}

.ready-up-modal h2 {
  color: #2c5f2d;
  margin: 0 0 10px 0;
  font-size: 20px;
}

.ready-up-modal h3 {
  color: #333;
  margin: 10px 0 8px 0;
  font-size: 15px;
}

/* Score Summary Styles */
.score-summary {
  margin-bottom: 15px;
  text-align: left;
}

.round-end-message {
  background: #fff3cd;
  color: #856404;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
  font-weight: bold;
  margin-bottom: 12px;
  font-size: 14px;
}

.player-scores-section h3 {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: #333;
  text-align: center;
}

.player-scores-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.player-score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 4px solid #ccc;
  background: #f9f9f9;
}

.player-score-item.team-a {
  border-left-color: #4caf50;
  background: linear-gradient(to right, #e8f5e9 0%, #f9f9f9 15%);
}

.player-score-item.team-b {
  border-left-color: #2196f3;
  background: linear-gradient(to right, #e3f2fd 0%, #f9f9f9 15%);
}

.player-score-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.player-name {
  font-weight: bold;
  font-size: 13px;
  color: #333;
}

.team-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  color: white;
}

.team-badge.team-a {
  background: #4caf50;
}

.team-badge.team-b {
  background: #2196f3;
}

.closer-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  background: #ffd700;
  color: #333;
}

.player-score-value {
  font-weight: bold;
  font-size: 16px;
  min-width: 50px;
  text-align: right;
}

.player-score-value.positive {
  color: #2e7d32;
}

.player-score-value.negative {
  color: #c62828;
}

.team-totals-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.team-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.team-total {
  padding: 8px 10px;
  border-radius: 6px;
  text-align: center;
}

.team-a-total {
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
  color: white;
}

.team-b-total {
  background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
  color: white;
}

.team-total-label {
  font-size: 11px;
  opacity: 0.9;
  margin-bottom: 3px;
}

.team-total-value {
  font-size: 18px;
  font-weight: bold;
}

.game-total {
  padding: 8px 10px;
  border-radius: 6px;
  text-align: center;
  border: 2px solid;
}

.team-a-game-total {
  border-color: #4caf50;
  background: #e8f5e9;
  color: #2e7d32;
}

.team-b-game-total {
  border-color: #2196f3;
  background: #e3f2fd;
  color: #1565c0;
}

.game-total-label {
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 3px;
}

.game-total-value {
  font-size: 18px;
  font-weight: bold;
}

.winner-announcement {
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
  animation: pulse 2s ease-in-out infinite;
}

.winner-announcement.team-a-win {
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
  color: white;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.winner-announcement.team-b-win {
  background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
  color: white;
  box-shadow: 0 0 20px rgba(33, 150, 243, 0.5);
}

.winner-announcement.tie {
  background: #ff9800;
  color: white;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.no-cards {
  color: #4caf50;
  font-weight: bold;
  font-style: italic;
}

.mucked-hand {
  color: #999;
  font-style: italic;
}

.ready-players {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.ready-player {
  background: #f0f0f0;
  padding: 8px 6px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.ready-player.ready {
  background: #4caf50;
  color: white;
}

.ready-btn {
  background: #2196f3;
  color: white;
  border: none;
  padding: 10px 30px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s ease;
}

.ready-btn:hover {
  background: #1976d2;
}

.final-hands-section {
  margin-top: 12px;
  border-top: 1px solid #ddd;
  padding-top: 12px;
}

.toggle-hands-btn {
  width: 100%;
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #333;
}

.toggle-hands-btn:hover {
  background: #e0e0e0;
}

.final-hands-list {
  margin-top: 10px;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
}

.final-hand-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 4px;
  background: white;
  border-left: 3px solid #ccc;
}

.final-hand-item.team-a {
  border-left-color: #4caf50;
}

.final-hand-item.team-b {
  border-left-color: #2196f3;
}

.final-hand-item:last-child {
  margin-bottom: 0;
}

.final-hand-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-weight: bold;
}

.final-hand-cards-text {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
  word-wrap: break-word;
}

@media (max-width: 767px) {
  .ready-up-modal {
    padding: 12px 15px;
    max-width: 95%;
  }
  
  .ready-up-modal h2 {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  .ready-up-modal h3 {
    font-size: 13px;
  }
  
  /* Score summary mobile styles */
  .round-end-message {
    font-size: 12px;
    padding: 6px 10px;
  }
  
  .player-scores-section h3 {
    font-size: 13px;
  }
  
  .player-scores-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .player-score-item {
    padding: 6px 8px;
  }
  
  .player-name {
    font-size: 12px;
  }
  
  .team-badge {
    font-size: 10px;
    padding: 1px 4px;
  }
  
  .closer-badge {
    font-size: 9px;
    padding: 1px 4px;
  }
  
  .player-score-value {
    font-size: 14px;
    min-width: 45px;
  }
  
  .team-totals-section {
    gap: 6px;
  }
  
  .team-row {
    gap: 6px;
  }
  
  .team-total {
    padding: 6px 8px;
  }
  
  .team-total-label {
    font-size: 10px;
  }
  
  .team-total-value {
    font-size: 16px;
  }
  
  .game-total {
    padding: 6px 8px;
  }
  
  .game-total-label {
    font-size: 10px;
  }
  
  .game-total-value {
    font-size: 16px;
  }
  
  .winner-announcement {
    font-size: 16px;
    padding: 10px 12px;
  }
  
  .ready-players {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }
  
  .ready-player {
    padding: 6px 4px;
    font-size: 11px;
  }
  
  .ready-btn {
    padding: 8px 20px;
    font-size: 13px;
  }
}

/* Flash animation for discard pile when cards are picked */
.flash-pickup {
  animation: flashGold 1.5s ease-in-out;
}

@keyframes flashGold {
  0%, 100% {
    box-shadow: 0 0 0px rgba(255, 215, 0, 0);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 30px 15px rgba(255, 215, 0, 0.9);
    filter: brightness(1.5) saturate(2);
  }
}

/* Glowing effect for the target card in hand */
.glowing-target {
  animation: pulseGlow 2s ease-in-out infinite;
  box-shadow: 0 0 20px 5px rgba(255, 215, 0, 0.8);
  position: relative;
  z-index: 100;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 15px 3px rgba(255, 215, 0, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 25px 8px rgba(255, 215, 0, 0.9);
    transform: scale(1.03);
  }
}

/* ===== VICTORY CELEBRATION ===== */

/* Card flip animation when player wins - flips upside down */
.victory-flip {
  animation: victoryCardFlip 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  z-index: 200;
}

@keyframes victoryCardFlip {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 30px 10px rgba(255, 215, 0, 0.8);
  }
  100% {
    transform: rotate(180deg) scale(1);
    box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.5);
  }
}

/* Victory banner */
#victory-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#victory-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#victory-banner.fade-out {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  transition: all 0.5s ease-out;
}

.victory-content {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
  padding: 40px 60px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
              0 0 40px rgba(255, 215, 0, 0.6);
  text-align: center;
  border: 4px solid #fff;
}

.victory-content h1 {
  margin: 0 0 15px 0;
  font-size: clamp(24px, 5vw, 48px);
  color: #1a237e;
  text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
  animation: victoryTextPulse 1s ease-in-out infinite;
}

.victory-content p {
  margin: 0;
  font-size: clamp(16px, 3vw, 24px);
  color: #283593;
  font-weight: bold;
}

@keyframes victoryTextPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Mobile responsive adjustments */
@media (max-width: 600px) {
  .victory-content {
    padding: 30px 40px;
  }
  
  .victory-content h1 {
    font-size: 28px;
  }
  
  .victory-content p {
    font-size: 16px;
  }
}

/* Settings Panel Styles */
.icon-btn {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.icon-btn:hover {
  background: white;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.icon-btn:active {
  transform: translateY(-50%) scale(0.95);
}

/* Hamburger Menu Styles */
.menu-item-btn {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px 15px;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease;
  margin-bottom: 5px;
}

.menu-item-btn:hover {
  background: #f0f0f0;
}

.menu-item-btn:active {
  background: #e0e0e0;
}

#settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  animation: fadeIn 0.3s ease;
}

#settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

#settings-content {
  background: white;
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.settings-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header h2 {
  margin: 0;
  font-size: 24px;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.settings-body {
  padding: 20px;
}

.settings-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  margin: 0 0 15px 0;
  font-size: 18px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
}

.setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #667eea;
}

.setting-item span {
  font-size: 15px;
  color: #555;
}

.setting-item:hover span {
  color: #667eea;
}

.setting-item input[type="range"] {
  flex: 1;
  margin: 0 10px;
  accent-color: #667eea;
  cursor: pointer;
}

.setting-item label {
  font-size: 15px;
  color: #555;
  font-weight: 500;
  min-width: 80px;
}

#ai-speed-label {
  font-weight: bold;
  color: #667eea;
  min-width: 100px;
  text-align: right;
}

.speed-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #999;
  padding: 0 5px;
  margin-top: -5px;
}

.settings-footer {
  padding: 15px 20px;
  background: #f5f5f5;
  border-radius: 0 0 12px 12px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.primary-btn, .secondary-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.primary-btn:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
}

.secondary-btn:hover {
  background: #f5f5ff;
}

/* Mobile responsive for settings */
@media (max-width: 600px) {
  #settings-content {
    max-width: 100%;
    margin: 10px;
  }
  
  .settings-header h2 {
    font-size: 20px;
  }
  
  .settings-footer {
    flex-direction: column;
  }
  
  .icon-btn {
    right: 10px;
    padding: 6px 10px;
    font-size: 18px;
  }
}

/* ===========================
   ACCESSIBILITY SETTINGS EFFECTS
   =========================== */

/* Large Cards Mode - Increase card size by 35% */
body.large-cards-mode {
  --card-width: clamp(54px, 7.5vw, 97px);
  --card-height: calc(var(--card-width) * 1.4);
}

/* High Contrast Mode - Darker borders and stronger colors */
body.high-contrast-mode .card {
  border: 3px solid #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.high-contrast-mode .card.hearts,
body.high-contrast-mode .card.diamonds {
  color: #d50000;
}

body.high-contrast-mode .card.spades,
body.high-contrast-mode .card.clubs {
  color: #000;
}

body.high-contrast-mode .card-value,
body.high-contrast-mode .card-suit {
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Card Labels Mode - Show text labels below cards */
body.card-labels-mode .card::after {
  content: attr(data-value) attr(data-suit);
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: bold;
  color: #333;
  background: rgba(255, 255, 255, 0.95);
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  pointer-events: none;
}

body.card-labels-mode .hand-card {
  margin-bottom: 25px;
}

/* Show Counts Mode - Display card count on deck only */
body.show-counts-mode .pile-deck::before {
  content: attr(data-count);
  position: absolute;
  top: -10px;
  right: -10px;
  background: #4CAF50;
  color: white;
  font-weight: bold;
  font-size: 14px;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 10;
  border: 2px solid white;
}

/* Hide default deck count label when show counts is enabled */
body.show-counts-mode #deck-pile .pile-label {
  display: none;
}

/* Achievement Notification Popup */
.achievement-notification {
  position: fixed;
  top: 80px;
  right: -400px;
  width: 350px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 10000;
  transition: right 0.3s ease-out;
  animation: achievement-glow 2s ease-in-out infinite;
}

.achievement-notification.show {
  right: 20px;
}

@keyframes achievement-glow {
  0%, 100% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
  50% {
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.6), 0 0 20px rgba(118, 75, 162, 0.4);
  }
}

.achievement-icon {
  font-size: 48px;
  flex-shrink: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.achievement-content {
  flex-grow: 1;
}

.achievement-title {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.9;
  margin-bottom: 4px;
}

.achievement-name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.achievement-desc {
  font-size: 14px;
  opacity: 0.95;
}

@media (max-width: 768px) {
  .achievement-notification {
    width: 300px;
    padding: 15px;
    top: 60px;
  }
  
  .achievement-notification.show {
    right: 10px;
  }
  
  .achievement-icon {
    font-size: 36px;
  }
  
  .achievement-name {
    font-size: 16px;
  }
  
  .achievement-desc {
    font-size: 12px;
  }
}

