/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: #ffffff;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Screen Management */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  padding: 20px;
}

.screen.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.container {
  max-width: 800px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Loading Screen */
#loading-screen h1 {
  font-size: 3rem;
  margin-bottom: 20px;
  text-align: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 30px auto;
}

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

/* Join Screen */
#join-screen h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  text-align: center;
}

#join-screen p {
  text-align: center;
  margin-bottom: 30px;
  opacity: 0.9;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

.join-form input {
  padding: 15px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}

.btn {
  padding: 15px 30px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #4CAF50;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-primary:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
}

.rules-summary {
  margin-top: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.rules-summary h3 {
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.rules-summary ul {
  list-style: none;
  padding: 0;
}

.rules-summary li {
  margin: 10px 0;
  padding-left: 10px;
  line-height: 1.6;
}

/* Waiting Room */
#waiting-screen h2 {
  text-align: center;
  margin-bottom: 20px;
  font-size: 2rem;
}

.room-id {
  text-align: center;
  margin-bottom: 30px;
  font-family: monospace;
  font-size: 1.1rem;
}

.players-waiting h3 {
  margin-bottom: 15px;
  text-align: center;
}

#players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.you-badge {
  background: #4CAF50;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.waiting-message {
  text-align: center;
  margin: 20px 0;
  opacity: 0.8;
}

/* Game Screen */
#game-screen {
  display: none;
  padding: 0;
  min-height: 100vh;
}

#game-screen.active {
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.room-info, .player-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.9rem;
}

#transaction-id {
  font-family: monospace;
  font-weight: 600;
  color: #FFD700;
}

.timer-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.timer {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
  border: 4px solid rgba(255, 255, 255, 0.5);
}

.timer.warning {
  background: rgba(255, 82, 82, 0.3);
  border-color: #ff5252;
  animation: pulse 0.5s infinite;
}

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

.opponents-area {
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
}

#opponents-container {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.opponent {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  min-width: 150px;
  text-align: center;
}

.opponent-name {
  font-weight: 600;
  margin-bottom: 8px;
}

.opponent-status {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 5px;
}

.opponent-score {
  font-size: 0.9rem;
  color: #4CAF50;
}

.playing-area {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.hand-zones {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.hand-zone {
  background: rgba(255, 255, 255, 0.1);
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  padding: 15px;
  min-height: 120px;
}

.hand-zone.drag-over {
  background: rgba(76, 175, 80, 0.2);
  border-color: #4CAF50;
}

.zone-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  opacity: 0.8;
}



.cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 80px;
}

/* Cards */
.card {
  width: 70px;
  height: 100px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: grab;
  transition: transform 0.2s ease;
  position: relative;
}

.card:hover {
  transform: translateY(-5px);
}

.card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.card-inner {
  padding: 8px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.card-rank {
  font-size: 1.5rem;
  font-weight: bold;
}

.card-suit {
  font-size: 2rem;
}

.card.red {
  color: #e53935;
}

.card.black {
  color: #212121;
}

.action-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
}

.action-buttons .btn {
  min-width: 200px;
}

/* Results Screen */
#results-screen h2 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 2.5rem;
}

#results-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  transition: all 0.3s ease;
}

.result-item.my-result {
  background: rgba(76, 175, 80, 0.3);
  border: 2px solid #4CAF50;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 20px;
}

.rank {
  font-size: 2rem;
  font-weight: bold;
  min-width: 60px;
  text-align: center;
}

.result-item .player-info {
  flex: 1;
}

.result-item .name {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-item .scores {
  display: flex;
  gap: 20px;
  font-size: 0.95rem;
  opacity: 0.9;
}

/* VS Players Breakdown */
.vs-players-breakdown {
  margin-top: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 0.85rem;
}

.vs-players-title {
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.9;
}

.vs-player-item {
  padding: 4px 8px;
  margin: 3px 0;
  border-radius: 4px;
  display: inline-block;
  margin-right: 8px;
}

.vs-player-item.positive {
  background: rgba(76, 175, 80, 0.3);
  color: #4CAF50;
}

.vs-player-item.negative {
  background: rgba(244, 67, 54, 0.3);
  color: #ff5252;
}

.vs-player-item.neutral {
  background: rgba(158, 158, 158, 0.3);
  color: #9e9e9e;
}

.vs-player-item .detail-text {
  font-size: 0.85em;
  opacity: 0.8;
  font-weight: normal;
}

/* Scoop Information */
.scoop-info {
  margin-top: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 0.85rem;
}

.transaction-id-display {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  text-align: center;
  font-family: monospace;
  font-size: 13px;
  color: #FFD700;
  font-weight: 600;
}

.scoop-title {
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scoop-points {
  font-size: 1rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.scoop-points.positive {
  background: rgba(76, 175, 80, 0.3);
  color: #4CAF50;
}

.scoop-points.negative {
  background: rgba(244, 67, 54, 0.3);
  color: #ff5252;
}

.scoop-points.neutral {
  background: rgba(158, 158, 158, 0.3);
  color: #9e9e9e;
}

.scoop-success {
  padding: 6px 10px;
  margin: 4px 0;
  border-radius: 4px;
  background: rgba(255, 193, 7, 0.3);
  color: #FFC107;
  font-weight: 600;
}

.scoop-failed {
  padding: 6px 10px;
  margin: 4px 0;
  border-radius: 4px;
  background: rgba(156, 39, 176, 0.3);
  color: #CE93D8;
  font-weight: 600;
}

/* Result Cards Display */
.result-cards-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 5px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.result-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-row-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.row-name {
  font-weight: 600;
  min-width: 120px;
}

.row-hand {
  color: #FFD700;
  font-weight: 500;
}

.row-points {
  color: #FFD700;
  font-weight: 600;
  margin-left: 10px;
}

.row-comparison {
  font-size: 0.9em;
  font-weight: 700;
  margin-left: 5px;
  padding: 2px 6px;
  border-radius: 3px;
}

.row-comparison.positive {
  color: #4CAF50;
  background: rgba(76, 175, 80, 0.2);
}

.row-comparison.negative {
  color: #ff5252;
  background: rgba(244, 67, 54, 0.2);
}

.result-row-cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.result-card {
  width: 50px;
  height: 70px;
  background: white;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 6px;
}

.result-card-rank {
  font-size: 1.1rem;
  font-weight: bold;
}

.result-card-suit {
  font-size: 1.3rem;
}

.result-card.red {
  color: #e53935;
}

.result-card.black {
  color: #212121;
}

.next-round-message {
  text-align: center;
  font-size: 1.1rem;
  margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 20px;
  }
  
  .top-bar {
    flex-direction: column;
    gap: 10px;
    padding: 15px;
  }
  
  .card {
    width: 60px;
    height: 85px;
  }
  
  .card-rank {
    font-size: 1.2rem !important;
  }
  
  .card-suit {
    font-size: 1.5rem !important;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .action-buttons .btn {
    min-width: auto;
    width: 100%;
  }
  
  /* Results cards responsive */
  .result-card {
    width: 42px;
    height: 60px;
    padding: 4px;
  }
  
  .result-card-rank {
    font-size: 0.9rem;
  }
  
  .result-card-suit {
    font-size: 1.1rem;
  }
  
  .result-row-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .row-name {
    min-width: auto;
  }
  
  .row-points {
    margin-left: 0;
  }
  
  .result-header {
    flex-direction: row;
  }
  
  .rank {
    font-size: 1.5rem;
    min-width: 50px;
  }
}

/* Animation Phase Indicator */
.animation-phase-indicator {
  text-align: center;
  margin-bottom: 20px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  display: inline-block;
  width: 100%;
}

#animation-phase {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: all 0.3s ease;
}

.animation-phase.phase-begin {
  color: #64B5F6;
}

.animation-phase.phase-sopen {
  color: #81C784;
  animation: pulse 1.5s infinite;
}

.animation-phase.phase-sscoop {
  color: #FFD54F;
  animation: shake 0.5s infinite;
}

.animation-phase.phase-scoin {
  color: #FFB74D;
  animation: spin 2s linear infinite;
}

.animation-phase.phase-nround {
  color: #BA68C8;
  animation: pulse 1s infinite;
}

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

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

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