/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --felt-green: #1a6b3c;
  --felt-dark: #0f4d2a;
  --felt-shadow: #0a3a1f;
  --card-white: #f8f6f0;
  --card-border: #d4c9a8;
  --gold: #d4a843;
  --gold-light: #f0d080;
  --gold-dark: #b8862d;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-light: #f8f6f0;
  --bg-dark: #0d1b0e;
  --danger: #e74c3c;
  --success: #2ecc71;
  --transition-speed: 0.3s;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
}

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

/* ── Screens ──────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes cardDeal {
  from { opacity: 0; transform: translateY(-40px) rotate(-10deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

@keyframes treasureGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(212, 168, 67, 0.3); }
  50% { box-shadow: 0 0 40px rgba(212, 168, 67, 0.6); }
}

@keyframes confetti-fall {
  0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1a2e;
  box-shadow: 0 4px 15px rgba(212, 168, 67, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 168, 67, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.125rem;
}

.btn-icon {
  font-size: 1.2em;
}

/* ── Connection Overlay ───────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.overlay.active {
  display: flex;
}

.connect-card {
  background: linear-gradient(135deg, #1a3a2a, #0f4d2a);
  padding: 48px;
  border-radius: 24px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  border: 1px solid var(--gold-dark);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.5s ease-out;
}

.connect-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.connect-card h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.subtitle {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.connect-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.connect-form input {
  padding: 16px 20px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 1.1rem;
  font-family: 'Inter', sans-serif;
  text-align: center;
  transition: border-color var(--transition-speed);
}

.connect-form input:focus {
  outline: none;
  border-color: var(--gold);
}

.connect-form input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.error-message {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.5em;
  margin-top: 8px;
}

/* ── Game Header ──────────────────────────────────────────────── */
.game-header {
  background: linear-gradient(180deg, #0a1f12, #0d2a18);
  padding: 16px 24px;
  border-bottom: 1px solid rgba(212, 168, 67, 0.2);
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2rem;
}

.logo h1 {
  font-family: 'Playfair Display', serif;
  color: var(--gold);
  font-size: 1.8rem;
  letter-spacing: 2px;
}

.connection-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 8px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  flex-shrink: 0;
}

.connection-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.6);
}

.connection-dot.connecting {
  background: var(--gold-dark);
  box-shadow: 0 0 6px rgba(212, 168, 67, 0.4);
  animation: pulse 1.2s ease-in-out infinite;
}

.connection-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(231, 76, 60, 0.4);
}

.tagline {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  display: none;
}

.trick-display {
  color: var(--text-light);
  font-size: 1.1rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 20px;
  border-radius: 20px;
}

/* ── Lobby ────────────────────────────────────────────────────── */
.lobby-content {
  padding: 40px 24px;
  max-width: 900px;
  margin: 0 auto;
}

.table-container {
  margin-bottom: 40px;
}

.table-felt {
  background: radial-gradient(ellipse at center, var(--felt-green) 0%, var(--felt-dark) 100%);
  border-radius: 200px 200px 120px 120px;
  padding: 48px 40px;
  border: 3px solid var(--felt-shadow);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4);
  position: relative;
  min-height: 280px;
}

.table-label {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 4px;
}

.seats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.seat {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 20px 12px;
  text-align: center;
  transition: all var(--transition-speed) ease;
  border: 2px solid transparent;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.seat.occupied {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(212, 168, 67, 0.3);
}

.seat.computer {
  border-color: rgba(100, 200, 255, 0.2);
}

.seat.empty {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.3);
}

.seat.empty:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.seat-avatar {
  font-size: 2.2rem;
  margin-bottom: 8px;
  line-height: 1;
}

.seat-name {
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  word-break: break-word;
}

.seat-type {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.strategy-chip {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(100, 200, 255, 0.15);
  border: 1px solid rgba(100, 200, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.strategy-chip:hover {
  background: rgba(100, 200, 255, 0.25);
  border-color: rgba(100, 200, 255, 0.5);
  color: #fff;
}

.seat.self {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212, 168, 67, 0.2);
}

.empty-seat-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.empty-seat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
}

/* ── Lobby Controls ───────────────────────────────────────────── */
.lobby-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.computer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.comp-count {
  color: var(--text-light);
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
}

.game-info {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

/* ── Game Screen ──────────────────────────────────────────────── */
#game {
  background: radial-gradient(ellipse at 50% 40%, var(--felt-green) 0%, var(--felt-dark) 60%, #061a0e 100%);
  padding-bottom: 40px;
}

.game-header-playing {
  background: linear-gradient(180deg, #061a0e, transparent);
  border-bottom: none;
}

/* ── Scoreboard ──────────────────────────────────────────────── */
.scoreboard {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px 24px;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
}

.score-item {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 10px 18px;
  text-align: center;
  min-width: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-speed);
}

.score-item .name {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  font-weight: 500;
}

.score-item .score {
  color: var(--text-light);
  font-size: 1.3rem;
  font-weight: 700;
}

.score-item .score.positive {
  color: var(--success);
}

.score-item .score.negative {
  color: var(--danger);
}

.score-item.winner-highlight {
  border-color: var(--gold);
  background: rgba(212, 168, 67, 0.15);
  animation: pulse 1.5s infinite;
}

.score-item.winner-highlight .score {
  color: var(--gold-light);
}

/* ── Treasure Area ────────────────────────────────────────────── */
.treasure-area {
  text-align: center;
  padding: 20px;
  margin: 0 auto;
  max-width: 300px;
}

.treasure-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.treasure-value {
  font-family: 'Playfair Display', serif;
  font-size: 4rem;
  font-weight: 900;
  color: var(--gold);
  display: inline-block;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 40px;
  border-radius: 20px;
  border: 2px solid var(--gold-dark);
  animation: treasureGlow 2s ease-in-out infinite;
  min-width: 120px;
}

.treasure-value.negative {
  color: #e74c3c;
  border-color: #e74c3c;
  animation: none;
  box-shadow: 0 0 20px rgba(231, 76, 60, 0.3);
}

/* ── Bid Status ───────────────────────────────────────────────── */
.bid-status {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  max-width: 600px;
  margin: 0 auto;
}

.bid-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  transition: all var(--transition-speed);
}

.bid-dot .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all var(--transition-speed);
}

.bid-dot.ready .dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.bid-dot.ready {
  color: rgba(255, 255, 255, 0.8);
}

/* ── Hand Area ────────────────────────────────────────────────── */
.hand-area {
  max-width: 800px;
  margin: 24px auto 0;
  text-align: center;
  padding: 0 24px;
}

.hand-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 16px;
}

.hand-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  perspective: 800px;
}

.card {
  width: 64px;
  height: 90px;
  background: var(--card-white);
  border: 2px solid var(--card-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-family: 'Playfair Display', serif;
}

.card:hover:not(.disabled) {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border-color: var(--gold);
}

.card.selected {
  transform: translateY(-14px);
  border-color: var(--gold);
  background: linear-gradient(135deg, #fffcf0, var(--card-white));
  box-shadow: 0 10px 30px rgba(212, 168, 67, 0.3);
}

.card.disabled {
  cursor: default;
  opacity: 0.3;
  transform: none !important;
}

.card .card-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.card .card-suit {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card .card-top-left {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.card .card-bottom-right {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.card.played {
  animation: cardDeal 0.4s ease-out forwards;
  pointer-events: none;
}

/* ── Bid Button ───────────────────────────────────────────────── */
#bid-btn {
  margin: 0 auto;
  min-width: 220px;
}

/* ── Result Overlay ───────────────────────────────────────────── */
#result-overlay .result-card {
  background: linear-gradient(135deg, #1a3a2a, #0f4d2a);
  padding: 40px;
  border-radius: 24px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.5s ease-out;
}

.result-treasure {
  font-size: 3rem;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 12px;
}

.result-winner {
  font-size: 1.2rem;
  color: var(--text-light);
  margin-bottom: 24px;
}

.result-bids {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.result-bid-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  font-size: 0.95rem;
}

.result-bid-item.won {
  background: rgba(212, 168, 67, 0.15);
  border: 1px solid rgba(212, 168, 67, 0.3);
}

.result-bid-item .bid-card {
  font-weight: 700;
}

.result-next-btn {
  margin-top: 8px;
}

/* ── Game Over ────────────────────────────────────────────────── */
#game-over {
  background: radial-gradient(ellipse at center, var(--felt-green) 0%, var(--felt-dark) 60%, #061a0e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

#game-over.active {
  display: flex;
}

.gameover-container {
  text-align: center;
  padding: 48px;
  animation: slideUp 0.6s ease-out;
}

.gameover-icon {
  font-size: 5rem;
  margin-bottom: 16px;
  animation: pulse 1.5s infinite;
}

.gameover-container h1 {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.gameover-winners {
  color: var(--text-light);
  font-size: 1.3rem;
  margin-bottom: 32px;
}

.gameover-scores {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.gameover-score-item {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px 28px;
  min-width: 140px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gameover-score-item .name {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.gameover-score-item .final-score {
  color: var(--text-light);
  font-size: 2rem;
  font-weight: 700;
}

.gameover-score-item.winner {
  border-color: var(--gold);
  background: rgba(212, 168, 67, 0.15);
}

.gameover-score-item.winner .final-score {
  color: var(--gold-light);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .seats {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .table-felt {
    padding: 32px 16px;
    border-radius: 100px 100px 60px 60px;
  }

  .treasure-value {
    font-size: 3rem;
    padding: 4px 24px;
  }

  .card {
    width: 52px;
    height: 74px;
  }

  .card .card-number {
    font-size: 1.2rem;
  }

  .hand-cards {
    gap: 6px;
  }

  .lobby-controls {
    flex-direction: column;
    gap: 16px;
  }

  .scoreboard {
    gap: 8px;
  }

  .score-item {
    min-width: 70px;
    padding: 8px 12px;
  }

  .connect-card {
    padding: 32px 24px;
  }

  .gameover-container h1 {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .seats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .seat {
    padding: 12px 8px;
    min-height: 80px;
  }

  .seat-avatar {
    font-size: 1.6rem;
  }

  .card {
    width: 44px;
    height: 64px;
  }

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

  .card .card-top-left,
  .card .card-bottom-right {
    font-size: 0.6rem;
  }

  .treasure-value {
    font-size: 2.5rem;
  }
}
