* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #0a0e17;
  color: #f5f5f5;
  min-height: 100vh;
  overflow: hidden;
}

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

.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Loading */
#loading {
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid #333;
  border-top-color: #d4af37;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Header */
.header {
  text-align: center;
  padding: 24px 16px;
}

.header h1 {
  font-size: 28px;
  color: #d4af37;
  margin-bottom: 8px;
}

/* Lobby */
.players-list {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4af37, #8b6914);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.btn {
  margin: 16px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

.btn-gold {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: #0a0e17;
}

.btn-gold:active {
  transform: scale(0.98);
}

.hidden {
  display: none !important;
}

.room-code {
  text-align: center;
  color: #888;
  padding-bottom: 24px;
  font-size: 14px;
}

.join-box {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}

.join-box input {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #1a1a2e;
  color: #fff;
  text-transform: uppercase;
  font-size: 16px;
}

.btn-outline {
  margin: 8px 16px;
  padding: 12px;
  border: 1px solid #666;
  border-radius: 12px;
  background: transparent;
  color: #aaa;
  font-size: 14px;
  cursor: pointer;
}

.team-scores {
  font-size: 13px;
  color: #d4af37;
  text-align: center;
  flex: 1;
}

.deal-hint {
  color: #888;
  font-size: 13px;
  margin-bottom: 12px;
}

.gameover h2 {
  font-size: 28px;
  margin-bottom: 16px;
}

.gameover p {
  font-size: 16px;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* Game table */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
}

.trump-badge {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(212, 175, 55, 0.2);
  border-radius: 50%;
  border: 2px solid #d4af37;
}

.scores {
  font-size: 13px;
  text-align: left;
  direction: ltr;
}

.table-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.table {
  width: min(92vw, 400px);
  height: min(55vh, 320px);
  border: 3px solid #d4af37;
  border-radius: 50% / 40%;
  background: radial-gradient(ellipse at center, #1a472a 0%, #0d2818 70%, #061510 100%);
  box-shadow: 0 0 40px rgba(212, 175, 55, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.5);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.opponents {
  position: absolute;
  top: -30px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 0 8px;
}

.opponent {
  text-align: center;
  font-size: 12px;
}

.opponent-name {
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.opponent-cards {
  font-size: 11px;
  color: #aaa;
}

.trick-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  padding: 16px;
}

.status-bar {
  position: absolute;
  bottom: 16px;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  color: #d4af37;
}

/* Cards - fan layout */
.hand {
  position: relative;
  width: 100%;
  height: 155px;
  overflow: visible;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
  margin-bottom: 8px;
}

.hand-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.hand .card {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 52px;
  height: 76px;
  margin-left: -26px;
  transform-origin: center 110px;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.hand .card.playable:hover,
.hand .card.playable.selected {
  filter: brightness(1.05);
}

.hand .card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.card {
  width: 52px;
  height: 76px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.card:not(.hand .card) {
  width: 52px;
  height: 76px;
}

.hand .card.playable {
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.55);
  cursor: pointer;
}

.card.red { color: #c0392b; }
.card.black { color: #2c3e50; }

.card-rank { font-size: 16px; line-height: 1; }
.card-suit { font-size: 22px; line-height: 1; }

.trick-area .card {
  width: 44px;
  height: 64px;
  font-size: 14px;
  animation: dealIn 0.3s ease-out;
}

@keyframes dealIn {
  from {
    opacity: 0;
    transform: scale(0.5) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.card-play-anim {
  animation: playCard 0.4s ease-out;
}

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

/* Trump modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  text-align: center;
  padding: 32px;
}

.modal-content h2 {
  color: #d4af37;
  margin-bottom: 20px;
  font-size: 22px;
}

.timer {
  font-size: 48px;
  color: #e74c3c;
  margin-bottom: 24px;
  font-weight: bold;
}

.suit-picker {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.suit-btn {
  width: 72px;
  height: 72px;
  font-size: 40px;
  border: 3px solid #d4af37;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.suit-btn:active {
  transform: scale(0.95);
  background: rgba(212, 175, 55, 0.3);
}

.suit-btn[data-suit="hearts"], .suit-btn[data-suit="diamonds"] { color: #e74c3c; }
.suit-btn[data-suit="clubs"], .suit-btn[data-suit="spades"] { color: #ecf0f1; }

/* Chat */
.chat-fab {
  position: fixed;
  bottom: 130px;
  left: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(212, 175, 55, 0.9);
  font-size: 22px;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.chat-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 240px;
  background: rgba(10, 14, 23, 0.95);
  border-top: 1px solid #d4af37;
  display: flex;
  flex-direction: column;
  z-index: 60;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 13px;
}

.chat-msg {
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.chat-msg .name {
  color: #d4af37;
  font-weight: bold;
  font-size: 12px;
}

.chat-input-row {
  display: flex;
  padding: 8px;
  gap: 8px;
}

.chat-input-row input {
  flex: 1;
  padding: 10px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 14px;
}

.chat-input-row button {
  padding: 10px 16px;
  background: #d4af37;
  border: none;
  border-radius: 8px;
  color: #0a0e17;
  font-weight: bold;
  cursor: pointer;
}

/* Audio unlock */
.audio-unlock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 18px;
  border: 1px solid #d4af37;
  border-radius: 20px;
  background: rgba(10, 14, 23, 0.95);
  color: #d4af37;
  font-size: 13px;
  cursor: pointer;
  animation: pulseBtn 2s infinite;
}

.audio-unlock.hidden { display: none; }

@keyframes pulseBtn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4); }
  50% { box-shadow: 0 0 16px 4px rgba(212, 175, 55, 0.25); }
}

/* Effects */
body.no-effects .deal-in,
body.no-effects .card-fly,
body.no-effects .particle,
body.no-effects .table.trump-flash,
body.no-effects .table.win-flash,
body.no-effects .trump-pop,
body.no-effects .my-turn,
body.no-effects .suit-pick,
body.no-effects .timer-urgent {
  animation: none !important;
}

.player-name.active-turn {
  border: 1px solid #d4af37;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.table.trump-flash {
  animation: trumpFlash 0.7s ease-out;
}

.table.win-flash {
  animation: winFlash 0.7s ease-out;
}

@keyframes trumpFlash {
  0% { box-shadow: 0 0 40px rgba(212, 175, 55, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 0 60px rgba(212, 175, 55, 0.55), inset 0 0 60px rgba(0, 0, 0, 0.5); }
  100% { box-shadow: 0 0 40px rgba(212, 175, 55, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.5); }
}

@keyframes winFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

.trump-badge.trump-pop {
  animation: trumpPop 0.6s ease-out;
}

@keyframes trumpPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.hand.my-turn {
  animation: handPulse 0.8s ease-out;
}

@keyframes handPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 -8px 24px rgba(212, 175, 55, 0.45); }
}

.card.deal-in {
  animation: dealIn 0.45s ease-out;
}

.card.card-fly {
  animation: cardFly 0.35s ease-in forwards;
}

@keyframes cardFly {
  to {
    opacity: 0;
    transform: translateY(-120px) scale(0.7);
  }
}

.suit-btn.suit-pick {
  animation: suitPick 0.4s ease-out;
}

@keyframes suitPick {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); background: rgba(212, 175, 55, 0.45); }
  100% { transform: scale(1); }
}

.timer.timer-urgent {
  animation: timerBlink 0.5s infinite alternate;
  color: #ff4444;
}

@keyframes timerBlink {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.trick-area {
  position: relative;
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4af37;
  pointer-events: none;
  animation: particleFly 0.8s ease-out forwards;
}

@keyframes particleFly {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-40px) scale(0.2); }
}
