/* =====================================================
   RESET E VARIABILI
   ===================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-blue: #0a1e3d;
  --electric-blue: #1a5fb4;
  --accent-blue: #2d7dd2;
  --light-blue: #4dabf7;
  --dark-bg: #050b16;
  --card-bg: rgba(26, 95, 180, 0.15);
  --border-color: rgba(77, 171, 247, 0.3);
  --text-white: #ffffff;
  --text-gray: #a0aec0;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow: 0 0 20px rgba(77, 171, 247, 0.5);
  --gradient: linear-gradient(
    135deg,
    var(--primary-blue),
    var(--electric-blue)
  );
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--dark-bg);
  color: var(--text-white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =====================================================
   ANIMAZIONI
   ===================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(77, 171, 247, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(77, 171, 247, 0.6);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* =====================================================
   CONTENITORI GENERALI
   ===================================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.full-height {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* =====================================================
   BOTTONI
   ===================================================== */
.btn {
  padding: 15px 40px;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--gradient);
  color: var(--text-white);
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: var(--glow);
}

.btn-primary:active {
  transform: translateY(-1px);
}

.btn-round {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =====================================================
   CARD E PANNELLI
   ===================================================== */
.card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  animation: fadeIn 0.5s ease;
}

.game-card {
  background: var(--card-bg);
  border: 3px solid var(--light-blue);
  border-radius: 25px;
  padding: 40px;
  box-shadow: var(--glow);
  position: relative;
  min-height: 300px;
}

.game-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(77, 171, 247, 0.1) 50%,
    transparent 70%
  );
  border-radius: 25px;
}

/* =====================================================
   GRIGLIA GIOCATORI
   ===================================================== */
.players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 20px;
}

.player-slot {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 15px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.3s ease;
  min-height: 80px;
}

.player-slot.empty {
  opacity: 0.3;
  border-style: dashed;
}

.player-slot.active {
  border-color: var(--light-blue);
  background: rgba(77, 171, 247, 0.2);
  animation: glow 2s infinite;
}

.player-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--light-blue);
  object-fit: cover;
}

.player-name {
  font-size: 18px;
  font-weight: bold;
  flex: 1;
}

.player-score {
  font-size: 24px;
  font-weight: bold;
  color: var(--light-blue);
  min-width: 50px;
  text-align: right;
}

/* =====================================================
   GRIGLIA AVATAR (SELEZIONE)
   ===================================================== */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin: 30px 0;
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 5px;
}

/* Scrollbar personalizzata */
.avatar-grid::-webkit-scrollbar {
  width: 6px;
}

.avatar-grid::-webkit-scrollbar-track {
  background: rgba(26, 95, 180, 0.1);
  border-radius: 10px;
}

.avatar-grid::-webkit-scrollbar-thumb {
  background: var(--light-blue);
  border-radius: 10px;
}

.avatar-grid::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 15px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  position: relative;
}

.avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-option:hover {
  transform: scale(1.1);
  border-color: var(--accent-blue);
}

.avatar-option.selected {
  border-color: var(--light-blue);
  box-shadow: var(--glow);
}

.avatar-option.selected::after {
  content: "✓";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  background: #2ecc71;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

/* =====================================================
   QR CODE E CODICE PARTITA
   ===================================================== */
.qr-container {
  text-align: center;
  padding: 30px;
}

.qr-code {
  background: white;
  padding: 20px;
  border-radius: 15px;
  display: inline-block;
  margin: 20px 0;
}

.game-code {
  font-size: 48px;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--light-blue);
  text-shadow: 0 0 20px rgba(77, 171, 247, 0.5);
  margin: 20px 0;
}

/* =====================================================
   INPUT
   ===================================================== */
.input-field {
  width: 100%;
  padding: 15px 20px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: rgba(26, 95, 180, 0.1);
  color: var(--text-white);
  transition: all 0.3s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--light-blue);
  box-shadow: 0 0 15px rgba(77, 171, 247, 0.3);
}

.input-field::placeholder {
  color: var(--text-gray);
}

/* =====================================================
   LOADING SPINNER
   ===================================================== */
.loading-spinner {
  width: 60px;
  height: 60px;
  border: 6px solid var(--border-color);
  border-top-color: var(--light-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

/* =====================================================
   LAYOUT A DUE COLONNE
   ===================================================== */
.two-column-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  padding: 20px;
  min-height: 100vh;
  align-items: start;
}

.left-column,
.right-column {
  padding: 20px;
}

/* =====================================================
   CLASSIFICA
   ===================================================== */
.leaderboard {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
}

.leaderboard-title {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  color: var(--light-blue);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  margin: 10px 0;
  background: rgba(26, 95, 180, 0.1);
  border-radius: 15px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.leaderboard-item.current-turn {
  border-color: var(--light-blue);
  background: rgba(77, 171, 247, 0.2);
  animation: glow 2s infinite;
}

.leaderboard-position {
  font-size: 20px;
  font-weight: bold;
  min-width: 30px;
}

/* =====================================================
   CARTA DI GIOCO
   ===================================================== */
.game-card-display {
  background: white;
  color: #000;
  border-radius: 25px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card-text {
  font-size: 24px;
  line-height: 1.6;
  font-weight: 500;
}

.card-id {
  position: absolute;
  bottom: 15px;
  right: 20px;
  font-size: 12px;
  color: #666;
}

/* =====================================================
   GRIGLIA VOTAZIONE
   ===================================================== */
.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.vote-option {
  background: var(--card-bg);
  border: 3px solid var(--border-color);
  border-radius: 15px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.vote-option:hover {
  transform: translateY(-5px);
  border-color: var(--accent-blue);
}

.vote-option.selected {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.2);
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

.vote-number {
  font-size: 48px;
  font-weight: bold;
  color: var(--light-blue);
}

/* =====================================================
   RISULTATI
   ===================================================== */
.results-container {
  text-align: center;
  padding: 40px;
}

.winner-display {
  margin: 30px 0;
}

.winner-avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 5px solid #2ecc71;
  margin: 20px auto;
  box-shadow: 0 0 40px rgba(46, 204, 113, 0.6);
}

.points-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin: 30px 0;
}

.point-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background: var(--card-bg);
  border-radius: 10px;
}

.point-item.earned {
  border: 2px solid #2ecc71;
}

.point-item.missed {
  border: 2px solid #e74c3c;
  opacity: 0.6;
}

.point-icon {
  font-size: 24px;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  .two-column-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .players-grid {
    grid-template-columns: 1fr;
  }

  .avatar-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 50vh;
    padding-right: 5px;
  }

  .game-code {
    font-size: 32px;
    letter-spacing: 4px;
  }

  .card-text {
    font-size: 18px;
  }

  .btn {
    padding: 12px 30px;
    font-size: 16px;
  }
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center {
  text-align: center;
}

.mt-20 {
  margin-top: 20px;
}

.mb-20 {
  margin-bottom: 20px;
}

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease;
}

/* =====================================================
   OPZIONI VOTO CON TESTO
   ===================================================== */
.vote-option p {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.vote-number {
  font-size: 36px;
  font-weight: bold;
  color: var(--light-blue);
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  .vote-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   GIOCATORE DISCONNESSO
   ===================================================== */
.player-slot.disconnected {
  opacity: 0.6;
  border-color: #e74c3c;
  border-style: dashed;
  background: rgba(231, 76, 60, 0.1);
}

.player-slot.disconnected .player-avatar {
  filter: grayscale(100%);
  opacity: 0.4;
}

.player-slot.disconnected .player-name {
  text-decoration: line-through;
  opacity: 0.5;
}
