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

body {
  background: #0a3d0a;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  color: #fff;
}

#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 800px;
  height: 100vh;
  padding: 8px;
}

/* --- Scoreboard --- */
#scoreboard {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
  padding: 6px 12px;
  background: rgba(12, 13, 20, 0.7);
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #ccc;
  flex-shrink: 0;
}

#scoreboard .score-entry {
  display: flex;
  gap: 4px;
}

#scoreboard .score-entry .score-name {
  color: #8b5cf6;
  font-weight: bold;
}

/* --- Opponents --- */
#opponents {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  flex-shrink: 0;
  padding: 8px 0;
}

.ai-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
  flex-shrink: 0;
}

#top-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.ai-label {
  font-size: 12px;
  color: #8b5cf6;
  font-weight: bold;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.ai-cards {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
}

.ai-card {
  width: 28px;
  height: 40px;
  background: linear-gradient(135deg, #3b3d5c, #2a2d3a);
  border: 1px solid #4a4d6a;
  border-radius: 4px;
  margin: 0 -6px;
  flex-shrink: 0;
}

/* --- Trick Area --- */
#trick-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  min-height: 180px;
}

.trick-row {
  display: flex;
  justify-content: center;
  gap: 80px;
  align-items: center;
}

.trick-card {
  width: 52px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  border-radius: 6px;
  margin: 4px;
  transition: opacity 0.2s;
}

.trick-card.played {
  background: #fff;
  border: 2px solid #ccc;
  color: #111;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.trick-card.played.red {
  color: #dc2626;
}

/* --- Player Area --- */
#player-area {
  width: 100%;
  flex-shrink: 0;
  padding: 8px 0 4px;
}

#player-hand {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0;
}

.card {
  width: 52px;
  height: 74px;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  color: #111;
  cursor: pointer;
  margin: 0 -4px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  line-height: 1.1;
}

.card .card-suit {
  font-size: 18px;
}

.card.red {
  color: #dc2626;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.card.selected {
  transform: translateY(-14px);
  border-color: #7c3aed;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
}

.card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Pass Prompt --- */
#pass-prompt {
  text-align: center;
  padding: 8px;
  flex-shrink: 0;
}

#pass-prompt p {
  font-size: 14px;
  color: #ccc;
  margin-bottom: 6px;
}

#pass-dir {
  color: #8b5cf6;
  font-weight: bold;
}

.action-btn {
  background: #7c3aed;
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.2s;
}

.action-btn:hover {
  background: #8b5cf6;
}

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

/* --- Message --- */
#message {
  text-align: center;
  font-size: 14px;
  color: #ccc;
  min-height: 22px;
  flex-shrink: 0;
  padding: 4px;
}

/* --- Overlay --- */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 13, 20, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#overlay.hidden {
  display: none;
}

#overlay-box {
  background: #161822;
  border: 1px solid #2a2d3a;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

#overlay-box h1 {
  font-size: 32px;
  color: #7c3aed;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.controls-hint {
  color: #999;
  font-size: 14px;
  margin-bottom: 8px;
}

.action-hint {
  color: #8b5cf6;
  font-size: 13px;
  margin-top: 16px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

#final-result {
  color: #ccc;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

.hidden {
  display: none !important;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  #game-container {
    padding: 4px;
  }

  .card {
    width: 40px;
    height: 58px;
    font-size: 12px;
    margin: 0 -5px;
    border-radius: 4px;
  }

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

  .ai-card {
    width: 22px;
    height: 32px;
    margin: 0 -5px;
  }

  .trick-card {
    width: 40px;
    height: 58px;
    font-size: 13px;
  }

  .trick-row {
    gap: 50px;
  }

  #scoreboard {
    font-size: 10px;
    gap: 8px;
    padding: 4px 8px;
  }

  #overlay-box {
    padding: 28px 24px;
  }

  #overlay-box h1 {
    font-size: 24px;
  }
}

@media (max-width: 400px) {
  .card {
    width: 34px;
    height: 50px;
    font-size: 11px;
    margin: 0 -6px;
  }

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

  .trick-card {
    width: 34px;
    height: 50px;
    font-size: 11px;
  }

  .trick-row {
    gap: 36px;
  }
}
