/* === CSS Variables — Complete Design Palette === */
:root {
  /* Gold family */
  --gold-light: #D4AF37;
  --gold-dark: #8A6D3B;
  --gold-muted: #c8b07a;

  /* Table colors */
  --table-dark: #0d381e;
  --table-mid: #14522c;
  --table-light: #1b6b3a;

  /* Buttons */
  --raise-green: #2D6A4F;
  --fold-gray: #495057;
  --action-gold: #FAB005;

  /* State colors */
  --win: #4caf50;
  --lose: #f44336;
  --strength-orange: #D9480F;
  --strength-gold: #F59F00;
  --strength-green: #2B8A3E;

  /* Text hierarchy */
  --text-body: #fff;
  --text-secondary: #ccc;
  --text-muted: #888;
  --text-dim: #666;

  /* Effects */
  --card-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

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

body {
  font-family: -apple-system, 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
  background: #1a1a2e;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

/* === Card (face-up) === */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid #ddd;
}

.card-rank {
  position: absolute;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
}

.card-rank.top-left { top: 6px; left: 7px; }
.card-rank.bottom-right { bottom: 6px; right: 7px; transform: rotate(180deg); }

.card-suit-center {
  font-size: 33px;
  line-height: 1;
  margin-top: 7px;
}

.card.suit-h, .card.suit-d { color: #d32f2f; }
.card.suit-c, .card.suit-s { color: #1a1a1a; }

.card.rank-K .card-suit-center,
.card.rank-Q .card-suit-center,
.card.rank-J .card-suit-center { font-size: 27px; margin-top: 6px; }
.card.rank-t .card-rank { font-size: 18px; }

/* === Card Back (face-down) === */
.card-back {
  background: linear-gradient(135deg, #1a3a8a, #2d5bcf);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  border: 2px solid var(--gold-light);
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1.5px solid rgba(212,175,55,0.4);
  border-radius: 4px;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 3px,
    rgba(255,255,255,0.04) 3px, rgba(255,255,255,0.04) 6px
  );
}

.card-back::after {
  content: '♠♥♦♣';
  font-size: 20px;
  color: rgba(212,175,55,0.4);
  letter-spacing: 5px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* === Card Shine Overlay === */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  background-size: 200% 200%;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.card:hover::after {
  opacity: 1;
  animation: cardShine 0.6s ease-out;
}
@keyframes cardShine {
  0% { background-position: 200% 200%; }
  100% { background-position: -200% -200%; }
}

/* === Card Hover Lift === */
.card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover:not(.winner-highlight) {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.6);
}

/* === Slot State Transitions === */
.card-slot.dealt .card-back,
.card-slot.dealt .card {
  animation: dealCard 0.35s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes dealCard {
  0% { opacity: 0; transform: translateY(-40px) scale(0.85) rotateX(10deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateX(0deg); }
}

.card-slot.flip .card-back {
  animation: flipOut 0.3s cubic-bezier(0.55, 0, 0.55, 0.2) forwards;
}

.card-slot.flip .card {
  animation: flipIn 0.3s cubic-bezier(0.22, 0.61, 0.36, 1) 0.15s both;
}

@keyframes flipOut {
  0% { transform: rotateY(0deg) scale(1); opacity: 1; }
  100% { transform: rotateY(90deg) scale(0.95); opacity: 0; }
}

@keyframes flipIn {
  0% { transform: rotateY(-90deg) scale(0.95); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

/* === Results & Animations === */
@keyframes resultBounce {
  0% { opacity: 0; transform: scale(0.85); }
  60% { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideInItem {
  0% { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* === Button Click Ripple === */
.btn.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--rx,50%) var(--ry,50%), rgba(255,255,255,0.3) 0%, transparent 60%);
  opacity: 0;
  pointer-events: none;
  animation: rippleOut 0.5s ease-out;
}
@keyframes rippleOut {
  0% { opacity: 1; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(2); }
}

/* === Toast Notification === */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}
.toast {
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--gold-light);
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.5s forwards;
  white-space: nowrap;
}
.toast.win { border-color: var(--win); }
.toast.lose { border-color: var(--lose); }
@keyframes toastIn {
  0% { opacity: 0; transform: translateY(-20px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  border: 2px solid #D4AF37;
  border-radius: 16px;
  padding: 32px 40px;
  background: linear-gradient(180deg, #1e2e1e 0%, #162316 100%);
  box-shadow: 0 0 60px rgba(212,175,55,0.15), inset 0 1px 0 rgba(212,175,55,0.1);
  text-align: center;
  min-width: 300px;
}
.modal-title {
  color: #D4AF37;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  text-shadow: 0 0 20px rgba(212,175,55,0.3);
}
.modal-text {
  color: #ccc;
  font-size: 14px;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.modal-btn {
  padding: 10px 28px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.modal-btn:hover { opacity: 0.85; }
.modal-btn-danger {
  background: linear-gradient(135deg, #D4AF37, #b8962f);
  color: #1a1a1a;
}
.modal-btn-cancel {
  background: #333;
  color: #aaa;
}
.modal-foot {
  color: #D4AF37;
  font-size: 9px;
  opacity: 0.2;
  margin-top: 20px;
}

/* === Rank Badge === */
.rank-badge {
  display: inline-block;
  font-size: 14px;
  margin-right: 4px;
}
.rank-badge.rf { color: #ffd700; }
.rank-badge.sf { color: var(--lose); }
.rank-badge.fk { color: #ff9800; }
.rank-badge.fh { color: #e040fb; }
.rank-badge.fl { color: #2196f3; }
.rank-badge.st { color: #4caf50; }
.rank-badge.default { color: var(--text-muted); }

/* === Star Rating === */
.star-rating {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 1px;
  margin-left: 6px;
}
.star-rating .star { color: #ffd700; }
.star-rating .star.empty { color: rgba(255,255,255,0.15); }

/* === Keyboard Badges === */
.key-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  padding: 0 5px;
  border-radius: 3px;
  margin-left: 3px;
  vertical-align: middle;
  opacity: 0.7;
}

@keyframes keyFlash {
  0% { background: rgba(255,255,255,0.5); transform: scale(1.3); }
  100% { background: rgba(255,255,255,0.15); transform: scale(1); }
}

/* === Button Base === */
.btn {
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  border-radius: 8px;
  transition: all 0.12s;
  letter-spacing: 0.5px;
  position: relative;
}

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

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