/* Root theme */
:root {
  --bg: #0d0f12;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #34d399; /* emerald */
  --danger: #ef4444;
  --gold: #fbbf24;
  --felt: #0f3d2e;
  --felt-2: #0b2d23;
  --rail: #111827;
  --card-bg: #ffffff;
  --card-fg: #111827;
  --card-red: #d11a2a;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% 10%, var(--felt), var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Ensure hidden attribute works even if components set display */
[hidden], .overlay[hidden] { display: none !important; }

#app { min-height: 100%; display: grid; grid-template-rows: auto 1fr; }

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: rgba(17,24,39,0.7); border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: 0.5px; }
.brand-mark { color: var(--gold); font-size: 20px; }
.brand-text { font-weight: 700; }
.bankroll { color: var(--muted); }
.bankroll span:last-child { color: var(--text); font-weight: 600; margin-left: 8px; }

/* Table */
.table { display: grid; grid-template-rows: 1fr auto; padding: 24px; gap: 18px; }
.table-surface {
  position: relative; border-radius: 24px; padding: 28px 24px 120px;
  background: radial-gradient(1200px 600px at 50% 30%, var(--felt), var(--felt-2));
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,0.04), inset 0 0 100px rgba(0,0,0,0.4);
}
.table-rail { position: absolute; inset: 12px; border-radius: 20px; pointer-events: none; border: 2px solid rgba(251, 191, 36, 0.25); z-index: 0; }
.table-rail .pot, .table-rail .blinds, .table-rail .hand-info {
  position: absolute; font-size: 14px; color: var(--muted); background: rgba(0,0,0,0.25); padding: 8px 10px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.table-rail .pot { top: 12px; left: 12px; }
.table-rail .blinds { top: 12px; right: 12px; }
/* Reposition hand/street label near pot to free vertical center space */
.table-rail .hand-info { top: 12px; left: 120px; transform: none; }
.table-rail strong { color: var(--text); margin-left: 8px; }

/* Seat layout: use flex and order elements */
.seat { position: absolute; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; justify-content: flex-start; }
.opponent { top: 58px; }
.player { bottom: 64px; }

/* Order elements so player's name is below cards */
.opponent .seat-header { order: 1; }
.opponent .hole-cards { order: 2; }
.opponent .action-chip { order: 3; }
.player .hole-cards { order: 1; }
.player .seat-header { order: 2; }
.player .action-chip { order: 3; }

/* Improve label contrast */
.seat .seat-header .name { text-shadow: 0 1px 2px rgba(0,0,0,0.6); }

.seat-header { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.seat-header .name { color: var(--text); font-weight: 600; }
.seat-header .stack { background: rgba(0,0,0,0.35); padding: 6px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }

.hole-cards { display: flex; gap: 16px; }

/* Card */
.card { width: 80px; height: 112px; background: var(--card-bg); color: var(--card-fg); border-radius: 10px; box-shadow: var(--shadow); position: relative; transform-style: preserve-3d; transition: transform 0.6s ease; }
.card .inner { position: absolute; inset: 0; padding: 8px; display: grid; grid-template-rows: auto 1fr auto; }
.card .corner { font-weight: 700; font-size: 16px; line-height: 1; }
.card .corner.bottom { align-self: end; transform: rotate(180deg); }
.card .pip { display: grid; place-items: center; font-size: 28px; }
.card.red { color: var(--card-red); }

/* Card back using custom image */
.card.back {
  background: center / contain no-repeat url('cover.png');
  background-color: transparent !important;
  color: transparent;
  border: 2px solid rgba(255,255,255,0.08);
}
.card.back::after { content: none; }

/* Community */
.board { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -52%); z-index: 1; }
.community-cards { display: flex; gap: 14px; }

/* Chips / action cue */
.action-chip { min-height: 20px; color: var(--muted); font-size: 14px; }
.action-chip .cue { display: inline-block; padding: 6px 10px; border-radius: 999px; background: rgba(0,0,0,0.35); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }

/* Controls */
.controls { display: grid; gap: 12px; }
.status { color: var(--muted); text-align: center; }
.betting { display: grid; gap: 12px; background: rgba(17,24,39,0.6); padding: 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.06); backdrop-filter: blur(4px); }
.bet-sizing { display: grid; gap: 8px; }
.bet-quick { display: none; }
.bet-amount { text-align: right; color: var(--muted); }
.action-buttons { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 8px; }

button { appearance: none; border: none; border-radius: 10px; padding: 12px 14px; color: var(--text); background: #1f2937; cursor: pointer; font-weight: 600; letter-spacing: 0.2px; box-shadow: inset 0 -2px 0 rgba(255,255,255,0.05); transition: transform 0.02s ease, background 0.2s ease, opacity 0.2s ease; }
button:hover { background: #27354a; }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(180deg, #10b981, #059669); }
button.primary:hover { background: linear-gradient(180deg, #10b981, #047857); }
button.danger { background: linear-gradient(180deg, #ef4444, #b91c1c); }
button.danger:hover { background: linear-gradient(180deg, #ef4444, #991b1b); }
button.ghost { background: rgba(255,255,255,0.06); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.06); color: var(--text); opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, -4px); }

/* Dialog */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: grid; place-items: center; }
.dialog { width: min(520px, 92vw); background: #0b1220; border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.dialog h2 { margin: 0 0 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* Responsive */
@media (max-width: 720px) {
  .card { width: 64px; height: 90px; }
  .opponent { top: 48px; }
  .player { bottom: 16px; }
  .table-surface { padding-bottom: 130px; }
  .board { top: 44%; transform: translate(-50%, -48%); }
  .hole-cards { gap: 12px; }
  .community-cards { gap: 10px; }
} 

/* --- Enhanced visual upgrades --- */

/* Buttons */
button {
  position: relative;
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.08)),
              linear-gradient(180deg, #1f2937, #111827);
  box-shadow:
    0 6px 18px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -1px 0 rgba(0,0,0,0.4);
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); filter: brightness(0.98); }
button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(16,185,129,0.25),
    0 6px 18px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -1px 0 rgba(0,0,0,0.4);
}
button.primary {
  border: 1px solid rgba(16,185,129,0.35);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0)),
              linear-gradient(180deg, #10b981, #0e9f75);
  box-shadow:
    0 10px 24px rgba(16,185,129,0.25),
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(0,0,0,0.35);
}
button.primary:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02)),
              linear-gradient(180deg, #10b981, #0b8f68);
}
button.danger {
  border: 1px solid rgba(239,68,68,0.35);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0)),
              linear-gradient(180deg, #ef4444, #b91c1c);
  box-shadow:
    0 10px 24px rgba(239,68,68,0.22),
    inset 0 1px 0 rgba(255,255,255,0.1),
    inset 0 -1px 0 rgba(0,0,0,0.35);
}
button.ghost {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.09);
  box-shadow:
    0 6px 18px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(52,211,153,0.35), rgba(251,191,36,0.35));
  outline: none;
  border: 1px solid rgba(255,255,255,0.08);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffffff, #e5e7eb);
  border: 1px solid rgba(0,0,0,0.25);
  box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.7);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffffff, #e5e7eb);
  border: 1px solid rgba(0,0,0,0.25);
  box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.7);
  cursor: pointer;
}

/* Fancy cards */
.card {
  border: 1px solid transparent;
  background-image:
    linear-gradient(180deg, #ffffff, #f3f4f6),
    linear-gradient(135deg, rgba(251,191,36,0.45), rgba(255,255,255,0.08));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 14px 28px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.3);
  animation: dealIn 260ms cubic-bezier(.2,.7,.2,1) both;
}
.card .corner {
  font-feature-settings: "tnum" on, "lnum" on;
  opacity: 0.9;
}
.card .pip { text-shadow: 0 1px 0 rgba(0,0,0,0.08); }
.card::after {
  content: "";
  position: absolute; inset: 8px; border-radius: 8px;
  pointer-events: none;
  background: repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0 6px, rgba(255,255,255,0.06) 6px 12px);
  opacity: 0.5;
}
.card.back {
  background: linear-gradient(160deg, #0f172a, #1f2937);
  border: 1px solid rgba(255,255,255,0.08);
}
.card.back::after {
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0.08) 0 6px, transparent 6px 12px);
  opacity: 0.35;
}

@keyframes dealIn {
  from {
    transform: translateY(-8px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
} 

/* Fan effect for hole cards without overlap */
.hole-cards .card { will-change: transform; }
.player .hole-cards .card:nth-child(1) { transform: rotate(-5deg) translateY(2px); }
.player .hole-cards .card:nth-child(2) { transform: rotate(5deg) translateY(2px); }
.opponent .hole-cards .card:nth-child(1) { transform: rotate(-5deg) translateY(2px); }
.opponent .hole-cards .card:nth-child(2) { transform: rotate(5deg) translateY(2px); } 

/* Improve player label visibility and positioning */
.seat.player .seat-header {
  background: rgba(0,0,0,0.35);
  padding: 6px 10px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  backdrop-filter: blur(3px);
}
.seat.player { bottom: 30px; }
/* Shift the board slightly lower for more air above dealer cards */
.board { top: 52%; transform: translate(-50%, -50%); }

/* Add small margin between player cards and label */
.player .seat-header { margin-top: 6px; }

/* Remove quick-bet spacing leftovers */
.bet-quick { display: none; } 

/* --- Winner animations and effects --- */

/* Seat glow when winning */
.seat.win {
  filter: drop-shadow(0 0 16px rgba(251,191,36,0.45));
}
.seat.win .hole-cards .card {
  animation: cardWinPop 320ms cubic-bezier(.2,.9,.2,1) both;
}

@keyframes cardWinPop {
  0% { transform: translateY(2px) scale(0.98) rotate(var(--tilt, 0deg)); }
  60% { transform: translateY(-4px) scale(1.03) rotate(var(--tilt, 0deg)); }
  100% { transform: translateY(0) scale(1) rotate(var(--tilt, 0deg)); }
}

/* Winner badge */
.winner-tag {
  margin-top: 4px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(251,191,36,0.2), rgba(251,191,36,0.08));
  border: 1px solid rgba(251,191,36,0.35);
  color: #fde68a;
  font-weight: 700; font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.winner-tag .trophy { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }

/* Table glow */
.table-surface.win-glow {
  animation: tableGlow 1200ms ease-out 1;
}
@keyframes tableGlow {
  0% { box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,0.04), inset 0 0 100px rgba(0,0,0,0.4); }
  40% { box-shadow: 0 12px 40px rgba(251,191,36,0.35), inset 0 0 0 2px rgba(251,191,36,0.35), inset 0 0 140px rgba(251,191,36,0.15); }
  100% { box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,0.04), inset 0 0 100px rgba(0,0,0,0.4); }
}

/* Confetti */
.fx-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute; width: 8px; height: 14px; border-radius: 2px;
  opacity: 0.95; transform: translateY(-20px) rotate(0deg);
  animation-name: confettiFall; animation-timing-function: cubic-bezier(.2,.8,.2,1); animation-fill-mode: both;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(120%) rotate(540deg); opacity: 0; }
}

/* Chip burst near the center */
.fx-chips { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); pointer-events: none; }
.chip-burst {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fcd34d, #f59e0b);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.6);
  animation: chipBurst 600ms ease-out forwards;
}
@keyframes chipBurst {
  0% { transform: translate(0,0) scale(0.6); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(1); opacity: 0; }
} 

/* Layering fixes */
.table-surface { position: relative; z-index: 1; }
.board { z-index: 2; }
.seat { z-index: 3; }
.fx-confetti, .fx-chips { z-index: 4; }
.overlay { position: fixed; z-index: 1000; }
.overlay .dialog { position: relative; z-index: 1001; }
.winner-tag { position: relative; z-index: 6; }

/* Winner tag stacking and order to avoid overlap */
.winner-tag { position: relative; z-index: 5; }
.player .winner-tag { order: 4; margin-top: 8px; }
.opponent .winner-tag { order: 4; margin-top: 8px; } 

/* Dialog overlay hard-center and spacing safety */
.overlay { display: grid; place-items: center; padding: 24px; }
.dialog { max-width: min(560px, 92vw); margin: 0 auto; }
.table-surface { padding-top: 48px; padding-bottom: 96px; }
.board { top: calc(50% - 6px); }
.player { bottom: 36px; } 

/* More air around cards to avoid touching */
.community-cards { gap: 18px; }
.hole-cards { gap: 18px; }
.board { top: 48%; }
.player { bottom: 44px; }
.opponent { top: 70px; }

@media (max-width: 720px) {
  .community-cards { gap: 12px; }
  .hole-cards { gap: 14px; }
  .board { top: 46%; }
  .player { bottom: 38px; }
  .opponent { top: 56px; }
} 

/* Final position tweaks for seat placement */
.seat.player { bottom: 88px; }
.opponent { top: 36px; }
@media (max-width: 720px) {
  .seat.player { bottom: 60px; }
  .opponent { top: 40px; }
} 

/* Pin player seat near bottom of table */
.seat.player { bottom: 24px !important; }
@media (max-width: 720px) {
  .seat.player { bottom: 20px !important; }
} 

/* Header controls */
.header-controls { display: flex; align-items: center; gap: 10px; }
/* Pretty select for difficulty */
/* Premium select styling */
.header-controls select {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 8px 28px 8px 12px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(31,41,55,1), rgba(17,24,39,1));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.header-controls select:hover { filter: brightness(1.06); }
.header-controls select:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(96,165,250,0.3); }
.header-controls { position: relative; }
.header-controls::after {
  content: "▾";
  position: absolute; right: 48px; top: 50%; transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 12px;
}
button.small { padding: 8px 10px; border-radius: 8px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; } 

/* Select wrapper chevron */
.select-wrap { position: relative; }
.select-wrap::after {
  content: "▾";
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none; font-size: 12px;
}
.select-wrap select { padding-right: 28px; }

/* Ensure dropdown options are readable */
select, option { color-scheme: dark; }
select option { color: #e5e7eb; background: #111827; }
select optgroup { color: #e5e7eb; background: #111827; } 

