@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Playfair+Display:wght@700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --felt-base: #061a14;
  --felt-highlight: #0d3328;
  --felt-shadow: #03110d;
  --gold: #e8c547;
  --gold-dim: rgba(232, 197, 71, 0.88);
  --danger: #ff5a5a;
  --ok: #3dd88a;
  --card-w: 128px;
  --card-h: 180px;
  --chip-size: 64px;
  --glass-cx: 50%;
  --glass-cy: 36%;
  --glass-shift-x: 0%;
  --glass-shift-y: 0%;
  --motion-fast: 180ms;
  --motion-medium: 340ms;
  --motion-slow: 560ms;
  --motion-deal: 620ms;
  --motion-flip: 520ms;
  --winner-pulse-duration: 560ms;
  --ambient-flow-speed: 22s;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.08);
  --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Liquid Glass */
  --glass-blur: 22px;
  --glass-saturate: 1.48;

  --glass-tint: rgba(255, 255, 255, 0.055);
  --glass-tint-hover: rgba(255, 255, 255, 0.095);
  --glass-tint-strong: rgba(255, 255, 255, 0.075);
  --glass-tint-active: rgba(255, 255, 255, 0.12);

  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-hover: rgba(255, 255, 255, 0.28);
  --glass-border-active: rgba(255, 255, 255, 0.36);

  --glass-shadow:
    0 4px 18px rgba(0, 0, 0, 0.26),
    0 1.5px 3px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 0 rgba(255, 255, 255, 0.04);
  --glass-shadow-lg:
    0 12px 36px rgba(0, 0, 0, 0.32),
    0 2px 8px rgba(0, 0, 0, 0.18),
    inset 0 1.5px 0 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 0 0 rgba(255, 255, 255, 0.05);
  --glass-shadow-xl:
    0 20px 50px rgba(0, 0, 0, 0.38),
    0 4px 14px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 0 rgba(255, 255, 255, 0.06);

  --glass-glow: 0 0 24px rgba(255, 255, 255, 0.035);
  --glass-glow-gold: 0 0 28px rgba(232, 197, 71, 0.12);
  --glass-glow-green: 0 0 28px rgba(61, 216, 138, 0.12);
  --glass-glow-red: 0 0 28px rgba(255, 90, 90, 0.12);
  --glass-glow-blue: 0 0 28px rgba(100, 160, 255, 0.12);

  --glass-specular: linear-gradient(
    168deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.05) 28%,
    transparent 52%
  );
  --glass-edge-light: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 100%
  );

  --transition-fast: 0.18s;
  --transition-mid: 0.32s;
  --transition-slow: 0.48s;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --glass-tint: rgba(10, 38, 28, 0.82);
    --glass-tint-hover: rgba(10, 38, 28, 0.88);
    --glass-tint-strong: rgba(10, 38, 28, 0.86);
    --glass-tint-active: rgba(10, 38, 28, 0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.05s !important;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  font-family: 'Outfit', system-ui, sans-serif;
  color: #fff;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  isolation: isolate;
  contain: strict;
  background:
    radial-gradient(ellipse 110% 85% at 50% -5%, rgba(13, 51, 40, 0.55) 0%, transparent 58%),
    radial-gradient(ellipse 85% 55% at 18% 72%, rgba(232, 197, 71, 0.05) 0%, transparent 52%),
    radial-gradient(ellipse 65% 45% at 82% 58%, rgba(61, 216, 138, 0.04) 0%, transparent 48%),
    radial-gradient(ellipse 50% 50% at 50% 50%, rgba(100, 160, 255, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse 130% 110% at 50% 50%, var(--felt-highlight) 0%, var(--felt-base) 52%, var(--felt-shadow) 100%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* Low Performance Mode */
body.perf-lite {
  background:
    radial-gradient(ellipse 130% 110% at 50% 50%, var(--felt-highlight) 0%, var(--felt-base) 52%, var(--felt-shadow) 100%);
  --glass-blur: 8px;
  --glass-saturate: 1.05;
  --glass-tint: rgba(10, 38, 28, 0.7);
  --glass-tint-hover: rgba(10, 38, 28, 0.78);
  --glass-tint-strong: rgba(10, 38, 28, 0.74);
  --glass-tint-active: rgba(10, 38, 28, 0.82);
  --glass-shadow:
    0 2px 10px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 0 rgba(255, 255, 255, 0.02);
  --glass-shadow-lg:
    0 4px 14px rgba(0, 0, 0, 0.22),
    0 1px 3px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 0 rgba(255, 255, 255, 0.02);
  --glass-shadow-xl: var(--glass-shadow-lg);
  --glass-glow: none;
  --glass-glow-gold: 0 0 6px rgba(232, 197, 71, 0.04);
  --glass-glow-green: 0 0 6px rgba(61, 216, 138, 0.04);
  --glass-glow-red: 0 0 6px rgba(255, 90, 90, 0.04);
  --glass-glow-blue: 0 0 6px rgba(100, 160, 255, 0.04);
  --glass-specular: none;
  --glass-edge-light: none;
  --transition-fast: 0.1s;
  --transition-mid: 0.2s;
  --transition-slow: 0.3s;
}

body.perf-lite *::before,
body.perf-lite *::after {
  animation: none !important;
}

body.perf-lite .glass-shimmer-overlay {
  display: none !important;
}

body.perf-lite::before,
body.perf-lite::after {
  opacity: 0;
  animation: none;
}

@keyframes glassShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes liquidPulse {
  0%, 100% {
    box-shadow: var(--glass-shadow);
    border-color: var(--glass-border);
  }
  50% {
    box-shadow: var(--glass-shadow-lg), var(--glass-glow);
    border-color: var(--glass-border-hover);
  }
}

@keyframes softBreathe {
  0%, 100% { opacity: 0.04; }
  50% { opacity: 0.08; }
}

@keyframes specularSweep {
  0% { transform: translateX(-100%) skewX(-15deg); }
  100% { transform: translateX(200%) skewX(-15deg); }
}


body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 42% 28% at var(--glass-cx) var(--glass-cy), rgba(255,255,255,0.06), transparent 72%),
    radial-gradient(ellipse 52% 36% at calc(100% - var(--glass-cx)) calc(100% - var(--glass-cy)), rgba(232,197,71,0.035), transparent 78%);
  mix-blend-mode: screen;
  opacity: 0.85;
  transition: opacity var(--transition-mid) var(--ease);
}

body.perf-lite::after {
  opacity: 0.22;
}
/* ——— Table ——— */
#table {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr 1fr auto;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 0);
  contain: layout style;
  z-index: 1;
}

#table::before {
  content: "";
  position: absolute;
  inset: -30px;
  background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(0,0,0,0.42) 100%);
  pointer-events: none;
  z-index: 1;
}

:where(.deck-shoe, .stat-box, .stats-row, .score-badge, .btn, .btn-icon, .bet-info, .insurance-strip, .peek-msg, #msg-text) {
  background-size: 170% 170%, 165% 165%, auto;
  background-position:
    calc(16% + var(--glass-shift-x)) calc(12% + var(--glass-shift-y)),
    calc(88% - var(--glass-shift-x)) calc(85% - var(--glass-shift-y)),
    center;
}

body.perf-lite :where(.deck-shoe, .stat-box, .stats-row, .score-badge, .btn, .btn-icon, .bet-info, .insurance-strip, .peek-msg, #msg-text) {
  background-size: auto;
  background-position: center;
}

/* ——— Deck shoe ——— */
.deck-shoe {
  position: absolute;
  top: 14%;
  right: 24px;
  width: 130px;
  height: 185px;
  border-radius: 20px;
  transform: rotate(-6deg) translateZ(0);
  z-index: 5;
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  transition: transform var(--transition-mid) var(--ease),
              box-shadow var(--transition-mid) var(--ease),
              border-color var(--transition-mid) var(--ease);
  overflow: hidden;
  contain: layout paint;
}
.deck-shoe::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 20px 20px 0 0;
  pointer-events: none;
}
.deck-shoe:hover {
  transform: rotate(-4deg) scale(1.025) translateZ(0);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow);
  border-color: var(--glass-border-hover);
}
.deck-shoe::after {
  content: '';
  position: absolute;
  inset: 12px;
  background: repeating-linear-gradient(45deg, #a00 0 11px, #c33 11px 22px);
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.12);
}

/* ——— Glass mixin via shared class ——— */
.glass-panel {
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  position: relative;
  transform: translateZ(0);
  contain: layout paint;
}

/* ——— HUD ——— */
#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 4px;
  z-index: 30;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
#wallet-val { letter-spacing: 0.3px; }
.stats-row { min-width: 0; }

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: auto;
  padding: 10px 18px;
  border-radius: 14px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  transition: border-color var(--transition-fast) var(--ease),
              box-shadow var(--transition-mid) var(--ease),
              transform var(--transition-mid) var(--ease);
  transform: translateZ(0);
  position: relative;
  contain: layout paint;
}
.stat-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 14px 14px 0 0;
  pointer-events: none;
}
.stat-box:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow);
  transform: scale(1.02) translateZ(0);
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2.2px;
  color: rgba(255,255,255,0.42);
  position: relative;
  z-index: 2;
}

.stat-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(232, 197, 71, 0.18);
  transition: color var(--transition-mid) var(--ease),
              transform var(--transition-mid) var(--ease-spring),
              text-shadow var(--transition-mid) var(--ease);
  position: relative;
  z-index: 2;
}
.stat-value.bump {
  color: #fff;
  transform: scale(1.1);
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.2);
}

.stats-row {
  display: flex;
  gap: 12px;
  pointer-events: auto;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.62);
  transform: translateZ(0);
  transition: border-color var(--transition-fast) var(--ease),
              box-shadow var(--transition-fast) var(--ease);
  position: relative;
  contain: layout paint;
}
.stats-row::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}
.stats-row:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow);
}
.stats-row span { color: var(--gold-dim); font-weight: 600; }

.rules {
  text-align: right;
  pointer-events: none;
  font-family: 'Playfair Display', serif;
  color: rgba(255,255,255,0.42);
  justify-self: end;
  max-width: 320px;
}
.rules small { font-family: 'Outfit', sans-serif; color: rgba(255,255,255,0.32); }

/* ——— Hand areas ——— */
.hand-container {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  perspective: 1100px;
  z-index: 10;
  contain: layout style;
}

.hand-label {
  position: absolute;
  font-family: 'Playfair Display', serif;
  font-size: 3.8rem;
  color: rgba(255,255,255,0.032);
  text-transform: uppercase;
  letter-spacing: 10px;
  z-index: 0;
  pointer-events: none;
}

.player-hands-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 36px;
  width: 100%;
  padding: 0 36px;
  z-index: 2;
  min-height: var(--card-h);
}

.player-hands-row.single .hand-slot:last-child { display: none; }

.hand-slot {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: var(--card-h);
  transition: opacity var(--transition-slow) var(--ease),
              filter var(--transition-slow) var(--ease),
              transform var(--transition-mid) var(--ease);
}
.hand-slot.inactive {
  opacity: 0.38;
  filter: saturate(0.72) brightness(0.9);
  transform: scale(0.97);
}
.hand-slot.active {
  opacity: 1;
  transform: scale(1);
}
.hand-slot .hand-slot-label {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: rgba(255,255,255,0.42);
  transition: color var(--transition-mid) var(--ease);
}
.hand-slot.active .hand-slot-label { color: var(--gold); }

.cards-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: var(--card-h);
  padding: 0 60px;
  position: relative;
  z-index: 2;
  overflow: visible;
}

.score-badge {
  position: relative;
  right: auto;
  top: auto;
  transform: translateY(0) translateX(0) translateZ(0) scale(0.92);
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity var(--transition-mid) var(--ease),
              transform var(--transition-slow) var(--ease-spring);
  z-index: 15;
  contain: layout paint;
}
.score-badge::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 999px 999px 0 0;
  pointer-events: none;
}
.score-badge.visible {
  opacity: 1;
  transform: translateY(0) translateX(0) translateZ(0) scale(1);
}

.dealer-area .score-badge { right: auto; }

.dimmed {
  opacity: 0.32;
  filter: saturate(0.72) brightness(0.85);
  transition: opacity var(--transition-slow) var(--ease),
              filter var(--transition-slow) var(--ease);
}

/* ——— Controls zone ——— */
.controls-zone {
  margin-top: 2px;
  position: relative;
  z-index: 90;
  min-height: 130px;
  contain: layout style;
}

/* ——— Gameplay controls ——— */
#gameplay-controls {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 92;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  transition: opacity var(--transition-mid) var(--ease),
              transform 0.42s var(--ease-spring);
}
#gameplay-controls.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}
#gameplay-controls.active .btn {
  animation: controlBtnIn 0.38s var(--ease-spring) backwards;
}
#gameplay-controls.active .btn:nth-child(1) { animation-delay: 0.02s; }
#gameplay-controls.active .btn:nth-child(2) { animation-delay: 0.06s; }
#gameplay-controls.active .btn:nth-child(3) { animation-delay: 0.1s; }
#gameplay-controls.active .btn:nth-child(4) { animation-delay: 0.14s; }
#gameplay-controls.active .btn:nth-child(5) { animation-delay: 0.18s; }
@keyframes controlBtnIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.92) translateZ(0);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) translateZ(0);
    filter: blur(0px);
  }
}

body.perf-lite #gameplay-controls.active .btn {
  animation: controlBtnInLite 0.2s var(--ease) backwards;
}
@keyframes controlBtnInLite {
  from { opacity: 0; transform: translateY(6px) translateZ(0); }
  to   { opacity: 1; transform: translateY(0) translateZ(0); }
}

.btn {
  position: relative;
  padding: 11px 24px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  font-family: inherit;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 1px;
  cursor: pointer;
  background: var(--glass-surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  transition: transform var(--transition-fast) var(--ease),
              border-color var(--transition-fast) var(--ease),
              box-shadow var(--transition-mid) var(--ease),
              background var(--transition-mid) var(--ease),
              opacity var(--transition-fast) var(--ease);
  transform: translateZ(0);
  color: #fff;
  overflow: hidden;
}
.btn::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 14px 14px 0 0;
  pointer-events: none;
  z-index: 1;
}
.btn::after {
  content: '';
  position: absolute;
  top: -100%;
  left: -60%;
  width: 40%;
  height: 300%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.06) 45%,
    rgba(255,255,255,0.1) 50%,
    rgba(255,255,255,0.06) 55%,
    transparent 100%
  );
  transform: skewX(-15deg);
  transition: left 0.5s var(--ease);
  pointer-events: none;
  z-index: 1;
}
.btn:hover:not(:disabled)::after {
  left: 120%;
}
.btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.015) translateZ(0);
  border-color: var(--glass-border-hover);
  background: var(--glass-surface-strong);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow);
}
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.97) translateZ(0);
  transition-duration: 0.06s;
  background: var(--glass-tint-active);
}

body.perf-lite .btn::after { display: none; }

.btn-hit {
  background: linear-gradient(150deg, rgba(61, 216, 138, 0.18) 0%, rgba(46, 180, 110, 0.07) 100%);
  border-color: rgba(61, 216, 138, 0.24);
  min-width: 92px;
}
.btn-hit:hover:not(:disabled) {
  box-shadow: var(--glass-shadow-lg), var(--glass-glow-green);
  border-color: rgba(61, 216, 138, 0.5);
  background: linear-gradient(150deg, rgba(61, 216, 138, 0.28) 0%, rgba(46, 180, 110, 0.12) 100%);
}
.btn-stand {
  background: linear-gradient(150deg, rgba(255, 90, 90, 0.18) 0%, rgba(200, 60, 60, 0.07) 100%);
  border-color: rgba(255, 90, 90, 0.24);
  min-width: 92px;
}
.btn-stand:hover:not(:disabled) {
  box-shadow: var(--glass-shadow-lg), var(--glass-glow-red);
  border-color: rgba(255, 90, 90, 0.5);
  background: linear-gradient(150deg, rgba(255, 90, 90, 0.28) 0%, rgba(200, 60, 60, 0.12) 100%);
}
.btn-double {
  background: linear-gradient(150deg, rgba(232, 197, 71, 0.14) 0%, rgba(200, 165, 50, 0.06) 100%);
  border-color: rgba(232, 197, 71, 0.24);
  min-width: 92px;
}
.btn-double:hover:not(:disabled) {
  box-shadow: var(--glass-shadow-lg), var(--glass-glow-gold);
  border-color: rgba(232, 197, 71, 0.52);
  background: linear-gradient(150deg, rgba(232, 197, 71, 0.24) 0%, rgba(200, 165, 50, 0.1) 100%);
}
.btn-split {
  background: linear-gradient(150deg, rgba(100, 160, 255, 0.14) 0%, rgba(80, 130, 220, 0.06) 100%);
  border-color: rgba(100, 160, 255, 0.24);
  min-width: 92px;
}
.btn-split:hover:not(:disabled) {
  box-shadow: var(--glass-shadow-lg), var(--glass-glow-blue);
  border-color: rgba(100, 160, 255, 0.5);
  background: linear-gradient(150deg, rgba(100, 160, 255, 0.24) 0%, rgba(80, 130, 220, 0.1) 100%);
}

/* ——— Betting overlay ——— */
#betting-overlay {
  border-radius: 20px;
  position: absolute;
  left: 50%;
  width: min(980px, calc(100% - 24px));
  bottom: max(6px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 14px 14px;
  z-index: 100;
  border: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(to top, rgba(6, 26, 20, 0.76) 0%, rgba(6, 26, 20, 0.22) 62%, rgba(6,26,20,0.04) 100%);
  backdrop-filter: blur(calc(var(--glass-blur) * 0.36)) saturate(calc(var(--glass-saturate) * 0.78));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 0.36)) saturate(calc(var(--glass-saturate) * 0.78));
  box-shadow: 0 10px 36px rgba(0,0,0,0.24);
  transition: opacity 0.38s var(--ease),
              transform 0.42s var(--ease-spring);
  contain: layout paint;
}
#betting-overlay.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(36px) scale(0.98);
  pointer-events: none;
}

.bet-info {
  padding: 10px 24px;
  border-radius: 999px;
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  color: var(--gold);
  font-weight: 800;
  margin-bottom: 14px;
  font-size: 1rem;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: border-color var(--transition-fast) var(--ease),
              box-shadow var(--transition-mid) var(--ease),
              transform var(--transition-mid) var(--ease);
  transform: translateZ(0);
  position: relative;
  contain: layout paint;
  overflow: hidden;
}
.bet-info::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 999px 999px 0 0;
  pointer-events: none;
}
.bet-info:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow-gold);
  transform: translateZ(0) scale(1.02);
}

.take-loan-strip { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 10px; }
.take-loan-msg { font-size: 0.82rem; color: rgba(255,255,255,0.72); text-align: center; }
.loan-buttons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.stat-loan .stat-value { color: #ff9f80; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 11px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform var(--transition-fast) var(--ease),
              border-color var(--transition-fast) var(--ease),
              box-shadow var(--transition-mid) var(--ease);
  pointer-events: auto;
  position: relative;
  contain: layout paint;
  overflow: hidden;
}
.btn-icon::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 11px 11px 0 0;
  pointer-events: none;
}
.btn-icon:hover {
  transform: scale(1.08);
  border-color: var(--glass-border-hover);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow);
}
.btn-icon:active {
  transform: scale(0.95);
  transition-duration: 0.06s;
}
.streak-badge {
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(232, 197, 71, 0.12);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.78rem;
}

.insurance-strip {
  position: absolute;
  left: 50%;
  bottom: 132px;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 16px;
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow-lg);
  position: relative;
  contain: layout paint;
  overflow: hidden;
  animation: fadeSlideUp 0.35s var(--ease-spring) both;
}
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}
.insurance-strip::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 16px 16px 0 0;
  pointer-events: none;
}
.insurance-msg { font-size: 0.85rem; color: rgba(255,255,255,0.82); margin: 0; position: relative; z-index: 2; }
.insurance-btns { display: flex; gap: 6px; position: relative; z-index: 2; }

.peek-msg {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 85;
  padding: 10px 20px;
  border-radius: 12px;
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  font-size: 0.86rem;
  color: rgba(255,255,255,0.82);
  transition: opacity var(--transition-mid) var(--ease);
  contain: layout paint;
  overflow: hidden;
  animation: peekPulse 1.2s var(--ease) infinite;
}
@keyframes peekPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}
.peek-msg::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}
.btn-surrender { min-width: 80px; }

.chips-rack { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }

.chip {
  width: var(--chip-size);
  height: var(--chip-size);
  border-radius: 50%;
  box-shadow:
    0 4px 0 rgba(0,0,0,0.35),
    0 6px 18px rgba(0,0,0,0.24),
    inset 0 1px 1px rgba(255,255,255,0.25);
  border: 3px dashed rgba(255,255,255,0.6);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  cursor: pointer;
  transition: transform 0.28s var(--ease-elastic),
              box-shadow 0.28s var(--ease);
  position: relative;
  overflow: hidden;
}
.chip::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}
.chip:hover {
  transform: translateY(-4px) scale(1.035);
  box-shadow:
    0 8px 0 rgba(0,0,0,0.28),
    0 12px 24px rgba(0,0,0,0.24),
    inset 0 1px 1px rgba(255,255,255,0.3);
}
.chip:active {
  transform: translateY(0) scale(0.94);
  transition-duration: 0.06s;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
}

.chip-10 { background: linear-gradient(145deg, #3da8db, #2980b9); }
.chip-50 { background: linear-gradient(145deg, #ef5a5a, #c0392b); }
.chip-100 { background: linear-gradient(145deg, #475569, #334155); color: var(--gold); }
.chip-500 { background: linear-gradient(145deg, var(--gold), #d4a82e); color: #1a1a1a; }

.chip-5 { background: linear-gradient(145deg, #22c55e, #15803d); }
.chip-25 { background: linear-gradient(145deg, #8b5cf6, #6d28d9); }
.chip-200 { background: linear-gradient(145deg, #06b6d4, #0369a1); }
.chip-1000 { background: linear-gradient(145deg, #f59e0b, #b45309); color: #1a1a1a; }

.custom-bet-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 2px 0 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

.custom-bet-row label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: rgba(255,255,255,0.68);
  font-weight: 600;
}

.custom-bet-input {
  width: 100%;
  padding: 10px 42px 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(9, 20, 32, 0.58);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast) var(--ease), box-shadow var(--transition-mid) var(--ease);
}

.custom-bet-input:focus {
  border-color: rgba(232, 197, 71, 0.62);
  box-shadow: 0 0 0 2px rgba(232, 197, 71, 0.18);
}


.custom-bet-input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.custom-stepper {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 4px;
}

.custom-step {
  width: 24px;
  height: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  border-radius: 6px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform var(--transition-fast) var(--ease),
              border-color var(--transition-fast) var(--ease),
              background var(--transition-fast) var(--ease);
}

.custom-step:hover {
  border-color: rgba(232, 197, 71, 0.55);
  background: rgba(232, 197, 71, 0.22);
  transform: scale(1.06);
}

.custom-step:active {
  transform: scale(0.94);
}


.btn-custom-bet {
  min-width: 116px;
  background: linear-gradient(150deg, rgba(88, 170, 255, 0.22) 0%, rgba(70, 124, 226, 0.16) 100%);
  border-color: rgba(125, 176, 255, 0.35);
}


.bet-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.btn-util {
  background: var(--glass-surface);
  color: rgba(255,255,255,0.82);
  border: 1px solid var(--glass-border);
}
.btn-rebet {
  background: var(--glass-surface);
  color: var(--gold);
  border-color: rgba(232, 197, 71, 0.22);
}
.btn-rebet:hover:not(:disabled) {
  border-color: rgba(232, 197, 71, 0.5);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow-gold);
}
.btn-deal {
  background: linear-gradient(150deg, rgba(232, 197, 71, 0.22) 0%, rgba(200, 165, 50, 0.12) 100%);
  color: #fff;
  font-size: 0.92rem;
  padding: 11px 40px;
  border-color: rgba(232, 197, 71, 0.35);
  box-shadow: var(--glass-shadow), var(--glass-glow-gold);
}
.btn-deal:hover:not(:disabled) {
  box-shadow: var(--glass-shadow-lg), 0 0 32px rgba(232, 197, 71, 0.18);
  background: linear-gradient(150deg, rgba(232, 197, 71, 0.32) 0%, rgba(200, 165, 50, 0.18) 100%);
}

/* ——— Perf mode toggle ——— */
.perf-toggle {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 11px;
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform var(--transition-fast) var(--ease),
              border-color var(--transition-fast) var(--ease),
              box-shadow var(--transition-mid) var(--ease);
  contain: layout paint;
  overflow: hidden;
  color: #fff;
  display: grid;
  place-items: center;
  position: relative;
}
.perf-toggle::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 11px 11px 0 0;
  pointer-events: none;
}
.perf-toggle:hover {
  transform: scale(1.08);
  border-color: var(--glass-border-hover);
  box-shadow: var(--glass-shadow-lg), var(--glass-glow);
}
.perf-toggle:active {
  transform: scale(0.95);
  transition-duration: 0.06s;
}
.perf-toggle.active {
  border-color: rgba(61, 216, 138, 0.4);
  box-shadow: var(--glass-shadow), var(--glass-glow-green);
}



.perf-tooltip {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  transform: translateX(-50%) translateY(-6px);
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
  max-width: min(280px, calc(100vw - 24px));
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(14, 19, 30, 0.94);
  color: rgba(255,255,255,0.96);
  font-size: 0.78rem;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
}

.perf-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ——— Message overlay ——— */
#msg-overlay {
  position: fixed;
  left: 50%;
  top: 21%;
  transform: translate(-50%, -50%);
  z-index: 150;
  pointer-events: none;
  text-align: center;
  width: 100%;
  padding: 0 20px;
}

#msg-text {
  display: inline-block;
  padding: 24px 48px;
  border-radius: 22px;
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(calc(var(--glass-saturate) + 0.1));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(calc(var(--glass-saturate) + 0.1));
  box-shadow: var(--glass-shadow-xl), var(--glass-glow);
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
  opacity: 0;
  transform: translateY(22px) scale(0.88) translateZ(0);
  transition: opacity var(--transition-mid) var(--ease),
              transform 0.52s var(--ease-spring);
  position: relative;
  contain: layout paint;
  overflow: hidden;
}
#msg-text::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: var(--glass-specular);
  border-radius: 22px 22px 0 0;
  pointer-events: none;
}
#msg-text::after {
  content: '';
  position: absolute;
  top: 0; left: -60%; right: 0; bottom: 0;
  width: 40%;
  height: 100%;
  border-radius: 22px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.05) 42%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.05) 58%,
    transparent 100%
  );
  pointer-events: none;
  opacity: 0;
  transform: skewX(-15deg);
}
#msg-text.visible {
  opacity: 1;
  transform: translateY(0) scale(1) translateZ(0);
}
#msg-text.visible::after {
  opacity: 1;
  animation: specularSweep 1.4s var(--ease) 0.2s 1 forwards;
}

body.perf-lite #msg-text::after { display: none; }

.flying-chip {
  position: absolute;
  width: 40px;
  height: 40px;
  background: var(--gold);
  border-radius: 50%;
  pointer-events: none;
  z-index: 220;
  border: 3px dashed rgba(255,255,255,0.75);
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
  will-change: transform, opacity;
  contain: strict;
}

.confetti {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  z-index: 140;
  pointer-events: none;
  border-radius: 2px;
  contain: strict;
}
.confetti-fly {
  will-change: transform, opacity;
  animation: confetti-fly var(--dur, 900ms) var(--ease) forwards;
}
@keyframes confetti-fly {
  0%   {
    transform: translate(-50%, -50%) rotate(0deg) scale(1.2);
    opacity: 1;
  }
  30% { opacity: 1; }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot)) scale(0);
    opacity: 0;
  }
}

@keyframes winnerPulse {
  0%, 100% {
    filter: drop-shadow(0 0 0 rgba(232, 197, 71, 0));
    transform: translateY(0) scale(1);
  }
  25% {
    filter: drop-shadow(0 0 12px rgba(232, 197, 71, 0.55));
    transform: translateY(-2px) scale(1.012);
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(232, 197, 71, 0.35));
    transform: translateY(0) scale(1.006);
  }
  75% {
    filter: drop-shadow(0 0 14px rgba(232, 197, 71, 0.5));
    transform: translateY(-1px) scale(1.01);
  }
}
.winner-pulse .card {
  animation: winnerPulse 1s var(--ease) 2;
}

@keyframes scorePopIn {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.7) translateZ(0);
    filter: blur(4px);
  }
  60% {
    opacity: 1;
    transform: translateY(-50%) scale(1.06) translateZ(0);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1) translateZ(0);
  }
}

.score-badge.visible.pop-in {
  animation: scorePopIn 0.42s var(--ease-spring) both;
}

body.perf-lite .score-badge.visible.pop-in {
  animation: none;
}

@media (max-width: 640px) {
  :root { --card-w: 88px; --card-h: 124px; --chip-size: 52px; }
  #hud { grid-template-columns: 1fr 1fr; padding: 8px 12px 4px; gap: 6px; }
  .rules { grid-column: 1 / -1; justify-self: start; text-align: left; }
  .stat-box { padding: 6px 12px; border-radius: 10px; }
  .stat-value { font-size: 1.15rem; }
  .btn-perf { min-width: 56px; padding: 0 7px; font-size: 0.55rem; }
  .deck-shoe { display: none; }
  .chips-rack { gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chip { font-size: 0.78rem; }
  .custom-bet-row { grid-template-columns: 1fr; gap: 8px; }
  .btn-custom-bet { width: 100%; }
  #msg-overlay { top: 16%; }
  .custom-stepper { right: 8px; }
  #betting-overlay { width: calc(100% - 14px); padding: 10px 10px 12px; bottom: 4px; }
  .hand-label { display: none; }
  .player-hands-row { gap: 18px; padding: 0 14px; }
  .card { margin-left: -30px; }
  .dealer-area .score-badge { right: auto; }
  #gameplay-controls { gap: 6px; bottom: 18px; }
  .btn { padding: 9px 16px; font-size: 0.75rem; min-width: 70px; border-radius: 12px; }
  .bet-controls { gap: 5px; }
  .btn-deal { padding: 9px 32px; }
}
/* ——— Cards ——— */
.card {
  width: var(--card-w);
  height: var(--card-h);
  position: relative;
  margin-left: -44px;
  perspective: 1000px;
  z-index: 1;
  transform: translate3d(52vw, -58vh, 0) rotate(112deg) scale(0.46);
  opacity: 0;
  will-change: auto;
  transition: none;
  transform-style: preserve-3d;
  transform-origin: 52% 70%;
}
.card:not(.dealt) { will-change: transform, opacity; }
.card.dealt { will-change: auto; }
.card:first-child { margin-left: 0; }
.card.dealt {
  opacity: 1;
  transform: translate3d(0, 0, 0) rotate(var(--rot)) scale(1);
  z-index: auto;
  animation: cardDealIn var(--deal-duration, 560ms) var(--ease) both;
}
.card.face-down { pointer-events: none; }
.card .inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: box-shadow var(--transition-mid) var(--ease);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transform: rotateY(0deg);
}
.card.dealt .inner { box-shadow: 0 6px 22px rgba(0,0,0,0.18), 0 2px 5px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.06); }
@keyframes cardDealIn {
  0%   { opacity:0; transform:translate3d(60vw,-60vh,0) rotate(120deg) scale(0.35); filter:blur(2px); }
  18%  { opacity:0.72; filter:blur(1.2px); }
  40%  { opacity:1; filter:blur(0px); transform:translate3d(8px,-8px,0) rotate(calc(var(--rot) + 3deg)) scale(1.04); }
  58%  { transform:translate3d(-3px,3px,0) rotate(calc(var(--rot) - 1.2deg)) scale(1.015); }
  74%  { transform:translate3d(1.5px,-1px,0) rotate(calc(var(--rot) + 0.5deg)) scale(1.004); }
  88%  { transform:translate3d(-0.5px,0.3px,0) rotate(calc(var(--rot) - 0.15deg)) scale(1.001); }
  100% { opacity:1; transform:translate3d(0,0,0) rotate(var(--rot)) scale(1); filter:blur(0px); }
}
body.perf-lite .card.dealt { animation: cardDealInLite var(--deal-duration, 380ms) var(--ease) both; }
@keyframes cardDealInLite {
  0%   { opacity:0; transform:translate3d(40vw,-40vh,0) rotate(60deg) scale(0.6); }
  50%  { opacity:1; transform:translate3d(-2px,2px,0) rotate(calc(var(--rot) + 1deg)) scale(1.01); }
  100% { opacity:1; transform:translate3d(0,0,0) rotate(var(--rot)) scale(1); }
}
.card.face-down .inner { transform: rotateY(180deg); }
.card-face, .card-back { position:absolute; inset:0; border-radius:12px; backface-visibility:hidden; -webkit-backface-visibility:hidden; overflow:hidden; }
.card-face { background:linear-gradient(170deg,#fefefe 0%,#f9f8f5 30%,#f3f1eb 100%); transform:rotateY(0deg); border:1.5px solid rgba(0,0,0,0.06); z-index:2; display:flex; flex-direction:column; justify-content:space-between; box-shadow:inset 0 1px 0 rgba(255,255,255,0.9),inset 0 -1px 0 rgba(0,0,0,0.025); }
.card-face::after { content:''; position:absolute; top:0; left:0; right:0; height:55%; background:linear-gradient(180deg,rgba(255,255,255,0.4) 0%,transparent 100%); border-radius:12px 12px 0 0; pointer-events:none; opacity:0.5; }
.card-back { transform:rotateY(180deg); z-index:1; background:#180808; border:3.5px solid #f0efe8; box-shadow:inset 0 0 0 5px #180808,inset 0 0 0 7px rgba(255,255,255,0.22); }
.card-back::before { content:''; position:absolute; inset:7px; border-radius:6px; background:repeating-linear-gradient(45deg,#8b0000 0 8px,#a52a2a 8px 16px); border:1.5px solid rgba(255,255,255,0.5); }
.card-back::after { content:'�0'; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); font-size:2.1rem; color:rgba(255,255,255,0.09); font-family:serif; z-index:2; }
.pip-red { color:#c62828; } .pip-black { color:#1a1a1a; }
.corner { position:absolute; top:5px; left:6px; display:flex; flex-direction:column; align-items:center; font-weight:800; line-height:1; z-index:3; }
.corner.bottom { top:auto; bottom:5px; left:auto; right:6px; transform:rotate(180deg); }
.rank { font-family:'JetBrains Mono',monospace; font-size:1.02rem; letter-spacing:-0.5px; }
.suit { font-size:0.92rem; margin-top:-1px; }
.card-content { flex:1; display:flex; align-items:center; justify-content:center; padding:22px 10px; z-index:3; position:relative; }
.face-art { font-family:'Playfair Display',serif; font-size:2.7rem; font-weight:700; opacity:0.84; border:2.5px solid currentColor; border-radius:10px; width:54px; height:70px; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,0.02); box-shadow:inset 0 0 8px rgba(0,0,0,0.025); }
.pip-grid { display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(5,1fr); width:100%; height:100%; place-items:center; }
.pip { font-size:1.25rem; line-height:1; } .pip.ace { font-size:4.3rem; text-shadow:0 2px 4px rgba(0,0,0,0.05); }
.bust-stamp { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) rotate(-15deg) scale(1.75); border:3.5px solid #ef4444; color:#ef4444; font-size:1.25rem; font-weight:900; text-transform:uppercase; padding:5px 12px; border-radius:8px; opacity:0; pointer-events:none; background:rgba(255,255,255,0.92); box-shadow:0 3px 12px rgba(0,0,0,0.14); z-index:10; letter-spacing:0.5px; transition:none; }
.card.busted .bust-stamp { animation:bustStampIn 0.4s var(--ease-elastic) forwards; }
@keyframes bustStampIn { 0%{opacity:0;transform:translate(-50%,-50%) rotate(-15deg) scale(2.2);filter:blur(2px);} 60%{opacity:1;transform:translate(-50%,-50%) rotate(-15deg) scale(0.92);filter:blur(0px);} 80%{transform:translate(-50%,-50%) rotate(-15deg) scale(1.04);} 100%{opacity:1;transform:translate(-50%,-50%) rotate(-15deg) scale(1);} }
.card.winner .inner { box-shadow:0 0 0 2px var(--gold),0 0 20px rgba(232,197,71,0.35),0 0 40px rgba(232,197,71,0.15); transform:rotateY(0deg) scale(1.03); }
.card.busted .inner { filter:saturate(0.5) brightness(0.85); transition:filter var(--transition-mid) var(--ease); }
@media (prefers-reduced-motion:reduce) { .card{transition:none!important;animation:none!important;transform:translate3d(0,0,0) rotate(var(--rot)) scale(1)!important;opacity:1!important;} .card .inner{transition:none!important;animation:none!important;} }
/* Glass surface variables not in base */
:root {
  --glass-surface: rgba(255,255,255,0.055);
  --glass-surface-strong: rgba(255,255,255,0.075);
}
/* Additional styles for elements not in blackjack.css */
.back-link {
  text-decoration: none;
  font-size: 1rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.chip-gold {
  background: radial-gradient(circle at 35% 30%, #f5d060, #b8860b);
  color: #1a1000;
  border-color: rgba(255,220,80,0.5);
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: center;
  font-weight: 800;
}
/* Modal */
.modal-overlay {
  position: fixed; inset:0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 360px; width:100%;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(6,26,20,0.9);
  backdrop-filter: blur(24px);
  box-shadow: var(--glass-shadow-xl);
}
.modal-title { font-family:'Playfair Display',serif; font-size:22px; color:var(--danger); }
.modal-sub   { font-size:13px; color:rgba(255,255,255,0.5); line-height:1.6; }
.loan-info   { font-size:12px; color:rgba(255,255,255,0.45); line-height:1.8; }
.loan-buttons { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
/* Game Over */
.gameover-overlay {
  position:fixed; inset:0; background:#000; z-index:400;
  display:flex; align-items:center; justify-content:center; flex-direction:column;
}
#gameover-video { width:100%; height:100%; object-fit:cover; }
.gameover-ui {
  flex-direction:column; align-items:center; gap:24px;
  text-align:center; padding:48px 28px;
  animation: fadeInUp 0.6s var(--ease) both;
}
@keyframes fadeInUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.gameover-title { font-family:'Playfair Display',serif; font-size:52px; color:var(--danger); letter-spacing:-1px; }
.gameover-stats { display:flex; gap:24px; font-size:16px; font-weight:700; flex-wrap:wrap; justify-content:center; }
.go-stat-w{color:var(--ok)} .go-stat-l{color:var(--danger)} .go-stat-p{color:rgba(255,255,255,0.45)}
.gameover-actions { display:flex; gap:12px; flex-wrap:wrap; justify-content:center; }
.btn-go-home { min-width:120px; }
/* Score pop-in */
@keyframes scorePopIn {
  0%   { opacity:0; transform:scale(0.7); filter:blur(4px); }
  60%  { opacity:1; transform:scale(1.06); filter:blur(0); }
  100% { opacity:1; transform:scale(1); }
}
.score-badge.visible.pop-in { animation: scorePopIn 0.42s var(--ease-spring) both; }
body.perf-lite .score-badge.visible.pop-in { animation: none; }

/* ── LEVEL BADGE ──────────────────────────────────────── */
.level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 14px;
  border-radius: 14px;
  background: var(--glass-surface);
  border: 1px solid rgba(232,197,71,0.2);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  min-width: 80px;
}
.level-badge::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--glass-specular);
  border-radius: 14px 14px 0 0;
  pointer-events: none;
}
.level-top {
  display: flex;
  align-items: baseline;
  gap: 3px;
}
.level-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(232,197,71,0.6);
  font-weight: 700;
  position: relative;
  z-index: 2;
}
.level-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(232,197,71,0.3);
  position: relative;
  z-index: 2;
  line-height: 1;
}
.level-xp-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  z-index: 2;
}
.level-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #fff5a0);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.22,1,0.36,1);
  box-shadow: 0 0 6px rgba(232,197,71,0.5);
}
.level-xp-text {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.35);
  font-family: 'JetBrains Mono', monospace;
  position: relative;
  z-index: 2;
  white-space: nowrap;
}

/* ── LEVEL UP OVERLAY ─────────────────────────────────── */
.levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: lvlFadeIn 0.3s ease both;
}
@keyframes lvlFadeIn { from{opacity:0} to{opacity:1} }

.levelup-box {
  background: rgba(6,26,20,0.92);
  border: 1px solid rgba(232,197,71,0.45);
  border-radius: 20px;
  padding: 32px 52px;
  text-align: center;
  box-shadow: 0 0 60px rgba(232,197,71,0.2), var(--glass-shadow-xl);
  backdrop-filter: blur(24px);
  animation: lvlPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes lvlPop { from{transform:scale(0.7);opacity:0} to{transform:scale(1);opacity:1} }

.levelup-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.levelup-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 5rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  text-shadow: 0 0 30px rgba(232,197,71,0.5);
}
.levelup-sub {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.5);
  margin-top: 6px;
}

/* ── GAME OVER LEVEL LINE ─────────────────────────────── */
.gameover-level {
  font-size: 18px;
  color: rgba(255,255,255,0.5);
  margin-top: -8px;
}
.gameover-level strong {
  color: var(--gold);
}