/* ═══════════════════════════════════════════════════════════
   UNO MULTIPLAYER — PREMIUM DARK THEME
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-tertiary: #1a1a3e;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);

  --text-primary: #f0f0ff;
  --text-secondary: rgba(240, 240, 255, 0.6);
  --text-muted: rgba(240, 240, 255, 0.35);

  /* UNO Card Colors */
  --uno-red: #e53935;
  --uno-red-glow: rgba(229, 57, 53, 0.4);
  --uno-yellow: #fdd835;
  --uno-yellow-glow: rgba(253, 216, 53, 0.4);
  --uno-green: #43a047;
  --uno-green-glow: rgba(67, 160, 71, 0.4);
  --uno-blue: #1e88e5;
  --uno-blue-glow: rgba(30, 136, 229, 0.4);
  --uno-wild: linear-gradient(135deg, #e53935, #fdd835, #43a047, #1e88e5);

  /* Accents */
  --accent: #7c4dff;
  --accent-glow: rgba(124, 77, 255, 0.4);
  --success: #00e676;
  --warning: #ffab40;
  --error: #ff5252;

  /* Typography */
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(124, 77, 255, 0.2);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Đảm bảo fit trong Discord iframe */
  max-width: 100vw;
  max-height: 100vh;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ─── Screens ──────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: scale(0.96);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

/* ─── Glass Panel ──────────────────────────────────────── */
.glass-panel {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #7c4dff, #651fff);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 30px var(--accent-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-large {
  padding: 16px 36px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.btn-stepper {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  font-size: 1.2rem;
}

.btn-stepper:hover {
  background: rgba(255,255,255,0.15);
}

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

/* ─── Input ────────────────────────────────────────────── */
.input-group {
  position: relative;
  width: 100%;
}

.input-group input {
  width: 100%;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
}

.input-group input:focus {
  border-color: var(--accent);
  background: rgba(124, 77, 255, 0.06);
  box-shadow: 0 0 20px var(--accent-glow);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-auth {
  background: radial-gradient(ellipse at 50% 0%, rgba(124, 77, 255, 0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(229, 57, 53, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 20% 100%, rgba(30, 136, 229, 0.08) 0%, transparent 50%),
              var(--bg-primary);
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  z-index: 1;
  padding: 40px 20px 20px;
  width: 100%;
  min-height: 100%;
  justify-content: center;
}

/* ─── Auth Footer ──────────────────────────────────────── */
.auth-footer {
  margin-top: auto;
  padding: 24px 20px 16px;
  text-align: center;
  z-index: 1;
}

.auth-footer p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.auth-footer p strong {
  color: var(--text-secondary);
  font-weight: 700;
}

.auth-footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: color 0.2s ease, transform 0.2s ease;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.footer-link:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.footer-link svg {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.footer-link:hover svg {
  opacity: 1;
}

.logo-wrapper {
  text-align: center;
}

.uno-logo {
  position: relative;
  width: 200px;
  height: 120px;
  margin: 0 auto;
}

.logo-card {
  position: absolute;
  width: 60px;
  height: 85px;
  border-radius: 10px;
  top: 50%;
  left: 50%;
  transition: transform 0.3s ease;
}

.logo-card-1 {
  background: var(--uno-red);
  transform: translate(-50%, -50%) rotate(-20deg) translateX(-40px);
  box-shadow: 0 4px 20px var(--uno-red-glow);
}

.logo-card-2 {
  background: var(--uno-yellow);
  transform: translate(-50%, -50%) rotate(-7deg) translateX(-14px);
  box-shadow: 0 4px 20px var(--uno-yellow-glow);
}

.logo-card-3 {
  background: var(--uno-green);
  transform: translate(-50%, -50%) rotate(7deg) translateX(14px);
  box-shadow: 0 4px 20px var(--uno-green-glow);
}

.logo-card-4 {
  background: var(--uno-blue);
  transform: translate(-50%, -50%) rotate(20deg) translateX(40px);
  box-shadow: 0 4px 20px var(--uno-blue-glow);
}

.logo-text {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #ff6b6b, #fdd835, #69f0ae, #64b5f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 10px rgba(255,255,255,0.2));
}

.tagline {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 16px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.auth-form {
  padding: 40px;
  width: 380px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: center;
}

.auth-form h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

/* Floating background cards */
.floating-cards {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.float-card {
  position: absolute;
  font-size: 2.5rem;
  opacity: 0.08;
  animation: floatCard 20s infinite ease-in-out;
}

.fc-1 { top: 10%; left: 5%; animation-delay: 0s; }
.fc-2 { top: 20%; right: 10%; animation-delay: -4s; }
.fc-3 { bottom: 30%; left: 15%; animation-delay: -8s; }
.fc-4 { bottom: 15%; right: 5%; animation-delay: -12s; }
.fc-5 { top: 50%; left: 50%; animation-delay: -16s; }

@keyframes floatCard {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-30px) rotate(10deg); }
  50% { transform: translateY(10px) rotate(-5deg); }
  75% { transform: translateY(-15px) rotate(5deg); }
}

/* ═══════════════════════════════════════════════════════════
   LOBBY SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-lobby {
  background: radial-gradient(ellipse at 30% 20%, rgba(67, 160, 71, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(253, 216, 53, 0.06) 0%, transparent 50%),
              var(--bg-primary);
}

.lobby-container {
  width: 100%;
  max-width: 800px;
  padding: 20px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
}

.lobby-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.logo-text-sm {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ff6b6b, #fdd835, #69f0ae, #64b5f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.spacer { flex: 1; }

.lobby-actions {
  display: flex;
  gap: 24px;
  align-items: stretch;
}

.lobby-card {
  flex: 1;
  padding: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lobby-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.lobby-card-icon {
  font-size: 3rem;
  margin-bottom: 4px;
}

.lobby-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.lobby-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.player-count-select {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  justify-content: center;
}

.player-count-select label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

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

#max-players-value {
  font-size: 1.6rem;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
}

.divider-or {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

.divider-or span {
  background: var(--bg-primary);
  padding: 8px 4px;
}

/* ═══════════════════════════════════════════════════════════
   WAITING ROOM
   ═══════════════════════════════════════════════════════════ */
#screen-waiting {
  background: radial-gradient(ellipse at 50% 30%, rgba(124, 77, 255, 0.08) 0%, transparent 60%),
              var(--bg-primary);
}

.waiting-container {
  width: 100%;
  max-width: 500px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto;
}

.waiting-header {
  padding: 32px;
  text-align: center;
}

.waiting-top-row {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.waiting-top-row h2 {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.room-code-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.code-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 72px;
  background: rgba(124, 77, 255, 0.1);
  border: 2px solid rgba(124, 77, 255, 0.3);
  border-radius: var(--radius-md);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0;
  animation: codeGlow 2s ease-in-out infinite;
}

.code-char:nth-child(2) { animation-delay: 0.2s; }
.code-char:nth-child(3) { animation-delay: 0.4s; }
.code-char:nth-child(4) { animation-delay: 0.6s; }

@keyframes codeGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(124, 77, 255, 0.1); }
  50% { box-shadow: 0 0 20px rgba(124, 77, 255, 0.25); }
}

.room-code-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.players-list {
  padding: 24px;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.player-item + .player-item {
  border-top: 1px solid var(--border);
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.player-info {
  flex: 1;
}

.player-name {
  font-weight: 600;
  font-size: 1rem;
}

.player-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.ready-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ready-badge.ready {
  background: rgba(0, 230, 118, 0.15);
  color: var(--success);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.ready-badge.not-ready {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.waiting-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-game {
  background: radial-gradient(ellipse at 50% 50%, rgba(67, 160, 71, 0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 50% 100%, rgba(30, 136, 229, 0.04) 0%, transparent 40%),
              var(--bg-primary);
  overflow: hidden;
}

.game-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

/* ─── Opponents Area ─── */
.opponents-area {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.opponent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  min-width: 160px;
}

.opponent-card.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  background: rgba(124, 77, 255, 0.08);
}

.opponent-card.has-uno {
  border-color: var(--uno-red);
  box-shadow: 0 0 20px var(--uno-red-glow);
  animation: unoPulse 1s ease-in-out infinite;
}

@keyframes unoPulse {
  0%, 100% { box-shadow: 0 0 20px var(--uno-red-glow); }
  50% { box-shadow: 0 0 35px var(--uno-red-glow); }
}

.opponent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.opponent-info {
  display: flex;
  flex-direction: column;
}

.opponent-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.opponent-cards {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.challenge-btn {
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--uno-red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: unoPulse 0.8s ease-in-out infinite;
  transition: transform 0.1s;
}

.challenge-btn:hover {
  transform: scale(1.1);
}

/* ─── Table Center ─── */
.table-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 200px;
}

.direction-indicator {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.direction-arrow {
  animation: spinDirection 8s linear infinite;
}

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

.direction-arrow.counter-clockwise {
  animation-direction: reverse;
}

.pile-area {
  display: flex;
  align-items: center;
  gap: 40px;
  z-index: 1;
}

/* ─── Cards ─── */
.card {
  width: 90px;
  height: 135px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-weight: 700;
  font-size: 1.6rem;
  color: white;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: default;
  user-select: none;
  font-family: var(--font);
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  border: 3px solid rgba(255,255,255,0.15);
}

.card-inner-oval {
  position: absolute;
  width: 65%;
  height: 80%;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transform: rotate(30deg);
}

.card-value {
  position: relative;
  z-index: 1;
  font-size: 2rem;
  font-weight: 800;
}

.card-label {
  position: relative;
  z-index: 1;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.card-corner {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 700;
  z-index: 1;
}

.card-corner-tl {
  top: 6px;
  left: 8px;
}

.card-corner-br {
  bottom: 6px;
  right: 8px;
  transform: rotate(180deg);
}

/* Card Colors */
.card-red { background: linear-gradient(145deg, #e53935, #c62828); box-shadow: 0 4px 20px var(--uno-red-glow); }
.card-yellow { background: linear-gradient(145deg, #fdd835, #f9a825); color: #333; text-shadow: none; box-shadow: 0 4px 20px var(--uno-yellow-glow); }
.card-green { background: linear-gradient(145deg, #43a047, #2e7d32); box-shadow: 0 4px 20px var(--uno-green-glow); }
.card-blue { background: linear-gradient(145deg, #1e88e5, #1565c0); box-shadow: 0 4px 20px var(--uno-blue-glow); }
.card-wild {
  background: linear-gradient(145deg, #e53935 0%, #e53935 25%, #fdd835 25%, #fdd835 50%, #43a047 50%, #43a047 75%, #1e88e5 75%, #1e88e5 100%);
  box-shadow: 0 4px 20px rgba(124, 77, 255, 0.3);
}

/* Card Back */
.card-back {
  background: linear-gradient(145deg, #1a1a3e, #12122a);
  border: 3px solid rgba(124, 77, 255, 0.3);
  cursor: pointer;
}

.card-back:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.card-back-design {
  width: 70%;
  height: 75%;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c4dff, #651fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.pile-count {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

.draw-pile {
  position: relative;
  cursor: pointer;
}

/* Discard pile */
.discard-pile {
  position: relative;
}

.discard-pile .card {
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

/* Active color indicator */
.active-color-indicator {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.active-color-indicator.color-red { background: rgba(229,57,53,0.2); color: var(--uno-red); border: 1px solid rgba(229,57,53,0.4); }
.active-color-indicator.color-yellow { background: rgba(253,216,53,0.2); color: var(--uno-yellow); border: 1px solid rgba(253,216,53,0.4); }
.active-color-indicator.color-green { background: rgba(67,160,71,0.2); color: var(--uno-green); border: 1px solid rgba(67,160,71,0.4); }
.active-color-indicator.color-blue { background: rgba(30,136,229,0.2); color: var(--uno-blue); border: 1px solid rgba(30,136,229,0.4); }

.draw-stack-indicator {
  position: absolute;
  top: -30px;
  right: calc(50% - 100px);
  padding: 4px 14px;
  border-radius: 16px;
  background: rgba(255, 82, 82, 0.2);
  color: var(--error);
  border: 1px solid rgba(255, 82, 82, 0.4);
  font-size: 1rem;
  font-weight: 800;
  animation: pulseDraw 0.8s ease-in-out infinite;
}

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

/* ─── Player Hand ─── */
.hand-area {
  padding: 8px 0 16px;
}

.hand-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
}

.btn-draw {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-draw:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.btn-draw.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
  animation: pulseDraw 1s ease-in-out infinite;
}

.turn-indicator {
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.turn-indicator.my-turn {
  background: rgba(0, 230, 118, 0.12);
  color: var(--success);
  border: 1px solid rgba(0, 230, 118, 0.3);
  animation: turnGlow 1.5s ease-in-out infinite;
}

.turn-indicator.not-my-turn {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

@keyframes turnGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(0, 230, 118, 0.1); }
  50% { box-shadow: 0 0 25px rgba(0, 230, 118, 0.25); }
}

.btn-uno {
  background: linear-gradient(135deg, #e53935, #c62828);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  box-shadow: 0 4px 15px var(--uno-red-glow);
}

.btn-uno:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--uno-red-glow);
}

.btn-uno.pulse {
  animation: unoPulse 0.6s ease-in-out infinite;
}

.player-hand {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0 20px;
  min-height: 140px;
  align-items: flex-end;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.player-hand .card {
  flex-shrink: 0;
  cursor: pointer;
  margin-left: -20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, margin 0.2s ease;
}

.player-hand .card:first-child {
  margin-left: 0;
}

.player-hand .card:hover {
  transform: translateY(-20px) scale(1.08);
  z-index: 10;
  margin-left: 0;
  margin-right: 0;
}

.player-hand .card.playable {
  border-color: rgba(255, 255, 255, 0.4);
}

.player-hand .card.playable:hover {
  box-shadow: 0 8px 40px rgba(255, 255, 255, 0.15);
}

.player-hand .card:not(.playable) {
  opacity: 0.5;
  filter: brightness(0.7);
}

.player-hand .card:not(.playable):hover {
  transform: translateY(-8px);
}

/* Play animation */
@keyframes playCard {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-100px) scale(0.8); opacity: 0.7; }
  100% { transform: translateY(-200px) scale(0.3); opacity: 0; }
}

.card.playing {
  animation: playCard 0.4s ease-out forwards;
}

/* Deal animation — subtle fade + slide up, no spin */
@keyframes dealCard {
  0%   { transform: translateY(-40px) rotate(-8deg) scale(0.85); opacity: 0; }
  70%  { transform: translateY(4px)   rotate(1deg)  scale(1.02); opacity: 1; }
  100% { transform: translateY(0)     rotate(0deg)  scale(1);    opacity: 1; }
}

/* Draw animation — snappy bounce from below */
@keyframes drawCard {
  0%   { transform: translateY(60px) scale(0.85); opacity: 0; }
  60%  { transform: translateY(-4px) scale(1.03); opacity: 1; }
  100% { transform: translateY(0)    scale(1);    opacity: 1; }
}

.card.dealing {
  animation: dealCard 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.card.drawing {
  animation: drawCard 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ═══════════════════════════════════════════════════════════
   COLOR PICKER MODAL
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.color-picker {
  padding: 40px;
  text-align: center;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.color-picker h3 {
  font-size: 1.3rem;
  margin-bottom: 28px;
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 280px;
}

.color-btn {
  width: 100%;
  height: 100px;
  border: 3px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  transition: all 0.2s ease;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.color-btn:hover {
  transform: scale(1.08);
  border-color: rgba(255, 255, 255, 0.5);
}

.color-red { background: linear-gradient(145deg, #e53935, #c62828); box-shadow: 0 4px 20px var(--uno-red-glow); }
.color-yellow { background: linear-gradient(145deg, #fdd835, #f9a825); color: #333; text-shadow: none; box-shadow: 0 4px 20px var(--uno-yellow-glow); }
.color-green { background: linear-gradient(145deg, #43a047, #2e7d32); box-shadow: 0 4px 20px var(--uno-green-glow); }
.color-blue { background: linear-gradient(145deg, #1e88e5, #1565c0); box-shadow: 0 4px 20px var(--uno-blue-glow); }

/* ═══════════════════════════════════════════════════════════
   GAME OVER MODAL
   ═══════════════════════════════════════════════════════════ */
.game-over {
  padding: 60px 80px;
  text-align: center;
  animation: modalSlideIn 0.3s ease;
}

.game-over-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.trophy {
  font-size: 5rem;
  animation: trophyBounce 0.6s ease;
}

@keyframes trophyBounce {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.game-over h2 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fdd835, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-over-sub {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  padding: 14px 22px;
  border-radius: var(--radius-md);
  background: rgba(30, 30, 60, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastSlideIn 0.3s ease, toastSlideOut 0.3s ease 3.7s forwards;
  max-width: 360px;
  pointer-events: auto;
}

@keyframes toastSlideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100px); opacity: 0; }
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-error { border-left: 3px solid var(--error); }
.toast.toast-info { border-left: 3px solid var(--accent); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Auth */
  .auth-container {
    gap: 32px;
    padding: 30px 16px 12px;
  }

  .auth-form {
    width: 100%;
    padding: 28px 20px;
  }

  .uno-logo {
    width: 160px;
    height: 100px;
  }

  .logo-card {
    width: 48px;
    height: 68px;
  }

  .logo-text {
    font-size: 2.4rem;
  }

  .tagline {
    font-size: 0.85rem;
    margin-top: 12px;
  }

  /* Lobby */
  .lobby-container {
    padding: 16px;
  }

  .lobby-header {
    margin-bottom: 24px;
  }

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

  .lobby-card {
    padding: 24px 20px;
    gap: 12px;
  }

  .lobby-card-icon {
    font-size: 2.2rem;
    margin-bottom: 0;
  }

  .lobby-card h3 {
    font-size: 1.1rem;
  }

  .lobby-card p {
    font-size: 0.82rem;
  }

  .divider-or {
    padding: 4px 0;
  }

  .logo-text-sm {
    font-size: 1.4rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  /* Waiting Room */
  .waiting-container {
    padding: 16px;
    gap: 16px;
  }

  .waiting-header {
    padding: 24px 16px;
  }

  .code-char {
    width: 50px;
    height: 60px;
    font-size: 1.6rem;
  }

  .waiting-actions {
    flex-direction: column;
  }

  /* Game */
  .game-container {
    padding: 8px;
  }

  .card {
    width: 70px;
    height: 105px;
  }

  .card-value {
    font-size: 1.5rem;
  }

  .card-label {
    font-size: 0.55rem;
  }

  .card-corner {
    font-size: 0.6rem;
  }

  .opponents-area {
    gap: 8px;
    padding: 8px 0;
  }

  .opponent-card {
    padding: 8px 12px;
    min-width: auto;
    gap: 8px;
    border-radius: var(--radius-md);
  }

  .opponent-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .opponent-name {
    font-size: 0.8rem;
    max-width: 70px;
  }

  .opponent-cards {
    font-size: 0.7rem;
  }

  .table-center {
    min-height: 160px;
  }

  .pile-area {
    gap: 24px;
  }

  .direction-arrow {
    width: 120px;
    height: 120px;
  }

  .hand-controls {
    gap: 12px;
  }

  .btn-draw {
    padding: 8px 14px;
    font-size: 0.78rem;
  }

  .turn-indicator {
    padding: 6px 14px;
    font-size: 0.78rem;
  }

  .btn-uno {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .player-hand {
    padding: 0 8px;
    min-height: 110px;
  }

  .player-hand .card {
    margin-left: -18px;
  }

  .hand-area {
    padding: 4px 0 8px;
  }

  /* Active color & draw stack on mobile */
  .active-color-indicator {
    font-size: 0.7rem;
    padding: 4px 12px;
    bottom: -32px;
  }

  .draw-stack-indicator {
    font-size: 0.85rem;
    padding: 3px 10px;
    top: -24px;
  }

  /* Color picker */
  .color-picker {
    padding: 28px 20px;
  }

  .color-grid {
    width: 240px;
    gap: 12px;
  }

  .color-btn {
    height: 80px;
    font-size: 0.95rem;
  }

  /* Game over */
  .game-over {
    padding: 40px 30px;
  }

  .trophy {
    font-size: 3.5rem;
  }

  .game-over h2 {
    font-size: 1.5rem;
  }

  /* Toast on mobile */
  #toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: 100%;
    font-size: 0.82rem;
    padding: 10px 16px;
  }
}

@media (max-width: 480px) {
  /* Auth */
  .auth-container {
    gap: 24px;
    padding: 24px 12px 8px;
  }

  .auth-form {
    padding: 24px 16px;
    gap: 18px;
  }

  .auth-form h2 {
    font-size: 1.1rem;
  }

  .btn-large {
    padding: 14px 28px;
    font-size: 1rem;
  }

  .auth-footer-links {
    gap: 16px;
  }

  .footer-link {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  /* Lobby */
  .lobby-card {
    padding: 20px 16px;
    gap: 10px;
  }

  .lobby-card-icon {
    font-size: 1.8rem;
  }

  .lobby-card h3 {
    font-size: 1rem;
  }

  .input-group input {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  #room-code-input {
    font-size: 1.2rem !important;
    letter-spacing: 0.2em !important;
  }

  .player-count-select {
    gap: 10px;
  }

  /* Waiting */
  .code-char {
    width: 44px;
    height: 54px;
    font-size: 1.4rem;
  }

  .room-code-display {
    gap: 8px;
  }

  .player-item {
    padding: 12px;
    gap: 12px;
  }

  .player-avatar {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .player-name {
    font-size: 0.9rem;
  }

  .ready-badge {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  /* Game */
  .card {
    width: 56px;
    height: 84px;
    border-radius: 8px;
    border-width: 2px;
  }

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

  .card-label {
    font-size: 0.45rem;
  }

  .card-corner {
    font-size: 0.5rem;
  }

  .card-corner-tl {
    top: 3px;
    left: 4px;
  }

  .card-corner-br {
    bottom: 3px;
    right: 4px;
  }

  .player-hand .card {
    margin-left: -22px;
  }

  .player-hand {
    min-height: 90px;
    padding: 0 4px;
  }

  .player-hand .card:hover {
    transform: translateY(-14px) scale(1.06);
  }

  .opponents-area {
    gap: 6px;
    padding: 4px 0;
  }

  .opponent-card {
    padding: 6px 8px;
    gap: 6px;
    border-radius: 10px;
  }

  .opponent-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .opponent-name {
    font-size: 0.72rem;
    max-width: 55px;
  }

  .opponent-cards {
    font-size: 0.62rem;
  }

  .challenge-btn {
    padding: 3px 7px;
    font-size: 0.6rem;
  }

  .table-center {
    min-height: 130px;
  }

  .pile-area {
    gap: 20px;
  }

  .direction-arrow {
    width: 100px;
    height: 100px;
  }

  .hand-controls {
    gap: 8px;
    margin-bottom: 8px;
  }

  .btn-draw {
    padding: 6px 10px;
    font-size: 0.72rem;
  }

  .btn-draw svg {
    width: 16px;
    height: 16px;
  }

  .turn-indicator {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .btn-uno {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .hand-area {
    padding: 2px 0 4px;
  }

  /* Deck card on discard/draw pile smaller too */
  .card-back-design {
    font-size: 0.75rem;
  }

  .pile-count {
    font-size: 0.7rem;
    margin-top: 4px;
  }

  /* Game Over modal on small screens */
  .game-over {
    padding: 32px 24px;
  }

  .game-over h2 {
    font-size: 1.3rem;
  }

  .trophy {
    font-size: 3rem;
  }
}

/* Extra small screens (iPhone SE, etc) */
@media (max-width: 360px) {
  .card {
    width: 48px;
    height: 72px;
  }

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

  .player-hand .card {
    margin-left: -24px;
  }

  .opponent-card {
    padding: 5px 6px;
  }

  .opponent-name {
    max-width: 45px;
    font-size: 0.65rem;
  }

  .opponent-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.6rem;
  }

  .hand-controls {
    gap: 6px;
  }

  .code-char {
    width: 38px;
    height: 48px;
    font-size: 1.2rem;
  }
}

/* Landscape on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .game-container {
    padding: 4px 8px;
  }

  .opponents-area {
    padding: 2px 0;
  }

  .table-center {
    min-height: 100px;
  }

  .card {
    width: 50px;
    height: 75px;
  }

  .player-hand {
    min-height: 80px;
  }

  .hand-area {
    padding: 0;
  }

  .hand-controls {
    margin-bottom: 4px;
  }

    .direction-arrow {
    width: 80px;
    height: 80px;
  }
}

/* ═══════════════════════════════════════════════════════════
   DISCORD LOADING OVERLAY
   ═══════════════════════════════════════════════════════════ */

.discord-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.discord-loading.active {
  opacity: 1;
  pointer-events: all;
}

.discord-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* Mini UNO logo nằm trong loading */
.uno-logo-sm {
  position: relative;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.uno-logo-sm .logo-card {
  position: absolute;
  width: 30px;
  height: 42px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.uno-logo-sm .logo-card-1 {
  background: var(--uno-red);
  transform: rotate(-15deg) translate(-8px, 2px);
}

.uno-logo-sm .logo-card-2 {
  background: var(--uno-blue);
  transform: rotate(0deg);
  z-index: 2;
}

.uno-logo-sm .logo-card-3 {
  background: var(--uno-green);
  transform: rotate(15deg) translate(8px, 2px);
}

.uno-logo-sm .logo-text {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.05em;
  z-index: 3;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

/* Spinner */
.discord-spinner {
  width: 48px;
  height: 48px;
  position: relative;
}

.spinner-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

.discord-loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* ─── Discord Activity: safe-area insets ────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .hand-area {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

/* ─── Discord avatar in player list ─────────────────────── */
.player-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.player-item-me .player-avatar {
  box-shadow: 0 0 0 2px #7c4dff, 0 0 12px rgba(124, 77, 255, 0.4);
}

.player-item-me .player-name {
  color: #c4b5fd;
}

.you-tag {
  font-size: 0.7em;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════
   DISCORD PARTICIPANTS PANEL
   ═══════════════════════════════════════════════════════════ */
.discord-participants-panel {
  background: rgba(88, 101, 242, 0.12);
  border: 1px solid rgba(88, 101, 242, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 10px;
}

.participants-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(88, 101, 242, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.participants-count {
  margin-left: auto;
  background: rgba(88, 101, 242, 0.3);
  color: #fff;
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.participants-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.participant-item.participant-me {
  background: rgba(88, 101, 242, 0.15);
}

.participant-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(88, 101, 242, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.participant-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.participant-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.participant-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pstatus-in {
  background: rgba(67, 160, 71, 0.25);
  color: #81c784;
}

.pstatus-out {
  background: rgba(255, 152, 0, 0.2);
  color: #ffb74d;
}
