/* =====================================================
   JACKER — Pixel Blackjack CSS
   Mobile-first, Pixel Art style
   ===================================================== */

:root {
  --felt: #0d3d1a;
  --felt-light: #1a5c2e;
  --felt-dark: #081f0e;
  --gold: #ffd700;
  --gold-dark: #b89400;
  --red: #e84040;
  --red-dark: #8b0000;
  --green-win: #44ff88;
  --blue: #4499ff;
  --white: #f0e8d0;
  --gray: #888888;
  --black: #0a0a0a;
  --border: #1a1a1a;
  --hud-bg: rgba(0,0,0,0.6);
  --card-scale: 2.6;
  --card-w: 52px;
  --card-h: 77px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--black);
}

body {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--white);
  image-rendering: pixelated;
}

/* CRT scanlines overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

#root {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
}

/* ─── CARDS ─────────────────────────────────── */

.card {
  width: 135px;
  height: 200px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  border-radius: 2px;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  flex-shrink: 0;
  position: relative;
  /* No default animation — added via class */
}

/* ── Card animations ── */
@keyframes cardAppear {
  from { opacity: 0; transform: translateY(-24px) scale(0.82); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardFlipIn {
  0%   { transform: perspective(500px) rotateY(90deg) scale(0.85); opacity: 0.2; }
  55%  { transform: perspective(500px) rotateY(-8deg) scale(1.04); opacity: 1; }
  80%  { transform: perspective(500px) rotateY(3deg) scale(1); }
  100% { transform: perspective(500px) rotateY(0deg) scale(1); opacity: 1; }
}

.card.card-appear { animation: cardAppear 0.22s ease-out both; }
.card.card-flip   { animation: cardFlipIn 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }

/* ── Overlapping fan layout ── */
.cards-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  min-height: 200px;
  align-items: flex-start;
  overflow: visible;
}

.cards-row .card + .card {
  margin-left: -72px;
  filter: drop-shadow(-5px 2px 6px rgba(0,0,0,0.7));
}

/* Smaller cards on very small screens */
@media (max-height: 700px) {
  .card { width: 91px; height: 135px; }
  .cards-row { min-height: 135px; }
  .cards-row .card + .card { margin-left: -50px; }
  .bet-deco-card { width: 91px !important; height: 135px !important; }
}

@media (max-height: 500px) {
  .card { width: 72px; height: 107px; }
  .cards-row { min-height: 107px; }
  .cards-row .card + .card { margin-left: -40px; }
  .bet-deco-card { width: 72px !important; height: 107px !important; }
}

/* ─── BUTTONS ───────────────────────────────── */

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  border: none;
  cursor: pointer;
  color: var(--white);
  padding: 12px 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  outline: none;
  display: inline-block;
  position: relative;
  transition: transform 0.06s;
}

.btn:active { transform: translateY(2px); }

.btn-primary {
  background: #2255cc;
  box-shadow: 0 4px 0 #112266, inset 0 0 0 2px #4488ff;
  color: #ffffff;
}
.btn-primary:active { box-shadow: 0 2px 0 #112266, inset 0 0 0 2px #4488ff; }

.btn-secondary {
  background: #333333;
  box-shadow: 0 4px 0 #111111, inset 0 0 0 2px #666666;
  color: #cccccc;
}
.btn-secondary:active { box-shadow: 0 2px 0 #111111, inset 0 0 0 2px #666666; }

.btn-large {
  font-size: 12px;
  padding: 16px 28px;
  box-shadow: 0 6px 0 #112266, inset 0 0 0 2px #4488ff;
}
.btn-large:active { box-shadow: 0 3px 0 #112266, inset 0 0 0 2px #4488ff; transform: translateY(3px); }

.btn-hit {
  background: #cc2222;
  box-shadow: 0 4px 0 #661111, inset 0 0 0 2px #ff4444;
  flex: 1;
  font-size: 11px;
  padding: 14px;
}
.btn-hit:active { box-shadow: 0 2px 0 #661111, inset 0 0 0 2px #ff4444; }

.btn-stand {
  background: #226622;
  box-shadow: 0 4px 0 #113311, inset 0 0 0 2px #44aa44;
  flex: 1;
  font-size: 11px;
  padding: 14px;
}
.btn-stand:active { box-shadow: 0 2px 0 #113311, inset 0 0 0 2px #44aa44; }

.btn-double {
  background: #886622;
  box-shadow: 0 4px 0 #443311, inset 0 0 0 2px #ffaa44;
  flex: 1;
  font-size: 11px;
  padding: 14px;
}
.btn-double:active { box-shadow: 0 2px 0 #443311, inset 0 0 0 2px #ffaa44; }

.btn-deal {
  background: var(--gold-dark);
  box-shadow: 0 4px 0 #665500, inset 0 0 0 2px var(--gold);
  color: var(--black);
  font-size: 12px;
  padding: 14px 28px;
  width: 100%;
}
.btn-deal:active { box-shadow: 0 2px 0 #665500, inset 0 0 0 2px var(--gold); }

.btn-upgrade {
  background: var(--upg-color, #4488ff);
  box-shadow: 0 3px 0 rgba(0,0,0,0.5);
  color: #000;
  font-size: 8px;
  padding: 8px 12px;
  width: 100%;
  margin-top: 8px;
}

.btn-bet {
  background: #333;
  box-shadow: 0 3px 0 #111, inset 0 0 0 1px #555;
  font-size: 9px;
  padding: 10px 10px;
  flex: 1;
}
.btn-bet-preset {
  background: #1a3a1a;
  box-shadow: 0 3px 0 #0a1a0a, inset 0 0 0 1px #336633;
  color: var(--green-win);
  font-size: 9px;
  padding: 10px 10px;
  flex: 1;
}

/* ─── SCREENS ───────────────────────────────── */

.screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 50%, var(--felt-dark) 100%);
}

/* ─── MENU ──────────────────────────────────── */

.screen-menu {
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px 24px;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}

.screen-menu::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 40% at 50% 30%, rgba(255,215,0,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 20% 80%, rgba(68,153,255,0.06) 0%, transparent 60%);
}

.title-logo {
  text-align: center;
  z-index: 1;
  line-height: 1.6;
}

.title-main {
  font-size: clamp(30px, 10vw, 52px);
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255,215,0,0.6), 4px 4px 0 #000;
  letter-spacing: 6px;
}

.title-tagline {
  font-size: 7px;
  color: var(--gray);
  text-align: center;
  z-index: 1;
  max-width: 280px;
  line-height: 1.8;
}

.menu-rules {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 16px;
  z-index: 1;
  width: 100%;
  max-width: 320px;
}

.rules-title {
  font-size: 8px;
  color: var(--gold);
  margin-bottom: 12px;
  text-align: center;
}

.menu-rules div:not(.rules-title) {
  font-size: 7px;
  color: #aaa;
  line-height: 2.2;
}

/* ─── LEVEL INTRO ───────────────────────────── */

.screen-intro {
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}

.intro-label {
  font-size: 10px;
  color: var(--gray);
  letter-spacing: 3px;
}

.intro-name {
  font-size: clamp(14px, 5vw, 22px);
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255,215,0,0.4), 2px 2px 0 #000;
  text-align: center;
}

.intro-details {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,215,0,0.2);
  padding: 16px 24px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.intro-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: #aaa;
  gap: 12px;
}

.intro-row span:last-child { font-size: 10px; }

.gold { color: var(--gold); }
.green { color: var(--green-win); }
.red { color: var(--red); }

/* ─── HUD ───────────────────────────────────── */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #0e1a0e 0%, #0a140a 100%);
  padding: 6px 12px 8px;
  border-bottom: 1px solid rgba(255,215,0,0.18);
  box-shadow: 0 2px 12px rgba(0,0,0,0.6), inset 0 -1px 0 rgba(255,215,0,0.08);
  flex-shrink: 0;
  gap: 6px;
  min-height: 58px;
  position: relative;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.hud-level {
  font-size: 9px;
  color: var(--gold);
  letter-spacing: 1px;
}

.hud-rounds {
  font-size: 6px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
}

.hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.hud-coins {
  font-size: 13px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255,215,0,0.55), 0 1px 0 #000;
  letter-spacing: 1px;
}

.progress-bar-wrap {
  position: relative;
  width: 100%;
  max-width: 160px;
  height: 10px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,215,0,0.22);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a4d1a, #3aaa3a, #5fd85f);
  transition: width 0.45s cubic-bezier(0.4,0,0.2,1);
  min-width: 2px;
}

.progress-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6px;
  color: rgba(255,255,255,0.75);
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.hud-right {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  max-width: 80px;
  flex-shrink: 0;
}

/* ─── UPGRADE CHIPS (HUD) ───────────────────── */

.upgrade-chip {
  width: 28px;
  height: 28px;
  background: var(--upg-bg, #222);
  border: 2px solid var(--upg-color, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: var(--upg-color, #fff);
  box-shadow: 0 0 6px var(--upg-color, transparent);
  cursor: default;
  flex-shrink: 0;
}

/* ─── GAME SCREEN ───────────────────────────── */

.screen-game {
  height: 100%;
  overflow: hidden;
  position: relative;
}

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
  overflow: visible;
  min-height: 0;
}

.player-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dealer-section {
  padding-top: 4px;
  isolation: isolate; /* contain card z-indexes within dealer section */
}

.section-label {
  font-size: 8px;
  color: #aaa;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.hand-value {
  font-size: 12px;
  color: var(--white);
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border: 1px solid rgba(255,255,255,0.2);
}

.hand-value.bust { color: var(--red); border-color: var(--red); }

.table-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 60px;
  padding: 4px;
  position: relative;
  z-index: 5;
}

/* ─── RESULT DISPLAY ────────────────────────── */

.result-text {
  font-size: clamp(20px, 6vw, 34px);
  text-align: center;
  text-shadow: 3px 3px 0 #000, 0 0 20px currentColor;
  animation: resultPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  letter-spacing: 2px;
}

@keyframes resultPop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.result-win  { color: var(--green-win); }
.result-push { color: var(--gold); }
.result-lose { color: var(--red); }

/* Colored table-center border on result */
.table-center.tc-win {
  border: 2px solid rgba(68,255,136,0.45);
  background: rgba(68,255,136,0.07);
  border-radius: 2px;
}
.table-center.tc-lose {
  border: 2px solid rgba(232,64,64,0.45);
  background: rgba(232,64,64,0.07);
  border-radius: 2px;
}

/* Full-screen flash overlay on win/lose */
.screen-game.result-win-state::before,
.screen-game.result-lose-state::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  animation: resultOverlay 0.8s ease-out forwards;
}
.screen-game.result-win-state::before  { background: rgba(68,255,136,0.22); }
.screen-game.result-lose-state::before { background: rgba(232,64,64,0.22);  }
@keyframes resultOverlay {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

.payout-text {
  font-size: 11px;
  color: var(--white);
  text-align: center;
}

.trigger-log {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.trigger-log span {
  font-size: 7px;
  color: var(--gold);
  background: rgba(255,215,0,0.1);
  border: 1px solid rgba(255,215,0,0.3);
  padding: 2px 6px;
}

/* ─── ACTION AREA ───────────────────────────── */

.action-area {
  flex-shrink: 0;
  background: rgba(0,0,0,0.5);
  border-top: 2px solid rgba(255,255,255,0.08);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
  justify-content: center;
}

.play-controls {
  display: flex;
  gap: 8px;
}

.current-bet {
  font-size: 8px;
  color: #888;
  text-align: center;
}

.waiting-text {
  font-size: 9px;
  color: var(--gold);
  text-align: center;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── BET CONTROLS ──────────────────────────── */

.bet-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.bet-display {
  font-size: 11px;
  color: var(--gold);
  text-align: center;
}

.bet-buttons {
  display: flex;
  gap: 6px;
}

.bet-presets {
  display: flex;
  gap: 6px;
}

/* ─── SHOP ──────────────────────────────────── */

.screen-shop {
  overflow-y: auto;
  padding: 16px;
  gap: 16px;
  align-items: center;
  background: #0a0a12;
}

.shop-title {
  font-size: clamp(14px, 4vw, 18px);
  color: var(--gold);
  text-align: center;
  text-shadow: 0 0 12px rgba(255,215,0,0.4);
}

.shop-subtitle {
  font-size: 8px;
  color: #aaa;
  text-align: center;
  line-height: 1.8;
}

.shop-coins {
  font-size: 10px;
  color: var(--gold);
}

.shop-offers {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

.current-upgrades {
  width: 100%;
  max-width: 360px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
}

.current-upgrades-title {
  font-size: 8px;
  color: #777;
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.upgrades-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── UPGRADE CARD ──────────────────────────── */

.upgrade-card {
  background: var(--upg-bg, #111);
  border: 2px solid var(--upg-color, #fff);
  box-shadow: 0 0 12px color-mix(in srgb, var(--upg-color, #fff) 30%, transparent);
  padding: 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  position: relative;
}

.upgrade-card-icon {
  font-size: 18px;
  color: var(--upg-color, #fff);
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  text-shadow: 0 0 8px var(--upg-color, transparent);
}

.upgrade-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.upgrade-card-name {
  font-size: 9px;
  color: var(--upg-color, #fff);
  text-shadow: 0 0 6px var(--upg-color, transparent);
}

.upgrade-card-desc {
  font-size: 7px;
  color: #bbb;
  line-height: 1.6;
}

.upgrade-card .btn-upgrade {
  flex-shrink: 0;
  font-size: 7px;
  padding: 8px 10px;
  width: auto;
  white-space: nowrap;
}

/* ─── SWAP SCREEN ───────────────────────────── */

.screen-swap {
  overflow-y: auto;
  padding: 16px;
  gap: 16px;
  align-items: center;
  background: #0a0a12;
}

.swap-label {
  font-size: 8px;
  color: #888;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
}

.swap-new, .swap-current {
  width: 100%;
  max-width: 360px;
}

.swap-new .upgrade-card {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255,215,0,0.3);
}

.swap-divider {
  font-size: 20px;
  text-align: center;
  color: var(--gold);
  opacity: 0.6;
}

/* ─── GAMEOVER / WIN ────────────────────────── */

.screen-gameover, .screen-win {
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}

.screen-gameover {
  background: radial-gradient(ellipse at center, #1a0505 0%, #0a0a0a 100%);
}

.screen-win {
  background: radial-gradient(ellipse at center, #1a1a05 0%, #0a0a0a 100%);
}

.gameover-title {
  font-size: clamp(20px, 6vw, 30px);
  color: var(--red);
  text-shadow: 0 0 20px rgba(232,64,64,0.5), 3px 3px 0 #000;
  letter-spacing: 2px;
}

.gameover-sub {
  font-size: 8px;
  color: #888;
  text-align: center;
  line-height: 1.8;
  max-width: 280px;
}

.gameover-stats {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  font-size: 9px;
  color: #aaa;
}

.win-title {
  font-size: clamp(12px, 3.5vw, 16px);
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.5), 2px 2px 0 #000;
  text-align: center;
  line-height: 1.6;
  max-width: 320px;
}

.win-sub {
  font-size: 8px;
  color: #aaa;
  text-align: center;
  line-height: 1.8;
  max-width: 280px;
}

.win-coins {
  font-size: 16px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255,215,0,0.4);
}

/* ─── DESKTOP LAYOUT ────────────────────────── */

@media (min-width: 600px) {
  html, body { overflow: hidden; height: 100%; }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(ellipse 80% 60% at 50% 50%, rgba(13,61,26,0.6) 0%, transparent 65%),
      radial-gradient(ellipse 100% 100% at 50% 50%, #0c180c 0%, #050505 100%);
  }

  #root {
    width: 560px;
    height: 100vh;
    flex-shrink: 0;
    align-items: stretch;
    border-left:  1px solid rgba(255,215,0,0.13);
    border-right: 1px solid rgba(255,215,0,0.13);
    box-shadow: 0 0 80px rgba(0,0,0,0.9), 0 0 30px rgba(255,215,0,0.04);
    overflow: hidden;
  }

  .screen { height: 100%; min-height: unset; }

  /* Cards slightly smaller so they fit comfortably */
  .card { width: 115px; height: 170px; }

  /* Mouse hover/active */
  .btn { transition: filter 0.08s, transform 0.06s; cursor: pointer; }
  .btn:hover:not(:disabled) { filter: brightness(1.2); }
  .btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(0.9); }

  /* Hotkeys as visible second line */
  .btn-hit::after    { content: '[H]'; }
  .btn-stand::after  { content: '[S]'; }
  .btn-double::after { content: '[D]'; }
  .btn-deal::after   { content: '[Enter]'; }
  .btn-hit::after, .btn-stand::after,
  .btn-double::after, .btn-deal::after {
    display: block;
    font-size: 7px;
    margin-top: 5px;
    opacity: 0.5;
    letter-spacing: 0;
  }

  /* Dealer cards rotated 180° — facing toward player */
  .dealer-section .cards-row {
    transform: rotate(180deg);
  }
  /* Flip individual card drop-shadows so they still look right */
  .dealer-section .cards-row .card + .card {
    filter: drop-shadow(5px -2px 6px rgba(0,0,0,0.7));
  }
}

/* ─── DESKTOP MEDIUM (900px+) ───────────────── */
@media (min-width: 900px) {
  #root { width: 620px; }
  .card { width: 125px; height: 185px; }
  .action-area { min-height: 120px; padding: 14px 20px; }
  .btn-hit, .btn-stand, .btn-double, .btn-split {
    font-size: 11px;
    padding: 13px 20px;
    flex: 1;
  }
}

/* ─── DESKTOP LARGE (1300px+) ───────────────── */
@media (min-width: 1300px) {
  #root { width: 680px; }
  .card { width: 135px; height: 200px; }
}

/* Prevent scroll bounce on iOS */
.screen-shop {
  -webkit-overflow-scrolling: touch;
}

/* ─── STARS IN HUD ──────────────────────────────── */

.hud-stars {
  font-size: 7px;
  color: var(--gold);
  opacity: 0.9;
  letter-spacing: 0.5px;
}

/* ─── STAR REWARD NOTICE ────────────────────────── */

.star-reward {
  font-size: 13px;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255,215,0,0.5);
  animation: resultPop 0.4s 0.15s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ─── SHOP REDESIGN ─────────────────────────────── */

.shop-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
}

.shop-stars {
  font-size: 16px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255,215,0,0.4);
}

.shop-section-title {
  font-size: 8px;
  color: #666;
  letter-spacing: 3px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 6px;
  margin-top: 4px;
}

.shop-spacer { flex: 1; min-height: 12px; }

.shop-continue { width: 100%; max-width: 360px; }

/* Shop offer card with right-side price+button column */
.shop-offer-card {
  transition: opacity 0.2s;
}

.shop-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  min-width: 80px;
}

.shop-price-tag {
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
  font-weight: normal;
}

.btn-shop-buy {
  font-size: 7px;
  padding: 8px 10px;
  width: 100%;
  box-shadow: 0 3px 0 rgba(0,0,0,0.4);
}
.btn-shop-buy:not(:disabled):active {
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
  transform: translateY(2px);
}

.btn-sell {
  background: #333;
  box-shadow: 0 3px 0 #111, inset 0 0 0 1px #666;
  color: var(--gold);
  font-size: 7px;
  padding: 8px 10px;
  width: 100%;
}
.btn-sell:active { box-shadow: 0 1px 0 #111, inset 0 0 0 1px #666; }

/* ─── DIFFICULTY SELECTOR ───────────────────────── */

.diff-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 1;
  width: 100%;
  max-width: 340px;
}

.diff-label {
  font-size: 8px;
  color: #777;
  letter-spacing: 3px;
}

.diff-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.diff-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.btn-diff {
  background: #1a1a1a;
  box-shadow: 0 3px 0 #000, inset 0 0 0 2px #333;
  color: #888;
  font-size: 7px;
  padding: 10px 6px;
  width: 100%;
  text-align: center;
}

.btn-diff.btn-diff-active {
  background: #111;
  box-shadow: 0 3px 0 #000, inset 0 0 0 2px var(--diff-color, #ffd700);
  color: var(--diff-color, #ffd700);
}

.diff-btn-sub {
  font-size: 6px;
  text-align: center;
  opacity: 0.8;
}

/* ─── BETTING CENTER ────────────────────────────── */

.bet-center-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
}

.bet-card-deco {
  position: relative;
  width: 180px;
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bet-deco-card {
  position: absolute;
  width: 135px;
  height: 200px;
  animation: none !important;
  opacity: 0.7;
}

.bet-deco-card-0 {
  transform: rotate(-10deg) translateX(-30px);
  z-index: 1;
  filter: drop-shadow(3px 3px 6px rgba(0,0,0,0.5));
}

.bet-deco-card-1 {
  transform: rotate(6deg) translateX(20px);
  z-index: 2;
  filter: drop-shadow(-4px 3px 6px rgba(0,0,0,0.6));
}

.bet-center-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.bet-center-title {
  font-size: 10px;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255,215,0,0.4);
  letter-spacing: 2px;
}

.bet-center-coins {
  font-size: 14px;
  color: var(--white);
}

.bet-center-target {
  font-size: 8px;
  color: #888;
}

.bet-center-diff {
  font-size: 7px;
  letter-spacing: 2px;
  opacity: 0.8;
}

/* ─── SPLIT MECHANIC ────────────────────────────── */

.split-hands-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

/* Smaller cards in split mode so all hands + dealer fit on screen */
.game-area.split-mode .card {
  width: 91px;
  height: 135px;
}
.game-area.split-mode .cards-row {
  min-height: 135px;
}
.game-area.split-mode .cards-row .card + .card {
  margin-left: -50px;
}

.split-hand {
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 2px;
  transition: border-color 0.2s;
}

.split-hand.split-active {
  border-color: rgba(255,215,0,0.5);
  box-shadow: 0 0 10px rgba(255,215,0,0.12);
}

.split-status {
  font-size: 7px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  margin-left: 4px;
  opacity: 0.85;
}

.split-inline-result {
  text-align: center;
  font-size: 11px;
  padding: 6px 0 2px;
  letter-spacing: 1px;
  animation: resultPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.split-inline-result.win  { color: var(--green-win); text-shadow: 0 0 10px currentColor; }
.split-inline-result.lose { color: var(--red);       text-shadow: 0 0 10px currentColor; }
.split-inline-result.push { color: var(--gold); }

.btn-split {
  background: #224488;
  box-shadow: 0 4px 0 #112244, inset 0 0 0 2px #4488ff;
  flex: 1;
  font-size: 9px;
  padding: 14px;
  color: #88ccff;
}
.btn-split:active { box-shadow: 0 2px 0 #112244, inset 0 0 0 2px #4488ff; }

/* ── PAUSE MENU ───────────────────────── */
.btn-pause {
  align-self: center;
  background: transparent;
  border: none;
  box-shadow: none;
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  padding: 4px 10px;
  margin-left: 4px;
  letter-spacing: 2px;
  flex-shrink: 0;
}
.btn-pause:active { color: rgba(255,255,255,0.9); box-shadow: none; }

.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 100;
}

.pause-title {
  font-size: clamp(22px, 7vw, 32px);
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255,215,0,0.5), 3px 3px 0 #000;
  letter-spacing: 8px;
}

.pause-overlay .btn {
  width: 220px;
  text-align: center;
}

/* ── DEBUG OVERLAY ───────────────────────────── */
.debug-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 12px;
  gap: 10px;
  z-index: 200;
  overflow-y: auto;
}
.debug-title {
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 4px;
  margin-bottom: 4px;
}
.debug-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-height: 32px;
  padding: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 2px;
  width: 100%;
  max-width: 340px;
}
.debug-queue-empty { font-size: 7px; color: rgba(255,255,255,0.3); align-self: center; }
.debug-card-chip {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,215,0,0.12); border: 1px solid rgba(255,215,0,0.3);
  border-radius: 2px; padding: 3px 6px; font-size: 10px;
}
.debug-rm-btn {
  background: none; border: none; color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 10px; padding: 0 2px; line-height: 1;
  font-family: inherit;
}
.debug-rm-btn:hover { color: #e84040; }
.debug-row {
  display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
  width: 100%; max-width: 340px;
}
.debug-btn {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7); font-family: inherit; font-size: 8px;
  padding: 5px 7px; cursor: pointer; border-radius: 2px;
  letter-spacing: 0; transition: background 0.1s;
}
.debug-btn:hover { background: rgba(255,255,255,0.15); }
.debug-btn-active {
  background: rgba(255,215,0,0.2); border-color: var(--gold);
  color: var(--gold);
}
.debug-add-btn { width: 200px; font-size: 9px; padding: 10px; margin-top: 4px; }
.debug-clear-btn { width: 160px; font-size: 8px; padding: 8px; }
.debug-overlay .btn-primary { width: 160px; font-size: 9px; padding: 10px; }
.debug-order-note { font-size: 6px; color: rgba(255,255,255,0.3); letter-spacing: 0.5px; }

/* ── WATERMARK ───────────────────────────── */
.watermark {
  position: fixed;
  bottom: 10px;
  right: 12px;
  font-size: 6px;
  color: rgba(255,255,255,0.18);
  letter-spacing: 1px;
  pointer-events: none;
  z-index: 9999;
  font-family: 'Press Start 2P', monospace;
}

/* ── SCREEN FLASH ────────────────────────── */
@keyframes flashRed {
  0%   { box-shadow: inset 0 0 0 6px rgba(220,50,50,0); }
  30%  { box-shadow: inset 0 0 0 6px rgba(220,50,50,0.65); }
  100% { box-shadow: inset 0 0 0 6px rgba(220,50,50,0); }
}
@keyframes flashGold {
  0%   { box-shadow: inset 0 0 0 6px rgba(255,215,0,0); }
  30%  { box-shadow: inset 0 0 0 6px rgba(255,215,0,0.7); }
  100% { box-shadow: inset 0 0 0 6px rgba(255,215,0,0); }
}
@keyframes flashGreen {
  0%   { box-shadow: inset 0 0 0 6px rgba(68,255,136,0); }
  30%  { box-shadow: inset 0 0 0 6px rgba(68,255,136,0.55); }
  100% { box-shadow: inset 0 0 0 6px rgba(68,255,136,0); }
}
.screen-game.flash-red   { animation: flashRed   0.55s ease-out; }
.screen-game.flash-gold  { animation: flashGold  0.55s ease-out; }
.screen-game.flash-green { animation: flashGreen 0.55s ease-out; }

/* ── COIN FLOAT ──────────────────────────── */
@keyframes coinFloat {
  0%   { opacity: 1;   transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1;   transform: translateX(-50%) translateY(-36px); }
  100% { opacity: 0;   transform: translateX(-50%) translateY(-52px); }
}
.coin-float {
  position: fixed;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  pointer-events: none;
  z-index: 9998;
  animation: coinFloat 1.1s ease-out forwards;
  white-space: nowrap;
}
.coin-float-win  { color: #44ff88; text-shadow: 0 0 8px rgba(68,255,136,0.6); }
.coin-float-lose { color: #ff5555; text-shadow: 0 0 8px rgba(255,85,85,0.6); }

/* ── DEALER THINKING DOTS ────────────────── */
@keyframes thinkDots {
  0%, 20%  { content: ''; }
  40%, 55%  { content: '.'; }
  60%, 75%  { content: '..'; }
  80%, 100% { content: '...'; }
}
.thinking-dots::after {
  content: '';
  animation: thinkDots 1.2s infinite;
}

/* ── STORY MESSAGE ───────────────────────── */
.story-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 32px;
  z-index: 9997;
  pointer-events: all;
  animation: storySlideUp 0.4s cubic-bezier(0.34,1.3,0.64,1) both;
}
.story-overlay.story-exit {
  animation: storySlideDown 0.4s ease-in both;
}
@keyframes storySlideUp {
  from { transform: translateY(100px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
@keyframes storySlideDown {
  from { transform: translateY(0);     opacity: 1; }
  to   { transform: translateY(80px);  opacity: 0; }
}
.story-bubble {
  background: #111;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 16px 18px;
  max-width: 300px;
  width: 88%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,215,0,0.08);
}
.story-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.story-avatar {
  width: 28px;
  height: 28px;
  background: #222;
  border: 1px solid rgba(255,215,0,0.4);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--gold);
  flex-shrink: 0;
}
.story-sender {
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 2px;
}
.story-text {
  font-size: 8px;
  color: rgba(255,255,255,0.85);
  line-height: 1.9;
  letter-spacing: 0.5px;
  min-height: 1.9em;
}
.story-cursor {
  display: inline-block;
  color: var(--gold);
  animation: cursorBlink 0.7s infinite;
  font-size: 9px;
}
@keyframes cursorBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── INSURANCE ───────────────────────────── */
.insurance-label {
  font-size: 8px;
  color: rgba(255,255,255,0.75);
  text-align: center;
  padding: 6px 0 10px;
  line-height: 1.8;
}
.insurance-btns {
  display: flex;
  gap: 10px;
  width: 100%;
}
.insurance-btns .btn {
  flex: 1;
  font-size: 11px;
  padding: 14px;
}

/* ── HIGHSCORE / STATS ───────────────────── */
.menu-hs {
  font-size: 7px;
  color: rgba(255,215,0,0.55);
  letter-spacing: 1px;
  text-align: center;
  z-index: 1;
}

/* ─── GLOBAL STATS GRID ─────────────────────── */

.menu-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  padding: 0 4px;
}

.menu-stat-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 2px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.menu-stat-val {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0;
}

.menu-stat-lbl {
  font-size: 6px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 1px;
}
.gameover-hs {
  font-size: 7px;
  color: rgba(255,215,0,0.6);
  letter-spacing: 1px;
  text-align: center;
  margin: 4px 0 8px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: #aaa;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.stat-win  { color: #44ff88; }
.stat-lose { color: #ff5555; }
