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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: white;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  color: #333;
}

.screen {
  display: none;
  width: 100%;
  max-width: 100%;
  padding: 0;
}

.screen.active {
  display: block;
}

.lobby-container {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.lobby-container h1 {
  font-size: 3em;
  margin-bottom: 30px;
  color: #2e7d32;
}

.join-form {
  margin: 30px 0;
}

.join-form input {
  width: 100%;
  padding: 15px;
  font-size: 1.2em;
  border: 2px solid #ddd;
  border-radius: 10px;
  margin-bottom: 15px;
  transition: border-color 0.3s;
}

.join-form input:focus {
  outline: none;
  border-color: #2e7d32;
}

.join-form button {
  width: 100%;
  padding: 15px;
  font-size: 1.2em;
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s;
}

.join-form button:hover {
  background: #1b5e20;
}

.lobby-info {
  margin-top: 30px;
}

.lobby-info h2 {
  color: #2e7d32;
  margin-bottom: 15px;
}

.player-count {
  font-size: 1.3em;
  font-weight: bold;
  margin: 10px 0;
}

.min-players {
  color: #666;
  margin-bottom: 20px;
}

.player-list {
  background: #f5f5f5;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
  min-height: 100px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin: 5px 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.player-item .player-name {
  font-weight: bold;
}

.player-item .ready-status {
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: bold;
}

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

.player-item .ready-status.not-ready {
  background: #ff9800;
  color: white;
}

.ready-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.2em;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.3s;
}

.ready-btn:hover {
  background: #45a049;
}

.ready-btn.active {
  background: #ff9800;
}

.waiting-message {
  margin-top: 20px;
  color: #666;
  font-style: italic;
}

.game-in-progress {
  text-align: center;
  padding: 40px;
}

.game-in-progress h2 {
  color: #2e7d32;
  margin-bottom: 20px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #2e7d32;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 30px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Game Screen */
.game-container {
  background: #1a5e1a;
  padding: 10px;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.info-bar {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}

.game-info {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 15px;
}

.game-info span {
  font-size: 1.1em;
  font-weight: bold;
}

/* Rankings Bar */
.rankings-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  margin-bottom: 8px;
  justify-content: center;
}

.rank-header {
  color: #ffd700;
  font-weight: bold;
  font-size: 0.9em;
  width: 100%;
  text-align: center;
  margin-bottom: 2px;
}

.rank-item {
  color: white;
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

/* Other Players */
.other-players {
  position: relative;
  width: 100%;
  height: 180px;
  margin-bottom: 5px;
}

.other-player {
  background: rgba(255, 255, 255, 0.9);
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: absolute;
  transition: all 0.3s ease;
  width: 120px;
  max-width: 120px;
}

.other-player:nth-child(1):nth-last-child(1) {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.other-player:nth-child(1):nth-last-child(2) {
  top: 20px;
  left: 15%;
}

.other-player:nth-child(2):nth-last-child(1) {
  top: 20px;
  right: 15%;
}

.other-player:nth-child(1):nth-last-child(3) {
  top: 80px;
  left: 5%;
}

.other-player:nth-child(2):nth-last-child(2) {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.other-player:nth-child(3):nth-last-child(1) {
  top: 80px;
  right: 5%;
}

.other-player:nth-child(1):nth-last-child(4) {
  top: 120px;
  left: 2%;
}

.other-player:nth-child(2):nth-last-child(3) {
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
}

.other-player:nth-child(3):nth-last-child(2) {
  top: 80px;
  left: 25%;
}

.other-player:nth-child(4):nth-last-child(1) {
  top: 120px;
  right: 2%;
}

.other-player:nth-child(1):nth-last-child(5) {
  top: 140px;
  left: 5%;
}

.other-player:nth-child(2):nth-last-child(4) {
  top: 60px;
  left: 20%;
}

.other-player:nth-child(3):nth-last-child(3) {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}

.other-player:nth-child(4):nth-last-child(2) {
  top: 60px;
  right: 20%;
}

.other-player:nth-child(5):nth-last-child(1) {
  top: 140px;
  right: 5%;
}

.other-player:nth-child(n+6) {
  top: 100px;
}

.other-player:nth-child(6) {
  left: 15%;
}

.other-player:nth-child(7) {
  left: 35%;
}

.other-player:nth-child(8) {
  left: 55%;
}

.other-player:nth-child(9) {
  left: 75%;
}

.other-player .turn-indicator {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  margin: 8px auto 0;
  z-index: 1;
}

.other-player.active-turn {
  border: 3px solid #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
}

.turn-indicator {
  width: 20px;
  height: 20px;
  background: #ffd700;
  border-radius: 50%;
  margin: 5px auto;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

.turn-indicator.active {
  opacity: 1;
  visibility: visible;
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
  50% { transform: scale(1.3); box-shadow: 0 0 25px rgba(255, 215, 0, 1); }
}

.other-player .player-name {
  font-weight: bold;
  margin-bottom: 5px;
  font-size: 0.9em;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  line-height: 1.2;
}

.other-player .card-count {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
  position: relative;
  height: 40px;
  min-width: 30px;
}

.other-player .mini-card {
  width: 20px;
  height: 30px;
  border-radius: 3px;
  background: linear-gradient(135deg, #1a5e1a 0%, #2e7d32 100%);
  border: 1px solid #0d3d0d;
  position: absolute;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.other-player .mini-card:nth-child(1) { left: 0; z-index: 1; }
.other-player .mini-card:nth-child(2) { left: 12px; z-index: 2; }
.other-player .mini-card:nth-child(3) { left: 24px; z-index: 3; }
.other-player .mini-card:nth-child(4) { left: 36px; z-index: 4; }
.other-player .mini-card:nth-child(5) { left: 48px; z-index: 5; }
.other-player .mini-card:nth-child(6) { left: 60px; z-index: 6; }
.other-player .mini-card:nth-child(7) { left: 72px; z-index: 7; }
.other-player .mini-card:nth-child(8) { left: 84px; z-index: 8; }
.other-player .mini-card:nth-child(9) { left: 96px; z-index: 9; }
.other-player .mini-card:nth-child(10) { left: 108px; z-index: 10; }

.finished-label {
  font-size: 1.5em;
}

/* Play Area */
.play-area {
  text-align: center;
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 15px;
  margin-bottom: 10px;
  min-height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}

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

.pile-cards {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.pile-label {
  font-size: 1em;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.7);
}

/* Pass Button */
.pass-container {
  text-align: center;
  padding: 10px;
}

.pass-btn {
  padding: 12px 40px;
  font-size: 1.2em;
  background: #ff5722;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.pass-btn:hover {
  background: #e64a19;
  transform: scale(1.05);
}

/* Playing Card Styles */
.card.playing-card {
  width: 90px;
  height: 135px;
  border-radius: 10px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px solid #999;
  position: relative;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  background: white;
  font-weight: bold;
  gap: 2px;
}

.card.playing-card:hover:not([style*="cursor: not-allowed"]) {
  transform: translateY(-10px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.card.playing-card.selected,
.card.playing-card.selected:hover {
  transform: translateY(-20px);
  box-shadow: 0 8px 20px rgba(255, 215, 0, 0.6);
  border: 3px solid #ffd700;
}

.card.playing-card .card-rank {
  font-size: 1.4em;
  line-height: 1;
}

.card.playing-card .card-suit {
  font-size: 1.8em;
  line-height: 1;
}

.card.playing-card.hearts,
.card.playing-card.diamonds {
  color: #d32f2f;
}

.card.playing-card.clubs,
.card.playing-card.spades {
  color: #1a1a1a;
}

.card.playing-card.hearts { border-color: #d32f2f; }
.card.playing-card.diamonds { border-color: #d32f2f; }
.card.playing-card.clubs { border-color: #1a1a1a; }
.card.playing-card.spades { border-color: #1a1a1a; }

/* Player Hand */
.player-hand-container {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 15px;
}

.player-hand-container h3 {
  text-align: center;
  margin-bottom: 8px;
  color: #ffd700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
}

.player-hand-container .turn-indicator {
  position: relative;
  margin: 0;
}

.player-hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  flex-direction: row;
  gap: 6px;
  min-height: 150px;
  align-items: flex-start;
  padding: 5px;
}

.player-hand .error-message {
  color: #ffcdd2;
  font-size: 1.1em;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  border: 2px solid #ffcdd2;
  width: 100%;
  text-align: center;
}

.player-hand .card.playing-card {
  width: 80px;
  height: 120px;
}

/* Play Action Button */
.play-action {
  position: fixed;
  bottom: 200px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 40px;
  font-size: 1.3em;
  background: #ffd700;
  color: #1a1a1a;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5);
  z-index: 1000;
  animation: pulse-action 1.5s infinite;
  transition: opacity 0.3s;
}

.play-action:hover {
  background: #ffc107;
  transform: translateX(-50%) scale(1.05);
}

@keyframes pulse-action {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5); }
  50% { box-shadow: 0 4px 30px rgba(255, 215, 0, 0.8); }
}

/* Game Messages */
.game-messages {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: 300px;
  z-index: 1000;
}

.message {
  background: #333;
  color: white;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s;
}

.message.error {
  background: #f44336;
}

.message.success {
  background: #4caf50;
}

.message.info {
  background: #2196f3;
}

.message.warning {
  background: #ff9800;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Game Over Screen */
.gameover-container {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.gameover-container h1 {
  font-size: 2.5em;
  color: #2e7d32;
  margin-bottom: 30px;
}

.final-rankings {
  margin: 20px 0;
}

.final-rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  margin: 8px 0;
  background: #f5f5f5;
  border-radius: 10px;
  font-size: 1.1em;
  font-weight: bold;
}

.final-rank-item.gold {
  background: linear-gradient(135deg, #ffd700, #ffed4a);
  color: #1a1a1a;
  font-size: 1.3em;
  padding: 15px 20px;
}

.final-rank-item.scum {
  background: linear-gradient(135deg, #795548, #a1887f);
  color: white;
}

.final-rank-item .rank-label {
  color: #666;
}

.final-rank-item.gold .rank-label {
  color: #8d6e00;
}

.final-rank-item.scum .rank-label {
  color: rgba(255, 255, 255, 0.7);
}

.final-rank-item .rank-player {
  color: #333;
}

.final-rank-item.gold .rank-player {
  color: #1a1a1a;
}

.final-rank-item.scum .rank-player {
  color: white;
}

.gameover-container p {
  margin-top: 10px;
  color: #666;
  font-style: italic;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .game-info {
    flex-direction: column;
    align-items: center;
  }

  .player-hand .card.playing-card {
    width: 60px;
    height: 90px;
  }

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

  .card.playing-card .card-rank {
    font-size: 1.1em;
  }

  .card.playing-card .card-suit {
    font-size: 1.4em;
  }

  .other-players {
    flex-direction: column;
  }
}