:root {
  --bg: #0b132b;
  --surface: #1c2541;
  --surface-2: #3a506b;
  --text: #e6eef9;
  --muted: #aac4e6;
  --accent: #5eead4;
  --danger: #fb7185;
  --gold: #fbbf24;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #121a36, var(--bg));
}

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app__header {
  text-align: center;
  padding: 24px 16px 8px;
}

.title {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.table {
  width: 100%;
  margin: 0 auto;
  padding: 8px 16px 24px;
}

/* 16:9 stage with futuristic neon frame */
.stage {
  aspect-ratio: 16 / 9;
  width: min(1100px, 95vw);
  margin: 0 auto;
  position: relative;
  border-radius: 22px;
  padding: 16px 20px 96px; /* move play area slightly upward */
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(94,234,212,0.08), rgba(94,234,212,0) 60%),
    radial-gradient(40% 60% at 80% 30%, rgba(168,85,247,0.10), rgba(168,85,247,0) 65%),
    linear-gradient(180deg, #0f172a, #0b132b);
  box-shadow:
    0 30px 60px rgba(0,0,0,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.06);
}

.stage::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(94,234,212,0.2), rgba(168,85,247,0.2));
  filter: blur(8px);
  z-index: -1;
}

.hand {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 16px;
  backdrop-filter: blur(4px);
}

.hand__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hand h2 {
  margin: 0;
  font-size: 18px;
}

.score {
  font-weight: 700;
  color: var(--gold);
}

.cards {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: nowrap;
}

.card {
  width: 86px;
  height: 124px;
  perspective: 1000px; /* for 3D flip */
}

.card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  transform-style: preserve-3d;
  transition: transform 420ms ease;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}

.card__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
}

.card__face--front {
  background: #fff;
  color: #111827;
  border: 1px solid #e5e7eb;
}

.card__face--back {
  transform: rotateY(180deg);
  background:
    radial-gradient(60% 60% at 30% 30%, rgba(94,234,212,0.12), rgba(94,234,212,0) 65%),
    linear-gradient(180deg, #1c2541, #0f172a);
  border: 1px solid rgba(255,255,255,0.12);
}

/* Ensure red suits appear red on the front face */
.card[data-suit="hearts"] .card__face--front,
.card[data-suit="diamonds"] .card__face--front {
  color: #dc2626;
}

/* Flip states */
.card.is-back .card__inner {
  transform: rotateY(180deg);
}

.card[data-suit="hearts"],
.card[data-suit="diamonds"] {
  color: #dc2626;
}

.card .corner {
  position: absolute;
  font-weight: 700;
  font-size: 14px;
}

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

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

.card .pip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
}

/* kept for compatibility if used elsewhere */
.card--back { border-color: rgba(255,255,255,0.12); }

.card--ghost {
  opacity: 0;
  transform: translateY(-6px);
}

.messages {
  text-align: center;
  margin: 0 0 6px;
  min-height: 24px;
  color: #e7f8eb;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.controls {
  position: absolute;
  left: 0; right: 0; bottom: 16px;
  margin: 0 auto;
  display: grid;
  gap: 8px;
  padding: 8px 16px 0;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 10px;
}

.toggles {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* removed bank and chips styles */

.toggles .toggle, .toggles .speed { font-size: 12px; color: var(--muted); }
.toggles input[type="range"] { vertical-align: middle; }

.hint {
  text-align: center;
  min-height: 18px;
  font-size: 12px;
  color: #9ae6b4;
}

.stats { text-align: center; color: var(--muted); font-size: 12px; }

.buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.12);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: none;
}

.result--win { color: #34d399; }
.result--lose { color: var(--danger); }
.result--push { color: var(--muted); }

.app__footer {
  color: var(--muted);
  text-align: center;
  padding: 16px;
  font-size: 12px;
}

@media (min-width: 640px) {
  .card { width: 96px; height: 138px; }
  .card .pip { font-size: 28px; }
}

/* Additional flavor */
.hand--dealer { margin-bottom: 28px; }
.hand--player { margin-top: 10px; }

.buttons {
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
  padding: 12px;
  border-radius: 14px;
}

.card:hover .card__inner { transform: translateY(-2px); }
.card--ghost .card__inner { transition: opacity 200ms ease, transform 200ms ease; }

/* Do not reveal or animate facedown dealer card on hover */
.hand--dealer .card.is-back { pointer-events: none; transform: none !important; }
.card.is-back:hover .card__inner { transform: rotateY(180deg) translateY(0); }

/* Subtle fan effect for hands */
.cards .card { transition: transform 200ms ease; }
.cards .card:nth-child(1) { transform: rotate(-4deg); }
.cards .card:nth-child(2) { transform: rotate(-2deg); }
.cards .card:nth-child(3) { transform: rotate(0deg); }
.cards .card:nth-child(4) { transform: rotate(2deg); }
.cards .card:nth-child(5) { transform: rotate(4deg); }

/* Neon accent polish */
.btn:hover:not(:disabled) {
  box-shadow: 0 0 0 1px rgba(94,234,212,0.5), 0 0 18px rgba(94,234,212,0.25);
}

.result--win { color: #34d399; text-shadow: 0 0 10px rgba(52,211,153,0.45); }
.result--lose { color: #fb7185; text-shadow: 0 0 10px rgba(251,113,133,0.45); }
.result--push { color: #a3b9ff; text-shadow: 0 0 10px rgba(163,185,255,0.35); }

/* Button ripple effect */
.ripple {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(94,234,212,0.35) 0%, rgba(94,234,212,0.2) 40%, rgba(94,234,212,0) 70%);
  width: 14px;
  height: 14px;
  animation: ripple 520ms ease-out forwards;
}

@keyframes ripple {
  from { opacity: 0.9; }
  to { opacity: 0; width: 220px; height: 220px; }
}

/* Score pulse */
.score {
  transition: transform 200ms ease, filter 200ms ease;
}
.score--pulse {
  animation: pulseScore 500ms ease;
}
@keyframes pulseScore {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(94,234,212,0)); }
  40% { transform: scale(1.15); filter: drop-shadow(0 0 6px rgba(94,234,212,0.55)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(94,234,212,0)); }
}

/* Confetti */
.confetti {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 12px;
  opacity: 0.9;
  transform: translateY(-20px) rotate(0deg);
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(calc(100% + 40px)) rotate(540deg); opacity: 0; }
}

/* Icon buttons */
.btn {
  position: relative;
  padding-left: 38px;
}
.btn::before {
  content: attr(data-icon);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.9;
}

/* Add overflow hidden for ripple */
.btn { overflow: hidden; font-size: 15px; }

/* Stage win/lose animations */
.stage.win-anim { animation: winPulse 700ms ease-out; }
.stage.lose-anim { animation: loseFlash 500ms ease-out; }
.stage.push-anim { animation: pushPulse 700ms ease-out; }

@keyframes winPulse {
  0% { box-shadow: 0 30px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06); }
  40% { box-shadow: 0 30px 60px rgba(0,0,0,0.45), 0 0 24px rgba(34,197,94,0.45), inset 0 0 0 1px rgba(34,197,94,0.5); }
  100% { box-shadow: 0 30px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06); }
}

@keyframes loseFlash {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

@keyframes pushPulse {
  0% { box-shadow: 0 30px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06); }
  40% { box-shadow: 0 30px 60px rgba(0,0,0,0.45), 0 0 24px rgba(59,130,246,0.4), inset 0 0 0 1px rgba(59,130,246,0.5); }
  100% { box-shadow: 0 30px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06); }
}


