/* Mobile-first Hand & Foot Card Game Styles */

* {
  box-sizing: border-box;
  
  /* Prevent text selection globally to avoid mobile selection issues */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #0d5d2c;
  color: #ffffff;
  overflow-x: hidden;
}

/* Screen Management */
.screen {
  display: none;
  min-height: 100vh;
  padding: 0;
}

.screen.active {
  display: block;
}

/* Headers */
header {
  background-color: #0a4721;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #1a7a3a;
}

.header-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.player-name-header {
  font-size: 0.75rem;
  color: #c8e6c9;
  font-weight: 400;
}

h2 {
  margin: 0.5rem 0;
  font-size: 1.2rem;
  color: #c8e6c9;
}

h3 {
  margin: 0.5rem 0;
  font-size: 1rem;
  color: #e8f5e8;
}

/* Content Areas */
.content {
  padding: 0.5rem;
  max-width: 100%;
}

/* Buttons */
.primary-btn {
  background-color: #2e7d32;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 120px;
}

.primary-btn:hover:not(:disabled) {
  background-color: #388e3c;
}

.primary-btn:disabled {
  background-color: #4e4e4e;
  cursor: not-allowed;
}

.secondary-btn {
  background-color: transparent;
  color: #c8e6c9;
  border: 1px solid #4caf50;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.secondary-btn:hover {
  background-color: #1a4f28;
}

.small-btn {
  background-color: #1a5929;
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.nav-btn {
  background-color: #2e7d32;
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
}

/* Forms */
.form-container {
  background-color: #1a5929;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #4caf50;
  border-radius: 6px;
  background-color: #0d5d2c;
  color: white;
  font-size: 1rem;
  margin-bottom: 1rem;

  /* Allow text selection for input fields */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

input[type="text"]:focus {
  outline: none;
  border-color: #66bb6a;
  background-color: #0f6b30;
}

.button-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Games List */
.games-list {
  margin-top: 2rem;
}

#games-container {
  background-color: #1a5929;
  border-radius: 8px;
  overflow: hidden;
}

.game-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #2e7d32;
  cursor: pointer;
}

.game-item:hover {
  background-color: #0f4f20;
}

.game-item:last-child {
  border-bottom: none;
}

.game-info h3 {
  margin: 0 0 0.25rem 0;
  color: white;
}

.game-info .game-meta {
  font-size: 0.8rem;
  color: #c8e6c9;
}

.no-games {
  padding: 2rem;
  text-align: center;
  color: #888;
}

/* Players Grid (Matchmaking) */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

/* Players List (Low Profile Rows) */
#players-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 1rem 0;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #1a5929;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 2.5rem;
}

.player-row.selected {
  border-color: #ffd700;
  background-color: #0f4f20;
}

.player-row.ready {
  border-color: #4caf50;
}

.player-row .player-name {
  font-weight: 600;
  color: #ffffff;
}

.player-row .player-status-icons {
  font-size: 1rem;
  color: #4caf50;
}

/* Legacy player card styles (kept for compatibility) */
.player-card {
  background-color: #1a5929;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}

.player-card.selected {
  border-color: #ffd700;
  background-color: #0f4f20;
}

.player-card.ready {
  border-color: #4caf50;
}

.player-card .player-name {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.player-card .player-status {
  font-size: 0.8rem;
  color: #c8e6c9;
}

.ready-indicator {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #4caf50;
}

/* Instructions */
.instructions {
  background-color: #1a5929;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  text-align: center;
}

.instruction-text {
  color: #ffd700;
  font-weight: 500;
  font-size: 1rem;
}

/* Partnerships */
.partnerships-section {
  margin: 2rem 0;
}

.partnership {
  background-color: #1a5929;
  padding: 0.75rem;
  margin: 0.5rem 0;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.partnership-players {
  font-weight: 500;
}

/* Overview Table */
.table-container {
  background-color: #1a5929;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.4rem 0.3rem;
  text-align: center;
  border-bottom: 1px solid #2e7d32;
}

th {
  background-color: #0f4f20;
  font-weight: 600;
  font-size: 0.8rem;
}

td {
  font-size: 0.8rem;
}

/* Preview Section */
#preview-section {
  background-color: #1a5929;
  border-radius: 6px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

#preview-player-name {
  font-weight: 600;
  font-size: 1rem;
}

.preview-melds {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.preview-cards {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.card-count {
  font-size: 0.9rem;
  color: #c8e6c9;
}

/* Piles Row */
.piles-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pile-section {
  flex: 1;
  background-color: #1a5929;
  border-radius: 6px;
  padding: 0.4rem;
  min-height: 60px;
  position: relative;
}

.pile-section h3 {
  position: absolute;
  top: 0.2rem;
  left: 0.4rem;
  margin: 0;
  opacity: 0.3;
  font-size: 0.8rem;
  color: #c8e6c9;
  z-index: 1;
  pointer-events: none;
}

.book-piles {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.book-pile {
  width: 40px;
  height: 60px;
  background-color: #2e7d32;
  border-radius: 4px;
  position: relative;
  transform: rotate(90deg);
  border: 1px solid #4caf50;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
}

/* Team Melds */
.melds-container {
  display: flex;
  gap: 0.125rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  min-height: 95px;
  max-width: 100vw;
}

.team-meld {
  background-color: transparent;
  border: none;
  padding: 0;
  min-width: 35px;
  min-height: 35px;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.team-meld.can-receive {
  background-color: rgba(76, 175, 80, 0.2);
  border-radius: 4px;
}

.team-meld.expanded {
  z-index: 1000;
}

.no-melds {
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

.more-cards {
  color: #c8e6c9;
  font-size: 0.8rem;
  font-weight: bold;
  align-self: center;
  margin-left: 0.5rem;
}

.meld-stack {
  position: relative;
  min-height: 75px;
  margin-top: 0;
  width: 35px;
  transition: all 0.3s ease;
}

.meld-stack .card {
  position: absolute;
  left: 0;
  margin-left: 0;
  width: 35px !important;
  height: 52px !important;
  font-size: 0.6rem;
  transition: all 0.3s ease;
}

/* Compact stacked cards with visible numbers */
.meld-stack .card:nth-child(1) {
  top: 0px;
}
.meld-stack .card:nth-child(2) {
  top: 10px;
}
.meld-stack .card:nth-child(3) {
  top: 20px;
}
.meld-stack .card:nth-child(4) {
  top: 30px;
}
.meld-stack .card:nth-child(5) {
  top: 40px;
}
.meld-stack .card:nth-child(6) {
  top: 50px;
}
.meld-stack .card:nth-child(7) {
  top: 60px;
}

/* Expanded preview cards - vertical spread */
.team-meld.expanded .meld-stack {
  width: 35px;
  position: relative;
  min-height: 200px;
}

.team-meld.expanded .meld-stack .card {
  width: 35px !important;
  height: 52px !important;
  font-size: 0.6rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.team-meld.expanded .meld-stack .card:nth-child(1) {
  top: 0px;
  left: 0px;
}
.team-meld.expanded .meld-stack .card:nth-child(2) {
  top: 25px;
  left: 0px;
}
.team-meld.expanded .meld-stack .card:nth-child(3) {
  top: 50px;
  left: 0px;
}
.team-meld.expanded .meld-stack .card:nth-child(4) {
  top: 75px;
  left: 0px;
}
.team-meld.expanded .meld-stack .card:nth-child(5) {
  top: 100px;
  left: 0px;
}
.team-meld.expanded .meld-stack .card:nth-child(6) {
  top: 125px;
  left: 0px;
}
.team-meld.expanded .meld-stack .card:nth-child(7) {
  top: 150px;
  left: 0px;
}

/* Mobile adjustments for vertical spread */
@media (max-width: 480px) {
  .team-meld.expanded .meld-stack {
    width: 30px;
    min-height: 180px;
  }

  .team-meld.expanded .meld-stack .card {
    width: 30px !important;
    height: 45px !important;
    font-size: 0.55rem;
  }

  .team-meld.expanded .meld-stack .card:nth-child(1) {
    top: 0px;
    left: 0px;
  }
  .team-meld.expanded .meld-stack .card:nth-child(2) {
    top: 22px;
    left: 0px;
  }
  .team-meld.expanded .meld-stack .card:nth-child(3) {
    top: 44px;
    left: 0px;
  }
  .team-meld.expanded .meld-stack .card:nth-child(4) {
    top: 66px;
    left: 0px;
  }
  .team-meld.expanded .meld-stack .card:nth-child(5) {
    top: 88px;
    left: 0px;
  }
  .team-meld.expanded .meld-stack .card:nth-child(6) {
    top: 110px;
    left: 0px;
  }
  .team-meld.expanded .meld-stack .card:nth-child(7) {
    top: 132px;
    left: 0px;
  }
}

/* Discard Pile */
.discard-spread {
  display: flex;
  overflow-x: hidden;
  padding: 0.5rem;
  min-height: 80px;
  max-width: 100%;
}

.discard-card {
  position: relative;
  margin-left: -15px; /* Overlap cards like hand cards */
  width: 50px !important;
  height: 75px !important;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: none;
}

.discard-card:first-child {
  margin-left: 0; /* First card doesn't overlap */
}

.empty-pile {
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 2rem;
  border: 2px dashed #555;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.1);
}

/* Playing Space */
#playing-space {
  position: fixed;
  bottom: 60px; /* Just above the footer */
  left: 0;
  right: 0;
  padding: 1rem 1rem 0 1rem; /* Remove bottom padding */
  background-color: transparent;
}

.work-area {
  background-color: #1a5929;
  border-radius: 6px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 80px;
}

#work-piles-container {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.work-pile {
  min-width: 80px;
  min-height: 100px;
  background-color: #0f4f20;
  border: 2px dashed #4caf50;
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
}

.work-pile.has-cards {
  border-style: solid;
  background-color: #2e7d32;
}

/* Hand Area */
.hand-area {
  background-color: #1a5929;
  border-radius: 8px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.hand-header h3 {
  margin: 0;
}

.card-container {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: flex-end;
  min-height: 100px;
  position: relative;
  width: 100%;
  padding: 20px 20px 0 20px;
  overflow: visible;
}

.card {
  width: 50px;
  height: 75px;
  background-color: white;
  border-radius: 6px;
  border: 1px solid #ddd;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s;
  margin-left: -20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.card:last-child {
  margin-left: 0;
}

.card.selected {
  border-color: #ffd700;
  border-width: 2px;
  transform: translateY(-15px);
  z-index: 10; /* Bring selected card to front */
}

.card.newest-card {
  border-color: #ff5722;
  border-width: 3px;
}

.card:hover {
  z-index: 5; /* Bring hovered card to front */
}

/* Card corner numbers */
.card-corner {
  position: absolute;
  font-size: 0.7rem;
  font-weight: bold;
  line-height: 0.8;
  font-family: "Times New Roman", serif;
}

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

.card-corner.bottom-right {
  bottom: 3px;
  right: 3px;
  transform: rotate(180deg);
}

/* Card center number */
.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: bold;
  font-family: "Times New Roman", serif;
}

/* Rook card colors */
.card.red {
  color: #d32f2f;
}

.card.blue {
  color: #1976d2;
}

.card.yellow {
  color: #f57c00;
}

.card.black {
  color: #333;
}

.card.rook-card {
  color: black;
  background-color: white;
}

.card .number {
  font-size: 2rem;
  line-height: 1;
}

/* WIP Piles */
.wip-area {
  margin-bottom: 1rem;
}

.wip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.wip-header h3 {
  margin: 0;
}

/* Card slot system for natural stacking */
.card-slot {
  position: relative;
  display: inline-block;
  width: 50px; /* Card width */
  height: 75px; /* Card height */
  margin-left: -15px; /* Overlapping effect */
}

.card-slot:first-child {
  margin-left: 0; /* First card doesn't overlap */
}

.card-slot.gap-slot {
  width: 20px; /* Just a gap, no card */
  margin-left: 5px; /* Small additional gap */
}

.card-slot .card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Grouped card styling */
.card-slot.grouped .card {
  pointer-events: none; /* Grouped cards are not selectable */
}

/* Group destroy button */
.group-destroy-btn {
  position: absolute;
  top: 2px;
  right: 22px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: rgba(244, 67, 54, 1);
  color: white;
  border: none;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1020; /* Higher than any card */
  transition: opacity 0.2s;
  pointer-events: auto; /* Ensure button is clickable */
}

.card-slot.grouped:hover .group-destroy-btn {
  opacity: 1;
}

/* Team melds preview styles */
.team-melds-preview {
  padding: 0.5rem;
}

.preview-section-header {
  font-size: 0.9rem;
  font-weight: bold;
  color: #4caf50;
  margin: 0.5rem 0 0.25rem 0;
  border-bottom: 1px solid #4caf50;
  padding-bottom: 0.25rem;
}

.preview-melds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.preview-meld {
  display: flex;
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 4px;
  padding: 0.25rem;
  background-color: rgba(76, 175, 80, 0.1);
}

.preview-books {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.no-melds {
  text-align: center;
  color: #888;
  font-style: italic;
  padding: 2rem;
}

.group-destroy-btn:hover {
  background-color: #f44336;
  opacity: 1;
}

.destroy-pile-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #d32f2f;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.destroy-pile-btn:hover {
  background-color: #b71c1c;
}

.wip-pile .card-container {
  min-height: 60px;
  padding: 0;
}

/* Action Buttons */
#action-buttons {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #0f4f20;
  border-top: 2px solid #4caf50;
  height: 50px;
  line-height: 50px;
  text-align: center;
  white-space: nowrap;
}

#action-buttons button {
  margin: 6px 1px;
  padding: 4px !important;
  font-size: 1rem;
  vertical-align: middle;
  display: inline-block;
  min-width: 0;
}

/* Foot Indicator Inline */
.foot-display-inline {
  color: #c8e6c9;
  font-size: 14px;
  float: right;
  margin-right: 15px;
  line-height: 50px;
}

/* Legacy foot display (hidden) */
.foot-display {
  display: none;
}

/* Group Cards Button */
#new-pile-btn {
  position: absolute;
  bottom: 125px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.foot-label {
  font-size: 0.7rem;
  color: #c8e6c9;
  transform: rotate(-90deg);
  line-height: 1;
}

.foot-number {
  font-size: 1.2rem;
  font-weight: bold;
  color: white;
  margin-top: 0.25rem;
}

/* Error Container */
#error-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #d32f2f;
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  max-width: 90vw;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#close-error-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Turn Flash Animation */
@keyframes flashTurn {
  0% {
    background-color: #0d5d2c;
  }
  50% {
    background-color: #ffd700;
  }
  100% {
    background-color: #0d5d2c;
  }
}

.flash-turn {
  animation: flashTurn 1s ease-in-out infinite;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

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

/* Responsive Design */
@media (min-width: 768px) {
  .content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
  }

  .piles-row {
    gap: 2rem;
  }

  .card-container {
    gap: 0.75rem;
  }

  .card {
    width: 60px;
    height: 84px;
  }

  #action-buttons {
    position: static;
    float: right;
    margin-top: 1rem;
  }

  .foot-display {
    position: static;
    float: left;
    margin-top: 1rem;
  }
}

@media (min-width: 1024px) {
  .players-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .preview-melds {
    gap: 2rem;
  }

  .book-piles {
    gap: 1rem;
  }

  .work-area {
    min-height: 140px;
  }
}

/* Completed book styling */
.completed-book {
  position: relative;
  margin-right: 5px; /* Space between books so they stack to the right */
  flex-shrink: 0;
  overflow: hidden; /* Contain the rotated card */
}

.book-stack {
  position: relative;
  width: 52px; /* Swapped width/height to accommodate rotation */
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card {
  transform: rotate(90deg);
  transform-origin: center center;
  width: 35px;
  height: 52px;
  position: relative; /* Changed from absolute to relative */
}

/* Multiple books stack to the right with slight overlap for compact display */
.completed-book:nth-child(n + 2) {
  margin-left: -25px; /* Adjusted for new dimensions */
  z-index: 1;
}

.completed-book:nth-child(n + 3) {
  margin-left: -50px;
  z-index: 2;
}

.completed-book:nth-child(n + 4) {
  margin-left: -75px;
  z-index: 3;
}

/* Round Over Overlay */
.round-over-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  pointer-events: all;
}

.round-over-overlay.active {
  display: flex;
}

.overlay-content {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
  font-size: 3rem;
  color: #dc3545;
  margin: 0 0 1rem 0;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.overlay-content p {
  font-size: 1.2rem;
  color: #666;
  margin: 0 0 2rem 0;
}

.overlay-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.overlay-buttons button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.overlay-buttons button:first-child {
  background-color: #007bff;
  color: white;
}

.overlay-buttons button:first-child:hover {
  background-color: #0056b3;
}

.overlay-buttons button:nth-child(2) {
  background-color: #6c757d;
  color: white;
}

.overlay-buttons button:nth-child(2):hover {
  background-color: #545b62;
}

.overlay-buttons button:last-child {
  background-color: #28a745;
  color: white;
}

.overlay-buttons button:last-child:hover {
  background-color: #1e7e34;
}

/* Scores Table Styling */
.scores-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.scores-table th,
.scores-table td {
  padding: 0.75rem;
  text-align: center;
  border-bottom: 1px solid #ddd;
}

.scores-table th {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #495057;
}

.scores-table .team-name {
  text-align: left;
  font-weight: bold;
  color: #495057;
}

.scores-table .total-score {
  font-weight: bold;
  font-size: 1.1rem;
  color: #007bff;
}

.scores-table .round-score {
  color: #6c757d;
}

.scores-table .winning-round {
  background-color: #d4edda;
  color: #155724;
  font-weight: bold;
}

.scores-table .go-down-req {
  font-weight: bold;
  color: #6c757d;
  text-align: center;
}

.round-summary {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin-top: 1rem;
}

.round-summary h3 {
  color: #28a745;
  margin: 0 0 0.5rem 0;
}

.round-summary p {
  margin: 0.25rem 0;
  color: #495057;
}

@media (max-width: 768px) {
  .scores-table th,
  .scores-table td {
    padding: 0.5rem;
    font-size: 0.9rem;
  }

  .scores-table .team-name {
    font-size: 0.8rem;
  }
}

/* Preview layout for other teams' cards */
.preview-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.preview-layout .melds-container {
  flex: 1;
}

.preview-layout .books-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 60px;
}

.preview-layout .clean-books,
.preview-layout .dirty-books {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Turn highlighting styles */
.draw-turn {
  background-color: #ffeb3b;
  color: #000;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-weight: bold;
}

.discard-turn {
  background-color: #f44336;
  color: #fff;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-weight: bold;
}

.waiting-turn {
  background-color: #757575;
  color: #fff;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-weight: bold;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background-color: #1a4f28;
  border: 2px solid #4caf50;
  border-radius: 12px;
  max-width: 600px;
  max-height: 90vh;
  width: 100%;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #4caf50;
  background-color: #0a4721;
}

.modal-header h2 {
  margin: 0;
  color: #c8e6c9;
  font-size: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: #c8e6c9;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background-color: #2e7d32;
}

.modal-body {
  padding: 1.5rem;
}

.rules-section {
  margin-bottom: 1.5rem;
}

.rules-section h3 {
  margin: 0 0 0.5rem 0;
  color: #66bb6a;
  font-size: 1.2rem;
  font-weight: 600;
}

.rules-section p {
  margin: 0;
  line-height: 1.6;
  color: #e8f5e8;
}

.rules-section strong {
  color: #a5d6a7;
}

/* Rules Button */
.rules-button-container {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.rules-btn {
  background-color: rgba(76, 175, 80, 0.2);
  color: #a5d6a7;
  border: 1px solid #4caf50;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.rules-btn:hover {
  background-color: rgba(76, 175, 80, 0.3);
  border-color: #66bb6a;
  color: #c8e6c9;
  transform: translateY(-1px);
}

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

/* Mobile responsive */
@media (max-width: 768px) {
  .modal {
    padding: 0.5rem;
  }

  .modal-content {
    max-height: 95vh;
  }

  .modal-header {
    padding: 1rem;
  }

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

  .modal-body {
    padding: 1rem;
  }

  .rules-section h3 {
    font-size: 1.1rem;
  }

  .rules-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
}
