/* ═══════════════════════════════════════════════════════════
   style.css — Dark Casino / Poker-Table Aesthetic
   Premium card-game UI with glass-morphism, gold accents,
   and smooth micro-interactions.
   ═══════════════════════════════════════════════════════════ */

/* ── CUSTOM PROPERTIES ────────────────────────────────── */
:root {
  --bg-deep:       #0a0a1a;
  --bg-surface:    #111128;
  --felt-green:    #1a5c38;
  --felt-dark:     #0d3320;
  --card-white:    #f0f0f0;
  --card-shadow:   rgba(0,0,0,0.45);
  --gold:          #d4a037;
  --gold-hover:    #e8b84a;
  --gold-dim:      #a07828;
  --red-suit:      #e63946;
  --black-suit:    #1d1d1d;
  --text-primary:  #e8e8e8;
  --text-secondary:#888;
  --text-muted:    #555;
  --success:       #4ade80;
  --danger:        #ef4444;
  --glass:         rgba(255,255,255,0.05);
  --glass-border:  rgba(255,255,255,0.08);
  --glass-hover:   rgba(255,255,255,0.1);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-xs:     4px;
  --transition:    0.25s cubic-bezier(.4,0,.2,1);
  --font-body:     'Inter', system-ui, sans-serif;
  --font-display:  'Outfit', 'Inter', system-ui, sans-serif;
  --card-w:        60px;
  --card-h:        84px;
  --card-w-sm:     42px;
  --card-h-sm:     60px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  /* Subtle background pattern */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(26,92,56,0.15), transparent),
    radial-gradient(circle at 20% 80%, rgba(212,160,55,0.04), transparent),
    radial-gradient(circle at 80% 20%, rgba(212,160,55,0.04), transparent);
}

/* ── CUSTOM SCROLLBAR ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── SCREEN MANAGEMENT ────────────────────────────────── */
.screen {
  display: none;
  animation: fadeIn 0.4s ease;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

/* ── GLASS PANELS ─────────────────────────────────────── */
.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px;
  transition: border-color var(--transition), background var(--transition);
}
.glass-panel:hover {
  border-color: rgba(255,255,255,0.12);
}

/* ══════════════════════════════════════════════════════════
   TYPOGRAPHY
   ══════════════════════════════════════════════════════════ */
.section-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 24px;
  letter-spacing: 0.02em;
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.97); }

/* Primary — gold gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-hover));
  color: #1a1a1a;
  box-shadow: 0 4px 20px rgba(212,160,55,0.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--gold-hover), #f0c860);
  box-shadow: 0 6px 28px rgba(212,160,55,0.45);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  background: linear-gradient(135deg, #555, #444);
  color: #888;
  box-shadow: none;
  cursor: not-allowed;
}

/* Secondary — glass */
.btn-secondary {
  background: var(--glass);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--glass-hover);
  border-color: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Danger */
.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239,68,68,0.25);
  border-color: rgba(239,68,68,0.4);
}
.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-small {
  padding: 6px 16px;
  font-size: 0.85rem;
}

.btn-icon-only {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon-only:hover { background: var(--glass-hover); }

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

/* ══════════════════════════════════════════════════════════
   INPUTS
   ══════════════════════════════════════════════════════════ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.input-group label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.input-group input {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  font-size: 1rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,160,55,0.15);
}
.input-group input::placeholder {
  color: var(--text-muted);
}
.input-code {
  font-family: 'Outfit', monospace !important;
  font-size: 1.3rem !important;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════
   DIVIDER
   ══════════════════════════════════════════════════════════ */
.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

/* ══════════════════════════════════════════════════════════
   HOME SCREEN
   ══════════════════════════════════════════════════════════ */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 420px;
  width: 100%;
}

.logo-area {
  text-align: center;
  margin-bottom: 8px;
}
.logo-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 8px;
  animation: bounce 2s ease infinite;
}
.logo-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--gold), var(--gold-hover), #fff, var(--gold));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}
.logo-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 300;
  letter-spacing: 0.08em;
}

.home-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: 100%;
}

/* Rules */
.rules-section {
  width: 100%;
  cursor: pointer;
  font-size: 0.92rem;
}
.rules-section summary {
  font-weight: 600;
  color: var(--gold);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rules-section summary::-webkit-details-marker { display: none; }
.rules-section[open] summary { margin-bottom: 12px; }
.rules-content {
  color: var(--text-secondary);
  line-height: 1.6;
}
.rules-content ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.rules-content strong { color: var(--gold); }
.rules-content em { color: var(--danger); font-style: normal; font-weight: 600; }

.audio-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
}

/* ══════════════════════════════════════════════════════════
   LOBBY SCREEN
   ══════════════════════════════════════════════════════════ */
.lobby-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 480px;
  width: 100%;
}

.room-code-display {
  text-align: center;
  width: 100%;
}
.room-code-display label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 12px;
}
.room-code-chars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}
.room-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 56px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0;
  box-shadow: 0 0 16px rgba(212,160,55,0.15);
}

.player-list-panel {
  width: 100%;
}
.player-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-align: center;
}
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.player-list-item.disconnected { opacity: 0.45; }
.player-icon { font-size: 1rem; }
.player-name { font-weight: 500; }

.waiting-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.waiting-dots .dots span {
  animation: bounce 1.4s ease infinite;
  display: inline-block;
}
.waiting-dots .dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots .dots span:nth-child(3) { animation-delay: 0.4s; }

.lobby-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ══════════════════════════════════════════════════════════
   SWAP SCREEN
   ══════════════════════════════════════════════════════════ */
.swap-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 600px;
  width: 100%;
}
.swap-instruction {
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.95rem;
}
.swap-instruction strong { color: var(--gold); }

.swap-counter {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.swap-counter.complete {
  color: var(--success);
}

.swap-cards-area {
  width: 100%;
}
.swap-hand {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px;
}

.swap-facedown-preview {
  text-align: center;
}
.swap-facedown-preview label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.facedown-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* ══════════════════════════════════════════════════════════
   GAME BOARD
   ══════════════════════════════════════════════════════════ */
.game-board {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  min-height: 100vh;
  gap: 12px;
  padding: 8px;
}

/* Status bar */
.status-bar {
  position: relative;
  text-align: center;
  padding: 10px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.game-menu-container {
  position: absolute;
  top: 6px;
  right: 8px;
}
.btn-menu-trigger {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition);
}
.btn-menu-trigger:hover {
  color: var(--gold);
  background: rgba(255, 255, 255, 0.05);
}
.game-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  padding: 6px;
  z-index: 1000;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
}
.game-menu-dropdown.active {
  display: flex;
}
.btn-menu-item {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 8px 12px;
  text-align: left;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  white-space: nowrap;
}
.btn-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
}
.btn-menu-item.btn-danger {
  color: var(--red-suit);
}
.btn-menu-item.btn-danger:hover {
  background: rgba(230, 57, 70, 0.15);
  color: var(--red-suit);
}
.status-text.my-turn {
  color: var(--gold);
  font-weight: 600;
  animation: pulse 1.5s ease infinite;
}
.room-code-badge {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.3);
  padding: 4px 8px;
  border-radius: 4px;
  position: absolute;
  top: 8px;
  left: 8px;
  border: 1px solid var(--glass-border);
}
.room-code-badge span {
  color: var(--gold);
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Play Area Grid - Poker Table Layout */
.play-area {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    ". top ."
    "left center right"
    ". bottom .";
  width: 100%;
  max-width: 1200px;
  min-height: calc(100vh - 120px);
  gap: 16px;
  margin: 0 auto;
}

.player-slot {
  display: flex;
}

.slot-top {
  grid-area: top;
  justify-content: center;
  align-items: flex-start;
}

.slot-left {
  grid-area: left;
  justify-content: flex-start;
  align-items: center;
}

.slot-right {
  grid-area: right;
  justify-content: flex-end;
  align-items: center;
}

.slot-bottom {
  grid-area: bottom;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

/* Opponents */
.opponent-panel {
  min-width: 140px;
  max-width: 220px;
  width: 100%;
  padding: 14px;
  transition: all var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.opponent-panel.current-turn {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,160,55,0.2);
}
.opponent-panel.current-turn::before {
  content: '⚡';
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 1.2rem;
  animation: pulse 1s ease infinite;
}
.opponent-panel.finished { opacity: 0.5; }
.opponent-panel.disconnected { border-color: rgba(239,68,68,0.3); }

.opponent-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--text-primary);
  text-align: center;
}
.opponent-card-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.card-row-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 100%;
  text-align: center;
  margin-bottom: 4px;
}
.more-cards {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 2px;
}

.table-center {
  grid-area: center;
  position: relative;
  background:
    radial-gradient(ellipse at center, var(--felt-green) 0%, var(--felt-dark) 70%, rgba(10,10,26,0.9) 100%);
  border-radius: 120px; /* Pill shape for poker table */
  border: 4px solid rgba(26,92,56,0.4);
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.6),
    0 8px 32px rgba(0,0,0,0.5);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: 1fr auto 1fr;
  grid-template-areas:
    ". tc-top ."
    "tc-left tc-middle tc-right"
    ". tc-bottom .";
  align-items: center;
  justify-items: center;
  padding: 32px;
  min-height: 380px;
  width: 100%;
}

.tc-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 84px;
  min-width: 60px;
}
.tc-top { grid-area: tc-top; align-self: start; margin-top: -10px; }
.tc-bottom { grid-area: tc-bottom; align-self: end; margin-bottom: -10px; }
.tc-left { grid-area: tc-left; justify-self: start; margin-left: -10px; }
.tc-right { grid-area: tc-right; justify-self: end; margin-right: -10px; }

.table-middle {
  grid-area: tc-middle;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  width: 100%;
}

/* Mobile Responsiveness for the Grid */
@media (max-width: 768px) {
  .play-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: auto;
  }
  
  .table-center {
    border-radius: var(--radius); /* Regular rounded corners on mobile */
    padding: 10px;
    min-height: 280px;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
  }

  .table-middle {
    gap: 20px;
  }
  
  .slot-top, .slot-left, .slot-right, .slot-bottom {
    justify-content: center;
  }
  
  .opponent-panel {
    max-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  
  .opponent-name {
    margin-bottom: 0;
    width: 100%;
  }
  
  .card-row-label {
    width: auto;
    margin-bottom: 0;
    margin-right: 8px;
  }
}

.deck-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.deck-stack {
  position: relative;
  width: var(--card-w-sm);
  height: var(--card-h-sm);
}
.deck-count {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  font-weight: 600;
}
.deck-empty {
  width: var(--card-w-sm);
  height: var(--card-h-sm);
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.pile-area {
  position: relative;
  min-width: 80px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pile-area.burning .card {
  animation: cardBurn 0.6s ease forwards;
}
.pile-empty {
  color: rgba(255,255,255,0.25);
  font-size: 0.85rem;
  font-style: italic;
}
.pile-count-badge {
  position: absolute;
  bottom: -8px;
  right: -8px;
  background: var(--gold);
  color: #1a1a1a;
  font-size: 0.7rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.pile-mirror-indicator {
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 26, 0.95);
  border: 1px solid var(--gold);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 4px;
}
.pile-mirror-indicator strong {
  color: var(--gold);
  font-weight: 700;
}
.text-red {
  color: var(--red-suit);
}
.text-white {
  color: var(--text-primary);
}
.pile-card-under {
  opacity: 0.5;
}
.pile-card-top {
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.burn-zone {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.3s;
}
.burn-zone.active {
  opacity: 1;
  background: radial-gradient(circle, rgba(239,68,68,0.2), rgba(255,120,0,0.1), transparent 70%);
  animation: cardBurn 0.8s ease forwards;
}

/* Player area */
.my-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 8px;
}
.my-table-cards, .my-hand {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 10px;
}
.my-hand { gap: 6px; }

.table-cards {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.tc-left .table-cards,
.tc-right .table-cards {
  flex-direction: column;
  /* Use negative margin on card-stacks to reduce visual vertical gap caused by rotation */
  gap: 0;
}

.tc-left .card-stack { transform: rotate(90deg); margin: -4px 0; }
.tc-right .card-stack { transform: rotate(-90deg); margin: -4px 0; }
.tc-top .card-stack { transform: rotate(180deg); }
.card-stack {
  position: relative;
  display: flex;
  justify-content: center;
  width: var(--card-w);
  height: var(--card-h);
}
.card-stack.small {
  width: var(--card-w-sm);
  height: var(--card-h-sm);
}
.card.overlap-top {
  position: absolute !important;
  top: 4px; /* Tighter offset so rotated cards don't misalign too much */
  left: 4px;
  z-index: 2;
}

/* Game actions */
.game-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  opacity: 0.3;
  pointer-events: none;
  transition: opacity var(--transition);
}
.game-actions.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ══════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════ */
.card {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--card-white);
  border-radius: var(--radius-sm);
  position: relative;
  box-shadow: 0 2px 8px var(--card-shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  user-select: none;
  flex-shrink: 0;
  border: 2px solid transparent;
  overflow: hidden;
}

/* Small variant */
.card.card-sm {
  width: var(--card-w-sm);
  height: var(--card-h-sm);
  border-radius: var(--radius-xs);
}
.card.card-sm .card-rank { font-size: 0.65rem; }
.card.card-sm .card-suit { font-size: 0.55rem; }
.card.card-sm .card-suit-lg { font-size: 1.1rem; }
.card.card-sm .card-corner { padding: 2px 3px; }

/* Hover */
.card.selectable {
  cursor: pointer;
}
.card.selectable:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 10;
}

/* Selected */
.card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(212,160,55,0.5), 0 4px 12px rgba(0,0,0,0.3);
  transform: translateY(-8px) scale(1.04);
  z-index: 11;
}

/* Disabled */
.card.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Corners */
.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  padding: 4px 5px;
}
.card-corner-tl { top: 0; left: 0; }
.card-corner-br { bottom: 0; right: 0; transform: rotate(180deg); }

.card-rank {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--black-suit);
}
.card-suit {
  font-size: 0.65rem;
  color: var(--black-suit);
}

/* Red suit coloring */
.card.red .card-rank,
.card.red .card-suit,
.card.red .card-suit-lg {
  color: var(--red-suit);
}

/* Center suit */
.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.card-suit-lg {
  font-size: 1.8rem;
  color: var(--black-suit);
  opacity: 0.85;
}

/* Card Back */
.card.card-back {
  background: linear-gradient(135deg, #1a237e, #283593);
  border-color: #3949ab;
}
.card-back-pattern {
  position: absolute;
  inset: 4px;
  border-radius: calc(var(--radius-sm) - 4px);
  border: 1px solid rgba(255,255,255,0.1);
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 4px,
      rgba(255,255,255,0.03) 4px,
      rgba(255,255,255,0.03) 8px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 4px,
      rgba(255,255,255,0.03) 4px,
      rgba(255,255,255,0.03) 8px
    );
}
.card.card-sm .card-back-pattern {
  inset: 3px;
  border-radius: calc(var(--radius-xs) - 2px);
}

/* ══════════════════════════════════════════════════════════
   RESULTS SCREEN
   ══════════════════════════════════════════════════════════ */
.results-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 500px;
  width: 100%;
}
.results-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
  animation: fadeIn 0.6s ease;
}

.results-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  animation: fadeIn 0.5s ease both;
  transition: all var(--transition);
}
.result-row:nth-child(1) { animation-delay: 0.1s; }
.result-row:nth-child(2) { animation-delay: 0.25s; }
.result-row:nth-child(3) { animation-delay: 0.4s; }
.result-row:nth-child(4) { animation-delay: 0.55s; }

.result-row.winner {
  border-color: var(--gold);
  background: rgba(212,160,55,0.08);
  box-shadow: 0 0 20px rgba(212,160,55,0.15);
}
.result-row.shithead {
  border-color: var(--danger);
  background: rgba(239,68,68,0.08);
  box-shadow: 0 0 20px rgba(239,68,68,0.15);
  animation: shake 0.5s ease 0.7s;
}
.result-row.is-me {
  border-width: 2px;
}

.result-position {
  font-size: 2rem;
  width: 48px;
  text-align: center;
  flex-shrink: 0;
}
.result-name {
  flex: 1;
  font-weight: 600;
  font-size: 1.1rem;
}
.result-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.shithead-title {
  color: var(--danger) !important;
  font-weight: 700 !important;
  font-size: 1rem !important;
  animation: pulse 1.2s ease infinite;
}

.results-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  max-width: 400px;
  width: 90vw;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  background: rgba(20,20,40,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  pointer-events: auto;
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.hide {
  transform: translateY(-20px);
  opacity: 0;
}
.toast-success { border-color: rgba(74,222,128,0.3); }
.toast-error { border-color: rgba(239,68,68,0.3); }
.toast-warning { border-color: rgba(251,191,36,0.3); }
.toast-info { border-color: rgba(96,165,250,0.3); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { line-height: 1.3; }

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════ */

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes cardPlay {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.8); opacity: 0; }
}

@keyframes cardBurn {
  0%   { opacity: 1; filter: brightness(1); }
  40%  { opacity: 1; filter: brightness(1.8) saturate(2); }
  100% { opacity: 0; filter: brightness(2) saturate(0); transform: scale(0.8); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%      { transform: translateX(-6px); }
  20%      { transform: translateX(6px); }
  30%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  50%      { transform: translateX(-4px); }
  60%      { transform: translateX(4px); }
  70%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
  90%      { transform: translateX(-1px); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  :root {
    --card-w: 50px;
    --card-h: 70px;
    --card-w-sm: 36px;
    --card-h-sm: 50px;
  }

  .screen.active {
    padding: 12px;
  }

  .logo-title {
    font-size: 2.5rem;
  }
  .logo-emoji {
    font-size: 3rem;
  }

  .home-form, .glass-panel {
    padding: 16px;
  }

  .room-char {
    width: 38px;
    height: 46px;
    font-size: 1.4rem;
  }

  .opponents-area {
    flex-direction: column;
    align-items: stretch;
  }
  .opponent-panel {
    max-width: 100%;
    min-width: auto;
  }

  .table-center {
    padding: 16px;
    gap: 20px;
    min-height: 140px;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .my-hand { gap: 4px; }

  .section-title {
    font-size: 1.4rem;
  }

  .swap-hand {
    gap: 6px;
    padding: 10px;
  }

  .results-title {
    font-size: 1.8rem;
  }
  .result-position {
    font-size: 1.5rem;
    width: 36px;
  }
  .result-name {
    font-size: 0.95rem;
  }
}

@media (max-width: 380px) {
  :root {
    --card-w: 44px;
    --card-h: 62px;
    --card-w-sm: 32px;
    --card-h-sm: 45px;
  }
  .card-suit-lg { font-size: 1.3rem; }
  .card-rank { font-size: 0.75rem; }
  .card-suit { font-size: 0.55rem; }
  .logo-title { font-size: 2rem; }
}
