*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; min-height: 100vh;
  background: #071510;
  font-family: 'Poppins', sans-serif;
  color: #fff;
  overflow: hidden;
  user-select: none;
}

/* ── Game Container ─────────────────────────────── */
#game-wrap {
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 40%, #0d2b1e 0%, #071510 100%);
  position: relative; overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────── */
.game-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(0,0,0,.4);
  border-bottom: 1px solid rgba(255,255,255,.08);
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.back-btn {
  background: rgba(255,255,255,.1); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.back-btn:hover { background: rgba(255,255,255,.2); }
.game-title { font-family: 'Orbitron', sans-serif; font-size: 14px; color: #f4c542; }

.pot-display {
  background: rgba(0,0,0,.5); border: 1.5px solid #f4c542;
  border-radius: 20px; padding: 5px 14px;
  font-size: 13px; font-weight: 700; color: #f4c542;
  display: flex; align-items: center; gap: 6px;
}

.points-bar {
  background: rgba(0,200,83,.15); border: 1px solid rgba(0,200,83,.4);
  border-radius: 20px; padding: 5px 12px;
  font-size: 12px; font-weight: 700; color: #4caf50;
}

/* ── Table Area ──────────────────────────────────── */
.table-area {
  flex: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
}

.felt-table {
  position: relative;
  width: min(500px, 95vw);
  aspect-ratio: 1 / 1.1;
  background: radial-gradient(ellipse at 50% 50%, #1a5c35 0%, #0d3a21 60%, #082515 100%);
  border-radius: 50%;
  border: 8px solid #3a2510;
  box-shadow:
    inset 0 0 40px rgba(0,0,0,.5),
    0 0 40px rgba(0,0,0,.6),
    0 0 0 4px #5a3a18,
    0 0 0 8px #3a2510;
}

/* ── AI Players ──────────────────────────────────── */
.ai-player {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  z-index: 5;
}
.ai-player[data-pos="top"]    { top: -30px; left: 50%; transform: translateX(-50%); }
.ai-player[data-pos="left"]   { left: -30px; top: 50%; transform: translateY(-50%); }
.ai-player[data-pos="right"]  { right: -30px; top: 50%; transform: translateY(-50%); }

.ai-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid #5a7060;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: radial-gradient(135deg, #1a2535, #0f1923);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  transition: border-color .3s;
}
.ai-player.active .ai-avatar { border-color: #f4c542; box-shadow: 0 0 16px rgba(244,197,66,.5); }
.ai-player.folded .ai-avatar { opacity: .4; filter: grayscale(1); }

.ai-name { font-size: 10px; color: #aabfd0; font-weight: 600; white-space: nowrap; }
.ai-bet  { font-size: 10px; color: #f4c542; font-weight: 700; }

/* Mini cards for AI */
.ai-cards { display: flex; gap: 2px; }
.mini-card {
  width: 18px; height: 26px;
  background: linear-gradient(135deg, #1a4ca8, #0d3580);
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.mini-card.revealed {
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 800; color: #e53e3e;
}

/* ── Center Pot ──────────────────────────────────── */
.center-pot {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; z-index: 4;
}
.pot-chips { font-size: 28px; }
.pot-amt { font-size: 14px; color: #f4c542; font-weight: 700; }

/* ── Player Hand (bottom) ────────────────────────── */
.player-section {
  position: relative; z-index: 10;
  background: linear-gradient(0deg, rgba(0,0,0,.7) 0%, transparent 100%);
  padding: 14px 16px 20px;
}

/* Player info row */
.player-info-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.player-avatar-row { display: flex; align-items: center; gap: 10px; }
.player-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #f4c542, #e6a800);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; border: 3px solid #fff;
  box-shadow: 0 0 20px rgba(244,197,66,.4);
}
.player-name-pts { }
.player-name-pts .pname { font-size: 14px; font-weight: 700; color: #fff; }
.player-name-pts .ppts {
  font-size: 12px; color: #4caf50; font-weight: 600;
}

.blind-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  font-weight: 700; letter-spacing: .5px;
}
.blind-badge.blind { background: #1e3a0f; color: #4caf50; border: 1px solid #4caf50; }
.blind-badge.seen  { background: #2a1800; color: #f4c542; border: 1px solid #f4c542; }

/* Cards row */
.player-cards {
  display: flex; gap: 12px; justify-content: center;
  margin-bottom: 14px;
}

/* ── Playing Card ────────────────────────────────── */
.card {
  width: 72px; height: 100px;
  background: linear-gradient(145deg, #f8f8f0, #fff);
  border-radius: 10px;
  border: 1.5px solid #e0e0e0;
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 2px 4px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
  position: relative;
  transition: transform .3s, box-shadow .3s;
  perspective: 600px;
  transform-style: preserve-3d;
}

.card.face-down .card-front { display: none; }
.card.face-down .card-back  { display: flex; }

.card-back {
  display: none;
  position: absolute; inset: 0;
  border-radius: 9px;
  background: linear-gradient(145deg, #1a4ca8, #0d2d7a);
  align-items: center; justify-content: center;
  overflow: hidden;
}
.card-back::after {
  content: '♠♥♦♣';
  font-size: 10px; color: rgba(255,255,255,.15);
  letter-spacing: 2px; word-spacing: 4px;
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 6px, rgba(255,255,255,.03) 6px, rgba(255,255,255,.03) 12px
  );
}
.card-back-logo { font-size: 28px; z-index: 1; }

.card-front { position: absolute; inset: 0; padding: 5px 6px; display: flex; flex-direction: column; }
.card-top { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.card-top .rank { font-size: 16px; font-weight: 900; line-height: 1; }
.card-top .suit { font-size: 13px; }
.card-bottom { position: absolute; bottom: 5px; right: 6px;
  display: flex; flex-direction: column; align-items: flex-end;
  transform: rotate(180deg); line-height: 1.1; }
.card-bottom .rank { font-size: 16px; font-weight: 900; }
.card-bottom .suit { font-size: 13px; }
.card-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 32px; }

.card.red .rank, .card.red .suit { color: #e53e3e; }
.card.black .rank, .card.black .suit { color: #1a1a1a; }

.card.selected { transform: translateY(-8px);
  box-shadow: 0 16px 32px rgba(244,197,66,.5), 0 2px 4px rgba(0,0,0,.3); }
.card.win-glow { box-shadow: 0 0 30px rgba(0,200,83,.7); border-color: #00c853; }

/* Flip animation */
@keyframes cardFlip {
  0%   { transform: rotateY(90deg) scale(.8); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
.card.flip { animation: cardFlip .4s ease forwards; }

/* ── Action Buttons ──────────────────────────────── */
.action-buttons {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.action-btn {
  padding: 11px 8px; border: none; border-radius: 10px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  letter-spacing: .3px; transition: transform .15s, opacity .2s;
  font-family: 'Poppins', sans-serif;
}
.action-btn:active { transform: scale(.95); }
.action-btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-see   { background: linear-gradient(135deg, #f4c542, #e6a800); color: #1a1a1a; }
.btn-call  { background: linear-gradient(135deg, #00c853, #00962a); color: #fff; }
.btn-raise { background: linear-gradient(135deg, #e53e3e, #b52525); color: #fff; }
.btn-fold  { background: linear-gradient(135deg, #4a5568, #2d3748); color: #fff; }
.btn-show  { background: linear-gradient(135deg, #805ad5, #553c9a); color: #fff;
             display: none; }

/* ── Result Overlay ──────────────────────────────── */
#result-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.85);
  align-items: center; justify-content: center;
  padding: 20px;
}
#result-overlay.show { display: flex; animation: fadeIn .3s ease; }

.result-box {
  background: linear-gradient(145deg, #1a2535, #111827);
  border-radius: 20px; padding: 36px 28px;
  text-align: center; max-width: 340px; width: 100%;
  border: 2px solid var(--border-clr, #2e3f52);
  box-shadow: 0 0 60px var(--glow-clr, rgba(0,0,0,.5));
  animation: bounceIn .4s cubic-bezier(.36,.07,.19,.97);
}
.result-box.win  { --border-clr: #f4c542; --glow-clr: rgba(244,197,66,.4); }
.result-box.lose { --border-clr: #e53e3e; --glow-clr: rgba(229,62,62,.3); }
.result-box.tie  { --border-clr: #7a8fa6; --glow-clr: rgba(122,143,166,.3); }

.result-emoji { font-size: 60px; margin-bottom: 12px; animation: pulse 1s infinite; }
.result-title { font-family: 'Orbitron', sans-serif; font-size: 26px; margin-bottom: 6px; }
.result-box.win  .result-title { color: #f4c542; }
.result-box.lose .result-title { color: #e53e3e; }
.result-box.tie  .result-title { color: #7a8fa6; }
.result-sub { color: #aabfd0; font-size: 14px; margin-bottom: 20px; }
.result-hands { display: flex; gap: 14px; justify-content: center; margin-bottom: 22px; flex-wrap: wrap; }
.result-hand { background: rgba(0,0,0,.3); border-radius: 10px; padding: 10px 14px; }
.result-hand .rh-name { font-size: 11px; color: #7a8fa6; margin-bottom: 4px; }
.result-hand .rh-type { font-size: 13px; font-weight: 700; color: #fff; }
.result-hand .rh-pts  { font-size: 11px; color: #f4c542; margin-top: 2px; }

.btn-play-again {
  padding: 13px 28px; background: linear-gradient(135deg, #f4c542, #e6a800);
  color: #1a1a1a; font-size: 15px; font-weight: 700; border: none;
  border-radius: 10px; cursor: pointer; letter-spacing: .5px;
  font-family: 'Poppins', sans-serif; transition: transform .15s;
}
.btn-play-again:active { transform: scale(.97); }

/* ── Message Toast ───────────────────────────────── */
#toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff;
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  z-index: 500; pointer-events: none;
  opacity: 0; transition: opacity .3s;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.15);
}
#toast.show { opacity: 1; }

/* ── Chips animation ─────────────────────────────── */
.chip-fly {
  position: absolute; width: 20px; height: 20px;
  border-radius: 50%; background: #f4c542;
  pointer-events: none; z-index: 100;
  animation: chipFly .6s ease forwards;
}
@keyframes chipFly {
  from { transform: scale(1); opacity: 1; }
  to   { transform: scale(0) translate(0, -60px); opacity: 0; }
}

/* Confetti for win */
.confetti-piece {
  position: fixed; width: 10px; height: 10px;
  border-radius: 2px; pointer-events: none; z-index: 9999;
  animation: confettiFall 1.5s ease forwards;
}
@keyframes confettiFall {
  from { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  to   { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Animations ──────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes bounceIn {
  0%   { transform: scale(.8); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Turn indicator */
.turn-indicator {
  position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 3px; background: #f4c542; border-radius: 2px;
  display: none;
}
.active .turn-indicator { display: block; }

/* Responsive */
@media(max-height: 680px) {
  .card { width: 62px; height: 88px; }
  .card-center { font-size: 26px; }
}
@media(max-width: 380px) {
  .card { width: 64px; height: 90px; }
  .action-btn { font-size: 11px; padding: 9px 6px; }
}
